[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/20828] New: [MIPS] produces invalid dynamic symbol table when --
From: |
james410 at cowgill dot org.uk |
Subject: |
[Bug ld/20828] New: [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix |
Date: |
Wed, 16 Nov 2016 17:09:46 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=20828
Bug ID: 20828
Summary: [MIPS] produces invalid dynamic symbol table when
--gc-sections is used since PR ld/13177 fix
Product: binutils
Version: 2.27
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: james410 at cowgill dot org.uk
Target Milestone: ---
Originally from Debian: https://bugs.debian.org/844357
Related: https://bugs.debian.org/844227
On MIPS, it is possible for ld to generate an invalid symbol table if
--gc-sections is used when linking. This can be seen in all versions of
Debian's libGL.so.1 since jessie.
Steps to reproduce:
$ cat libstubs.c
void alpha(void) {}
$ cat stubs.c
void psi(void) {}
void omega(void) {}
$ gcc -shared libstubs.c -o libstubs.so
$ gcc -c stubs.c
$ ld -shared --gc-sections -o liboutput.so stubs.o libstubs.so
After doing the above, the dynamic symbol table contains:
$ readelf --dyn-sym liboutput.so
Symbol table '.dynsym' contains 10 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000430 0 SECTION LOCAL DEFAULT 6
2: 0000000000010490 0 NOTYPE LOCAL DEFAULT 7 _end
3: 0000000000010490 0 NOTYPE LOCAL DEFAULT 7 __bss_start
4: 0000000000000430 0 NOTYPE LOCAL DEFAULT 6 _ftext
5: 0000000000010490 0 NOTYPE LOCAL DEFAULT 7 _edata
6: 0000000000000454 36 FUNC GLOBAL DEFAULT 6 omega
7: 0000000000010490 0 NOTYPE LOCAL DEFAULT 7 _fbss
8: 0000000000000430 36 FUNC GLOBAL DEFAULT 6 psi
9: 0000000000010480 0 NOTYPE LOCAL DEFAULT 7 _fdata
This is clearly invalid because there are LOCAL symbols which appear after
GLOBAL symbols. The bug only appears if --gc-sections is used - without this
flag the "good" symbol table looks like this:
Symbol table '.dynsym' contains 10 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000450 0 SECTION LOCAL DEFAULT 7
2: 00000000000104b0 0 NOTYPE GLOBAL DEFAULT 8 _end
3: 00000000000104b0 0 NOTYPE GLOBAL DEFAULT 8 __bss_start
4: 0000000000000450 0 NOTYPE GLOBAL DEFAULT 7 _ftext
5: 00000000000104b0 0 NOTYPE GLOBAL DEFAULT 8 _edata
6: 0000000000000474 36 FUNC GLOBAL DEFAULT 7 omega
7: 00000000000104b0 0 NOTYPE GLOBAL DEFAULT 8 _fbss
8: 0000000000000450 36 FUNC GLOBAL DEFAULT 7 psi
9: 00000000000104a0 0 NOTYPE GLOBAL DEFAULT 8 _fdata
I have bisected this bug to the following commit. Binutils 2.22 in Debian
wheezy was also OK because the commit was reverted in the binutils 2.22 branch.
commit 1a766c6843ce0005fee23633b3b30c98e81a7b07
Author: H.J. Lu <address@hidden>
Date: Fri Sep 16 01:17:16 2011 +0000
Also hide symbols without PLT nor GOT references.
bfd/
2011-09-15 H.J. Lu <address@hidden>
PR ld/13177
* elflink.c (elf_gc_sweep_symbol): Also hide symbols without PLT
nor GOT references.
----
While this bug is quite old, it was only found very recently due to a change in
the calculation of the .dynsym sh_info value in:
commit 90ac242072dc68ad454aaaa228868b0f1c8e10f9
Author: Alan Modra <address@hidden>
Date: Sat Aug 13 00:03:43 2016 +0930
Correct .dynsym sh_info
The combination of this commit along with the above bug is causing lots of
undefined references when linking to libGL in Debian (which is compiled using
--gc-sections).
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/20828] New: [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix,
james410 at cowgill dot org.uk <=
- [Bug ld/20828] [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix, address@hidden, 2016/11/16
- [Bug ld/20828] [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix, amodra at gmail dot com, 2016/11/17
- [Bug ld/20828] [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix, pochu27 at gmail dot com, 2016/11/18
- [Bug ld/20828] [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix, james410 at cowgill dot org.uk, 2016/11/18
- [Bug ld/20828] [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix, mh-sourceware at glandium dot org, 2016/11/20
- [Bug ld/20828] [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix, amodra at gmail dot com, 2016/11/20
- [Bug ld/20828] [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix, amodra at gmail dot com, 2016/11/20
- [Bug ld/20828] [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix, pochu27 at gmail dot com, 2016/11/24
- [Bug ld/20828] [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix, address@hidden, 2016/11/24
- [Bug ld/20828] [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix, james410 at cowgill dot org.uk, 2016/11/24