On 8/10/25 1:55 AM, 赵佳炜 wrote:
Hi Yonghong,
I found another issue where symbols can be duplicated, and I’m not sure how to
tell them apart.
For example, I created two C files named usdt_rip.c and hello.c. Both define
their own static ti variables, like:`static volatile char ti = 0;`.
After compiling, I obtained an ELF file usdt_rip whose .symtab contains the
following entries:
$ readelf -s usdt_rip
Symbol table '.symtab' contains 42 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS Scrt1.o
2: 000000000000038c 32 OBJECT LOCAL DEFAULT 4 __abi_tag
3: 0000000000000000 0 FILE LOCAL DEFAULT ABS usdt_rip.c
4: 0000000000004021 1 OBJECT LOCAL DEFAULT 25 ti
5: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
6: 00000000000010a0 0 FUNC LOCAL DEFAULT 14 deregister_tm_clones
7: 00000000000010d0 0 FUNC LOCAL DEFAULT 14 register_tm_clones
8: 0000000000001110 0 FUNC LOCAL DEFAULT 14
__do_global_dtors_aux
9: 0000000000004020 1 OBJECT LOCAL DEFAULT 25 completed.0
10: 0000000000003df8 0 OBJECT LOCAL DEFAULT 21
__do_global_dtor[...]
11: 0000000000001150 0 FUNC LOCAL DEFAULT 14 frame_dummy
12: 0000000000003df0 0 OBJECT LOCAL DEFAULT 20
__frame_dummy_in[...]
13: 0000000000000000 0 FILE LOCAL DEFAULT ABS damo.c
14: 0000000000004022 1 OBJECT LOCAL DEFAULT 25 ti
15: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
16: 00000000000020d8 0 OBJECT LOCAL DEFAULT 19 __FRAME_END__
As you can see, there are two ti variables in the .symtab section. Their values
are very close, making them hard to distinguish.
I’m unsure how to handle this situation. Do you have any suggestions?
Did you check relocations? Relocaitons should be able to point exact which
symbol.
Thanks,
Jiawei Zhao
[...]