xref: /netbsd-src/external/bsd/elftosb/dist/common/OutputSection.h (revision 993229b6fea628ff8b1fa09146c80b0cfb2768eb)
1 /*
2  * File:	OutputSection.h
3  *
4  * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5  * See included license file for license details.
6  */
7 #if !defined(_OutputSection_h_)
8 #define _OutputSection_h_
9 
10 #include "Operation.h"
11 #include "smart_ptr.h"
12 #include "Blob.h"
13 #include "OptionContext.h"
14 
15 namespace elftosb
16 {
17 
18 /*!
19  * @brief Base class for data model of sections of the output file.
20  */
21 class OutputSection
22 {
23 public:
OutputSection()24 	OutputSection() : m_id(0), m_options(0) {}
OutputSection(uint32_t identifier)25 	OutputSection(uint32_t identifier) : m_id(identifier), m_options(0) {}
~OutputSection()26 	virtual ~OutputSection() {}
27 
setIdentifier(uint32_t identifier)28 	void setIdentifier(uint32_t identifier) { m_id = identifier; }
getIdentifier()29 	uint32_t getIdentifier() const { return m_id; }
30 
31 	//! \brief Set the option context.
32 	//!
33 	//! The output section object will assume ownership of the option context
34 	//! and delete it when the section is deleted.
setOptions(OptionContext * context)35 	inline void setOptions(OptionContext * context) { m_options = context; }
36 
37 	//! \brief Return the option context.
getOptions()38 	inline const OptionContext * getOptions() const { return m_options; }
39 
40 protected:
41 	uint32_t m_id;	//!< Unique identifier.
42 	smart_ptr<OptionContext> m_options;	//!< Options associated with just this section.
43 };
44 
45 /*!
46  * @brief A section of the output that contains boot operations.
47  */
48 class OperationSequenceSection : public OutputSection
49 {
50 public:
OperationSequenceSection()51 	OperationSequenceSection() : OutputSection() {}
OperationSequenceSection(uint32_t identifier)52 	OperationSequenceSection(uint32_t identifier) : OutputSection(identifier) {}
53 
getSequence()54 	OperationSequence & getSequence() { return m_sequence; }
55 
56 protected:
57 	OperationSequence m_sequence;
58 };
59 
60 /*!
61  * @brief A section of the output file that contains arbitrary binary data.
62  */
63 class BinaryDataSection : public OutputSection, public Blob
64 {
65 public:
BinaryDataSection()66 	BinaryDataSection() : OutputSection(), Blob() {}
BinaryDataSection(uint32_t identifier)67 	BinaryDataSection(uint32_t identifier) : OutputSection(identifier), Blob() {}
68 };
69 
70 }; // namespace elftosb
71 
72 #endif // _OutputSection_h_
73