Skip to content

Commit ea72c08

Browse files
committed
[ELF] Change getSymbolIndex to use const reference. NFC
1 parent 18da51b commit ea72c08

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

lld/ELF/InputSection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ void InputSection::copyRelocations(uint8_t *buf,
408408
// Output section VA is zero for -r, so r_offset is an offset within the
409409
// section, but for --emit-relocs it is a virtual address.
410410
p->r_offset = sec->getVA(rel.offset);
411-
p->setSymbolAndType(in.symTab->getSymbolIndex(&sym), type,
411+
p->setSymbolAndType(in.symTab->getSymbolIndex(sym), type,
412412
config->isMips64EL);
413413

414414
if (sym.type == STT_SECTION) {

lld/ELF/OutputSections.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ static void finalizeShtGroup(OutputSection *os, InputSection *section) {
583583
// sh_info then contain index of an entry in symbol table section which
584584
// provides signature of the section group.
585585
ArrayRef<Symbol *> symbols = section->file->getSymbols();
586-
os->info = in.symTab->getSymbolIndex(symbols[section->info]);
586+
os->info = in.symTab->getSymbolIndex(*symbols[section->info]);
587587

588588
// Some group members may be combined or discarded, so we need to compute the
589589
// new size. The content will be rewritten in InputSection::copyShtGroup.

lld/ELF/SyntheticSections.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ uint32_t DynamicReloc::getSymIndex(SymbolTableBaseSection *symTab) const {
16001600
if (!needsDynSymIndex())
16011601
return 0;
16021602

1603-
size_t index = symTab->getSymbolIndex(sym);
1603+
size_t index = symTab->getSymbolIndex(*sym);
16041604
assert((index != 0 || (type != target->gotRel && type != target->pltRel) ||
16051605
!mainPart->dynSymTab->getParent()) &&
16061606
"GOT or PLT relocation must refer to symbol in dynamic symbol table");
@@ -2172,9 +2172,9 @@ void SymbolTableBaseSection::addSymbol(Symbol *b) {
21722172
symbols.push_back({b, strTabSec.addString(b->getName(), false)});
21732173
}
21742174

2175-
size_t SymbolTableBaseSection::getSymbolIndex(Symbol *sym) {
2175+
size_t SymbolTableBaseSection::getSymbolIndex(const Symbol &sym) {
21762176
if (this == mainPart->dynSymTab.get())
2177-
return sym->dynsymIndex;
2177+
return sym.dynsymIndex;
21782178

21792179
// Initializes symbol lookup tables lazily. This is used only for -r,
21802180
// --emit-relocs and dynsyms in partitions other than the main one.
@@ -2191,9 +2191,9 @@ size_t SymbolTableBaseSection::getSymbolIndex(Symbol *sym) {
21912191

21922192
// Section symbols are mapped based on their output sections
21932193
// to maintain their semantics.
2194-
if (sym->type == STT_SECTION)
2195-
return sectionIndexMap.lookup(sym->getOutputSection());
2196-
return symbolIndexMap.lookup(sym);
2194+
if (sym.type == STT_SECTION)
2195+
return sectionIndexMap.lookup(sym.getOutputSection());
2196+
return symbolIndexMap.lookup(&sym);
21972197
}
21982198

21992199
template <class ELFT>
@@ -2427,7 +2427,7 @@ void GnuHashTableSection::writeTo(uint8_t *buf) {
24272427
// Write a hash bucket. Hash buckets contain indices in the following hash
24282428
// value table.
24292429
write32(buckets + i->bucketIdx,
2430-
getPartition().dynSymTab->getSymbolIndex(i->sym));
2430+
getPartition().dynSymTab->getSymbolIndex(*i->sym));
24312431
oldBucket = i->bucketIdx;
24322432
}
24332433
}

lld/ELF/SyntheticSections.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ class SymbolTableBaseSection : public SyntheticSection {
641641
size_t getSize() const override { return getNumSymbols() * entsize; }
642642
void addSymbol(Symbol *sym);
643643
unsigned getNumSymbols() const { return symbols.size() + 1; }
644-
size_t getSymbolIndex(Symbol *sym);
644+
size_t getSymbolIndex(const Symbol &sym);
645645
ArrayRef<SymbolTableEntry> getSymbols() const { return symbols; }
646646

647647
protected:

0 commit comments

Comments
 (0)