This is an archive of the discontinued LLVM Phabricator instance.

[llvm-symbolizer][llvm-nm] Fix AArch64 and ARM mapping symbols handling.
ClosedPublic

Authored by yroux on Mar 17 2021, 12:01 PM.

Details

Summary

The goal of this patch is to exclude AArch64 mapping symbols ($x and $d) for symtab symbolization as it was done for ARM since D95916 to bring the bots back to green state.

This is implemented by setting SF_FormatSpecific such that llvm-symbolizer will ignore them, and use this flag to re-implement llvm-nm --special-syms option, by doing so it will work on AArch64 and ARM (it wasn't working on the later one since SF_FormatSpecific symbols were ignored in llvm-nm).

Diff Detail

Event Timeline

yroux created this revision.Mar 17 2021, 12:01 PM
yroux requested review of this revision.Mar 17 2021, 12:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2021, 12:01 PM
yroux edited the summary of this revision. (Show Details)Mar 17 2021, 12:03 PM
yroux edited the summary of this revision. (Show Details)
MaskRay accepted this revision.Mar 17 2021, 1:27 PM

LGTM.

llvm/test/DebugInfo/Symbolize/ELF/aarch64-mapping-symbol.s
2
# REQUIRES: aarch64-registered-target
## Ignore AArch64 mapping symbols (with a prefix of $d or $x).
This revision is now accepted and ready to land.Mar 17 2021, 1:27 PM

I suggest you split the llvm-nm part to a separate patch because that would affect RISC-V: D98669

You've got a set of test failures being reported by the pre-merge bots. They look like they could be coming from this patch. Please take a look at them.

I also agree with @MaskRay that you should split the llvm-nm aspect into its own patch.

yroux planned changes to this revision.Mar 18 2021, 2:18 AM

Thanks for the reviews,

@jhenderson, yes I'm looking at these COFF regressions, the reason I've included llvm-nm changes into this patch is that marking these symbols as SF_FormatSpecific breaks llvm --special-syms, thus I'd prefer to restrict llvm-nm changes to ARM and AArch64 targets if that's fine for you, otherwise I'll just split the patch.

Could you clarify why adding the format specific flag breaks the --special-syms option?

yroux added a comment.EditedMar 18 2021, 2:33 AM

Sure, because in dumpSymbolNamesFromObject line1815 these symbols are skipped if they are not debug ones, thus not printed even if --special-syms flag is used.

yroux updated this revision to Diff 331574.Mar 18 2021, 8:44 AM

This new version should just change llvm-nm behavior for ELF ARM and AArch64 targets to handle SF_FormatSpecific symbols and doesn't change the processing of COFF or debug symbols

This revision is now accepted and ready to land.Mar 18 2021, 8:44 AM
yroux marked an inline comment as done.Mar 18 2021, 8:44 AM

I assume there's already test coverage for --debug-syms with ARM and AARCH64 symbols?

llvm/test/DebugInfo/Symbolize/ELF/aarch64-mapping-symbol.s
9–12

It might be helpful to illustrate with an llvm-nm execution where the $d and $x appear, to help validate the test. At the moment, this test simply shows that foo is used for values 0 and 4.

llvm/test/tools/llvm-nm/ARM/special-syms.test
2

Add a comment to the top of this test explaining what symbols are considered special for ARM.

Do you need an AARCH64 version of this test?

llvm/tools/llvm-nm/llvm-nm.cpp
1808

Also, clang-format the new code below.

yroux added a comment.Mar 19 2021, 2:53 AM

Hmm, there is tools/llvm-nm/debug-syms.test which tests ARM --special-syms and --debug-syms, notice that with this change --special-syms is no more needed to dump mapping-symbols when --debug-syms is used, which is now in sync with gnu binutils nm. I don't see an AArch64 test though

llvm/test/DebugInfo/Symbolize/ELF/aarch64-mapping-symbol.s
9–12

I agree, I'll also add one to the existing arm version of this test

llvm/test/tools/llvm-nm/ARM/special-syms.test
2

I'll add a comment which describes the test.

AArch64 version already exists under llvm-nm/AArch64 directory

yroux updated this revision to Diff 332235.Mar 22 2021, 3:24 AM
jhenderson added inline comments.Mar 23 2021, 1:41 AM
llvm/test/DebugInfo/Symbolize/ELF/aarch64-mapping-symbol.s
4

I have this vague, and quite possibly incorrect, idea that you can just omit the "--" part of the triple completely (i.e. -triple=aarch64).

5

Add a comment explaining why the llvm-nm line is useful. Ditto for the ARM case.

llvm/test/tools/llvm-nm/ARM/special-syms.test
3
llvm/test/tools/llvm-nm/debug-syms.test
2–3

Does this behaviour (that mapping symbols are printed with --debug-syms and not --special-syms) match GNU nm behaviour?

llvm/tools/llvm-nm/llvm-nm.cpp
1808

Don't forget to run clang-format on this. I think there's a trailing space on the second line of the comment.

yroux added inline comments.Mar 23 2021, 2:33 AM
llvm/test/DebugInfo/Symbolize/ELF/aarch64-mapping-symbol.s
4

Ah yes that's correct, I think I'm use to write it that way because I saw that in other tests, but I'll change that

5

OK

llvm/test/tools/llvm-nm/debug-syms.test
2–3

Yes with that change llvm-nm will match nm behaviour w/r to --special-syms and --debug-syms

yroux updated this revision to Diff 332582.Mar 23 2021, 2:34 AM
jhenderson accepted this revision.Mar 23 2021, 3:13 AM

LGTM, with comment suggestion.

llvm/test/DebugInfo/Symbolize/ELF/aarch64-mapping-symbol.s
7
llvm/test/DebugInfo/Symbolize/ELF/arm-mapping-symbol.s
6
This revision was landed with ongoing or failed builds.Mar 23 2021, 6:17 AM
This revision was automatically updated to reflect the committed changes.