[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/31158] ld: Should --gc-sections respect RHS of a symbol assignme
From: |
i at maskray dot me |
Subject: |
[Bug ld/31158] ld: Should --gc-sections respect RHS of a symbol assignment? |
Date: |
Thu, 14 Dec 2023 08:23:20 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=31158
--- Comment #2 from Fangrui Song <i at maskray dot me> ---
Interesting. BFD's behavior depends on whether the assigned symbol is
referenced.
Let's enhance the test.
cat > a.s <<e
.globl _start, y1, y2
_start: .dc.a x1
.section .rodata.y1, "a"; y1: .quad 0x1122334455667788
.section .rodata.y2, "a"; y2: .quad 0x1122334455667788
e
echo 'x1 = y1; x2 = y2;' > a.t
as a.s -o a.o
ld.lld --gc-sections a.o a.t -o a.lld
ld.bfd --gc-sections a.o a.t -o a.gc.bfd
ld.bfd a.o a.t -o a.nogc.bfd
ld.gold --gc-sections a.o a.t -o a.gold
% readelf -Ws a.nogc.bfd | grep '[xy]'
Symbol table '.symtab' contains 9 entries:
Num: Value Size Type Bind Vis Ndx Name
1: 0000000000402008 0 NOTYPE GLOBAL DEFAULT 2 y2
2: 0000000000402008 0 NOTYPE GLOBAL DEFAULT 2 x2
5: 0000000000402000 0 NOTYPE GLOBAL DEFAULT 2 x1
8: 0000000000402000 0 NOTYPE GLOBAL DEFAULT 2 y1
% readelf -Ws a.gc.bfd | grep '[xy]'
Symbol table '.symtab' contains 8 entries:
Num: Value Size Type Bind Vis Ndx Name
1: 0000000000000000 0 NOTYPE GLOBAL DEFAULT ABS x2
4: 0000000000402000 0 NOTYPE GLOBAL DEFAULT 2 x1
7: 0000000000402000 0 NOTYPE GLOBAL DEFAULT 2 y1
x2 is non-zero in a GC link and zero in a no-GC link.
There appears unusual: a live symbol's value can be very different when GC is
enabled.
Or, is this a clever trick to check whether a section is GCed?
--
You are receiving this mail because:
You are on the CC list for the bug.