1 |
Hello, |
2 |
|
3 |
On Sun, 02 Oct 2016, Meino.Cramer@×××.de wrote: |
4 |
>Suppose I would compile a program, which uses shared libraries and I |
5 |
>specify an additional library, which will be completly unused by the |
6 |
>code...will the resulting executable differ from an executable which |
7 |
>is compiled without this library ? |
8 |
|
9 |
Suppose you'd just test it? |
10 |
|
11 |
$ echo 'int main(void) {return 0;}' > t.c |
12 |
$ gcc -o t_nolib t.c |
13 |
$ gcc -o t_lib -lglib t.c |
14 |
$ gcc -o t_lib_as -Wl,-as-needed -lglib t.c |
15 |
$ gcc -o t_lib_nas -Wl,-no-as-needed -lglib t.c |
16 |
$ cmp t_nolib t_lib_as; echo $? |
17 |
0 |
18 |
|
19 |
|
20 |
$ ls -l |
21 |
-rw-r----- 1 dh dh 27 Oct 2 05:40 t.c |
22 |
-rwxr-x--- 1 dh dh 6824 Oct 2 05:40 t_lib |
23 |
-rwxr-x--- 1 dh dh 6424 Oct 2 05:40 t_lib_as |
24 |
-rwxr-x--- 1 dh dh 6824 Oct 2 05:40 t_lib_nas |
25 |
-rwxr-x--- 1 dh dh 6424 Oct 2 05:40 t_nolib |
26 |
|
27 |
$ ldd t_* |
28 |
t_lib: |
29 |
linux-vdso.so.1 (0x00007fff0b7ff000) |
30 |
libglib-1.2.so.0 => /usr/lib64/libglib-1.2.so.0 (0x00007f372b55b000) |
31 |
libc.so.6 => /lib64/libc.so.6 (0x00007f372b1bb000) |
32 |
libdl.so.2 => /lib64/libdl.so.2 (0x00007f372afb7000) |
33 |
/lib64/ld-linux-x86-64.so.2 (0x00007f372b793000) |
34 |
t_lib_as: |
35 |
linux-vdso.so.1 (0x00007fffadf70000) |
36 |
libc.so.6 => /lib64/libc.so.6 (0x00007ff9289d7000) |
37 |
/lib64/ld-linux-x86-64.so.2 (0x00007ff928d77000) |
38 |
t_lib_nas: |
39 |
linux-vdso.so.1 (0x00007fffe9e6f000) |
40 |
libglib-1.2.so.0 => /usr/lib64/libglib-1.2.so.0 (0x00007f2a43afb000) |
41 |
libc.so.6 => /lib64/libc.so.6 (0x00007f2a4375b000) |
42 |
libdl.so.2 => /lib64/libdl.so.2 (0x00007f2a43557000) |
43 |
/lib64/ld-linux-x86-64.so.2 (0x00007f2a43d33000) |
44 |
t_nolib: |
45 |
linux-vdso.so.1 (0x00007fffbed58000) |
46 |
libc.so.6 => /lib64/libc.so.6 (0x00007fe55b4f4000) |
47 |
/lib64/ld-linux-x86-64.so.2 (0x00007fe55b894000) |
48 |
|
49 |
So: YES, it will differ unless you use the "-as-needed" ld flag. Which |
50 |
is why some distros have -as-needed as a default linker flag, to prune |
51 |
deps of packages, even though it causes "trouble" at times ... |
52 |
|
53 |
-dnh |
54 |
|
55 |
-- |
56 |
Graphisch??? Wie meinen? Hast du zuviel Fleisch von zu "gluecklichen" |
57 |
Rindern gefuttert? *scnr* Wozu zum Henker sollte man sowas brauchen? |
58 |
Logo ginge auch per ASCII :) (Logo? welches Logo? Wozu ueberhaupt?) |
59 |
[David Haller in suse-linux] |