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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 template void ELFObjectWriter::writeConstantPool<ConstantFloat>(Type Ty); | 525 template void ELFObjectWriter::writeConstantPool<ConstantFloat>(Type Ty); |
526 | 526 |
527 template void ELFObjectWriter::writeConstantPool<ConstantDouble>(Type Ty); | 527 template void ELFObjectWriter::writeConstantPool<ConstantDouble>(Type Ty); |
528 | 528 |
529 void ELFObjectWriter::writeAllRelocationSections(bool IsELF64) { | 529 void ELFObjectWriter::writeAllRelocationSections(bool IsELF64) { |
530 writeRelocationSections(IsELF64, RelTextSections); | 530 writeRelocationSections(IsELF64, RelTextSections); |
531 writeRelocationSections(IsELF64, RelDataSections); | 531 writeRelocationSections(IsELF64, RelDataSections); |
532 writeRelocationSections(IsELF64, RelRODataSections); | 532 writeRelocationSections(IsELF64, RelRODataSections); |
533 } | 533 } |
534 | 534 |
| 535 void ELFObjectWriter::setUndefinedSyms(const ConstantList &UndefSyms) { |
| 536 for (const Constant *S : UndefSyms) { |
| 537 const auto Sym = llvm::cast<ConstantRelocatable>(S); |
| 538 IceString Name = Sym->getName(); |
| 539 assert(Sym->getOffset() == 0); |
| 540 assert(Sym->getSuppressMangling()); |
| 541 SymTab->noteUndefinedSym(Name, NullSection); |
| 542 StrTab->add(Name); |
| 543 } |
| 544 } |
| 545 |
535 void ELFObjectWriter::writeRelocationSections(bool IsELF64, | 546 void ELFObjectWriter::writeRelocationSections(bool IsELF64, |
536 RelSectionList &RelSections) { | 547 RelSectionList &RelSections) { |
537 for (ELFRelocationSection *RelSec : RelSections) { | 548 for (ELFRelocationSection *RelSec : RelSections) { |
538 Elf64_Off Offset = alignFileOffset(RelSec->getSectionAlign()); | 549 Elf64_Off Offset = alignFileOffset(RelSec->getSectionAlign()); |
539 RelSec->setFileOffset(Offset); | 550 RelSec->setFileOffset(Offset); |
540 RelSec->setSize(RelSec->getSectionDataSize(Ctx, SymTab)); | 551 RelSec->setSize(RelSec->getSectionDataSize()); |
541 if (IsELF64) { | 552 if (IsELF64) { |
542 RelSec->writeData<true>(Ctx, Str, SymTab); | 553 RelSec->writeData<true>(Ctx, Str, SymTab); |
543 } else { | 554 } else { |
544 RelSec->writeData<false>(Ctx, Str, SymTab); | 555 RelSec->writeData<false>(Ctx, Str, SymTab); |
545 } | 556 } |
546 } | 557 } |
547 } | 558 } |
548 | 559 |
549 void ELFObjectWriter::writeNonUserSections() { | 560 void ELFObjectWriter::writeNonUserSections() { |
550 bool IsELF64 = isELF64(Ctx.getTargetArch()); | 561 bool IsELF64 = isELF64(Ctx.getTargetArch()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 if (IsELF64) { | 602 if (IsELF64) { |
592 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), | 603 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), |
593 AllSections.size()); | 604 AllSections.size()); |
594 } else { | 605 } else { |
595 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), | 606 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), |
596 AllSections.size()); | 607 AllSections.size()); |
597 } | 608 } |
598 } | 609 } |
599 | 610 |
600 } // end of namespace Ice | 611 } // end of namespace Ice |
OLD | NEW |