This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump] Should print strings when dumping DT_RPATH, DT_RUNPATH, DT_SONAME, DT_AUXILIARY and DT_FILTER tags in dynamic section.
ClosedPublic

Authored by Higuoxing on Feb 27 2019, 1:32 AM.

Details

Summary

Before:

Dynamic Section:
  NEEDED               libpthread.so.0
  ...
  NEEDED               ld-linux-x86-64.so.2
  RPATH                0x00000000001c2e61

After:

Dynamic Section:
  NEEDED               libpthread.so.0
  ...
  NEEDED               ld-linux-x86-64.so.2
  RPATH                $ORIGIN/../lib

Only a small problem here, I have no idea on choosing test case. I see there's a test
file(test/tools/llvm-objdump/private-headers-dynamic-section.test). But it has no DT_RPATH and DT_RUNPATH tags. Shall I replace the ELF file in the
Inputs dir by a new one?

Diff Detail

Repository
rL LLVM

Event Timeline

Higuoxing created this revision.Feb 27 2019, 1:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2019, 1:32 AM

Only a small problem here, I have no idea on choosing test case. I see there's a test
file(test/tools/llvm-objdump/private-headers-dynamic-section.test). But it has no DT_RPATH and DT_RUNPATH tags. Shall I replace the ELF file in the
Inputs dir by a new one?

Looking at that test, I think now we should be able to convert it to use yaml2obj instead of using the precompiled binary (as an independent change).

Only a small problem here, I have no idea on choosing test case. I see there's a test
file(test/tools/llvm-objdump/private-headers-dynamic-section.test). But it has no DT_RPATH and DT_RUNPATH tags. Shall I replace the ELF file in the
Inputs dir by a new one?

Looking at that test, I think now we should be able to convert it to use yaml2obj instead of using the precompiled binary (as an independent change).

+1 to this. You could go as far as basically duplicating the test I've got for dynamic section tags in llvm-readobj in D58677. The only difference would be the output patterns to check. I think that test should give you what you are looking for. I'd make the test change first, so that the test starts failing (locally) after you have made your changes in this patch, before you update the test, if that makes sense.

By the way, what about DT_SONAME, DT_AUXILIARY and DT_FILTER, all of which are string offsets in the dynamic string table, like DT_NEEDED etc?

Higuoxing updated this revision to Diff 188518.Feb 27 2019, 4:12 AM

Addressed @grimar and @jhenderson 's comments.

Thanks for the test file, I noticed that the last 5 d_tag are unknown. We should print them in hex format. I would like to resolve it in another
patch.

Higuoxing retitled this revision from [llvm-objdump] Should print strings when dumping DT_RPATH and DT_RUNPATH tags in dynamic section. to [llvm-objdump] Should print strings when dumping DT_RPATH, DT_RUNPATH, DT_SONAME, DT_AUXILIARY and DT_FILTER tags in dynamic section..Feb 27 2019, 4:13 AM

Thanks for the test file, I noticed that the last 5 d_tag are unknown. We should print them in hex format. I would like to resolve it in another
patch.

Sounds reasonable. You may notice from the comments in D58677 that I'm going to make a couple of changes to that file in the "unknown" region. Perhaps you should just miss them out for now, and do them later when you fix the behaviour? Basically, we just want to show that the values in that range are printed sensibly.

Higuoxing updated this revision to Diff 188524.Feb 27 2019, 6:27 AM

Remove unknown d_tags from dynamic section.

This revision is now accepted and ready to land.Feb 27 2019, 6:28 AM
This revision was automatically updated to reflect the committed changes.