This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump] --adjust-vma adjust symbol table
ClosedPublic

Authored by HamidrezaSK on Jun 15 2023, 7:31 AM.

Details

Summary

Add a shouldAdjustVA(Section) guard on top of address update.

Update llvm-objdump file to update symbol table when --adjust-vma used.

Fixes #63203

Diff Detail

Event Timeline

HamidrezaSK created this revision.Jun 15 2023, 7:31 AM
Herald added a reviewer: MaskRay. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
HamidrezaSK requested review of this revision.Jun 15 2023, 7:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2023, 7:31 AM
mysterymath added inline comments.
llvm/tools/llvm-objdump/llvm-objdump.cpp
2403

This needs a shouldAdjustVA(Section) guard like other places where the adjustment is added, to avoid adjusting e.g. non-alloc sections.

HamidrezaSK edited the summary of this revision. (Show Details)

Add a shouldAdjustVA(Section) guard on top of the address update.

As this patch is supposed to be fixing an issue in Github, please add "Fixes #63203" to your commit message for this patch.

llvm/test/tools/llvm-objdump/X86/adjust-vma.test
35–38

Nit: You will see in the other parts of this test that the ADJUST blocks are indented slightly to ensure they line up with the NOADJUST blocks. Please could you do the same here, to make it easier to read and compare.

llvm/tools/llvm-objdump/llvm-objdump.cpp
2403

We need a test case that shows that this shouldAdjustVA function has been called. I don't believe any of the symbols in the test you've added are impacted by this? You can add a symbol to the YAML in the test file that is in the .debug_str section, to achieve this, I believe.

MaskRay added inline comments.Jun 21 2023, 12:41 AM
llvm/tools/llvm-objdump/llvm-objdump.cpp
2403

I think this should be if (SecI != O.section_end() && shouldAdjustVA(*SecI)) to protect a dereference of O.section_end().

D153401 will add another interesting test about a SHN_ABS symbol.

MaskRay requested changes to this revision.Jun 23 2023, 1:08 PM
This revision now requires changes to proceed.Jun 23 2023, 1:08 PM
HamidrezaSK marked an inline comment as done.
HamidrezaSK edited the summary of this revision. (Show Details)

Adjust the indentation symbol table test ADJUST blocks to line up with the NOADJUST blocks.

Adjust the guard on top of the address update to if (SecI != O.section_end() && shouldAdjustVA(*SecI)) to protect a dereference of O.section_end().

Adjust adjust-vma test to add SHN_ABS symbol test (D153401).

MaskRay accepted this revision.Jun 25 2023, 9:43 AM

D153401 has landed, so you'll need to rebase on top of it.

This revision is now accepted and ready to land.Jun 25 2023, 9:43 AM
jhenderson accepted this revision.Jun 26 2023, 1:14 AM

LGTM too, after the rebase.