@@ -183,8 +183,8 @@ struct ELFWriter {
183
183
184
184
void writeHeader (const MCAssembler &Asm);
185
185
186
- void writeSymbol (const MCAssembler &Asm, SymbolTableWriter &Writer ,
187
- uint32_t StringIndex, ELFSymbolData &MSD);
186
+ void writeSymbol (SymbolTableWriter &Writer, uint32_t StringIndex ,
187
+ ELFSymbolData &MSD);
188
188
189
189
// Map from a signature symbol to the group section index
190
190
using RevGroupMapTy = DenseMap<const MCSymbol *, unsigned >;
@@ -408,8 +408,8 @@ static bool isIFunc(const MCSymbolELF *Symbol) {
408
408
return true ;
409
409
}
410
410
411
- void ELFWriter::writeSymbol (const MCAssembler &Asm, SymbolTableWriter &Writer ,
412
- uint32_t StringIndex, ELFSymbolData &MSD) {
411
+ void ELFWriter::writeSymbol (SymbolTableWriter &Writer, uint32_t StringIndex ,
412
+ ELFSymbolData &MSD) {
413
413
const auto &Symbol = cast<MCSymbolELF>(*MSD.Symbol );
414
414
const MCSymbolELF *Base =
415
415
cast_or_null<MCSymbolELF>(Asm.getBaseSymbol (Symbol));
@@ -647,7 +647,7 @@ void ELFWriter::computeSymbolTable(MCAssembler &Asm,
647
647
? 0
648
648
: StrTabBuilder.getOffset (MSD.Name );
649
649
MSD.Symbol ->setIndex (Index++);
650
- writeSymbol (Asm, Writer, StringIndex, MSD);
650
+ writeSymbol (Writer, StringIndex, MSD);
651
651
}
652
652
for (; FileNameIt != FileNames.end (); ++FileNameIt) {
653
653
Writer.writeSymbol (StrTabBuilder.getOffset (FileNameIt->first ),
@@ -662,7 +662,7 @@ void ELFWriter::computeSymbolTable(MCAssembler &Asm,
662
662
for (ELFSymbolData &MSD : ExternalSymbolData) {
663
663
unsigned StringIndex = StrTabBuilder.getOffset (MSD.Name );
664
664
MSD.Symbol ->setIndex (Index++);
665
- writeSymbol (Asm, Writer, StringIndex, MSD);
665
+ writeSymbol (Writer, StringIndex, MSD);
666
666
assert (MSD.Symbol ->getBinding () != ELF::STB_LOCAL);
667
667
}
668
668
@@ -1248,8 +1248,7 @@ void ELFObjectWriter::executePostLayoutBinding() {
1248
1248
// It is always valid to create a relocation with a symbol. It is preferable
1249
1249
// to use a relocation with a section if that is possible. Using the section
1250
1250
// allows us to omit some local symbols from the symbol table.
1251
- bool ELFObjectWriter::useSectionSymbol (const MCAssembler &Asm,
1252
- const MCValue &Val,
1251
+ bool ELFObjectWriter::useSectionSymbol (const MCValue &Val,
1253
1252
const MCSymbolELF *Sym, uint64_t C,
1254
1253
unsigned Type) const {
1255
1254
// Keep symbol type for a local ifunc because it may result in an IRELATIVE
@@ -1265,6 +1264,7 @@ bool ELFObjectWriter::useSectionSymbol(const MCAssembler &Asm,
1265
1264
// If we change such a relocation to use the section, the linker would think
1266
1265
// that it pointed to another string and subtracting 42 at runtime will
1267
1266
// produce the wrong value.
1267
+ auto EMachine = TargetObjectWriter->getEMachine ();
1268
1268
if (Sym->isInSection ()) {
1269
1269
auto &Sec = cast<MCSectionELF>(Sym->getSection ());
1270
1270
unsigned Flags = Sec.getFlags ();
@@ -1274,8 +1274,7 @@ bool ELFObjectWriter::useSectionSymbol(const MCAssembler &Asm,
1274
1274
1275
1275
// gold<2.34 incorrectly ignored the addend for R_386_GOTOFF (9)
1276
1276
// (http://sourceware.org/PR16794).
1277
- if (TargetObjectWriter->getEMachine () == ELF::EM_386 &&
1278
- Type == ELF::R_386_GOTOFF)
1277
+ if (EMachine == ELF::EM_386 && Type == ELF::R_386_GOTOFF)
1279
1278
return false ;
1280
1279
1281
1280
// ld.lld handles R_MIPS_HI16/R_MIPS_LO16 separately, not as a whole, so
@@ -1285,8 +1284,7 @@ bool ELFObjectWriter::useSectionSymbol(const MCAssembler &Asm,
1285
1284
// (like R_RISCV_PC_INDIRECT for R_RISCV_PCREL_HI20 / R_RISCV_PCREL_LO12)
1286
1285
// but the complexity is unnecessary given that GNU as keeps the original
1287
1286
// symbol for this case as well.
1288
- if (TargetObjectWriter->getEMachine () == ELF::EM_MIPS &&
1289
- !hasRelocationAddend ())
1287
+ if (EMachine == ELF::EM_MIPS && !hasRelocationAddend ())
1290
1288
return false ;
1291
1289
}
1292
1290
@@ -1302,7 +1300,7 @@ bool ELFObjectWriter::useSectionSymbol(const MCAssembler &Asm,
1302
1300
// bit. With a symbol that is done by just having the symbol have that bit
1303
1301
// set, so we would lose the bit if we relocated with the section.
1304
1302
// FIXME: We could use the section but add the bit to the relocation value.
1305
- if (Asm. isThumbFunc (Sym))
1303
+ if (EMachine == ELF::EM_ARM && Asm-> isThumbFunc (Sym))
1306
1304
return false ;
1307
1305
1308
1306
return !TargetObjectWriter->needsRelocateWithSymbol (Val, *Sym, Type);
@@ -1382,7 +1380,7 @@ void ELFObjectWriter::recordRelocation(const MCFragment &F,
1382
1380
bool UseSectionSym =
1383
1381
SymA && SymA->getBinding () == ELF::STB_LOCAL && !SymA->isUndefined ();
1384
1382
if (UseSectionSym) {
1385
- UseSectionSym = useSectionSymbol (*Asm, Target, SymA, Addend, Type);
1383
+ UseSectionSym = useSectionSymbol (Target, SymA, Addend, Type);
1386
1384
1387
1385
// Disable STT_SECTION adjustment for .reloc directives.
1388
1386
UseSectionSym &= !mc::isRelocRelocation (Fixup.getKind ());
0 commit comments