This change adds tests for llvm-nm, llvm-objdump and llvm-size when dumping symbol tables with invalid sh_size (sh_size % sizeof(Elf_Sym) != 0).
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| llvm/test/tools/llvm-nm/invalid-symbol-table-size.test | ||
|---|---|---|
| 13 | In this and other test cases you have 2 sections: .symtab and .dynsym, but only one section (with index 2) | |
| llvm/test/tools/llvm-nm/invalid-symbol-table-size.test | ||
|---|---|---|
| 13 | Yes, because there are malformed .symtab and .dynsym symbol tables in one ELF file. And getSymbolFlags() checks .symtab first. See ELFObjectFile.h. if (Expected<typename ELFT::SymRange> SymbolsOrErr =
EF.symbols(DotSymtabSec)) {
...
} else
// TODO: Test this error.
return SymbolsOrErr.takeError();
if (Expected<typename ELFT::SymRange> SymbolsOrErr =
EF.symbols(DotDynSymSec)) {
...
} else
// TODO: Test this error.
return SymbolsOrErr.takeError();I think it's a good point, and it's helpful to report errors on our interested sections. Currently, I have two approaches in mind.
| |
| llvm/test/tools/llvm-nm/invalid-symbol-table-size.test | ||
|---|---|---|
| 13 | I think change test cases partly resolve this problem. I mean, if we one broken .symtab, and a good .dynsym section, consider the following situation. # broken .symtab prevents us dumping .dynsym $ llvm-nm --dynamic broken-symtab.elf $ llvm-objdump --dynamic-syms broken-symtab.elf | |
| llvm/test/tools/llvm-nm/invalid-symbol-table-size.test | ||
|---|---|---|
| 13 | You can have Case 3: Both .symtab and .dynsym are broken. The same behavior as in Case 1. | |
| llvm/test/tools/llvm-nm/invalid-symbol-table-size.test | ||
|---|---|---|
| 13 | Ok, thanks a lot. | |
Addressed comments.
- Test .symtab and .dynsym separately.
- Add tests in llvm-size for different output format (sysv and berkeley).
LGTM! @grimar is away this week, I believe, so I don't think you need to wait for him.
will emit -> emits
(same in other tests)