Skip to content

Commit

Permalink
[ELF] Remove one redundant computeBinding
Browse files Browse the repository at this point in the history
This does resolve the redundancy in includeInDynsym().
  • Loading branch information
MaskRay committed Dec 26, 2021
1 parent 20b4704 commit aabe901
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lld/ELF/SyntheticSections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2116,9 +2116,8 @@ void SymbolTableBaseSection::finalizeContents() {
void SymbolTableBaseSection::sortSymTabSymbols() {
// Move all local symbols before global symbols.
auto e = std::stable_partition(
symbols.begin(), symbols.end(), [](const SymbolTableEntry &s) {
return s.sym->isLocal() || s.sym->computeBinding() == STB_LOCAL;
});
symbols.begin(), symbols.end(),
[](const SymbolTableEntry &s) { return s.sym->isLocal(); });
size_t numLocals = e - symbols.begin();
getParent()->info = numLocals + 1;

Expand Down Expand Up @@ -2208,12 +2207,8 @@ template <class ELFT> void SymbolTableSection<ELFT>::writeTo(uint8_t *buf) {

// Set st_info and st_other.
eSym->st_other = 0;
if (sym->isLocal()) {
eSym->setBindingAndType(STB_LOCAL, sym->type);
} else {
eSym->setBindingAndType(sym->computeBinding(), sym->type);
eSym->setVisibility(sym->visibility);
}
eSym->setBindingAndType(sym->binding, sym->type);
eSym->setVisibility(sym->visibility);

// The 3 most significant bits of st_other are used by OpenPOWER ABI.
// See getPPC64GlobalEntryToLocalEntryOffset() for more details.
Expand Down
1 change: 1 addition & 0 deletions lld/ELF/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
for (Symbol *sym : symtab->symbols()) {
if (!sym->isUsedInRegularObj || !includeInSymtab(*sym))
continue;
sym->binding = sym->computeBinding();
if (in.symTab)
in.symTab->addSymbol(sym);

Expand Down

0 comments on commit aabe901

Please sign in to comment.