Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceELFObjectWriter.cpp - ELF object file writer --------===// | 1 //===- subzero/src/IceELFObjectWriter.cpp - ELF object file writer --------===// |
| 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 // This file defines the writer for ELF relocatable object files. | 10 // This file defines the writer for ELF relocatable object files. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 struct { | 31 struct { |
| 32 bool IsELF64; | 32 bool IsELF64; |
| 33 uint16_t ELFMachine; | 33 uint16_t ELFMachine; |
| 34 uint32_t ELFFlags; | 34 uint32_t ELFFlags; |
| 35 } ELFTargetInfo[] = { | 35 } ELFTargetInfo[] = { |
| 36 #define X(tag, str, is_elf64, e_machine, e_flags) \ | 36 #define X(tag, str, is_elf64, e_machine, e_flags) \ |
| 37 { is_elf64, e_machine, e_flags } \ | 37 { is_elf64, e_machine, e_flags } \ |
| 38 , | 38 , |
| 39 TARGETARCH_TABLE | 39 TARGETARCH_TABLE |
| 40 #undef X | 40 #undef X |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 bool isELF64(TargetArch Arch) { | 43 bool isELF64(TargetArch Arch) { |
| 44 if (Arch < TargetArch_NUM) | 44 if (Arch < TargetArch_NUM) |
| 45 return ELFTargetInfo[Arch].IsELF64; | 45 return ELFTargetInfo[Arch].IsELF64; |
| 46 llvm_unreachable("Invalid target arch for isELF64"); | 46 llvm_unreachable("Invalid target arch for isELF64"); |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| 49 | 49 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 Section = TextSections[0]; | 237 Section = TextSections[0]; |
| 238 RelSection = RelTextSections[0]; | 238 RelSection = RelTextSections[0]; |
| 239 } | 239 } |
| 240 RelocOffsetT OffsetInSection = Section->getCurrentSize(); | 240 RelocOffsetT OffsetInSection = Section->getCurrentSize(); |
| 241 // Function symbols are set to 0 size in the symbol table, | 241 // Function symbols are set to 0 size in the symbol table, |
| 242 // in contrast to data symbols which have a proper size. | 242 // in contrast to data symbols which have a proper size. |
| 243 SizeT SymbolSize = 0; | 243 SizeT SymbolSize = 0; |
| 244 Section->appendData(Str, Asm->getBufferView()); | 244 Section->appendData(Str, Asm->getBufferView()); |
| 245 uint8_t SymbolType; | 245 uint8_t SymbolType; |
| 246 uint8_t SymbolBinding; | 246 uint8_t SymbolBinding; |
| 247 if (IsInternal) { | 247 if (IsInternal && !Ctx.getFlags().getDisableInternal()) { |
| 248 SymbolType = STT_NOTYPE; | 248 SymbolType = STT_NOTYPE; |
| 249 SymbolBinding = STB_LOCAL; | 249 SymbolBinding = STB_LOCAL; |
| 250 } else { | 250 } else { |
| 251 SymbolType = STT_FUNC; | 251 SymbolType = STT_FUNC; |
| 252 SymbolBinding = STB_GLOBAL; | 252 SymbolBinding = STB_GLOBAL; |
| 253 } | 253 } |
| 254 SymTab->createDefinedSym(FuncName, SymbolType, SymbolBinding, Section, | 254 SymTab->createDefinedSym(FuncName, SymbolType, SymbolBinding, Section, |
| 255 OffsetInSection, SymbolSize); | 255 OffsetInSection, SymbolSize); |
| 256 StrTab->add(FuncName); | 256 StrTab->add(FuncName); |
| 257 | 257 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 void ELFObjectWriter::writeAllRelocationSections(bool IsELF64) { | 538 void ELFObjectWriter::writeAllRelocationSections(bool IsELF64) { |
| 539 writeRelocationSections(IsELF64, RelTextSections); | 539 writeRelocationSections(IsELF64, RelTextSections); |
| 540 writeRelocationSections(IsELF64, RelDataSections); | 540 writeRelocationSections(IsELF64, RelDataSections); |
| 541 writeRelocationSections(IsELF64, RelRODataSections); | 541 writeRelocationSections(IsELF64, RelRODataSections); |
| 542 } | 542 } |
| 543 | 543 |
| 544 void ELFObjectWriter::setUndefinedSyms(const ConstantList &UndefSyms) { | 544 void ELFObjectWriter::setUndefinedSyms(const ConstantList &UndefSyms) { |
| 545 for (const Constant *S : UndefSyms) { | 545 for (const Constant *S : UndefSyms) { |
| 546 const auto Sym = llvm::cast<ConstantRelocatable>(S); | 546 const auto Sym = llvm::cast<ConstantRelocatable>(S); |
| 547 const IceString &Name = Sym->getName(); | 547 const IceString &Name = Sym->getName(); |
| 548 bool BadIntrinsic; | |
| 549 const Intrinsics::FullIntrinsicInfo *Info = | |
| 550 Ctx.getIntrinsicsInfo().find(Name, BadIntrinsic); | |
| 551 if (Info) | |
|
jvoung (off chromium)
2015/03/03 22:58:01
oops didn't think an intrinsic name would make it
Jim Stichnoth
2015/03/03 23:18:51
Yeah, these llvm.* symbols were making it into the
jvoung (off chromium)
2015/03/03 23:52:52
Okay, I agree it shouldn't be in the undefined sym
| |
| 552 continue; | |
| 553 assert(!BadIntrinsic); | |
| 548 assert(Sym->getOffset() == 0); | 554 assert(Sym->getOffset() == 0); |
| 549 assert(Sym->getSuppressMangling()); | 555 assert(Sym->getSuppressMangling()); |
| 550 SymTab->noteUndefinedSym(Name, NullSection); | 556 SymTab->noteUndefinedSym(Name, NullSection); |
| 551 StrTab->add(Name); | 557 StrTab->add(Name); |
| 552 } | 558 } |
| 553 } | 559 } |
| 554 | 560 |
| 555 void ELFObjectWriter::writeRelocationSections(bool IsELF64, | 561 void ELFObjectWriter::writeRelocationSections(bool IsELF64, |
| 556 RelSectionList &RelSections) { | 562 RelSectionList &RelSections) { |
| 557 for (ELFRelocationSection *RelSec : RelSections) { | 563 for (ELFRelocationSection *RelSec : RelSections) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 if (IsELF64) { | 617 if (IsELF64) { |
| 612 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), | 618 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), |
| 613 AllSections.size()); | 619 AllSections.size()); |
| 614 } else { | 620 } else { |
| 615 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), | 621 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), |
| 616 AllSections.size()); | 622 AllSections.size()); |
| 617 } | 623 } |
| 618 } | 624 } |
| 619 | 625 |
| 620 } // end of namespace Ice | 626 } // end of namespace Ice |
| OLD | NEW |