[llvm] [llvm-objdump][ELF]Fix crash when reading strings from .dynstr (PR #125679)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 12 02:35:52 PST 2025
================
@@ -221,6 +221,28 @@ template <class ELFT> void ELFDumper<ELFT>::printDynamicSection() {
std::string TagFmt = " %-" + std::to_string(MaxLen) + "s ";
outs() << "\nDynamic Section:\n";
+ typename ELFT::Xword StringTableSize{0};
+ for (const typename ELFT::Shdr &Sec : cantFail(Elf.sections())) {
+ if (Sec.sh_type == ELF::SHT_DYNSYM) {
----------------
jh7370 wrote:
This will work because it happens to be the same section in pretty much any normal ELF, but is not technically correct. You should check `SHT_DYNAMIC`, since the strings referenced by the dynamic section are the ones you need (not the dynamic symbol names).
https://github.com/llvm/llvm-project/pull/125679
More information about the llvm-commits
mailing list