[PATCH] D95916: DebugInfo/Symbolize: Allow STT_NOTYPE/STT_GNU_IFUNC symbols for .symtab symbolization
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 15 15:54:16 PDT 2021
MaskRay added a comment.
In D95916#2627565 <https://reviews.llvm.org/D95916#2627565>, @luismarques wrote:
> This broke debug info for RISC-V. Test case with broken symbolization:
>
> $ cat test.c
> void _start() {}
> $ clang --target=riscv64 --gcc-toolchain=<path> -nostdlib -g test.c
> $ addr=$((0x`readelf -Ws a.out | grep " _start" | awk '{print $2}'` + 4))
> $ hexaddr=`printf '%x\n' $addr`
(llvm-symbolizer works with a decimal address. So `$hexaddr` is not needed. However, addr2line parses the value in hexadecimal even if there is no 0x prefix.)
> $ r=`llvm-addr2line -f -e a.out $hexaddr | head -n 1`
> [ -z "$r" ] && echo "bad" || echo "good"
>
> Apologies for the terrible shell script, it was the most expedient thing I could come up with.
> That test case as written needs the GNU toolchain because LLD will complain about the `R_RISCV_ALIGN` relaxation relocation, and using `-mno-relax` breaks the test.
It can be argued that addr2line has the same problem.
With -g or -fasynchronous-unwind-tables, .debug_frame/.eh_frame has a label below `_start`. Its address is `_start + 2` and its name is empty.
Neither addr2line nor llvm-symbolizer skips such a symbol with empty name.
% ~/Dev/binutils-gdb/out/riscv64/binutils/addr2line -fe a.out 0x100e8
_start
??:?
% ~/Dev/binutils-gdb/out/riscv64/binutils/addr2line -fe a.out 0x100ea
??
test.c:?
In ARM, such symbols have names (`$a` `$t` `$x` and they are modeled as `SF_FormatSpecific`.
In binutils, such symbols are not printed by `nm`.
I will file a feature request about empty symbols on binutils and probably make such symbols `SF_FormatSpecific`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95916/new/
https://reviews.llvm.org/D95916
More information about the llvm-commits
mailing list