@@ -108,8 +108,8 @@ struct ELFWriter {
108
108
DwoOnly,
109
109
} Mode;
110
110
111
- static uint64_t symbolValue (const MCSymbol &Sym , const MCAssembler &Asm );
112
- static bool isInSymtab (const MCAsmLayout &Layout , const MCSymbolELF &Symbol,
111
+ static uint64_t symbolValue (const MCAssembler &Asm , const MCSymbol &Sym );
112
+ static bool isInSymtab (const MCAssembler &Asm , const MCSymbolELF &Symbol,
113
113
bool Used, bool Renamed);
114
114
115
115
// / Helper struct for containing some precomputed information on symbols.
@@ -168,8 +168,8 @@ struct ELFWriter {
168
168
169
169
void writeHeader (const MCAssembler &Asm);
170
170
171
- void writeSymbol (SymbolTableWriter &Writer, uint32_t StringIndex ,
172
- ELFSymbolData &MSD, const MCAsmLayout &Layout );
171
+ void writeSymbol (const MCAssembler &Asm, SymbolTableWriter &Writer ,
172
+ uint32_t StringIndex, ELFSymbolData &MSD );
173
173
174
174
// Start and end offset of each section
175
175
using SectionOffsetsTy =
@@ -183,7 +183,7 @@ struct ELFWriter {
183
183
// / \param Asm - The assembler.
184
184
// / \param SectionIndexMap - Maps a section to its index.
185
185
// / \param RevGroupMap - Maps a signature symbol to the group section.
186
- void computeSymbolTable (MCAssembler &Asm, const MCAsmLayout &Layout,
186
+ void computeSymbolTable (MCAssembler &Asm,
187
187
const SectionIndexMapTy &SectionIndexMap,
188
188
const RevGroupMapTy &RevGroupMap,
189
189
SectionOffsetsTy &SectionOffsets);
@@ -193,7 +193,7 @@ struct ELFWriter {
193
193
MCSectionELF *createRelocationSection (MCContext &Ctx,
194
194
const MCSectionELF &Sec);
195
195
196
- void writeSectionHeader (const MCAsmLayout &Layout ,
196
+ void writeSectionHeader (const MCAssembler &Asm ,
197
197
const SectionIndexMapTy &SectionIndexMap,
198
198
const SectionOffsetsTy &SectionOffsets);
199
199
@@ -453,7 +453,7 @@ void ELFWriter::writeHeader(const MCAssembler &Asm) {
453
453
W.write <uint16_t >(StringTableIndex);
454
454
}
455
455
456
- uint64_t ELFWriter::symbolValue (const MCSymbol &Sym , const MCAssembler &Asm ) {
456
+ uint64_t ELFWriter::symbolValue (const MCAssembler &Asm , const MCSymbol &Sym ) {
457
457
if (Sym.isCommon ())
458
458
return Sym.getCommonAlignment ()->value ();
459
459
@@ -515,11 +515,11 @@ static bool isIFunc(const MCSymbolELF *Symbol) {
515
515
return true ;
516
516
}
517
517
518
- void ELFWriter::writeSymbol (SymbolTableWriter &Writer, uint32_t StringIndex ,
519
- ELFSymbolData &MSD, const MCAsmLayout &Layout ) {
518
+ void ELFWriter::writeSymbol (const MCAssembler &Asm, SymbolTableWriter &Writer ,
519
+ uint32_t StringIndex, ELFSymbolData &MSD ) {
520
520
const auto &Symbol = cast<MCSymbolELF>(*MSD.Symbol );
521
521
const MCSymbolELF *Base =
522
- cast_or_null<MCSymbolELF>(Layout .getBaseSymbol (Symbol));
522
+ cast_or_null<MCSymbolELF>(Asm .getBaseSymbol (Symbol));
523
523
524
524
// This has to be in sync with when computeSymbolTable uses SHN_ABS or
525
525
// SHN_COMMON.
@@ -540,7 +540,7 @@ void ELFWriter::writeSymbol(SymbolTableWriter &Writer, uint32_t StringIndex,
540
540
uint8_t Visibility = Symbol.getVisibility ();
541
541
uint8_t Other = Symbol.getOther () | Visibility;
542
542
543
- uint64_t Value = symbolValue (*MSD.Symbol , Layout. getAssembler () );
543
+ uint64_t Value = symbolValue (Asm, *MSD.Symbol );
544
544
uint64_t Size = 0 ;
545
545
546
546
const MCExpr *ESize = MSD.Symbol ->getSize ();
@@ -567,7 +567,7 @@ void ELFWriter::writeSymbol(SymbolTableWriter &Writer, uint32_t StringIndex,
567
567
568
568
if (ESize) {
569
569
int64_t Res;
570
- if (!ESize->evaluateKnownAbsolute (Res, Layout ))
570
+ if (!ESize->evaluateKnownAbsolute (Res, *Asm. getLayout () ))
571
571
report_fatal_error (" Size expression must be absolute." );
572
572
Size = Res;
573
573
}
@@ -577,7 +577,7 @@ void ELFWriter::writeSymbol(SymbolTableWriter &Writer, uint32_t StringIndex,
577
577
IsReserved);
578
578
}
579
579
580
- bool ELFWriter::isInSymtab (const MCAsmLayout &Layout , const MCSymbolELF &Symbol,
580
+ bool ELFWriter::isInSymtab (const MCAssembler &Asm , const MCSymbolELF &Symbol,
581
581
bool Used, bool Renamed) {
582
582
if (Symbol.isVariable ()) {
583
583
const MCExpr *Expr = Symbol.getVariableValue ();
@@ -599,7 +599,7 @@ bool ELFWriter::isInSymtab(const MCAsmLayout &Layout, const MCSymbolELF &Symbol,
599
599
600
600
if (Symbol.isVariable () && Symbol.isUndefined ()) {
601
601
// FIXME: this is here just to diagnose the case of a var = commmon_sym.
602
- Layout .getBaseSymbol (Symbol);
602
+ Asm .getBaseSymbol (Symbol);
603
603
return false ;
604
604
}
605
605
@@ -612,10 +612,10 @@ bool ELFWriter::isInSymtab(const MCAsmLayout &Layout, const MCSymbolELF &Symbol,
612
612
return true ;
613
613
}
614
614
615
- void ELFWriter::computeSymbolTable (
616
- MCAssembler &Asm, const MCAsmLayout &Layout ,
617
- const SectionIndexMapTy &SectionIndexMap, const RevGroupMapTy &RevGroupMap,
618
- SectionOffsetsTy &SectionOffsets) {
615
+ void ELFWriter::computeSymbolTable (MCAssembler &Asm,
616
+ const SectionIndexMapTy &SectionIndexMap ,
617
+ const RevGroupMapTy &RevGroupMap,
618
+ SectionOffsetsTy &SectionOffsets) {
619
619
MCContext &Ctx = Asm.getContext ();
620
620
SymbolTableWriter Writer (*this , is64Bit ());
621
621
@@ -646,7 +646,7 @@ void ELFWriter::computeSymbolTable(
646
646
bool WeakrefUsed = Symbol.isWeakrefUsedInReloc ();
647
647
bool isSignature = Symbol.isSignature ();
648
648
649
- if (!isInSymtab (Layout , Symbol, Used || WeakrefUsed || isSignature,
649
+ if (!isInSymtab (Asm , Symbol, Used || WeakrefUsed || isSignature,
650
650
OWriter.Renames .count (&Symbol)))
651
651
continue ;
652
652
@@ -756,7 +756,7 @@ void ELFWriter::computeSymbolTable(
756
756
? 0
757
757
: StrTabBuilder.getOffset (MSD.Name );
758
758
MSD.Symbol ->setIndex (Index++);
759
- writeSymbol (Writer, StringIndex, MSD, Layout );
759
+ writeSymbol (Asm, Writer, StringIndex, MSD);
760
760
}
761
761
for (; FileNameIt != FileNames.end (); ++FileNameIt) {
762
762
Writer.writeSymbol (StrTabBuilder.getOffset (FileNameIt->first ),
@@ -771,7 +771,7 @@ void ELFWriter::computeSymbolTable(
771
771
for (ELFSymbolData &MSD : ExternalSymbolData) {
772
772
unsigned StringIndex = StrTabBuilder.getOffset (MSD.Name );
773
773
MSD.Symbol ->setIndex (Index++);
774
- writeSymbol (Writer, StringIndex, MSD, Layout );
774
+ writeSymbol (Asm, Writer, StringIndex, MSD);
775
775
assert (MSD.Symbol ->getBinding () != ELF::STB_LOCAL);
776
776
}
777
777
@@ -1033,9 +1033,9 @@ void ELFWriter::writeSection(const SectionIndexMapTy &SectionIndexMap,
1033
1033
Section.getEntrySize ());
1034
1034
}
1035
1035
1036
- void ELFWriter::writeSectionHeader (
1037
- const MCAsmLayout &Layout, const SectionIndexMapTy &SectionIndexMap,
1038
- const SectionOffsetsTy &SectionOffsets) {
1036
+ void ELFWriter::writeSectionHeader (const MCAssembler &Asm,
1037
+ const SectionIndexMapTy &SectionIndexMap,
1038
+ const SectionOffsetsTy &SectionOffsets) {
1039
1039
const unsigned NumSections = SectionTable.size ();
1040
1040
1041
1041
// Null section first.
@@ -1055,7 +1055,7 @@ void ELFWriter::writeSectionHeader(
1055
1055
SectionOffsets.find (Section)->second ;
1056
1056
uint64_t Size;
1057
1057
if (Type == ELF::SHT_NOBITS)
1058
- Size = Layout .getSectionAddressSize (Section);
1058
+ Size = Asm .getSectionAddressSize (* Section);
1059
1059
else
1060
1060
Size = Offsets.second - Offsets.first ;
1061
1061
@@ -1065,7 +1065,6 @@ void ELFWriter::writeSectionHeader(
1065
1065
}
1066
1066
1067
1067
uint64_t ELFWriter::writeObject (MCAssembler &Asm) {
1068
- auto &Layout = *Asm.getLayout ();
1069
1068
uint64_t StartOffset = W.OS .tell ();
1070
1069
1071
1070
MCContext &Ctx = Asm.getContext ();
@@ -1157,8 +1156,7 @@ uint64_t ELFWriter::writeObject(MCAssembler &Asm) {
1157
1156
}
1158
1157
1159
1158
// Compute symbol table information.
1160
- computeSymbolTable (Asm, Layout, SectionIndexMap, RevGroupMap,
1161
- SectionOffsets);
1159
+ computeSymbolTable (Asm, SectionIndexMap, RevGroupMap, SectionOffsets);
1162
1160
1163
1161
for (MCSectionELF *RelSection : Relocations) {
1164
1162
// Remember the offset into the file for this section.
@@ -1188,7 +1186,7 @@ uint64_t ELFWriter::writeObject(MCAssembler &Asm) {
1188
1186
const uint64_t SectionHeaderOffset = align (is64Bit () ? Align (8 ) : Align (4 ));
1189
1187
1190
1188
// ... then the section header table ...
1191
- writeSectionHeader (Layout , SectionIndexMap, SectionOffsets);
1189
+ writeSectionHeader (Asm , SectionIndexMap, SectionOffsets);
1192
1190
1193
1191
uint16_t NumSections = support::endian::byte_swap<uint16_t >(
1194
1192
(SectionTable.size () + 1 >= ELF::SHN_LORESERVE) ? (uint16_t )ELF::SHN_UNDEF
0 commit comments