[nolimips: 128] Name sections

Index: ChangeLog from BenoƮt Perrot <benoit@lrde.epita.fr> Name sections. * src/inst/section: Add name attribute. * src/inst/text_section.hh, src/inst/data_section.hh: Default it to `.text' for text sections and `.data' for data sections. * src/inst/text_section.cc, src/inst/data_section.cc (print): Display name. Index: src/inst/data_section.cc --- src/inst/data_section.cc (revision 127) +++ src/inst/data_section.cc (revision 128) @@ -26,8 +26,7 @@ // -------------------------------------------------------------------------- DataSection::~DataSection() - { - } + {} // -------------------------------------------------------------------------- // Print operator @@ -39,7 +38,7 @@ if (size_ == 0) return; - ostr << "\t.data" << std::endl; + ostr << "\t" << name_ << std::endl; int i = 0; while (i < size_) Index: src/inst/data_section.hh --- src/inst/data_section.hh (revision 127) +++ src/inst/data_section.hh (revision 128) @@ -33,11 +33,13 @@ namespace inst { + /// Abstract an assembly data section class DataSection: public Section { public: - DataSection(): + DataSection(const std::string &name = ".data"): + Section(name), size_(0) { std::memset(bytes_, 0, INST_DATA_DATASIZE); Index: src/inst/text_section.cc --- src/inst/text_section.cc (revision 127) +++ src/inst/text_section.cc (revision 128) @@ -39,7 +39,8 @@ void TextSection::print(std::ostream& ostr) const { - ostr << "\t.text" << std::endl; + ostr << "\t" << name_ << std::endl; + for (unsigned i = 0; i < insts_.size(); ++i) { std::map<int, label_list_type>::const_iterator it = Index: src/inst/section.hh --- src/inst/section.hh (revision 127) +++ src/inst/section.hh (revision 128) @@ -29,6 +29,7 @@ namespace inst { + /// Abstract an assembly section class Section { protected: @@ -39,12 +40,12 @@ typedef std::map<const Label, int> label_offset_type; public: - Section() - { - } + /// Construct an abstract section `\a name' + Section(const std::string &name): + name_(name) + {} virtual ~Section() - { - } + {} protected: void add_label(Label *label, int offset) @@ -76,6 +77,8 @@ virtual void print(std::ostream& ostr) const = 0; protected: + std::string name_; + // FIXME: Might be static, to avoid multi-definition of labels. offset_label_type labels_; label_offset_type offsets_; Index: src/inst/text_section.hh --- src/inst/text_section.hh (revision 127) +++ src/inst/text_section.hh (revision 128) @@ -30,13 +30,14 @@ namespace inst { + /// Implement an assembly text (code) section class TextSection: public Section { public: - TextSection() - { - } + TextSection(const std::string &name = ".text"): + Section(name) + {} virtual ~TextSection(); public:
participants (1)
-
Noe