Fix phantom imports in the section-less ELF symbol scan ##bin - #26475
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
.dynsymcarries no size tag, so with no section headers the scan bounded it atDT_STRTABalone. lld places.gnu.hash/.hash— and.gnu.versionwhen symbols are versioned — between.dynsymand.dynstr, so those tables were decoded as symbols:That line is the gnu-hash header read as an
Elf64_Sym:nbuckets(1) became the name index,bloom_size | bloom_shift << 32became the address. It also appeared inisasimp.fooand inimports_by_ord.Three commits:
DT_STRTAB/DT_GNU_HASH/DT_HASH/DT_VERSYM;DT_GNU_HASHis now parsed.st_shndxagainstSHT_NULL/SHT_DYNSYM— section types, not indices — so a symbol defined in section 11 was emitted as an import (_ftextinbins/elf/analysis/mipsbe-ubusd). It now uses theis_importedit already computes, matching the section-header path.DT_HASH'snchain(orDT_MIPS_SYMTABNO), so layouts where every table precedes.dynsymare bounded too; positional bounds remain the fallback.nchainmatches the real.dynsymsize on 145 of the 146 test binaries carrying both, and the one outlier states a larger count, so the cap cannot truncate.