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 /// \file | 10 /// \file |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 } | 575 } |
576 | 576 |
577 void ELFObjectWriter::writeJumpTable(const JumpTableData &JT, | 577 void ELFObjectWriter::writeJumpTable(const JumpTableData &JT, |
578 FixupKind RelocationKind, bool IsPIC) { | 578 FixupKind RelocationKind, bool IsPIC) { |
579 TimerMarker Timer(TimerStack::TT_writeELF, &Ctx); | 579 TimerMarker Timer(TimerStack::TT_writeELF, &Ctx); |
580 ELFDataSection *Section; | 580 ELFDataSection *Section; |
581 ELFRelocationSection *RelSection; | 581 ELFRelocationSection *RelSection; |
582 const Elf64_Xword PointerSize = typeWidthInBytes(getPointerType()); | 582 const Elf64_Xword PointerSize = typeWidthInBytes(getPointerType()); |
583 const Elf64_Xword ShAddralign = PointerSize; | 583 const Elf64_Xword ShAddralign = PointerSize; |
584 const Elf64_Xword ShEntsize = PointerSize; | 584 const Elf64_Xword ShEntsize = PointerSize; |
585 const GlobalString JTName = JT.getFunctionName(); | |
586 const std::string SectionName = MangleSectionName( | 585 const std::string SectionName = MangleSectionName( |
587 IsPIC ? ".data.rel.ro" : ".rodata", | 586 IsPIC ? ".data.rel.ro" : ".rodata", JT.getSectionName()); |
Jim Stichnoth
2016/04/04 13:42:30
It bothers me a tiny bit that we are instantiating
John
2016/04/05 12:22:43
This would change sz's output, so I'll leave as is
| |
588 (JTName.hasStdString() ? JTName.toString() | |
589 : std::to_string(JTName.getID())) + | |
590 "$jumptable"); | |
591 Section = createSection<ELFDataSection>(SectionName, SHT_PROGBITS, SHF_ALLOC, | 587 Section = createSection<ELFDataSection>(SectionName, SHT_PROGBITS, SHF_ALLOC, |
592 ShAddralign, ShEntsize); | 588 ShAddralign, ShEntsize); |
593 Section->setFileOffset(alignFileOffset(ShAddralign)); | 589 Section->setFileOffset(alignFileOffset(ShAddralign)); |
594 RODataSections.push_back(Section); | 590 RODataSections.push_back(Section); |
595 RelSection = createRelocationSection(Section); | 591 RelSection = createRelocationSection(Section); |
596 RelRODataSections.push_back(RelSection); | 592 RelRODataSections.push_back(RelSection); |
597 | 593 |
598 constexpr uint8_t SymbolType = STT_OBJECT; | 594 constexpr uint8_t SymbolType = STT_OBJECT; |
599 Section->padToAlignment(Str, PointerSize); | 595 Section->padToAlignment(Str, PointerSize); |
600 const bool IsExternal = Ctx.getFlags().getDisableInternal(); | 596 const bool IsExternal = Ctx.getFlags().getDisableInternal(); |
601 const uint8_t SymbolBinding = IsExternal ? STB_GLOBAL : STB_LOCAL; | 597 const uint8_t SymbolBinding = IsExternal ? STB_GLOBAL : STB_LOCAL; |
602 GlobalString JumpTableName = Ctx.getGlobalString( | 598 const auto JumpTableName = JT.getName(); |
603 InstJumpTable::makeName(JT.getFunctionName(), JT.getId())); | |
604 SymTab->createDefinedSym(JumpTableName, SymbolType, SymbolBinding, Section, | 599 SymTab->createDefinedSym(JumpTableName, SymbolType, SymbolBinding, Section, |
605 Section->getCurrentSize(), PointerSize); | 600 Section->getCurrentSize(), PointerSize); |
606 StrTab->add(JumpTableName); | 601 StrTab->add(JumpTableName); |
607 | 602 |
608 for (intptr_t TargetOffset : JT.getTargetOffsets()) { | 603 for (intptr_t TargetOffset : JT.getTargetOffsets()) { |
609 AssemblerFixup NewFixup; | 604 AssemblerFixup NewFixup; |
610 NewFixup.set_position(Section->getCurrentSize()); | 605 NewFixup.set_position(Section->getCurrentSize()); |
611 NewFixup.set_kind(RelocationKind); | 606 NewFixup.set_kind(RelocationKind); |
612 NewFixup.set_value(Ctx.getConstantSym(TargetOffset, JT.getFunctionName())); | 607 NewFixup.set_value(Ctx.getConstantSym(TargetOffset, JT.getFunctionName())); |
613 RelSection->addRelocation(NewFixup); | 608 RelSection->addRelocation(NewFixup); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
693 if (ELF64) { | 688 if (ELF64) { |
694 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), | 689 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), |
695 AllSections.size()); | 690 AllSections.size()); |
696 } else { | 691 } else { |
697 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), | 692 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), |
698 AllSections.size()); | 693 AllSections.size()); |
699 } | 694 } |
700 } | 695 } |
701 | 696 |
702 } // end of namespace Ice | 697 } // end of namespace Ice |
OLD | NEW |