This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Don't crash when dumping invalid dynamic relocation.
ClosedPublic

Authored by grimar on Jan 28 2020, 9:38 AM.

Details

Summary

Currently when we dump dynamic relocation with use of
DT_RELA/DT_RELASZ/DT_RELAENT tags, we crash when a symbol index
is larger than the number of dynamic symbols or
when there is no dynamic symbol table.

This patch adds test cases and fixes the issues.
It is rebased on top of D73484.

Diff Detail

Event Timeline

grimar created this revision.Jan 28 2020, 9:38 AM
Herald added a project: Restricted Project. · View Herald Transcript
grimar updated this revision to Diff 240913.Jan 28 2020, 9:41 AM
  • Added a new line at EOF to the test.
jhenderson added inline comments.Jan 30 2020, 1:27 AM
llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test
383–384

Do we have a test case somewhere that shows that relocations without symbols (e.g. R_X86_64_RELATIVE) are handled fine without warning?

428

when the symbol index...

435

larger or equal to -> greater than or equal to

(that's the more common way of saying '>=')

llvm/test/tools/llvm-readobj/ELF/dynamic-reloc-no-section-headers.test
2

May be worth splitting this line into two.

llvm/tools/llvm-readobj/ELFDumper.cpp
4006

don't -> not

grimar updated this revision to Diff 241409.Jan 30 2020, 4:23 AM
grimar marked 6 inline comments as done.
  • Addressed review comments.
llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test
383–384

Yes, I think the test case is:
https://github.com/llvm/llvm-project/blob/master/llvm/test/tools/llvm-readobj/ELF/reloc-zero-name-or-value.test#L22
We have the R_X86_64_NONE dynamic relocation with no symbol and no warnings.

This revision is now accepted and ready to land.Jan 31 2020, 1:32 AM
This revision was automatically updated to reflect the committed changes.