diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-05-18 17:28:24 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-05-18 17:28:24 +0000 |
commit | d5563f420a17f93858fbcc76a7fdfc4d47dbe16a (patch) | |
tree | 32886eb0c9d5c17bfb48552522f5cb8ea53a28b5 /llvm/lib/MC/MachObjectWriter.cpp | |
parent | f16c12d7a197b332330c9cdebd4695962342ae77 (diff) | |
download | bcm5719-llvm-d5563f420a17f93858fbcc76a7fdfc4d47dbe16a.tar.gz bcm5719-llvm-d5563f420a17f93858fbcc76a7fdfc4d47dbe16a.zip |
MC/Mach-O: Implement support for setting indirect symbol table offset in section header.
Also, create symbol data for LHS of assignment, to match 'as' symbol ordering better.
llvm-svn: 104033
Diffstat (limited to 'llvm/lib/MC/MachObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/MachObjectWriter.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp index b1dae3dd1d8..5a4bb7ad33e 100644 --- a/llvm/lib/MC/MachObjectWriter.cpp +++ b/llvm/lib/MC/MachObjectWriter.cpp @@ -185,6 +185,7 @@ class MachObjectWriterImpl { llvm::DenseMap<const MCSectionData*, std::vector<MachRelocationEntry> > Relocations; + llvm::DenseMap<const MCSectionData*, unsigned> IndirectSymBase; /// @} /// @name Symbol Table Data @@ -325,7 +326,7 @@ public: Write32(NumRelocations ? RelocationsStart : 0); Write32(NumRelocations); Write32(Flags); - Write32(0); // reserved1 + Write32(IndirectSymBase.lookup(&SD)); // reserved1 Write32(Section.getStubSize()); // reserved2 if (Is64Bit) Write32(0); // reserved3 @@ -815,20 +816,26 @@ public: // FIXME: Revisit this when the dust settles. // Bind non lazy symbol pointers first. + unsigned IndirectIndex = 0; for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin(), - ie = Asm.indirect_symbol_end(); it != ie; ++it) { + ie = Asm.indirect_symbol_end(); it != ie; ++it, ++IndirectIndex) { const MCSectionMachO &Section = cast<MCSectionMachO>(it->SectionData->getSection()); if (Section.getType() != MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS) continue; + // Initialize the section indirect symbol base, if necessary. + if (!IndirectSymBase.count(it->SectionData)) + IndirectSymBase[it->SectionData] = IndirectIndex; + Asm.getOrCreateSymbolData(*it->Symbol); } // Then lazy symbol pointers and symbol stubs. + IndirectIndex = 0; for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin(), - ie = Asm.indirect_symbol_end(); it != ie; ++it) { + ie = Asm.indirect_symbol_end(); it != ie; ++it, ++IndirectIndex) { const MCSectionMachO &Section = cast<MCSectionMachO>(it->SectionData->getSection()); @@ -836,6 +843,10 @@ public: Section.getType() != MCSectionMachO::S_SYMBOL_STUBS) continue; + // Initialize the section indirect symbol base, if necessary. + if (!IndirectSymBase.count(it->SectionData)) + IndirectSymBase[it->SectionData] = IndirectIndex; + // Set the symbol type to undefined lazy, but only on construction. // // FIXME: Do not hardcode. |