Skip to content

Commit

Permalink
[ELF] maybeReportUndefined: move sym.isUndefined() check to the calle…
Browse files Browse the repository at this point in the history
…r. NFC

Avoid a function call in the majority of cases.
  • Loading branch information
MaskRay committed Dec 16, 2021
1 parent 6bca9a4 commit 8617996
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lld/ELF/Relocations.cpp
Expand Up @@ -739,8 +739,6 @@ template <class ELFT> void elf::reportUndefinedSymbols() {
// Returns true if the undefined symbol will produce an error message.
static bool maybeReportUndefined(Symbol &sym, InputSectionBase &sec,
uint64_t offset) {
if (!sym.isUndefined())
return false;
// If versioned, issue an error (even if the symbol is weak) because we don't
// know the defining filename which is required to construct a Verneed entry.
if (*sym.getVersionSuffix() == '@') {
Expand Down Expand Up @@ -1327,7 +1325,8 @@ static void scanReloc(InputSectionBase &sec, OffsetGetter &getOffset, RelTy *&i,

// Error if the target symbol is undefined. Symbol index 0 may be used by
// marker relocations, e.g. R_*_NONE and R_ARM_V4BX. Don't error on them.
if (symIndex != 0 && maybeReportUndefined(sym, sec, rel.r_offset))
if (sym.isUndefined() && symIndex != 0 &&
maybeReportUndefined(sym, sec, rel.r_offset))
return;

const uint8_t *relocatedAddr = sec.data().begin() + rel.r_offset;
Expand Down

0 comments on commit 8617996

Please sign in to comment.