| OLD | NEW |
| 1 //===- subzero/src/IceELFSection.h - Model of ELF sections ------*- C++ -*-===// | 1 //===- subzero/src/IceELFSection.h - Model of ELF sections ------*- C++ -*-===// |
| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 : ELFSection(Name, ShType, ShFlags, ShAddralign, ShEntsize), | 225 : ELFSection(Name, ShType, ShFlags, ShAddralign, ShEntsize), |
| 226 RelatedSection(nullptr) {} | 226 RelatedSection(nullptr) {} |
| 227 | 227 |
| 228 const ELFSection *getRelatedSection() const { return RelatedSection; } | 228 const ELFSection *getRelatedSection() const { return RelatedSection; } |
| 229 void setRelatedSection(const ELFSection *Section) { | 229 void setRelatedSection(const ELFSection *Section) { |
| 230 RelatedSection = Section; | 230 RelatedSection = Section; |
| 231 } | 231 } |
| 232 | 232 |
| 233 /// Track additional relocations which start out relative to offset 0, but | 233 /// Track additional relocations which start out relative to offset 0, but |
| 234 /// should be adjusted to be relative to BaseOff. | 234 /// should be adjusted to be relative to BaseOff. |
| 235 void addRelocations(RelocOffsetT BaseOff, const FixupRefList &FixupRefs); | 235 void addRelocations(RelocOffsetT BaseOff, const FixupRefList &FixupRefs, |
| 236 ELFSymbolTableSection *SymTab); |
| 236 | 237 |
| 237 /// Track a single additional relocation. | 238 /// Track a single additional relocation. |
| 238 void addRelocation(const AssemblerFixup &Fixup) { Fixups.push_back(Fixup); } | 239 void addRelocation(const AssemblerFixup &Fixup) { Fixups.push_back(Fixup); } |
| 239 | 240 |
| 240 size_t getSectionDataSize() const; | 241 size_t getSectionDataSize() const; |
| 241 | 242 |
| 242 template <bool IsELF64> | 243 template <bool IsELF64> |
| 243 void writeData(ELFStreamer &Str, const ELFSymbolTableSection *SymTab); | 244 void writeData(ELFStreamer &Str, const ELFSymbolTableSection *SymTab); |
| 244 | 245 |
| 245 bool isRela() const { return Header.sh_type == SHT_RELA; } | 246 bool isRela() const { return Header.sh_type == SHT_RELA; } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 347 } |
| 347 } | 348 } |
| 348 | 349 |
| 349 template <bool IsELF64> | 350 template <bool IsELF64> |
| 350 void ELFRelocationSection::writeData(ELFStreamer &Str, | 351 void ELFRelocationSection::writeData(ELFStreamer &Str, |
| 351 const ELFSymbolTableSection *SymTab) { | 352 const ELFSymbolTableSection *SymTab) { |
| 352 for (const AssemblerFixup &Fixup : Fixups) { | 353 for (const AssemblerFixup &Fixup : Fixups) { |
| 353 const ELFSym *Symbol; | 354 const ELFSym *Symbol; |
| 354 if (Fixup.isNullSymbol()) { | 355 if (Fixup.isNullSymbol()) { |
| 355 Symbol = SymTab->getNullSymbol(); | 356 Symbol = SymTab->getNullSymbol(); |
| 357 } else if (Fixup.valueIsSymbol()) { |
| 358 Symbol = Fixup.getSymbolValue(); |
| 356 } else { | 359 } else { |
| 357 constexpr Assembler *Asm = nullptr; | 360 const IceString Name = Fixup.symbol(); |
| 358 const IceString Name = Fixup.symbol(Asm); | |
| 359 Symbol = SymTab->findSymbol(Name); | 361 Symbol = SymTab->findSymbol(Name); |
| 360 if (!Symbol) | 362 if (!Symbol) |
| 361 llvm::report_fatal_error(Name + ": Missing symbol mentioned in reloc"); | 363 llvm::report_fatal_error(Name + ": Missing symbol mentioned in reloc"); |
| 362 } | 364 } |
| 363 | 365 |
| 364 if (IsELF64) { | 366 if (IsELF64) { |
| 365 Elf64_Rela Rela; | 367 Elf64_Rela Rela; |
| 366 Rela.r_offset = Fixup.position(); | 368 Rela.r_offset = Fixup.position(); |
| 367 Rela.setSymbolAndType(Symbol->getNumber(), Fixup.kind()); | 369 Rela.setSymbolAndType(Symbol->getNumber(), Fixup.kind()); |
| 368 Rela.r_addend = Fixup.offset(); | 370 Rela.r_addend = Fixup.offset(); |
| 369 Str.writeAddrOrOffset<IsELF64>(Rela.r_offset); | 371 Str.writeAddrOrOffset<IsELF64>(Rela.r_offset); |
| 370 Str.writeELFXword<IsELF64>(Rela.r_info); | 372 Str.writeELFXword<IsELF64>(Rela.r_info); |
| 371 Str.writeELFXword<IsELF64>(Rela.r_addend); | 373 Str.writeELFXword<IsELF64>(Rela.r_addend); |
| 372 } else { | 374 } else { |
| 373 Elf32_Rel Rel; | 375 Elf32_Rel Rel; |
| 374 Rel.r_offset = Fixup.position(); | 376 Rel.r_offset = Fixup.position(); |
| 375 Rel.setSymbolAndType(Symbol->getNumber(), Fixup.kind()); | 377 Rel.setSymbolAndType(Symbol->getNumber(), Fixup.kind()); |
| 376 Str.writeAddrOrOffset<IsELF64>(Rel.r_offset); | 378 Str.writeAddrOrOffset<IsELF64>(Rel.r_offset); |
| 377 Str.writeELFWord<IsELF64>(Rel.r_info); | 379 Str.writeELFWord<IsELF64>(Rel.r_info); |
| 378 } | 380 } |
| 379 } | 381 } |
| 380 } | 382 } |
| 381 | 383 |
| 382 } // end of namespace Ice | 384 } // end of namespace Ice |
| 383 | 385 |
| 384 #endif // SUBZERO_SRC_ICEELFSECTION_H | 386 #endif // SUBZERO_SRC_ICEELFSECTION_H |
| OLD | NEW |