[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin |
Date: |
Mon, 24 Feb 2020 14:41:12 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=25593
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Richard Biener from comment #0)
> echo 'void foo() {}' > libt.c
> echo 'void foo(); int main() { foo(); }' > t.c
> gcc -o libt.so -shared libt.c -Wl,-soname,libt.so -fPIC -flto
> gcc -c t.c -flto
> gcc -Wl,--as-needed t.o libt.so
> readelf -d a.out | grep NEEDED
> 0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
> 0x0000000000000001 (NEEDED) Shared library: [libt.so]
>
> but libc has to come last so the program can use RTLD_NEXT to arrive at
> symbols from libc. Works fine with gold.
[hjl@gnu-cfl-2 pr25593]$ make
gcc -flto -c -o t.o t.c
gcc -fPIC -c -o libt.o libt.c
ld -shared -o libt.so libt.o
gcc -Wl,--as-needed -o x t.o libt.so
readelf -d x | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x0000000000000001 (NEEDED) Shared library: [libt.so]
[hjl@gnu-cfl-2 pr25593]$ rm libt.so
[hjl@gnu-cfl-2 pr25593]$ make LD=ld.gold
ld.gold -shared -o libt.so libt.o
gcc -Wl,--as-needed -o x t.o libt.so
readelf -d x | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x0000000000000001 (NEEDED) Shared library: [libt.so]
[hjl@gnu-cfl-2 pr25593]$ rm libt.so
[hjl@gnu-cfl-2 pr25593]$ make LD=gcc
gcc -shared -o libt.so libt.o
gcc -Wl,--as-needed -o x t.o libt.so
readelf -d x | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x0000000000000001 (NEEDED) Shared library: [libt.so]
[hjl@gnu-cfl-2 pr25593]$ gcc -Wl,--as-needed -o x t.o libt.so -fuse-ld=gold
[hjl@gnu-cfl-2 pr25593]$ make
readelf -d x | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [libt.so]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
[hjl@gnu-cfl-2 pr25593]$
ld needs to check DT_NEEDED of libt.so.
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/25593] New: --as-needed breaks DT_NEEDED order with linker plugin, rguenth at gcc dot gnu.org, 2020/02/24
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, rguenth at gcc dot gnu.org, 2020/02/24
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, address@hidden, 2020/02/24
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, matz at suse dot de, 2020/02/24
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin,
hjl.tools at gmail dot com <=
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, hjl.tools at gmail dot com, 2020/02/24
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, amodra at gmail dot com, 2020/02/24
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, hjl.tools at gmail dot com, 2020/02/24
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, amodra at gmail dot com, 2020/02/24
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, hjl.tools at gmail dot com, 2020/02/24
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, amodra at gmail dot com, 2020/02/24
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, hjl.tools at gmail dot com, 2020/02/25
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, hjl.tools at gmail dot com, 2020/02/25
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, cvs-commit at gcc dot gnu.org, 2020/02/25
- [Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin, amodra at gmail dot com, 2020/02/25