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 | 2ae4bfd76905fb6d5be2bf03eaca51da2f9a4d81 (patch) | |
tree | ba0ecffaef587995a58875c8c1c106391048d164 /lib/MC | |
parent | 56279f42b6d955be8a5f399f405ce0b1784e9502 (diff) | |
download | external_llvm-2ae4bfd76905fb6d5be2bf03eaca51da2f9a4d81.zip external_llvm-2ae4bfd76905fb6d5be2bf03eaca51da2f9a4d81.tar.gz external_llvm-2ae4bfd76905fb6d5be2bf03eaca51da2f9a4d81.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104033 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCMachOStreamer.cpp | 1 | ||||
-rw-r--r-- | lib/MC/MachObjectWriter.cpp | 17 |
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp index f1dc349..e4ddf1a 100644 --- a/lib/MC/MCMachOStreamer.cpp +++ b/lib/MC/MCMachOStreamer.cpp @@ -216,6 +216,7 @@ void MCMachOStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) { // FIXME: Lift context changes into super class. + Assembler.getOrCreateSymbolData(*Symbol); Symbol->setVariableValue(AddValueSymbols(Value)); } diff --git a/lib/MC/MachObjectWriter.cpp b/lib/MC/MachObjectWriter.cpp index b1dae3d..5a4bb7a 100644 --- a/lib/MC/MachObjectWriter.cpp +++ b/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. |