summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCAssembler.cpp
diff options
context:
space:
mode:
authorMatt Fleming <matt@console-pimps.org>2010-08-16 18:35:06 +0000
committerMatt Fleming <matt@console-pimps.org>2010-08-16 18:35:06 +0000
commit9cecd63b07930e4402aaec1eef807ed33fd29dba (patch)
tree5920ee26c0da99354f4fec1d8fbb61022299904a /llvm/lib/MC/MCAssembler.cpp
parentc6beca522cac1d512eb2ef474f081fb9cbe3bf17 (diff)
downloadbcm5719-llvm-9cecd63b07930e4402aaec1eef807ed33fd29dba.tar.gz
bcm5719-llvm-9cecd63b07930e4402aaec1eef807ed33fd29dba.zip
Layout helper function.
Introduce a helper method to add a section to the end of a layout. This will be used by the ELF ObjectWriter code to add the metadata sections (symbol table, etc) to the end of an object file. llvm-svn: 111171
Diffstat (limited to 'llvm/lib/MC/MCAssembler.cpp')
-rw-r--r--llvm/lib/MC/MCAssembler.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 8e255aa4ec4..35f39564cd5 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -652,6 +652,40 @@ void MCAssembler::WriteSectionData(const MCSectionData *SD,
assert(OW->getStream().tell() - Start == Layout.getSectionFileSize(SD));
}
+void MCAssembler::AddSectionToTheEnd(MCSectionData &SD, MCAsmLayout &Layout) {
+ // Create dummy fragments and assign section ordinals.
+ unsigned SectionIndex = 0;
+ for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it)
+ SectionIndex++;
+
+ SD.setOrdinal(SectionIndex);
+
+ // Assign layout order indices to sections and fragments.
+ unsigned FragmentIndex = 0;
+ unsigned i = 0;
+ for (unsigned e = Layout.getSectionOrder().size(); i != e; ++i) {
+ MCSectionData *SD = Layout.getSectionOrder()[i];
+
+ for (MCSectionData::iterator it2 = SD->begin(),
+ ie2 = SD->end(); it2 != ie2; ++it2)
+ FragmentIndex++;
+ }
+
+ SD.setLayoutOrder(i);
+ for (MCSectionData::iterator it2 = SD.begin(),
+ ie2 = SD.end(); it2 != ie2; ++it2) {
+ it2->setLayoutOrder(FragmentIndex++);
+ }
+ Layout.getSectionOrder().push_back(&SD);
+
+ Layout.LayoutSection(&SD);
+
+ // Layout until everything fits.
+ while (LayoutOnce(Layout))
+ continue;
+
+}
+
void MCAssembler::Finish(MCObjectWriter *Writer) {
DEBUG_WITH_TYPE("mc-dump", {
llvm::errs() << "assembler backend - pre-layout\n--\n";
OpenPOWER on IntegriCloud