@@ -120,7 +120,7 @@ struct ELFWriter {
120
120
} Mode;
121
121
122
122
uint64_t symbolValue (const MCSymbol &Sym);
123
- bool isInSymtab (const MCSymbolELF &Symbol, bool Used, bool Renamed );
123
+ bool isInSymtab (const MCSymbolELF &Symbol);
124
124
125
125
// / Helper struct for containing some precomputed information on symbols.
126
126
struct ELFSymbolData {
@@ -468,7 +468,13 @@ void ELFWriter::writeSymbol(SymbolTableWriter &Writer, uint32_t StringIndex,
468
468
IsReserved);
469
469
}
470
470
471
- bool ELFWriter::isInSymtab (const MCSymbolELF &Symbol, bool Used, bool Renamed) {
471
+ bool ELFWriter::isInSymtab (const MCSymbolELF &Symbol) {
472
+ if (Symbol.isUsedInReloc () || Symbol.isSignature ())
473
+ return true ;
474
+
475
+ if (OWriter.Renames .count (&Symbol))
476
+ return false ;
477
+
472
478
if (Symbol.isVariable ()) {
473
479
const MCExpr *Expr = Symbol.getVariableValue ();
474
480
// Target Expressions that are always inlined do not appear in the symtab
@@ -478,27 +484,18 @@ bool ELFWriter::isInSymtab(const MCSymbolELF &Symbol, bool Used, bool Renamed) {
478
484
// The .weakref alias does not appear in the symtab.
479
485
if (Symbol.isWeakref ())
480
486
return false ;
481
- }
482
-
483
- if (Used)
484
- return true ;
485
487
486
- if (Renamed)
487
- return false ;
488
-
489
- if (Symbol.isVariable () && Symbol.isUndefined ()) {
490
- // FIXME: this is here just to diagnose the case of a var = commmon_sym.
491
- Asm.getBaseSymbol (Symbol);
492
- return false ;
488
+ if (Symbol.isUndefined ()) {
489
+ // FIXME: this is here just to diagnose the case of a var = commmon_sym.
490
+ Asm.getBaseSymbol (Symbol);
491
+ return false ;
492
+ }
493
493
}
494
494
495
495
if (Symbol.isTemporary ())
496
496
return false ;
497
497
498
- if (Symbol.getType () == ELF::STT_SECTION)
499
- return false ;
500
-
501
- return true ;
498
+ return Symbol.getType () != ELF::STT_SECTION;
502
499
}
503
500
504
501
void ELFWriter::computeSymbolTable (const RevGroupMapTy &RevGroupMap) {
@@ -528,10 +525,7 @@ void ELFWriter::computeSymbolTable(const RevGroupMapTy &RevGroupMap) {
528
525
bool HasLargeSectionIndex = false ;
529
526
for (auto It : llvm::enumerate (Asm.symbols ())) {
530
527
const auto &Symbol = cast<MCSymbolELF>(It.value ());
531
- bool Used = Symbol.isUsedInReloc ();
532
- bool isSignature = Symbol.isSignature ();
533
- if (!isInSymtab (Symbol, Used || isSignature,
534
- OWriter.Renames .count (&Symbol)))
528
+ if (!isInSymtab (Symbol))
535
529
continue ;
536
530
537
531
if (Symbol.isTemporary () && Symbol.isUndefined ()) {
@@ -556,7 +550,7 @@ void ELFWriter::computeSymbolTable(const RevGroupMapTy &RevGroupMap) {
556
550
MSD.SectionIndex = ELF::SHN_COMMON;
557
551
}
558
552
} else if (Symbol.isUndefined ()) {
559
- if (isSignature && !Used ) {
553
+ if (Symbol. isSignature () && !Symbol. isUsedInReloc () ) {
560
554
MSD.SectionIndex = RevGroupMap.lookup (&Symbol);
561
555
if (MSD.SectionIndex >= ELF::SHN_LORESERVE)
562
556
HasLargeSectionIndex = true ;
0 commit comments