binutils-gdb/ld/testsuite/ld-cris
Maciej W. Rozycki 1f599d0e7b ELF/LD: Avoid producing hidden and internal dynamic symbols
Always turn hidden and internal symbols which have a dynamic index into
local ones.  This is required by the the ELF gABI[1]:

"A hidden symbol contained in a relocatable object must be either
removed or converted to STB_LOCAL binding by the link-editor when the
relocatable object is included in an executable file or shared object."

"An internal symbol contained in a relocatable object must be either
removed or converted to STB_LOCAL binding by the link-editor when the
relocatable object is included in an executable file or shared object."

The ELF linker usually respects this requirement, however in the case
where a dynamic symbol has been preallocated due to a reference of the
default export class aka visibility from the object being linked, and
then merged with a hidden or internal symbol definition from within the
same object, then the original export class is carried over to the
output dynamic symbol table, because while merging the generic ELF
linker only converts affected dynamic symbols to local when they are
defined or referenced by the object being linked and a dynamic object
involved in the link both at a time.

The dynamic symbol produced confuses then the dynamic loader at the run
time -- the hidden or internal export class is ignored and the symbol
follows preemption rules as with the default export class.

In the MIPS target it happens when `mips_elf_record_global_got_symbol'
creates a dynamic symbol when a call relocation is encountered.
Additionally if the undefined symbol referred by such a relocation does
specify the intended export class, then a local dynamic symbol is
created instead, which is harmless and allowed, but useless.  Normally
no local dynamic symbols are created, except for a single dummy one at
the beginning.

Correct the problem by removing the extra check for a dynamic symbol
being defined or referenced by the object being linked and a dynamic
object involved in the link both at a time.  The test cases included
cover the internal and hidden symbol cases, as well as a protected
symbol for a reference, the handling of which is unchanged by this fix.
Both cases described above are covered, that is where an internal or
hidden dynamic symbol is produced and where a local one is.

NB this change affects CRIS results where some symbols in the static
table produced in a final link are now converted from STV_HIDDEN to
STB_LOCAL.  This happens whenever the `elf_backend_hide_symbol' handler
is called, so the affected symbols must have been chosen for entering
into the dynamic symbol table, except in these test cases no such symbol
table is produced.  In fully linked binaries the static symbol table is
only used for debugging though, so such a change is fine.

References:

[1] "System V Application Binary Interface - DRAFT - 24 April 2001",
    The Santa Cruz Operation, Inc., "Symbol Table",
    <http://www.sco.com/developers/gabi/2001-04-24/ch4.symtab.html>

	bfd/
	PR ld/19908
	* elflink.c (elf_link_add_object_symbols): Always turn hidden
	and internal symbols which have a dynamic index into local
	ones.

	ld/
	PR ld/19908
	* testsuite/ld-cris/tls-e-20.d: Adjust for hidden symbol
	handling fix.
	* testsuite/ld-cris/tls-e-20a.d: Likewise.
	* testsuite/ld-cris/tls-e-21.d: Likewise.
	* testsuite/ld-cris/tls-e-23.d: Likewise.
	* testsuite/ld-cris/tls-e-80.d: Likewise.
	* testsuite/ld-cris/tls-gd-3h.d: Likewise.
	* testsuite/ld-cris/tls-leie-19.d: Likewise.
	* testsuite/ld-mips-elf/export-class-ref-lib.sd: New test.
	* testsuite/ld-mips-elf/export-hidden-ref.sd: New test.
	* testsuite/ld-mips-elf/export-internal-ref.sd: New test.
	* testsuite/ld-mips-elf/export-protected-ref.sd: New test.
	* testsuite/ld-mips-elf/export-class-ref-f0.s: New test source.
	* testsuite/ld-mips-elf/export-class-ref-f1.s: New test source.
	* testsuite/ld-mips-elf/export-class-ref-f2.s: New test source.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2016-04-05 15:14:54 +01:00
