This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump] Support --symbolize-operands when there is a single SHT_LLVM_BB_ADDR_MAP section for all text sections
ClosedPublic

Authored by rahmanl on Jul 16 2022, 12:49 AM.

Details

Summary

When linking, using -Wl,-z,keep-text-section-prefix results in multiple text sections while all SHT_LLVM_BB_ADDR_MAP sections are linked into a single one.
In such case, we should not read the corresponding section for each text section, and instead read all SHT_LLVM_BB_ADDR_MAP sections before disassembly.

Diff Detail

Event Timeline

rahmanl created this revision.Jul 16 2022, 12:49 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: rupprecht. · View Herald Transcript
rahmanl requested review of this revision.Jul 16 2022, 12:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 16 2022, 12:49 AM
rahmanl updated this revision to Diff 445203.Jul 16 2022, 1:02 AM

Add test case.

jhenderson accepted this revision.Jul 18 2022, 12:21 AM

LGTM, but maybe give it a bit in case @MaskRay has anything to add (especially given the relation this has to linking).

This revision is now accepted and ready to land.Jul 18 2022, 12:21 AM

-Wl,-z,-keep-text-section-prefix

Typo: -Wl,-z,keep-text-section-prefix. I am still reading the impl...

MaskRay accepted this revision.Jul 18 2022, 12:59 PM

The subject line usually doesn't have the trailing period.

A SHT_LLVM_BB_ADDR_MAP section does not have SHF_ALLOC. One such section referencing multiple text sections is fine. If a referenced text section is discarded (e.g. due to --gc-sections), the relocated location in SHT_LLVM_BB_ADDR_MAP will be zero.

llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-disassemble-symbolize-operands.yaml
114

If the preferred name is .llvm_bb_addr_map*, better to use it for most tests. You may keep one using a different name to check that the section name doesn't matter.

llvm/tools/llvm-objdump/llvm-objdump.cpp
1282

llvm style doesn't add a blank line after a variable declaration.

rahmanl updated this revision to Diff 445657.Jul 18 2022, 4:46 PM
rahmanl marked 2 inline comments as done.

Handle comments.

rahmanl retitled this revision from [llvm-objdump] Support --symbolize-operands when there is a single SHT_LLVM_BB_ADDR_MAP section for all text sections. to [llvm-objdump] Support --symbolize-operands when there is a single SHT_LLVM_BB_ADDR_MAP section for all text sections.Jul 18 2022, 4:46 PM
rahmanl edited the summary of this revision. (Show Details)
This revision was landed with ongoing or failed builds.Jul 18 2022, 4:51 PM
This revision was automatically updated to reflect the committed changes.