OLD | NEW |
1 //===- subzero/src/IceELFSection.cpp - Representation of ELF sections -----===// | 1 //===- subzero/src/IceELFSection.cpp - Representation of ELF sections -----===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 if (AlignDiff == 0) | 60 if (AlignDiff == 0) |
61 return; | 61 return; |
62 if (Header.sh_type != llvm::ELF::SHT_NOBITS) | 62 if (Header.sh_type != llvm::ELF::SHT_NOBITS) |
63 Str.writeZeroPadding(AlignDiff); | 63 Str.writeZeroPadding(AlignDiff); |
64 Header.sh_size += AlignDiff; | 64 Header.sh_size += AlignDiff; |
65 } | 65 } |
66 | 66 |
67 // Relocation sections. | 67 // Relocation sections. |
68 | 68 |
69 void ELFRelocationSection::addRelocations(RelocOffsetT BaseOff, | 69 void ELFRelocationSection::addRelocations(RelocOffsetT BaseOff, |
70 const FixupRefList &FixupRefs) { | 70 const FixupRefList &FixupRefs, |
| 71 ELFSymbolTableSection *SymTab) { |
71 for (const AssemblerFixup *FR : FixupRefs) { | 72 for (const AssemblerFixup *FR : FixupRefs) { |
72 Fixups.push_back(*FR); | 73 Fixups.push_back(*FR); |
73 AssemblerFixup &F = Fixups.back(); | 74 AssemblerFixup &F = Fixups.back(); |
74 F.set_position(BaseOff + F.position()); | 75 F.set_position(BaseOff + F.position()); |
| 76 assert(!F.valueIsSymbol()); |
| 77 if (!F.isNullSymbol()) { |
| 78 // Do an early lookup in the symbol table. If the symbol is found, |
| 79 // replace the Constant in the symbol with the ELFSym, and calculate the |
| 80 // final value of the addend. As such, a local label allocated from the |
| 81 // Assembler arena will be converted to a symbol before the Assembler |
| 82 // arena goes away. |
| 83 if (const ELFSym *Sym = SymTab->findSymbol(F.symbol())) { |
| 84 F.set_addend(F.offset()); |
| 85 F.set_value(Sym); |
| 86 } |
| 87 } |
75 } | 88 } |
76 } | 89 } |
77 | 90 |
78 size_t ELFRelocationSection::getSectionDataSize() const { | 91 size_t ELFRelocationSection::getSectionDataSize() const { |
79 return Fixups.size() * Header.sh_entsize; | 92 return Fixups.size() * Header.sh_entsize; |
80 } | 93 } |
81 | 94 |
82 // Symbol tables. | 95 // Symbol tables. |
83 | 96 |
84 void ELFSymbolTableSection::createNullSymbol(ELFSection *NullSection) { | 97 void ELFSymbolTableSection::createNullSymbol(ELFSection *NullSection) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 continue; | 232 continue; |
220 } | 233 } |
221 StringIndex.second = StringData.size(); | 234 StringIndex.second = StringData.size(); |
222 std::copy(Cur.begin(), Cur.end(), back_inserter(StringData)); | 235 std::copy(Cur.begin(), Cur.end(), back_inserter(StringData)); |
223 StringData.push_back(0); | 236 StringData.push_back(0); |
224 Prev = Cur; | 237 Prev = Cur; |
225 } | 238 } |
226 } | 239 } |
227 | 240 |
228 } // end of namespace Ice | 241 } // end of namespace Ice |
OLD | NEW |