..
asneed1.d * ld-cris/asneed1.d: New test. 2013-10-18 02:38:35 +00:00
badgotr1.d
comref1.s
cris.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
def2.d
def3.d
dso12-pltdis.d
dso-1.s
dso-1b.s
dso-2.s
dso-3.s
dso-pltdis1.d * ld-cris/dso-pltdis1.d, ld-cris/dso-pltdis2.d, dsofng.s 2012-06-18 06:17:36 +00:00
dso-pltdis2.d * ld-cris/dso-pltdis1.d, ld-cris/dso-pltdis2.d, dsofng.s 2012-06-18 06:17:36 +00:00
dsofn4g.s * ld-cris/dso-pltdis1.d, ld-cris/dso-pltdis2.d, dsofng.s 2012-06-18 06:17:36 +00:00
dsofnf2.s
dsofnf.s
dsofng.s Trim last, empty, line 2012-06-18 06:19:02 +00:00
dsov32-1.s
dsov32-2.s
dsov32-3.s
dsov32-4.s
euwref1.s
expalltst3
expdref1.s
expdref2.s
expdref3.s
expdref4.s
expdyn1.d
expdyn1.s
expdyn1w.s
expdyn2.d
expdyn2.s
expdyn3.d
expdyn4.d
expdyn5.d
expdyn6.d
expdyn7.d
globsym1ref.s
globsymw1.s
globsymw2.s
got7.s
gotplt1.d
gotplt2.d
gotplt3.d
gotrel1.s
gotrel2.s
hiddef1.d bfd/ 2012-06-06 10:50:18 +00:00
hiddef1.s
hide1
hidedsofns2468
hidrefgotplt1.s
init.s
ldsym1.d
libdso-1.d
libdso-1b.d
libdso-1c.d
libdso-1d.d
libdso-2.d ld/ 2012-06-15 15:13:41 +00:00
libdso-3.d
libdso-4.d
libdso-10.d
libdso-11.d
libdso-12.d
libdso-12b.d
libdso-12c.d
libdso-13.d * ld-cris/libdso-13.d: Adjust for --enable-new-dtags now 2013-01-31 09:55:23 +00:00
libdso-13b.d
libdso-14.d
libdso-15.d
libdso-15b.d
locref1.d
locref1.s
locref2.d Strip undefined symbols from .symtab 2015-02-19 13:36:34 +10:30
locref2.s
move-1.s
nodyn4.d
nodyn5.d
noglob1.d
noglob1.s
noov.d
noov.s
pcrelcp-1.d
pcrelcp-1.s
pic-gc-72.d
pic-gc-72.s
pic-gc-73.d
pic-gc-73.s
pv32-1.d ld/ 2012-06-15 15:13:41 +00:00
pv32.s
stabs1.s
start1.s
tls128.s
tls128g.s
tls-commx.s
tls-dso-dtpoffd2.d
tls-dso-dtpoffd4.d
tls-dso-tpoffgotcomm1.d * ld-cris/tls-e-tpiecomm1.d, ld-cris/tls-e-tpiecomm1.s: New test. 2012-06-17 07:29:55 +00:00
tls-dso-tpoffgotcomm1.s * ld-cris/tls-e-tpiecomm1.d, ld-cris/tls-e-tpiecomm1.s: New test. 2012-06-17 07:29:55 +00:00
tls-dso-x1x2-1.d
tls-dso-xz-1.d
tls-dtpoffdx.s
tls-dtprelm.s
tls-e-20.d ELF/LD: Avoid producing hidden and internal dynamic symbols 2016-04-05 15:14:54 +01:00
tls-e-20a.d ELF/LD: Avoid producing hidden and internal dynamic symbols 2016-04-05 15:14:54 +01:00
tls-e-21.d ELF/LD: Avoid producing hidden and internal dynamic symbols 2016-04-05 15:14:54 +01:00
tls-e-22.d
tls-e-23.d ELF/LD: Avoid producing hidden and internal dynamic symbols 2016-04-05 15:14:54 +01:00
tls-e-66.d
tls-e-80.d ELF/LD: Avoid producing hidden and internal dynamic symbols 2016-04-05 15:14:54 +01:00
tls-e-dtpoffd1.d
tls-e-dtpoffd3.d
tls-e-tpiecomm1.d * ld-cris/tls-e-tpiecomm1.d, ld-cris/tls-e-tpiecomm1.s: New test. 2012-06-17 07:29:55 +00:00
tls-e-tpiecomm1.s * ld-cris/tls-e-tpiecomm1.d, ld-cris/tls-e-tpiecomm1.s: New test. 2012-06-17 07:29:55 +00:00
tls-e-tpoffcomm1.d ld/ELF: refine fake STT_FILE symbol emission 2013-10-29 17:52:24 +01:00
tls-e-tpoffcomm1.s
tls-e-tpoffgotcomm1.d * ld-cris/tls-e-tpoffgotcomm1.d: New test. 2012-06-17 16:56:37 +00:00
tls-err-20x.d
tls-err-24.d
tls-err-25.d
tls-err-26.d
tls-err-27.d
tls-err-28.d
tls-err-29.d
tls-err-31.d
tls-err-33.d
tls-err-35.d
tls-err-37.d
tls-err-39.d
tls-err-40.d
tls-err-41.d
tls-err-43.d
tls-err-44.d
tls-err-45.d
tls-err-47.d
tls-err-48.d
tls-err-49.d
tls-err-51.d
tls-err-52.d
tls-err-53.d
tls-err-55.d
tls-err-55.s
tls-err-56.d
tls-err-56.s
tls-err-62.d
tls-err-62.s
tls-err-65.d
tls-err-67.d
tls-err-77.d
tls-gc-68.d Fix garbage collection of common symbols 2015-01-19 21:26:30 +10:30
tls-gc-69.d Fix garbage collection of common symbols 2015-01-19 21:26:30 +10:30
tls-gc-70.d Fix garbage collection of common symbols 2015-01-19 21:26:30 +10:30
tls-gc-71.d Fix garbage collection of common symbols 2015-01-19 21:26:30 +10:30
tls-gc-71.s
tls-gc-75.d Fix garbage collection of common symbols 2015-01-19 21:26:30 +10:30
tls-gc-76.d Fix garbage collection of common symbols 2015-01-19 21:26:30 +10:30
tls-gc-76.s
tls-gc-79.d Fix garbage collection of common symbols 2015-01-19 21:26:30 +10:30
tls-gd-1.d
tls-gd-1.s
tls-gd-1h.d
tls-gd-2.d
tls-gd-2.s
tls-gd-2h.d
tls-gd-3.d
tls-gd-3.s
tls-gd-3h.d ELF/LD: Avoid producing hidden and internal dynamic symbols 2016-04-05 15:14:54 +01:00
tls-gdgotrelm.s
tls-global-74.d
tls-gottprelm.s
tls-hx1x2.s
tls-hx.s
tls-ie-8.d
tls-ie-8.s
tls-ie-8e1.d
tls-ie-8e.s
tls-ie-9.d
tls-ie-9.s
tls-ie-10.d
tls-ie-10.s
tls-ie-11.d
tls-ie-11.s
tls-ie-78.d
tls-js1.d
tls-ld-4.d
tls-ld-4.s
tls-ld-5.d
tls-ld-5.s
tls-ld-6.d
tls-ld-6.s
tls-ld-7.d
tls-ld-7.s
tls-ldgd-14.d
tls-ldgd-14.s
tls-ldgd-15.d
tls-ldgd-15.s
tls-ldgde-14.d
tls-ldgde-15.d
tls-ldgdex-14.d
tls-ldgdex-15.d
tls-ldgdx-14.d
tls-ldgdx-15.d
tls-le-12.d
tls-le-12.s
tls-le-12s.d
tls-le-12s.s
tls-le-13.d
tls-le-13.s
tls-le-13s.d
tls-le-13s.s
tls-legd-16.d
tls-legd-16.s
tls-legd-17.d
tls-legdx-16.d
tls-legdx-17.d
tls-leie-18.d
tls-leie-19.d ELF/LD: Avoid producing hidden and internal dynamic symbols 2016-04-05 15:14:54 +01:00
tls-leie-19.s
tls-local-54.d
tls-local-54.s
tls-local-57.d
tls-local-57.s
tls-local-58.d
tls-local-58.s
tls-local-59.d
tls-local-59.s
tls-local-60.d
tls-local-61.d
tls-local-63.d
tls-local-64.d bfd/ 2012-06-06 10:50:18 +00:00
tls-ok-30.d
tls-ok-32.d
tls-ok-34.d
tls-ok-36.d
tls-tbss64.s
tls-tprelm.s
tls-und-38.d
tls-und-42.d
tls-und-46.d
tls-und-50.d
tls-x1x2.s
tls-x.s
tls-z.s
undef1.d
undef2.d
undef3.d
v10-v32.d
v10-va.d
v32-ba-1.d
v32-ba-1.s
v32-bin-1.d
v32-bin-1.s
v32-v10.d
v32-va.d
va-v10.d
va-v32.d
warn1.d
warn2.d
warn3.d
warn4.d
weakhid.s
weakhiddso.d ld/ 2012-06-15 15:13:41 +00:00
weakref1.d
weakref2.d
weakref3.d Display symbol version when dumping dynrelocs 2014-11-25 06:47:44 -08:00
weakref4.d Display symbol version when dumping dynrelocs 2014-11-25 06:47:44 -08:00