This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Fix the invalid dumping of the dynamic sections without terminating DT_NULL entry.
ClosedPublic

Authored by grimar on Feb 27 2019, 7:01 AM.

Details

Summary

This is https://bugs.llvm.org/show_bug.cgi?id=40861,

Previously llvm-readobj would print the DT_NULL sometimes for the dynamic section that
has no terminator entry. The logic of printDynamicTable was a bit overcomplicated
fo my eye, I rewrote it slightly and commented.

Diff Detail

Event Timeline

grimar created this revision.Feb 27 2019, 7:01 AM

Thanks, I completely agree with you that the logic is unnecessarily complicated.

test/tools/llvm-readobj/elf-no-dtnull.s
1

I'd rename this table to make it clear we're testing the dynamic table (i.e. something like elf-dynamic-table-no-dtnull.s).

4

I don't feel strongly about this, so if you don't want to that's fine, but as there is a chance of the GNU dumper diverging from the LLVM dumper here in the future (since the output is not all that GNU-like), I think you should test both styles.

30

.dynstr? What .dynstr?

Ditto below.

tools/llvm-readobj/ELFDumper.cpp
1917

terminated with an -> terminated with a

1918

I'd rephrase this and the last sentence somewhat, as it's not clear at first what you mean:

"However, sometimes the section content may continue past the DT_NULL entry, so to dump the section correctly, we first find the end of the entries by iterating over them."

grimar updated this revision to Diff 188541.Feb 27 2019, 7:56 AM
grimar marked 9 inline comments as done.
  • Addressed review comments.
test/tools/llvm-readobj/elf-no-dtnull.s
1

I renamed to elf-dynamic-table-dtnull.s (without -no- suffix, because I missed initially that the second sub-test
also actually checks the case when we have the DT_NULL)

4

I have no problems with doing that. Done.

30

Fixed.

tools/llvm-readobj/ELFDumper.cpp
1918

Done, thanks!

grimar marked an inline comment as done.Feb 27 2019, 7:59 AM
grimar added inline comments.
test/tools/llvm-readobj/elf-no-dtnull.s
4

The output is the same atm so I did not introduce LLVM and GNU checks testing the same. I guess that is fine for that situation?

jhenderson accepted this revision.Feb 27 2019, 8:34 AM

LGTM.

test/tools/llvm-readobj/elf-no-dtnull.s
4

Yes, that's fine.

This revision is now accepted and ready to land.Feb 27 2019, 8:34 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2019, 12:15 AM