ld: Hide symbols defined by HIDDEN/PROVIDE_HIDDEN

Message ID 20180518171817.GA25880@intel.com
State New
Headers show
Series
  • ld: Hide symbols defined by HIDDEN/PROVIDE_HIDDEN
Related show

Commit Message

H.J. Lu May 18, 2018, 5:18 p.m.
There should be no difference in output for symbols defined by HIDDEN
or PROVIDE_HIDDEN assignments whether they are explicitly marked as
hidden or not.  This patch adds a new BFD function, bfd_link_hide_symbol,
to hide symbols defined by HIDDEN and PROVIDE_HIDDEN assignments.

Any comments?

H.J.
---
bfd

	PR ld/23201
	* aout-target.h (MY_bfd_link_hide_symbol): New.
	* aout-tic30.c (MY_bfd_link_hide_symbol): Likewise.
	* binary.c (binary_bfd_link_hide_symbol): Likewise.
	* coff-alpha.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise.
	* coff-mips.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise.
	* coff-rs6000.c (_bfd_xcoff_bfd_link_hide_symbol): Likewise.
	* coffcode.h (coff_bfd_link_hide_symbol): Likewise.
	* elf-bfd.h (_bfd_elf_link_hide_symbol): Likewise.
	* elflink.c (_bfd_elf_link_hide_symbol): Likewise.
	* elfxx-target.h (bfd_elfNN_bfd_link_hide_symbol): Likewise.
	* i386msdos.c (msdos_bfd_link_hide_symbol): Likewise.
	* ihex.c (ihex_bfd_link_hide_symbol): Likewise.
	* libbfd-in.h (_bfd_nolink_bfd_link_hide_symbol): Likewise.
	* linker.c (_bfd_generic_link_hide_symbol): Likewise.
	(bfd_link_hide_symbol): Likewise.
	* mach-o-target.c (bfd_mach_o_bfd_link_hide_symbol): Likewise.
	* mmo.c (mmo_bfd_link_hide_symbol): Likewise.
	* pef.c (bfd_pef_bfd_link_hide_symbol): Likewise.
	* plugin.c (bfd_plugin_bfd_link_hide_symbol): Likewise.
	* ppcboot.c (ppcboot_bfd_link_hide_symbol): Likewise.
	* som.c (som_bfd_link_hide_symbol): Likewise.
	* srec.c (srec_bfd_link_hide_symbol): Likewise.
	* tekhex.c (tekhex_bfd_link_hide_symbol): Likewise.
	* vms-alpha.c (vms_bfd_link_hide_symbol): Likewise.
	(alpha_vms_bfd_link_hide_symbol): Likewise.
	* xsym.c (bfd_sym_bfd_link_hide_symbol): Likewise.
	* coff64-rs6000.c (rs6000_xcoff64_vec): Add
	_bfd_generic_link_hide_symbol.
	(rs6000_xcoff64_aix_vec): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't
	check root.ldscript_def.
	* targets.c (bfd_target): Add _bfd_link_hide_symbol.
	(BFD_JUMP_TABLE_LINK): Add NAME##_bfd_link_hide_symbol.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

ld/

	PR ld/23201
	* ldexp.c (exp_fold_tree_1): Call bfd_link_hide_symbol to hide
	a symbol.
	* testsuite/ld-elf/provide-hidden-dynabs.nd: Removed.
	* testsuite/ld-elf/provide-hidden-dynsec.nd: Likewise.
	* testsuite/ld-elf/provide-hidden.exp: Replace
	provide-hidden-dynsec.nd with provide-hidden-sec.nd and
	provide-hidden-dyn.nd.  Replace provide-hidden-dynabs.nd with
	provide-hidden-abs.nd and provide-hidden-dyn.nd.
	* testsuite/ld-i386/pr23189.d: Expect no dynamic relocation.
	* testsuite/ld-x86-64/pr23189.d: Likewise.
---
 bfd/aout-target.h                            |  3 +++
 bfd/aout-tic30.c                             |  3 +++
 bfd/bfd-in2.h                                | 12 +++++++++
 bfd/binary.c                                 |  1 +
 bfd/coff-alpha.c                             |  1 +
 bfd/coff-mips.c                              |  1 +
 bfd/coff-rs6000.c                            |  1 +
 bfd/coff64-rs6000.c                          |  2 ++
 bfd/coffcode.h                               |  4 +++
 bfd/elf-bfd.h                                |  2 ++
 bfd/elflink.c                                | 12 +++++++++
 bfd/elfxx-target.h                           |  4 +++
 bfd/elfxx-x86.c                              |  6 +----
 bfd/i386msdos.c                              |  1 +
 bfd/ihex.c                                   |  1 +
 bfd/libbfd-in.h                              |  2 ++
 bfd/libbfd.h                                 |  2 ++
 bfd/linker.c                                 | 26 ++++++++++++++++++++
 bfd/mach-o-target.c                          |  1 +
 bfd/mmo.c                                    |  1 +
 bfd/pef.c                                    |  1 +
 bfd/plugin.c                                 |  1 +
 bfd/ppcboot.c                                |  1 +
 bfd/som.c                                    |  1 +
 bfd/srec.c                                   |  1 +
 bfd/targets.c                                |  5 ++++
 bfd/tekhex.c                                 |  1 +
 bfd/vms-alpha.c                              |  2 ++
 bfd/xsym.c                                   |  1 +
 ld/ldexp.c                                   |  3 +++
 ld/testsuite/ld-elf/provide-hidden-dynabs.nd |  8 ------
 ld/testsuite/ld-elf/provide-hidden-dynsec.nd |  8 ------
 ld/testsuite/ld-elf/provide-hidden.exp       |  8 ++++--
 ld/testsuite/ld-i386/pr23189.d               |  4 +--
 ld/testsuite/ld-x86-64/pr23189.d             |  4 +--
 35 files changed, 106 insertions(+), 29 deletions(-)
 delete mode 100644 ld/testsuite/ld-elf/provide-hidden-dynabs.nd
 delete mode 100644 ld/testsuite/ld-elf/provide-hidden-dynsec.nd

-- 
2.17.0

Comments

H.J. Lu May 18, 2018, 5:56 p.m. | #1
On Fri, May 18, 2018 at 10:18 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> There should be no difference in output for symbols defined by HIDDEN

> or PROVIDE_HIDDEN assignments whether they are explicitly marked as

> hidden or not.  This patch adds a new BFD function, bfd_link_hide_symbol,

> to hide symbols defined by HIDDEN and PROVIDE_HIDDEN assignments.

>

> Any comments?

>

> H.J.

> ---

> bfd

>

>         PR ld/23201

>         * aout-target.h (MY_bfd_link_hide_symbol): New.

>         * aout-tic30.c (MY_bfd_link_hide_symbol): Likewise.

>         * binary.c (binary_bfd_link_hide_symbol): Likewise.

>         * coff-alpha.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise.

>         * coff-mips.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise.

>         * coff-rs6000.c (_bfd_xcoff_bfd_link_hide_symbol): Likewise.

>         * coffcode.h (coff_bfd_link_hide_symbol): Likewise.

>         * elf-bfd.h (_bfd_elf_link_hide_symbol): Likewise.

>         * elflink.c (_bfd_elf_link_hide_symbol): Likewise.

>         * elfxx-target.h (bfd_elfNN_bfd_link_hide_symbol): Likewise.

>         * i386msdos.c (msdos_bfd_link_hide_symbol): Likewise.

>         * ihex.c (ihex_bfd_link_hide_symbol): Likewise.

>         * libbfd-in.h (_bfd_nolink_bfd_link_hide_symbol): Likewise.

>         * linker.c (_bfd_generic_link_hide_symbol): Likewise.

>         (bfd_link_hide_symbol): Likewise.

>         * mach-o-target.c (bfd_mach_o_bfd_link_hide_symbol): Likewise.

>         * mmo.c (mmo_bfd_link_hide_symbol): Likewise.

>         * pef.c (bfd_pef_bfd_link_hide_symbol): Likewise.

>         * plugin.c (bfd_plugin_bfd_link_hide_symbol): Likewise.

>         * ppcboot.c (ppcboot_bfd_link_hide_symbol): Likewise.

>         * som.c (som_bfd_link_hide_symbol): Likewise.

>         * srec.c (srec_bfd_link_hide_symbol): Likewise.

>         * tekhex.c (tekhex_bfd_link_hide_symbol): Likewise.

>         * vms-alpha.c (vms_bfd_link_hide_symbol): Likewise.

>         (alpha_vms_bfd_link_hide_symbol): Likewise.

>         * xsym.c (bfd_sym_bfd_link_hide_symbol): Likewise.

>         * coff64-rs6000.c (rs6000_xcoff64_vec): Add

>         _bfd_generic_link_hide_symbol.

>         (rs6000_xcoff64_aix_vec): Likewise.

>         * elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't

>         check root.ldscript_def.

>         * targets.c (bfd_target): Add _bfd_link_hide_symbol.

>         (BFD_JUMP_TABLE_LINK): Add NAME##_bfd_link_hide_symbol.

>         * bfd-in2.h: Regenerated.

>         * libbfd.h: Likewise.

>

> ld/

>

>         PR ld/23201

>         * ldexp.c (exp_fold_tree_1): Call bfd_link_hide_symbol to hide

>         a symbol.

>         * testsuite/ld-elf/provide-hidden-dynabs.nd: Removed.

>         * testsuite/ld-elf/provide-hidden-dynsec.nd: Likewise.

>         * testsuite/ld-elf/provide-hidden.exp: Replace

>         provide-hidden-dynsec.nd with provide-hidden-sec.nd and

>         provide-hidden-dyn.nd.  Replace provide-hidden-dynabs.nd with

>         provide-hidden-abs.nd and provide-hidden-dyn.nd.

>         * testsuite/ld-i386/pr23189.d: Expect no dynamic relocation.

>         * testsuite/ld-x86-64/pr23189.d: Likewise.

>


The updated patch to call elf_backend_hide_symbol instead of
_bfd_elf_link_hash_hide_symbol.

H.J.
From 56b802da7d21486709cd82a9e5123bcd4675ffac Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 18 May 2018 07:48:13 -0700
Subject: [PATCH] ld: Hide symbols defined by HIDDEN/PROVIDE_HIDDEN

There should be no difference in output for symbols defined by HIDDEN
or PROVIDE_HIDDEN assignments whether they are explicitly marked as
hidden or not.  This patch adds a new BFD function, bfd_link_hide_symbol,
to hide symbols defined by HIDDEN and PROVIDE_HIDDEN assignments.

bfd

	PR ld/23201
	* aout-target.h (MY_bfd_link_hide_symbol): New.
	* aout-tic30.c (MY_bfd_link_hide_symbol): Likewise.
	* binary.c (binary_bfd_link_hide_symbol): Likewise.
	* coff-alpha.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise.
	* coff-mips.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise.
	* coff-rs6000.c (_bfd_xcoff_bfd_link_hide_symbol): Likewise.
	* coffcode.h (coff_bfd_link_hide_symbol): Likewise.
	* elf-bfd.h (_bfd_elf_link_hide_symbol): Likewise.
	* elflink.c (_bfd_elf_link_hide_symbol): Likewise.
	* elfxx-target.h (bfd_elfNN_bfd_link_hide_symbol): Likewise.
	* i386msdos.c (msdos_bfd_link_hide_symbol): Likewise.
	* ihex.c (ihex_bfd_link_hide_symbol): Likewise.
	* libbfd-in.h (_bfd_nolink_bfd_link_hide_symbol): Likewise.
	* linker.c (_bfd_generic_link_hide_symbol): Likewise.
	(bfd_link_hide_symbol): Likewise.
	* mach-o-target.c (bfd_mach_o_bfd_link_hide_symbol): Likewise.
	* mmo.c (mmo_bfd_link_hide_symbol): Likewise.
	* pef.c (bfd_pef_bfd_link_hide_symbol): Likewise.
	* plugin.c (bfd_plugin_bfd_link_hide_symbol): Likewise.
	* ppcboot.c (ppcboot_bfd_link_hide_symbol): Likewise.
	* som.c (som_bfd_link_hide_symbol): Likewise.
	* srec.c (srec_bfd_link_hide_symbol): Likewise.
	* tekhex.c (tekhex_bfd_link_hide_symbol): Likewise.
	* vms-alpha.c (vms_bfd_link_hide_symbol): Likewise.
	(alpha_vms_bfd_link_hide_symbol): Likewise.
	* xsym.c (bfd_sym_bfd_link_hide_symbol): Likewise.
	* coff64-rs6000.c (rs6000_xcoff64_vec): Add
	_bfd_generic_link_hide_symbol.
	(rs6000_xcoff64_aix_vec): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't
	check root.ldscript_def.
	* targets.c (bfd_target): Add _bfd_link_hide_symbol.
	(BFD_JUMP_TABLE_LINK): Add NAME##_bfd_link_hide_symbol.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

ld/

	PR ld/23201
	* ldexp.c (exp_fold_tree_1): Call bfd_link_hide_symbol to hide
	a symbol.
	* testsuite/ld-elf/provide-hidden-dynabs.nd: Removed.
	* testsuite/ld-elf/provide-hidden-dynsec.nd: Likewise.
	* testsuite/ld-elf/provide-hidden.exp: Replace
	provide-hidden-dynsec.nd with provide-hidden-sec.nd and
	provide-hidden-dyn.nd.  Replace provide-hidden-dynabs.nd with
	provide-hidden-abs.nd and provide-hidden-dyn.nd.
	* testsuite/ld-i386/pr23189.d: Expect no dynamic relocation.
	* testsuite/ld-x86-64/pr23189.d: Likewise.
---
 bfd/aout-target.h                            |  3 +++
 bfd/aout-tic30.c                             |  3 +++
 bfd/bfd-in2.h                                | 12 +++++++++
 bfd/binary.c                                 |  1 +
 bfd/coff-alpha.c                             |  1 +
 bfd/coff-mips.c                              |  1 +
 bfd/coff-rs6000.c                            |  1 +
 bfd/coff64-rs6000.c                          |  2 ++
 bfd/coffcode.h                               |  4 +++
 bfd/elf-bfd.h                                |  2 ++
 bfd/elflink.c                                | 17 +++++++++++++
 bfd/elfxx-target.h                           |  4 +++
 bfd/elfxx-x86.c                              |  6 +----
 bfd/i386msdos.c                              |  1 +
 bfd/ihex.c                                   |  1 +
 bfd/libbfd-in.h                              |  2 ++
 bfd/libbfd.h                                 |  2 ++
 bfd/linker.c                                 | 26 ++++++++++++++++++++
 bfd/mach-o-target.c                          |  1 +
 bfd/mmo.c                                    |  1 +
 bfd/pef.c                                    |  1 +
 bfd/plugin.c                                 |  1 +
 bfd/ppcboot.c                                |  1 +
 bfd/som.c                                    |  1 +
 bfd/srec.c                                   |  1 +
 bfd/targets.c                                |  5 ++++
 bfd/tekhex.c                                 |  1 +
 bfd/vms-alpha.c                              |  2 ++
 bfd/xsym.c                                   |  1 +
 ld/ldexp.c                                   |  3 +++
 ld/testsuite/ld-elf/provide-hidden-dynabs.nd |  8 ------
 ld/testsuite/ld-elf/provide-hidden-dynsec.nd |  8 ------
 ld/testsuite/ld-elf/provide-hidden.exp       |  8 ++++--
 ld/testsuite/ld-i386/pr23189.d               |  4 +--
 ld/testsuite/ld-x86-64/pr23189.d             |  4 +--
 35 files changed, 111 insertions(+), 29 deletions(-)
 delete mode 100644 ld/testsuite/ld-elf/provide-hidden-dynabs.nd
 delete mode 100644 ld/testsuite/ld-elf/provide-hidden-dynsec.nd

diff --git a/bfd/aout-target.h b/bfd/aout-target.h
index f245b1e885..9123afcef6 100644
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -512,6 +512,9 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 #ifndef MY_bfd_define_common_symbol
 #define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
 #endif
+#ifndef MY_bfd_link_hide_symbol
+#define MY_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
+#endif
 #ifndef MY_bfd_define_start_stop
 #define MY_bfd_define_start_stop bfd_generic_define_start_stop
 #endif
diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c
index 31248ecd91..ddeaaaa98f 100644
--- a/bfd/aout-tic30.c
+++ b/bfd/aout-tic30.c
@@ -967,6 +967,9 @@ tic30_aout_set_arch_mach (bfd *abfd,
 #ifndef MY_bfd_define_common_symbol
 #define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
 #endif
+#ifndef MY_bfd_link_hide_symbol
+#define MY_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
+#endif
 #ifndef MY_bfd_define_start_stop
 #define MY_bfd_define_start_stop bfd_generic_define_start_stop
 #endif
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 9d11dd0c39..62a2c249b4 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7685,6 +7685,7 @@ typedef struct bfd_target
   NAME##_bfd_discard_group, \
   NAME##_section_already_linked, \
   NAME##_bfd_define_common_symbol, \
+  NAME##_bfd_link_hide_symbol, \
   NAME##_bfd_define_start_stop
 
   int         (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
@@ -7751,6 +7752,10 @@ typedef struct bfd_target
   bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
                                             struct bfd_link_hash_entry *);
 
+  /* Hide a symbol.  */
+  void (*_bfd_link_hide_symbol) (bfd *, struct bfd_link_info *,
+                                 struct bfd_link_hash_entry *);
+
   /* Define a __start, __stop, .startof. or .sizeof. symbol.  */
   struct bfd_link_hash_entry *
               (*_bfd_define_start_stop) (struct bfd_link_info *, const char *,
@@ -7834,6 +7839,13 @@ bfd_boolean bfd_generic_define_common_symbol
 #define bfd_define_common_symbol(output_bfd, info, h) \
        BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h))
 
+void _bfd_generic_link_hide_symbol
+   (bfd *output_bfd, struct bfd_link_info *info,
+    struct bfd_link_hash_entry *h);
+
+#define bfd_link_hide_symbol(output_bfd, info, h) \
+       BFD_SEND (output_bfd, _bfd_link_hide_symbol, (output_bfd, info, h))
+
 struct bfd_link_hash_entry *bfd_generic_define_start_stop
    (struct bfd_link_info *info,
     const char *symbol, asection *sec);
diff --git a/bfd/binary.c b/bfd/binary.c
index 0713f5a496..c467b429f6 100644
--- a/bfd/binary.c
+++ b/bfd/binary.c
@@ -310,6 +310,7 @@ binary_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define binary_bfd_discard_group		   bfd_generic_discard_group
 #define binary_section_already_linked		  _bfd_generic_section_already_linked
 #define binary_bfd_define_common_symbol		   bfd_generic_define_common_symbol
+#define binary_bfd_link_hide_symbol		   _bfd_generic_link_hide_symbol
 #define binary_bfd_define_start_stop		   bfd_generic_define_start_stop
 #define binary_bfd_link_hash_table_create	  _bfd_generic_link_hash_table_create
 #define binary_bfd_link_just_syms		  _bfd_generic_link_just_syms
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index 0e39f317ed..699398f494 100644
--- a/bfd/coff-alpha.c
+++ b/bfd/coff-alpha.c
@@ -2394,6 +2394,7 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data =
 #define _bfd_ecoff_section_already_linked \
   _bfd_coff_section_already_linked
 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define _bfd_ecoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define _bfd_ecoff_bfd_define_start_stop    bfd_generic_define_start_stop
 #define _bfd_ecoff_bfd_link_check_relocs    _bfd_generic_link_check_relocs
 
diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c
index 3a0163a256..d83e10d4b7 100644
--- a/bfd/coff-mips.c
+++ b/bfd/coff-mips.c
@@ -1420,6 +1420,7 @@ static const struct ecoff_backend_data mips_ecoff_backend_data =
 #define _bfd_ecoff_section_already_linked \
   _bfd_coff_section_already_linked
 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define _bfd_ecoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define _bfd_ecoff_bfd_define_start_stop bfd_generic_define_start_stop
 #define _bfd_ecoff_set_reloc _bfd_generic_set_reloc
 
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index d8db1f3894..053ab18940 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -4045,6 +4045,7 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = {
 #define _bfd_xcoff_bfd_discard_group bfd_generic_discard_group
 #define _bfd_xcoff_section_already_linked _bfd_generic_section_already_linked
 #define _bfd_xcoff_bfd_define_common_symbol _bfd_xcoff_define_common_symbol
+#define _bfd_xcoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define _bfd_xcoff_bfd_define_start_stop    bfd_generic_define_start_stop
 #define _bfd_xcoff_bfd_link_check_relocs    _bfd_generic_link_check_relocs
 
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 78f14a09f4..2135001f19 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -2786,6 +2786,7 @@ const bfd_target rs6000_xcoff64_vec =
     bfd_generic_discard_group,
     _bfd_generic_section_already_linked,
     _bfd_xcoff_define_common_symbol,
+    _bfd_generic_link_hide_symbol,
     bfd_generic_define_start_stop,
 
     /* Dynamic */
@@ -3047,6 +3048,7 @@ const bfd_target rs6000_xcoff64_aix_vec =
     bfd_generic_discard_group,
     _bfd_generic_section_already_linked,
     _bfd_xcoff_define_common_symbol,
+    _bfd_generic_link_hide_symbol,
     bfd_generic_define_start_stop,
 
     /* Dynamic */
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 6ad991cf9d..2ca32059cb 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -5749,6 +5749,10 @@ static bfd_coff_backend_data bigobj_swap_table =
 #define coff_bfd_define_common_symbol	    bfd_generic_define_common_symbol
 #endif
 
+#ifndef coff_bfd_link_hide_symbol
+#define coff_bfd_link_hide_symbol	    _bfd_generic_link_hide_symbol
+#endif
+
 #ifndef coff_bfd_define_start_stop
 #define coff_bfd_define_start_stop	    bfd_generic_define_start_stop
 #endif
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 7b746900ba..e051c9c089 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2086,6 +2086,8 @@ extern void _bfd_elf_link_hash_copy_indirect
    struct elf_link_hash_entry *);
 extern void _bfd_elf_link_hash_hide_symbol
   (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
+extern void _bfd_elf_link_hide_symbol
+  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
 extern bfd_boolean _bfd_elf_link_hash_fixup_symbol
   (struct bfd_link_info *, struct elf_link_hash_entry *);
 extern bfd_boolean _bfd_elf_link_hash_table_init
diff --git a/bfd/elflink.c b/bfd/elflink.c
index ce3765e45b..d57c6fc789 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -7429,6 +7429,23 @@ _bfd_elf_link_hash_hide_symbol (struct bfd_link_info *info,
     }
 }
 
+/* Hide a symbol. */
+
+void
+_bfd_elf_link_hide_symbol (bfd *output_bfd,
+			   struct bfd_link_info *info,
+			   struct bfd_link_hash_entry *h)
+{
+  if (is_elf_hash_table (info->hash))
+    {
+      const struct elf_backend_data *bed
+	= get_elf_backend_data (output_bfd);
+      bed->elf_backend_hide_symbol (info,
+				    (struct elf_link_hash_entry *) h,
+				    TRUE);
+    }
+}
+
 /* Initialize an ELF linker hash table.  *TABLE has been zeroed by our
    caller.  */
 
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 89efed3a5e..a86ea587a2 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -205,6 +205,10 @@
 #define bfd_elfNN_bfd_define_common_symbol bfd_generic_define_common_symbol
 #endif
 
+#ifndef bfd_elfNN_bfd_link_hide_symbol
+#define bfd_elfNN_bfd_link_hide_symbol _bfd_elf_link_hide_symbol
+#endif
+
 #ifndef bfd_elfNN_bfd_lookup_section_flags
 #define bfd_elfNN_bfd_lookup_section_flags bfd_elf_lookup_section_flags
 #endif
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index f4dbddf15e..936b4c67d2 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -2047,11 +2047,7 @@ _bfd_x86_elf_link_symbol_references_local (struct bfd_link_info *info,
       return TRUE;
     }
 
-  /* Symbols created by HIDDEN and PROVIDE_HIDDEN assignments in linker
-     script aren't forced local here yet.  */
-  if (!h->root.ldscript_def)
-    eh->local_ref = 1;
-
+  eh->local_ref = 1;
   return FALSE;
 }
 
diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c
index a47acf4953..77e9880ced 100644
--- a/bfd/i386msdos.c
+++ b/bfd/i386msdos.c
@@ -230,6 +230,7 @@ msdos_set_section_contents (bfd *abfd,
 #define msdos_section_already_linked \
   _bfd_generic_section_already_linked
 #define msdos_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define msdos_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define msdos_bfd_define_start_stop bfd_generic_define_start_stop
 #define msdos_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define msdos_bfd_link_add_symbols _bfd_generic_link_add_symbols
diff --git a/bfd/ihex.c b/bfd/ihex.c
index 096c19ce2e..80bcbe9f90 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -943,6 +943,7 @@ ihex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define ihex_bfd_discard_group			  bfd_generic_discard_group
 #define ihex_section_already_linked		  _bfd_generic_section_already_linked
 #define ihex_bfd_define_common_symbol		  bfd_generic_define_common_symbol
+#define ihex_bfd_link_hide_symbol		  _bfd_generic_link_hide_symbol
 #define ihex_bfd_define_start_stop		  bfd_generic_define_start_stop
 #define ihex_bfd_link_hash_table_create		  _bfd_generic_link_hash_table_create
 #define ihex_bfd_link_add_symbols		  _bfd_generic_link_add_symbols
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index bb3cf48f70..9796f2d67e 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -534,6 +534,8 @@ extern bfd_boolean _bfd_nolink_section_already_linked
 extern bfd_boolean _bfd_nolink_bfd_define_common_symbol
   (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *)
   ATTRIBUTE_HIDDEN;
+#define _bfd_nolink_bfd_link_hide_symbol \
+  _bfd_generic_link_hide_symbol
 extern struct bfd_link_hash_entry *_bfd_nolink_bfd_define_start_stop
   (struct bfd_link_info *, const char *, asection *) ATTRIBUTE_HIDDEN;
 #define _bfd_nolink_bfd_link_check_relocs \
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index b810c40c40..f357e0e4ab 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -539,6 +539,8 @@ extern bfd_boolean _bfd_nolink_section_already_linked
 extern bfd_boolean _bfd_nolink_bfd_define_common_symbol
   (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *)
   ATTRIBUTE_HIDDEN;
+#define _bfd_nolink_bfd_link_hide_symbol \
+  _bfd_generic_link_hide_symbol
 extern struct bfd_link_hash_entry *_bfd_nolink_bfd_define_start_stop
   (struct bfd_link_info *, const char *, asection *) ATTRIBUTE_HIDDEN;
 #define _bfd_nolink_bfd_link_check_relocs \
diff --git a/bfd/linker.c b/bfd/linker.c
index 3019919a91..6b4c8e57e1 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -3110,6 +3110,32 @@ bfd_generic_define_common_symbol (bfd *output_bfd,
   return TRUE;
 }
 
+/*
+FUNCTION
+	_bfd_generic_link_hide_symbol
+
+SYNOPSIS
+	void _bfd_generic_link_hide_symbol
+	  (bfd *output_bfd, struct bfd_link_info *info,
+	   struct bfd_link_hash_entry *h);
+
+DESCRIPTION
+	Hide symbol @var{h}.
+	This is an internal function.  It should not be called from
+	outside the BFD library.
+
+.#define bfd_link_hide_symbol(output_bfd, info, h) \
+.	BFD_SEND (output_bfd, _bfd_link_hide_symbol, (output_bfd, info, h))
+.
+*/
+
+void
+_bfd_generic_link_hide_symbol (bfd *output_bfd ATTRIBUTE_UNUSED,
+			       struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			       struct bfd_link_hash_entry *h ATTRIBUTE_UNUSED)
+{
+}
+
 /*
 FUNCTION
 	bfd_generic_define_start_stop
diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
index 8859b23907..9f3b487b8d 100644
--- a/bfd/mach-o-target.c
+++ b/bfd/mach-o-target.c
@@ -55,6 +55,7 @@
 #define bfd_mach_o_bfd_discard_group		      bfd_generic_discard_group
 #define bfd_mach_o_section_already_linked	      _bfd_generic_section_already_linked
 #define bfd_mach_o_bfd_define_common_symbol	      bfd_generic_define_common_symbol
+#define bfd_mach_o_bfd_link_hide_symbol		      _bfd_generic_link_hide_symbol
 #define bfd_mach_o_bfd_define_start_stop	      bfd_generic_define_start_stop
 #define bfd_mach_o_bfd_copy_private_bfd_data	      _bfd_generic_bfd_copy_private_bfd_data
 #define bfd_mach_o_core_file_matches_executable_p     generic_core_file_matches_executable_p
diff --git a/bfd/mmo.c b/bfd/mmo.c
index 4b969c2c03..6a3e255803 100644
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -3318,6 +3318,7 @@ mmo_write_object_contents (bfd *abfd)
 #define mmo_section_already_linked \
   _bfd_generic_section_already_linked
 #define mmo_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define mmo_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define mmo_bfd_define_start_stop bfd_generic_define_start_stop
 
 /* We want to copy time of creation, otherwise we'd use
diff --git a/bfd/pef.c b/bfd/pef.c
index a55ca0693a..5746b96b43 100644
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -59,6 +59,7 @@
 #define bfd_pef_bfd_discard_group		    bfd_generic_discard_group
 #define bfd_pef_section_already_linked		    _bfd_generic_section_already_linked
 #define bfd_pef_bfd_define_common_symbol	    bfd_generic_define_common_symbol
+#define bfd_pef_bfd_link_hide_symbol		    _bfd_generic_link_hide_symbol
 #define bfd_pef_bfd_define_start_stop		    bfd_generic_define_start_stop
 #define bfd_pef_bfd_link_hash_table_create	    _bfd_generic_link_hash_table_create
 #define bfd_pef_bfd_link_add_symbols		    _bfd_generic_link_add_symbols
diff --git a/bfd/plugin.c b/bfd/plugin.c
index a2c1bd5776..16a706a548 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -105,6 +105,7 @@ dlerror (void)
 #define bfd_plugin_bfd_discard_group		      bfd_generic_discard_group
 #define bfd_plugin_section_already_linked	      _bfd_generic_section_already_linked
 #define bfd_plugin_bfd_define_common_symbol	      bfd_generic_define_common_symbol
+#define bfd_plugin_bfd_link_hide_symbol		      _bfd_generic_link_hide_symbol
 #define bfd_plugin_bfd_define_start_stop	      bfd_generic_define_start_stop
 #define bfd_plugin_bfd_copy_link_hash_symbol_type     _bfd_generic_copy_link_hash_symbol_type
 #define bfd_plugin_bfd_link_check_relocs	      _bfd_generic_link_check_relocs
diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c
index bbb2cc77d4..0d92fd1c82 100644
--- a/bfd/ppcboot.c
+++ b/bfd/ppcboot.c
@@ -460,6 +460,7 @@ ppcboot_bfd_print_private_bfd_data (bfd *abfd, void * farg)
 #define ppcboot_section_already_linked \
   _bfd_generic_section_already_linked
 #define ppcboot_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define ppcboot_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define ppcboot_bfd_define_start_stop bfd_generic_define_start_stop
 #define ppcboot_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define ppcboot_bfd_link_add_symbols _bfd_generic_link_add_symbols
diff --git a/bfd/som.c b/bfd/som.c
index 6220df7eb8..d2bdc6f5c4 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -6759,6 +6759,7 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
 #define som_bfd_discard_group			bfd_generic_discard_group
 #define som_section_already_linked		_bfd_generic_section_already_linked
 #define som_bfd_define_common_symbol		bfd_generic_define_common_symbol
+#define som_bfd_link_hide_symbol		_bfd_generic_link_hide_symbol
 #define som_bfd_define_start_stop		bfd_generic_define_start_stop
 #define som_bfd_merge_private_bfd_data		_bfd_generic_bfd_merge_private_bfd_data
 #define som_bfd_copy_private_header_data	_bfd_generic_bfd_copy_private_header_data
diff --git a/bfd/srec.c b/bfd/srec.c
index 4996109ed1..66cc72fea8 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -1278,6 +1278,7 @@ srec_print_symbol (bfd *abfd,
 #define srec_bfd_discard_group			  bfd_generic_discard_group
 #define srec_section_already_linked		  _bfd_generic_section_already_linked
 #define srec_bfd_define_common_symbol		  bfd_generic_define_common_symbol
+#define srec_bfd_link_hide_symbol		  _bfd_generic_link_hide_symbol
 #define srec_bfd_define_start_stop		  bfd_generic_define_start_stop
 #define srec_bfd_link_hash_table_create		  _bfd_generic_link_hash_table_create
 #define srec_bfd_link_add_symbols		  _bfd_generic_link_add_symbols
diff --git a/bfd/targets.c b/bfd/targets.c
index 5a2a684bc8..531703d226 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -465,6 +465,7 @@ BFD_JUMP_TABLE macros.
 .  NAME##_bfd_discard_group, \
 .  NAME##_section_already_linked, \
 .  NAME##_bfd_define_common_symbol, \
+.  NAME##_bfd_link_hide_symbol, \
 .  NAME##_bfd_define_start_stop
 .
 .  int	       (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
@@ -531,6 +532,10 @@ BFD_JUMP_TABLE macros.
 .  bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
 .					     struct bfd_link_hash_entry *);
 .
+.  {* Hide a symbol.  *}
+.  void (*_bfd_link_hide_symbol) (bfd *, struct bfd_link_info *,
+.				  struct bfd_link_hash_entry *);
+.
 .  {* Define a __start, __stop, .startof. or .sizeof. symbol.  *}
 .  struct bfd_link_hash_entry *
 .	       (*_bfd_define_start_stop) (struct bfd_link_info *, const char *,
diff --git a/bfd/tekhex.c b/bfd/tekhex.c
index 6a00c9f773..893d06def6 100644
--- a/bfd/tekhex.c
+++ b/bfd/tekhex.c
@@ -981,6 +981,7 @@ tekhex_print_symbol (bfd *abfd,
 #define tekhex_bfd_discard_group		    bfd_generic_discard_group
 #define tekhex_section_already_linked		    _bfd_generic_section_already_linked
 #define tekhex_bfd_define_common_symbol		    bfd_generic_define_common_symbol
+#define tekhex_bfd_link_hide_symbol		    _bfd_generic_link_hide_symbol
 #define tekhex_bfd_define_start_stop		    bfd_generic_define_start_stop
 #define tekhex_bfd_link_hash_table_create	    _bfd_generic_link_hash_table_create
 #define tekhex_bfd_link_add_symbols		    _bfd_generic_link_add_symbols
diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c
index b52f580ad3..11817cfbec 100644
--- a/bfd/vms-alpha.c
+++ b/bfd/vms-alpha.c
@@ -9498,6 +9498,7 @@ bfd_vms_get_data (bfd *abfd)
 #define vms_bfd_discard_group		  bfd_generic_discard_group
 #define vms_section_already_linked	  _bfd_generic_section_already_linked
 #define vms_bfd_define_common_symbol	  bfd_generic_define_common_symbol
+#define vms_bfd_link_hide_symbol	  _bfd_generic_link_hide_symbol
 #define vms_bfd_define_start_stop         bfd_generic_define_start_stop
 #define vms_bfd_copy_private_header_data  _bfd_generic_bfd_copy_private_header_data
 
@@ -9545,6 +9546,7 @@ bfd_vms_get_data (bfd *abfd)
   _bfd_generic_section_already_linked
 
 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
 #define alpha_vms_bfd_copy_link_hash_symbol_type \
diff --git a/bfd/xsym.c b/bfd/xsym.c
index 8ea0e7e71f..56607f026f 100644
--- a/bfd/xsym.c
+++ b/bfd/xsym.c
@@ -51,6 +51,7 @@
 #define bfd_sym_bfd_discard_group		    bfd_generic_discard_group
 #define bfd_sym_section_already_linked		    _bfd_generic_section_already_linked
 #define bfd_sym_bfd_define_common_symbol	    bfd_generic_define_common_symbol
+#define bfd_sym_bfd_link_hide_symbol		    _bfd_generic_link_hide_symbol
 #define bfd_sym_bfd_define_start_stop		    bfd_generic_define_start_stop
 #define bfd_sym_bfd_link_hash_table_create	    _bfd_generic_link_hash_table_create
 #define bfd_sym_bfd_link_add_symbols		    _bfd_generic_link_add_symbols
diff --git a/ld/ldexp.c b/ld/ldexp.c
index f9dc362930..6fa251e79e 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -1200,6 +1200,9 @@ exp_fold_tree_1 (etree_type *tree)
 		  h->u.def.section = expld.result.section;
 		  h->linker_def = ! tree->assign.type.lineno;
 		  h->ldscript_def = 1;
+		  if (tree->assign.hidden)
+		    bfd_link_hide_symbol (link_info.output_bfd,
+					  &link_info, h);
 
 		  /* Copy the symbol type if this is an expression only
 		     referencing a single symbol.  (If the expression
diff --git a/ld/testsuite/ld-elf/provide-hidden-dynabs.nd b/ld/testsuite/ld-elf/provide-hidden-dynabs.nd
deleted file mode 100644
index 86e3adcdf9..0000000000
--- a/ld/testsuite/ld-elf/provide-hidden-dynabs.nd
+++ /dev/null
@@ -1,8 +0,0 @@
-Symbol table '\.dynsym' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +ABS foo
-#...
-Symbol table '\.symtab' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +ABS foo
-#pass
diff --git a/ld/testsuite/ld-elf/provide-hidden-dynsec.nd b/ld/testsuite/ld-elf/provide-hidden-dynsec.nd
deleted file mode 100644
index 716dfa1f71..0000000000
--- a/ld/testsuite/ld-elf/provide-hidden-dynsec.nd
+++ /dev/null
@@ -1,8 +0,0 @@
-Symbol table '\.dynsym' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ foo
-#...
-Symbol table '\.symtab' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ foo
-#pass
diff --git a/ld/testsuite/ld-elf/provide-hidden.exp b/ld/testsuite/ld-elf/provide-hidden.exp
index 1fc4e61a19..4b72134911 100644
--- a/ld/testsuite/ld-elf/provide-hidden.exp
+++ b/ld/testsuite/ld-elf/provide-hidden.exp
@@ -86,7 +86,9 @@ run_ld_link_tests [list \
 	"$LFLAGS -T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \
 	"" \
 	[list provide-hidden-3.s] \
-	[list "readelf -s provide-hidden-dynsec.nd"] \
+	[list \
+	    [list readelf -s provide-hidden-sec.nd] \
+	    [list readelf -s provide-hidden-dyn.nd]] \
 	"provide-hidden-4"] \
     [list \
 	"$testname 5" \
@@ -138,7 +140,9 @@ run_ld_link_tests [list \
 	"$LFLAGS -T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \
 	"" \
 	[list provide-hidden-3.s] \
-	[list "readelf -s provide-hidden-dynabs.nd"] \
+	[list \
+	    [list readelf -s provide-hidden-abs.nd] \
+	    [list readelf -s provide-hidden-dyn.nd]] \
 	"provide-hidden-10"] \
     [list \
 	"$testname 11" \
diff --git a/ld/testsuite/ld-i386/pr23189.d b/ld/testsuite/ld-i386/pr23189.d
index 9345b42bd0..d388830f61 100644
--- a/ld/testsuite/ld-i386/pr23189.d
+++ b/ld/testsuite/ld-i386/pr23189.d
@@ -2,6 +2,4 @@
 #ld: -shared -melf_i386 -T pr23189.t
 #readelf: -r --wide
 
-Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
- Offset     Info    Type                Sym. Value  Symbol's Name
-[0-9a-f]+ +[0-9a-f]+ +R_386_RELATIVE +
+There are no relocations in this file.
diff --git a/ld/testsuite/ld-x86-64/pr23189.d b/ld/testsuite/ld-x86-64/pr23189.d
index 7951c7acc3..6fc4b7ee2c 100644
--- a/ld/testsuite/ld-x86-64/pr23189.d
+++ b/ld/testsuite/ld-x86-64/pr23189.d
@@ -2,6 +2,4 @@
 #ld: -shared -melf_x86_64 -T pr23189.t
 #readelf: -r --wide
 
-Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
-    Offset             Info             Type               Symbol's Value  Symbol's Name \+ Addend
-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9a-f]+
+There are no relocations in this file.
Alan Modra May 19, 2018, 3:23 a.m. | #2
On Fri, May 18, 2018 at 10:56:21AM -0700, H.J. Lu wrote:
> The updated patch to call elf_backend_hide_symbol instead of

> _bfd_elf_link_hash_hide_symbol.


I see x86_64-linux and powerpc64le-linux segfaults with this patch.

I'm also unconvinced that we need bfd_link_hide_symbol.  We'll be
calling bfd_elf_record_link_assignment for any symbol defined by a
linker script.  Why can't bfd_elf_record_link_assignment be corrected
if it is doing something wrong?

-- 
Alan Modra
Australia Development Lab, IBM
H.J. Lu May 19, 2018, 3:39 a.m. | #3
On Fri, May 18, 2018 at 8:23 PM, Alan Modra <amodra@gmail.com> wrote:
> On Fri, May 18, 2018 at 10:56:21AM -0700, H.J. Lu wrote:

>> The updated patch to call elf_backend_hide_symbol instead of

>> _bfd_elf_link_hash_hide_symbol.

>

> I see x86_64-linux and powerpc64le-linux segfaults with this patch.


I will take a look.

> I'm also unconvinced that we need bfd_link_hide_symbol.  We'll be

> calling bfd_elf_record_link_assignment for any symbol defined by a

> linker script.  Why can't bfd_elf_record_link_assignment be corrected

> if it is doing something wrong?


bfd_elf_record_link_assignment is called too late. I need this info
when scanning relocation.

-- 
H.J.
H.J. Lu May 19, 2018, 3:49 a.m. | #4
On Fri, May 18, 2018 at 8:39 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Fri, May 18, 2018 at 8:23 PM, Alan Modra <amodra@gmail.com> wrote:

>> On Fri, May 18, 2018 at 10:56:21AM -0700, H.J. Lu wrote:

>>> The updated patch to call elf_backend_hide_symbol instead of

>>> _bfd_elf_link_hash_hide_symbol.

>>

>> I see x86_64-linux and powerpc64le-linux segfaults with this patch.

>


Do you have a testcase?

>

>> I'm also unconvinced that we need bfd_link_hide_symbol.  We'll be

>> calling bfd_elf_record_link_assignment for any symbol defined by a

>> linker script.  Why can't bfd_elf_record_link_assignment be corrected

>> if it is doing something wrong?

>

> bfd_elf_record_link_assignment is called too late. I need this info

> when scanning relocation.

>

> --

> H.J.




-- 
H.J.
Alan Modra May 21, 2018, 2:11 a.m. | #5
On Fri, May 18, 2018 at 08:49:19PM -0700, H.J. Lu wrote:
> On Fri, May 18, 2018 at 8:39 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

> > On Fri, May 18, 2018 at 8:23 PM, Alan Modra <amodra@gmail.com> wrote:

> >> I see x86_64-linux and powerpc64le-linux segfaults with this patch.

> >

> 

> Do you have a testcase?


These are my test results.  Looking in x86_64-linux/ld/ld.log shows

Executing on host: sh -c {./ld-new -z norelro  -L/home/alan/src/binutils-gdb/ld/testsuite/ld-i386  -shared -melf_i386 --version-script pr23194.map -o tmpdir/dump tmpdir/pr23194.o  2>&1}  /dev/null ld.tmp (timeout = 300)
spawn [open ...]
Segmentation fault (core dumped)
failed with: <Segmentation fault (core dumped)>, no expected output
Segmentation fault (core dumped)
FAIL: ld-i386/pr23194

and a similar result for ld-x86-64/pr23194

The first powerpc64le-linux failure is:

Executing on host: sh -c {/home/alan/build/gas/powerpc64le-linux/ld/ld-new   -o tmpdir/provide-hidden-4 -z norelro -L/home/alan/src/binutils-gdb/ld/testsuite/ld-elf  -T provide-hidden-1.ld tmpdir/provide-hidden-3.o tmpdir/provide-hidden-s.so 2>&1}  /dev/null ld.tmp (timeout = 300)
spawn [open ...]
/home/alan/build/gas/powerpc64le-linux/ld/ld-new: BFD (GNU Binutils) 2.30.51.20180519 assertion fail /home/alan/src/binutils-gdb/bfd/elf-strtab.c:197
/home/alan/build/gas/powerpc64le-linux/ld/ld-new: BFD (GNU Binutils) 2.30.51.20180519 assertion fail /home/alan/src/binutils-gdb/bfd/elf-strtab.c:198
Segmentation fault (core dumped)
/home/alan/build/gas/powerpc64le-linux/ld/ld-new: BFD (GNU Binutils) 2.30.51.20180519 assertion fail /home/alan/src/binutils-gdb/bfd/elf-strtab.c:197
/home/alan/build/gas/powerpc64le-linux/ld/ld-new: BFD (GNU Binutils) 2.30.51.20180519 assertion fail /home/alan/src/binutils-gdb/bfd/elf-strtab.c:198
Segmentation fault (core dumped)
FAIL: PROVIDE_HIDDEN test 4

arm-symbianelf  -FAIL: PROVIDE_HIDDEN test 3
arm-symbianelf  -FAIL: PROVIDE_HIDDEN test 5
arm-symbianelf  -FAIL: PROVIDE_HIDDEN test 6
arm-symbianelf  +FAIL: PROVIDE_HIDDEN test 10
i586-linux  +FAIL: ld-i386/pr23194
i686-nacl  +FAIL: ld-i386/pr23194
i686-pc-elf  +FAIL: ld-i386/pr23194
powerpc64-freebsd  +FAIL: PROVIDE_HIDDEN test 4
powerpc64-freebsd  +FAIL: PROVIDE_HIDDEN test 10
powerpc64le-linux  +FAIL: PROVIDE_HIDDEN test 4
powerpc64le-linux  +FAIL: PROVIDE_HIDDEN test 10
powerpc64-linux  +FAIL: PROVIDE_HIDDEN test 4
powerpc64-linux  +FAIL: PROVIDE_HIDDEN test 10
powerpc-eabisim  +FAIL: PROVIDE_HIDDEN test 4
powerpc-eabisim  +FAIL: PROVIDE_HIDDEN test 10
powerpc-eabivle  +FAIL: PROVIDE_HIDDEN test 4
powerpc-eabivle  +FAIL: PROVIDE_HIDDEN test 10
powerpc-freebsd  +FAIL: PROVIDE_HIDDEN test 4
powerpc-freebsd  +FAIL: PROVIDE_HIDDEN test 10
powerpcle-elf  +FAIL: PROVIDE_HIDDEN test 4
powerpcle-elf  +FAIL: PROVIDE_HIDDEN test 10
powerpc-linux  +FAIL: PROVIDE_HIDDEN test 4
powerpc-linux  +FAIL: PROVIDE_HIDDEN test 10
powerpc-nto  +FAIL: PROVIDE_HIDDEN test 4
powerpc-nto  +FAIL: PROVIDE_HIDDEN test 10
ppc-lynxos  +FAIL: PROVIDE_HIDDEN test 4
ppc-lynxos  +FAIL: PROVIDE_HIDDEN test 10
tic6x-elf  -FAIL: PROVIDE_HIDDEN test 6
tic6x-elf  -FAIL: PROVIDE_HIDDEN test 12
tic6x-elf  +FAIL: C6X shared library without --dsbt-index
tic6x-elf  +FAIL: C6X shared library, LE, RELA
tic6x-elf  +FAIL: C6X nonstatic app using shared library, LE, RELA
tic6x-elf  +FAIL: C6X shared library, LE, REL
tic6x-elf  +FAIL: C6X nonstatic app using shared library, LE, REL
tic6x-elf  +FAIL: C6X shared library, BE, RELA
tic6x-elf  +FAIL: C6X nonstatic app using shared library, BE, RELA
tic6x-elf  +FAIL: C6X shared library, BE, REL
tic6x-elf  +FAIL: C6X nonstatic app using shared library, BE, REL
tic6x-elf  +FAIL: C6X static app, LE, RELA
tic6x-elf  +FAIL: C6X static app, LE, REL
tic6x-elf  +FAIL: C6X static app, BE, RELA
tic6x-elf  +FAIL: C6X static app, BE, REL
x86_64-linux  +FAIL: ld-i386/pr23194
x86_64-linux  +FAIL: ld-x86-64/pr23194
x86_64-nacl  +FAIL: ld-i386/pr23194
x86_64-nacl  +FAIL: ld-x86-64/pr23194
x86_64-pc-linux-gnux32  +FAIL: ld-i386/pr23194
x86_64-pc-linux-gnux32  +FAIL: ld-x86-64/pr23194

-- 
Alan Modra
Australia Development Lab, IBM
H.J. Lu May 21, 2018, 4:02 a.m. | #6
On Sun, May 20, 2018 at 7:11 PM, Alan Modra <amodra@gmail.com> wrote:
> On Fri, May 18, 2018 at 08:49:19PM -0700, H.J. Lu wrote:

>> On Fri, May 18, 2018 at 8:39 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

>> > On Fri, May 18, 2018 at 8:23 PM, Alan Modra <amodra@gmail.com> wrote:

>> >> I see x86_64-linux and powerpc64le-linux segfaults with this patch.

>> >

>>

>> Do you have a testcase?

>

> These are my test results.  Looking in x86_64-linux/ld/ld.log shows

>

> Executing on host: sh -c {./ld-new -z norelro  -L/home/alan/src/binutils-gdb/ld/testsuite/ld-i386  -shared -melf_i386 --version-script pr23194.map -o tmpdir/dump tmpdir/pr23194.o  2>&1}  /dev/null ld.tmp (timeout = 300)

> spawn [open ...]

> Segmentation fault (core dumped)

> failed with: <Segmentation fault (core dumped)>, no expected output

> Segmentation fault (core dumped)

> FAIL: ld-i386/pr23194

>

> and a similar result for ld-x86-64/pr23194


I can't reproduce it on native x86-64 nor i686.

> The first powerpc64le-linux failure is:

>

> Executing on host: sh -c {/home/alan/build/gas/powerpc64le-linux/ld/ld-new   -o tmpdir/provide-hidden-4 -z norelro -L/home/alan/src/binutils-gdb/ld/testsuite/ld-elf  -T provide-hidden-1.ld tmpdir/provide-hidden-3.o tmpdir/provide-hidden-s.so 2>&1}  /dev/null ld.tmp (timeout = 300)

> spawn [open ...]

> /home/alan/build/gas/powerpc64le-linux/ld/ld-new: BFD (GNU Binutils) 2.30.51.20180519 assertion fail /home/alan/src/binutils-gdb/bfd/elf-strtab.c:197

> /home/alan/build/gas/powerpc64le-linux/ld/ld-new: BFD (GNU Binutils) 2.30.51.20180519 assertion fail /home/alan/src/binutils-gdb/bfd/elf-strtab.c:198

> Segmentation fault (core dumped)

> /home/alan/build/gas/powerpc64le-linux/ld/ld-new: BFD (GNU Binutils) 2.30.51.20180519 assertion fail /home/alan/src/binutils-gdb/bfd/elf-strtab.c:197

> /home/alan/build/gas/powerpc64le-linux/ld/ld-new: BFD (GNU Binutils) 2.30.51.20180519 assertion fail /home/alan/src/binutils-gdb/bfd/elf-strtab.c:198

> Segmentation fault (core dumped)

> FAIL: PROVIDE_HIDDEN test 4


I can reproduce it.  bfd_elf_record_link_assignment has

  /* STV_HIDDEN and STV_INTERNAL symbols must be STB_LOCAL in shared objects
     and executables.  */
  if (!bfd_link_relocatable (info)
      && h->dynindx != -1
      && (ELF_ST_VISIBILITY (h->other) == STV_HIDDEN
          || ELF_ST_VISIBILITY (h->other) == STV_INTERNAL))
    h->forced_local = 1;

  if ((h->def_dynamic
       || h->ref_dynamic
       || bfd_link_dll (info)
       || elf_hash_table (info)->is_relocatable_executable)
      && h->dynindx == -1)
    {
      if (! bfd_elf_link_record_dynamic_symbol (info, h))
        return FALSE;

Should we make a forced local symbol dynamic here?

> arm-symbianelf  -FAIL: PROVIDE_HIDDEN test 3

> arm-symbianelf  -FAIL: PROVIDE_HIDDEN test 5

> arm-symbianelf  -FAIL: PROVIDE_HIDDEN test 6

> arm-symbianelf  +FAIL: PROVIDE_HIDDEN test 10


I took a look at arm-symbian.   There are so many linker test failures.
My patch is actually an improvement.

> i586-linux  +FAIL: ld-i386/pr23194

> i686-nacl  +FAIL: ld-i386/pr23194

> i686-pc-elf  +FAIL: ld-i386/pr23194

> powerpc64-freebsd  +FAIL: PROVIDE_HIDDEN test 4

> powerpc64-freebsd  +FAIL: PROVIDE_HIDDEN test 10

> powerpc64le-linux  +FAIL: PROVIDE_HIDDEN test 4

> powerpc64le-linux  +FAIL: PROVIDE_HIDDEN test 10

> powerpc64-linux  +FAIL: PROVIDE_HIDDEN test 4

> powerpc64-linux  +FAIL: PROVIDE_HIDDEN test 10

> powerpc-eabisim  +FAIL: PROVIDE_HIDDEN test 4

> powerpc-eabisim  +FAIL: PROVIDE_HIDDEN test 10

> powerpc-eabivle  +FAIL: PROVIDE_HIDDEN test 4

> powerpc-eabivle  +FAIL: PROVIDE_HIDDEN test 10

> powerpc-freebsd  +FAIL: PROVIDE_HIDDEN test 4

> powerpc-freebsd  +FAIL: PROVIDE_HIDDEN test 10

> powerpcle-elf  +FAIL: PROVIDE_HIDDEN test 4

> powerpcle-elf  +FAIL: PROVIDE_HIDDEN test 10

> powerpc-linux  +FAIL: PROVIDE_HIDDEN test 4

> powerpc-linux  +FAIL: PROVIDE_HIDDEN test 10

> powerpc-nto  +FAIL: PROVIDE_HIDDEN test 4

> powerpc-nto  +FAIL: PROVIDE_HIDDEN test 10

> ppc-lynxos  +FAIL: PROVIDE_HIDDEN test 4

> ppc-lynxos  +FAIL: PROVIDE_HIDDEN test 10


I can reproduce them.

> tic6x-elf  -FAIL: PROVIDE_HIDDEN test 6

> tic6x-elf  -FAIL: PROVIDE_HIDDEN test 12


2 new passes.

> tic6x-elf  +FAIL: C6X shared library without --dsbt-index

> tic6x-elf  +FAIL: C6X shared library, LE, RELA

> tic6x-elf  +FAIL: C6X nonstatic app using shared library, LE, RELA

> tic6x-elf  +FAIL: C6X shared library, LE, REL

> tic6x-elf  +FAIL: C6X nonstatic app using shared library, LE, REL

> tic6x-elf  +FAIL: C6X shared library, BE, RELA

> tic6x-elf  +FAIL: C6X nonstatic app using shared library, BE, RELA

> tic6x-elf  +FAIL: C6X shared library, BE, REL

> tic6x-elf  +FAIL: C6X nonstatic app using shared library, BE, REL

> tic6x-elf  +FAIL: C6X static app, LE, RELA

> tic6x-elf  +FAIL: C6X static app, LE, REL

> tic6x-elf  +FAIL: C6X static app, BE, RELA

> tic6x-elf  +FAIL: C6X static app, BE, REL


These failures are due to offset/address changes.  The binaries are smaller.
They may be related to 2 new passes.

> x86_64-linux  +FAIL: ld-i386/pr23194

> x86_64-linux  +FAIL: ld-x86-64/pr23194

> x86_64-nacl  +FAIL: ld-i386/pr23194

> x86_64-nacl  +FAIL: ld-x86-64/pr23194

> x86_64-pc-linux-gnux32  +FAIL: ld-i386/pr23194

> x86_64-pc-linux-gnux32  +FAIL: ld-x86-64/pr23194

>


Here is the updated patch which avoids making forced local symbol
dynamic.  There are no regressions on native x86-64 and i686 as
well as for cross ppc-linux and ppc64-linux.

-- 
H.J.
From 80865b8b4f043c903834385a0d7fd27faece12eb Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 18 May 2018 07:48:13 -0700
Subject: [PATCH] ld: Hide symbols defined by HIDDEN/PROVIDE_HIDDEN

There should be no difference in output for symbols defined by HIDDEN
or PROVIDE_HIDDEN assignments whether they are explicitly marked as
hidden or not.  This patch adds a new BFD function, bfd_link_hide_symbol,
to hide symbols defined by HIDDEN and PROVIDE_HIDDEN assignments.

bfd

	PR ld/23201
	* aout-target.h (MY_bfd_link_hide_symbol): New.
	* aout-tic30.c (MY_bfd_link_hide_symbol): Likewise.
	* binary.c (binary_bfd_link_hide_symbol): Likewise.
	* coff-alpha.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise.
	* coff-mips.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise.
	* coff-rs6000.c (_bfd_xcoff_bfd_link_hide_symbol): Likewise.
	* coffcode.h (coff_bfd_link_hide_symbol): Likewise.
	* elf-bfd.h (_bfd_elf_link_hide_symbol): Likewise.
	* elfxx-target.h (bfd_elfNN_bfd_link_hide_symbol): Likewise.
	* i386msdos.c (msdos_bfd_link_hide_symbol): Likewise.
	* ihex.c (ihex_bfd_link_hide_symbol): Likewise.
	* libbfd-in.h (_bfd_nolink_bfd_link_hide_symbol): Likewise.
	* linker.c (_bfd_generic_link_hide_symbol): Likewise.
	(bfd_link_hide_symbol): Likewise.
	* mach-o-target.c (bfd_mach_o_bfd_link_hide_symbol): Likewise.
	* mmo.c (mmo_bfd_link_hide_symbol): Likewise.
	* pef.c (bfd_pef_bfd_link_hide_symbol): Likewise.
	* plugin.c (bfd_plugin_bfd_link_hide_symbol): Likewise.
	* ppcboot.c (ppcboot_bfd_link_hide_symbol): Likewise.
	* som.c (som_bfd_link_hide_symbol): Likewise.
	* srec.c (srec_bfd_link_hide_symbol): Likewise.
	* tekhex.c (tekhex_bfd_link_hide_symbol): Likewise.
	* vms-alpha.c (vms_bfd_link_hide_symbol): Likewise.
	(alpha_vms_bfd_link_hide_symbol): Likewise.
	* xsym.c (bfd_sym_bfd_link_hide_symbol): Likewise.
	* coff64-rs6000.c (rs6000_xcoff64_vec): Add
	_bfd_generic_link_hide_symbol.
	(rs6000_xcoff64_aix_vec): Likewise.
	* elflink.c (bfd_elf_record_link_assignment): Don't make forced
	local symbol dynamic.
	(_bfd_elf_link_hide_symbol): New function.
	* elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't
	check root.ldscript_def.
	* targets.c (bfd_target): Add _bfd_link_hide_symbol.
	(BFD_JUMP_TABLE_LINK): Add NAME##_bfd_link_hide_symbol.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

ld/

	PR ld/23201
	* ldexp.c (exp_fold_tree_1): Call bfd_link_hide_symbol to hide
	a symbol.
	* testsuite/ld-elf/provide-hidden-dynabs.nd: Removed.
	* testsuite/ld-elf/provide-hidden-dynsec.nd: Likewise.
	* testsuite/ld-elf/provide-hidden.exp: Replace
	provide-hidden-dynsec.nd with provide-hidden-sec.nd and
	provide-hidden-dyn.nd.  Replace provide-hidden-dynabs.nd with
	provide-hidden-abs.nd and provide-hidden-dyn.nd.
	* testsuite/ld-i386/pr23189.d: Expect no dynamic relocation.
	* testsuite/ld-x86-64/pr23189.d: Likewise.
---
 bfd/aout-target.h                            |  3 +++
 bfd/aout-tic30.c                             |  3 +++
 bfd/bfd-in2.h                                | 12 +++++++++
 bfd/binary.c                                 |  1 +
 bfd/coff-alpha.c                             |  1 +
 bfd/coff-mips.c                              |  1 +
 bfd/coff-rs6000.c                            |  1 +
 bfd/coff64-rs6000.c                          |  2 ++
 bfd/coffcode.h                               |  4 +++
 bfd/elf-bfd.h                                |  2 ++
 bfd/elflink.c                                | 21 ++++++++++++++++
 bfd/elfxx-target.h                           |  4 +++
 bfd/elfxx-x86.c                              | 10 +++-----
 bfd/i386msdos.c                              |  1 +
 bfd/ihex.c                                   |  1 +
 bfd/libbfd-in.h                              |  2 ++
 bfd/libbfd.h                                 |  2 ++
 bfd/linker.c                                 | 26 ++++++++++++++++++++
 bfd/mach-o-target.c                          |  1 +
 bfd/mmo.c                                    |  1 +
 bfd/pef.c                                    |  1 +
 bfd/plugin.c                                 |  1 +
 bfd/ppcboot.c                                |  1 +
 bfd/som.c                                    |  1 +
 bfd/srec.c                                   |  1 +
 bfd/targets.c                                |  5 ++++
 bfd/tekhex.c                                 |  1 +
 bfd/vms-alpha.c                              |  2 ++
 bfd/xsym.c                                   |  1 +
 ld/ldexp.c                                   |  3 +++
 ld/testsuite/ld-elf/provide-hidden-dynabs.nd |  8 ------
 ld/testsuite/ld-elf/provide-hidden-dynsec.nd |  8 ------
 ld/testsuite/ld-elf/provide-hidden.exp       |  8 ++++--
 ld/testsuite/ld-i386/pr23189.d               |  4 +--
 ld/testsuite/ld-x86-64/pr23189.d             |  4 +--
 35 files changed, 118 insertions(+), 30 deletions(-)
 delete mode 100644 ld/testsuite/ld-elf/provide-hidden-dynabs.nd
 delete mode 100644 ld/testsuite/ld-elf/provide-hidden-dynsec.nd

diff --git a/bfd/aout-target.h b/bfd/aout-target.h
index f245b1e885..9123afcef6 100644
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -512,6 +512,9 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 #ifndef MY_bfd_define_common_symbol
 #define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
 #endif
+#ifndef MY_bfd_link_hide_symbol
+#define MY_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
+#endif
 #ifndef MY_bfd_define_start_stop
 #define MY_bfd_define_start_stop bfd_generic_define_start_stop
 #endif
diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c
index 31248ecd91..ddeaaaa98f 100644
--- a/bfd/aout-tic30.c
+++ b/bfd/aout-tic30.c
@@ -967,6 +967,9 @@ tic30_aout_set_arch_mach (bfd *abfd,
 #ifndef MY_bfd_define_common_symbol
 #define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
 #endif
+#ifndef MY_bfd_link_hide_symbol
+#define MY_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
+#endif
 #ifndef MY_bfd_define_start_stop
 #define MY_bfd_define_start_stop bfd_generic_define_start_stop
 #endif
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 9d11dd0c39..62a2c249b4 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7685,6 +7685,7 @@ typedef struct bfd_target
   NAME##_bfd_discard_group, \
   NAME##_section_already_linked, \
   NAME##_bfd_define_common_symbol, \
+  NAME##_bfd_link_hide_symbol, \
   NAME##_bfd_define_start_stop
 
   int         (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
@@ -7751,6 +7752,10 @@ typedef struct bfd_target
   bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
                                             struct bfd_link_hash_entry *);
 
+  /* Hide a symbol.  */
+  void (*_bfd_link_hide_symbol) (bfd *, struct bfd_link_info *,
+                                 struct bfd_link_hash_entry *);
+
   /* Define a __start, __stop, .startof. or .sizeof. symbol.  */
   struct bfd_link_hash_entry *
               (*_bfd_define_start_stop) (struct bfd_link_info *, const char *,
@@ -7834,6 +7839,13 @@ bfd_boolean bfd_generic_define_common_symbol
 #define bfd_define_common_symbol(output_bfd, info, h) \
        BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h))
 
+void _bfd_generic_link_hide_symbol
+   (bfd *output_bfd, struct bfd_link_info *info,
+    struct bfd_link_hash_entry *h);
+
+#define bfd_link_hide_symbol(output_bfd, info, h) \
+       BFD_SEND (output_bfd, _bfd_link_hide_symbol, (output_bfd, info, h))
+
 struct bfd_link_hash_entry *bfd_generic_define_start_stop
    (struct bfd_link_info *info,
     const char *symbol, asection *sec);
diff --git a/bfd/binary.c b/bfd/binary.c
index 0713f5a496..c467b429f6 100644
--- a/bfd/binary.c
+++ b/bfd/binary.c
@@ -310,6 +310,7 @@ binary_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define binary_bfd_discard_group		   bfd_generic_discard_group
 #define binary_section_already_linked		  _bfd_generic_section_already_linked
 #define binary_bfd_define_common_symbol		   bfd_generic_define_common_symbol
+#define binary_bfd_link_hide_symbol		   _bfd_generic_link_hide_symbol
 #define binary_bfd_define_start_stop		   bfd_generic_define_start_stop
 #define binary_bfd_link_hash_table_create	  _bfd_generic_link_hash_table_create
 #define binary_bfd_link_just_syms		  _bfd_generic_link_just_syms
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index 0e39f317ed..699398f494 100644
--- a/bfd/coff-alpha.c
+++ b/bfd/coff-alpha.c
@@ -2394,6 +2394,7 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data =
 #define _bfd_ecoff_section_already_linked \
   _bfd_coff_section_already_linked
 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define _bfd_ecoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define _bfd_ecoff_bfd_define_start_stop    bfd_generic_define_start_stop
 #define _bfd_ecoff_bfd_link_check_relocs    _bfd_generic_link_check_relocs
 
diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c
index 3a0163a256..d83e10d4b7 100644
--- a/bfd/coff-mips.c
+++ b/bfd/coff-mips.c
@@ -1420,6 +1420,7 @@ static const struct ecoff_backend_data mips_ecoff_backend_data =
 #define _bfd_ecoff_section_already_linked \
   _bfd_coff_section_already_linked
 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define _bfd_ecoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define _bfd_ecoff_bfd_define_start_stop bfd_generic_define_start_stop
 #define _bfd_ecoff_set_reloc _bfd_generic_set_reloc
 
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index d8db1f3894..053ab18940 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -4045,6 +4045,7 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = {
 #define _bfd_xcoff_bfd_discard_group bfd_generic_discard_group
 #define _bfd_xcoff_section_already_linked _bfd_generic_section_already_linked
 #define _bfd_xcoff_bfd_define_common_symbol _bfd_xcoff_define_common_symbol
+#define _bfd_xcoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define _bfd_xcoff_bfd_define_start_stop    bfd_generic_define_start_stop
 #define _bfd_xcoff_bfd_link_check_relocs    _bfd_generic_link_check_relocs
 
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 78f14a09f4..2135001f19 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -2786,6 +2786,7 @@ const bfd_target rs6000_xcoff64_vec =
     bfd_generic_discard_group,
     _bfd_generic_section_already_linked,
     _bfd_xcoff_define_common_symbol,
+    _bfd_generic_link_hide_symbol,
     bfd_generic_define_start_stop,
 
     /* Dynamic */
@@ -3047,6 +3048,7 @@ const bfd_target rs6000_xcoff64_aix_vec =
     bfd_generic_discard_group,
     _bfd_generic_section_already_linked,
     _bfd_xcoff_define_common_symbol,
+    _bfd_generic_link_hide_symbol,
     bfd_generic_define_start_stop,
 
     /* Dynamic */
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 6ad991cf9d..2ca32059cb 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -5749,6 +5749,10 @@ static bfd_coff_backend_data bigobj_swap_table =
 #define coff_bfd_define_common_symbol	    bfd_generic_define_common_symbol
 #endif
 
+#ifndef coff_bfd_link_hide_symbol
+#define coff_bfd_link_hide_symbol	    _bfd_generic_link_hide_symbol
+#endif
+
 #ifndef coff_bfd_define_start_stop
 #define coff_bfd_define_start_stop	    bfd_generic_define_start_stop
 #endif
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 7b746900ba..e051c9c089 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2086,6 +2086,8 @@ extern void _bfd_elf_link_hash_copy_indirect
    struct elf_link_hash_entry *);
 extern void _bfd_elf_link_hash_hide_symbol
   (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
+extern void _bfd_elf_link_hide_symbol
+  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
 extern bfd_boolean _bfd_elf_link_hash_fixup_symbol
   (struct bfd_link_info *, struct elf_link_hash_entry *);
 extern bfd_boolean _bfd_elf_link_hash_table_init
diff --git a/bfd/elflink.c b/bfd/elflink.c
index ce3765e45b..0383e4e370 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -720,6 +720,7 @@ bfd_elf_record_link_assignment (bfd *output_bfd,
        || h->ref_dynamic
        || bfd_link_dll (info)
        || elf_hash_table (info)->is_relocatable_executable)
+      && !h->forced_local
       && h->dynindx == -1)
     {
       if (! bfd_elf_link_record_dynamic_symbol (info, h))
@@ -7429,6 +7430,26 @@ _bfd_elf_link_hash_hide_symbol (struct bfd_link_info *info,
     }
 }
 
+/* Hide a symbol. */
+
+void
+_bfd_elf_link_hide_symbol (bfd *output_bfd,
+			   struct bfd_link_info *info,
+			   struct bfd_link_hash_entry *h)
+{
+  if (is_elf_hash_table (info->hash))
+    {
+      const struct elf_backend_data *bed
+	= get_elf_backend_data (output_bfd);
+      struct elf_link_hash_entry *eh
+	= (struct elf_link_hash_entry *) h;
+      bed->elf_backend_hide_symbol (info, eh, TRUE);
+      eh->def_dynamic = 0;
+      eh->ref_dynamic = 0;
+      eh->dynamic_def = 0;
+    }
+}
+
 /* Initialize an ELF linker hash table.  *TABLE has been zeroed by our
    caller.  */
 
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 89efed3a5e..a86ea587a2 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -205,6 +205,10 @@
 #define bfd_elfNN_bfd_define_common_symbol bfd_generic_define_common_symbol
 #endif
 
+#ifndef bfd_elfNN_bfd_link_hide_symbol
+#define bfd_elfNN_bfd_link_hide_symbol _bfd_elf_link_hide_symbol
+#endif
+
 #ifndef bfd_elfNN_bfd_lookup_section_flags
 #define bfd_elfNN_bfd_lookup_section_flags bfd_elf_lookup_section_flags
 #endif
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index 29d92d288a..710417f90c 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -2047,12 +2047,10 @@ _bfd_x86_elf_link_symbol_references_local (struct bfd_link_info *info,
       return TRUE;
     }
 
-  /* Symbols created by HIDDEN and PROVIDE_HIDDEN assignments in linker
-     script aren't forced local here yet.  bfd_hide_sym_by_version
-     can't be used to check if a versioned symbol is hidden.  It has to
-     be syncd with _bfd_elf_link_assign_sym_version to get the correct
-     answer.  */
-  if (!h->root.ldscript_def && h->versioned == unversioned)
+  /* bfd_hide_sym_by_version can't be used to check if a versioned symbol
+     is hidden.  It has to be syncd with _bfd_elf_link_assign_sym_version
+     to get the correct answer.  */
+  if (h->versioned == unversioned)
     eh->local_ref = 1;
 
   return FALSE;
diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c
index a47acf4953..77e9880ced 100644
--- a/bfd/i386msdos.c
+++ b/bfd/i386msdos.c
@@ -230,6 +230,7 @@ msdos_set_section_contents (bfd *abfd,
 #define msdos_section_already_linked \
   _bfd_generic_section_already_linked
 #define msdos_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define msdos_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define msdos_bfd_define_start_stop bfd_generic_define_start_stop
 #define msdos_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define msdos_bfd_link_add_symbols _bfd_generic_link_add_symbols
diff --git a/bfd/ihex.c b/bfd/ihex.c
index 096c19ce2e..80bcbe9f90 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -943,6 +943,7 @@ ihex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define ihex_bfd_discard_group			  bfd_generic_discard_group
 #define ihex_section_already_linked		  _bfd_generic_section_already_linked
 #define ihex_bfd_define_common_symbol		  bfd_generic_define_common_symbol
+#define ihex_bfd_link_hide_symbol		  _bfd_generic_link_hide_symbol
 #define ihex_bfd_define_start_stop		  bfd_generic_define_start_stop
 #define ihex_bfd_link_hash_table_create		  _bfd_generic_link_hash_table_create
 #define ihex_bfd_link_add_symbols		  _bfd_generic_link_add_symbols
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index bb3cf48f70..9796f2d67e 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -534,6 +534,8 @@ extern bfd_boolean _bfd_nolink_section_already_linked
 extern bfd_boolean _bfd_nolink_bfd_define_common_symbol
   (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *)
   ATTRIBUTE_HIDDEN;
+#define _bfd_nolink_bfd_link_hide_symbol \
+  _bfd_generic_link_hide_symbol
 extern struct bfd_link_hash_entry *_bfd_nolink_bfd_define_start_stop
   (struct bfd_link_info *, const char *, asection *) ATTRIBUTE_HIDDEN;
 #define _bfd_nolink_bfd_link_check_relocs \
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index b810c40c40..f357e0e4ab 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -539,6 +539,8 @@ extern bfd_boolean _bfd_nolink_section_already_linked
 extern bfd_boolean _bfd_nolink_bfd_define_common_symbol
   (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *)
   ATTRIBUTE_HIDDEN;
+#define _bfd_nolink_bfd_link_hide_symbol \
+  _bfd_generic_link_hide_symbol
 extern struct bfd_link_hash_entry *_bfd_nolink_bfd_define_start_stop
   (struct bfd_link_info *, const char *, asection *) ATTRIBUTE_HIDDEN;
 #define _bfd_nolink_bfd_link_check_relocs \
diff --git a/bfd/linker.c b/bfd/linker.c
index 3019919a91..6b4c8e57e1 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -3110,6 +3110,32 @@ bfd_generic_define_common_symbol (bfd *output_bfd,
   return TRUE;
 }
 
+/*
+FUNCTION
+	_bfd_generic_link_hide_symbol
+
+SYNOPSIS
+	void _bfd_generic_link_hide_symbol
+	  (bfd *output_bfd, struct bfd_link_info *info,
+	   struct bfd_link_hash_entry *h);
+
+DESCRIPTION
+	Hide symbol @var{h}.
+	This is an internal function.  It should not be called from
+	outside the BFD library.
+
+.#define bfd_link_hide_symbol(output_bfd, info, h) \
+.	BFD_SEND (output_bfd, _bfd_link_hide_symbol, (output_bfd, info, h))
+.
+*/
+
+void
+_bfd_generic_link_hide_symbol (bfd *output_bfd ATTRIBUTE_UNUSED,
+			       struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			       struct bfd_link_hash_entry *h ATTRIBUTE_UNUSED)
+{
+}
+
 /*
 FUNCTION
 	bfd_generic_define_start_stop
diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
index 8859b23907..9f3b487b8d 100644
--- a/bfd/mach-o-target.c
+++ b/bfd/mach-o-target.c
@@ -55,6 +55,7 @@
 #define bfd_mach_o_bfd_discard_group		      bfd_generic_discard_group
 #define bfd_mach_o_section_already_linked	      _bfd_generic_section_already_linked
 #define bfd_mach_o_bfd_define_common_symbol	      bfd_generic_define_common_symbol
+#define bfd_mach_o_bfd_link_hide_symbol		      _bfd_generic_link_hide_symbol
 #define bfd_mach_o_bfd_define_start_stop	      bfd_generic_define_start_stop
 #define bfd_mach_o_bfd_copy_private_bfd_data	      _bfd_generic_bfd_copy_private_bfd_data
 #define bfd_mach_o_core_file_matches_executable_p     generic_core_file_matches_executable_p
diff --git a/bfd/mmo.c b/bfd/mmo.c
index 4b969c2c03..6a3e255803 100644
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -3318,6 +3318,7 @@ mmo_write_object_contents (bfd *abfd)
 #define mmo_section_already_linked \
   _bfd_generic_section_already_linked
 #define mmo_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define mmo_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define mmo_bfd_define_start_stop bfd_generic_define_start_stop
 
 /* We want to copy time of creation, otherwise we'd use
diff --git a/bfd/pef.c b/bfd/pef.c
index a55ca0693a..5746b96b43 100644
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -59,6 +59,7 @@
 #define bfd_pef_bfd_discard_group		    bfd_generic_discard_group
 #define bfd_pef_section_already_linked		    _bfd_generic_section_already_linked
 #define bfd_pef_bfd_define_common_symbol	    bfd_generic_define_common_symbol
+#define bfd_pef_bfd_link_hide_symbol		    _bfd_generic_link_hide_symbol
 #define bfd_pef_bfd_define_start_stop		    bfd_generic_define_start_stop
 #define bfd_pef_bfd_link_hash_table_create	    _bfd_generic_link_hash_table_create
 #define bfd_pef_bfd_link_add_symbols		    _bfd_generic_link_add_symbols
diff --git a/bfd/plugin.c b/bfd/plugin.c
index a2c1bd5776..16a706a548 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -105,6 +105,7 @@ dlerror (void)
 #define bfd_plugin_bfd_discard_group		      bfd_generic_discard_group
 #define bfd_plugin_section_already_linked	      _bfd_generic_section_already_linked
 #define bfd_plugin_bfd_define_common_symbol	      bfd_generic_define_common_symbol
+#define bfd_plugin_bfd_link_hide_symbol		      _bfd_generic_link_hide_symbol
 #define bfd_plugin_bfd_define_start_stop	      bfd_generic_define_start_stop
 #define bfd_plugin_bfd_copy_link_hash_symbol_type     _bfd_generic_copy_link_hash_symbol_type
 #define bfd_plugin_bfd_link_check_relocs	      _bfd_generic_link_check_relocs
diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c
index bbb2cc77d4..0d92fd1c82 100644
--- a/bfd/ppcboot.c
+++ b/bfd/ppcboot.c
@@ -460,6 +460,7 @@ ppcboot_bfd_print_private_bfd_data (bfd *abfd, void * farg)
 #define ppcboot_section_already_linked \
   _bfd_generic_section_already_linked
 #define ppcboot_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define ppcboot_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define ppcboot_bfd_define_start_stop bfd_generic_define_start_stop
 #define ppcboot_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define ppcboot_bfd_link_add_symbols _bfd_generic_link_add_symbols
diff --git a/bfd/som.c b/bfd/som.c
index 6220df7eb8..d2bdc6f5c4 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -6759,6 +6759,7 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
 #define som_bfd_discard_group			bfd_generic_discard_group
 #define som_section_already_linked		_bfd_generic_section_already_linked
 #define som_bfd_define_common_symbol		bfd_generic_define_common_symbol
+#define som_bfd_link_hide_symbol		_bfd_generic_link_hide_symbol
 #define som_bfd_define_start_stop		bfd_generic_define_start_stop
 #define som_bfd_merge_private_bfd_data		_bfd_generic_bfd_merge_private_bfd_data
 #define som_bfd_copy_private_header_data	_bfd_generic_bfd_copy_private_header_data
diff --git a/bfd/srec.c b/bfd/srec.c
index 4996109ed1..66cc72fea8 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -1278,6 +1278,7 @@ srec_print_symbol (bfd *abfd,
 #define srec_bfd_discard_group			  bfd_generic_discard_group
 #define srec_section_already_linked		  _bfd_generic_section_already_linked
 #define srec_bfd_define_common_symbol		  bfd_generic_define_common_symbol
+#define srec_bfd_link_hide_symbol		  _bfd_generic_link_hide_symbol
 #define srec_bfd_define_start_stop		  bfd_generic_define_start_stop
 #define srec_bfd_link_hash_table_create		  _bfd_generic_link_hash_table_create
 #define srec_bfd_link_add_symbols		  _bfd_generic_link_add_symbols
diff --git a/bfd/targets.c b/bfd/targets.c
index 5a2a684bc8..531703d226 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -465,6 +465,7 @@ BFD_JUMP_TABLE macros.
 .  NAME##_bfd_discard_group, \
 .  NAME##_section_already_linked, \
 .  NAME##_bfd_define_common_symbol, \
+.  NAME##_bfd_link_hide_symbol, \
 .  NAME##_bfd_define_start_stop
 .
 .  int	       (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
@@ -531,6 +532,10 @@ BFD_JUMP_TABLE macros.
 .  bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
 .					     struct bfd_link_hash_entry *);
 .
+.  {* Hide a symbol.  *}
+.  void (*_bfd_link_hide_symbol) (bfd *, struct bfd_link_info *,
+.				  struct bfd_link_hash_entry *);
+.
 .  {* Define a __start, __stop, .startof. or .sizeof. symbol.  *}
 .  struct bfd_link_hash_entry *
 .	       (*_bfd_define_start_stop) (struct bfd_link_info *, const char *,
diff --git a/bfd/tekhex.c b/bfd/tekhex.c
index 6a00c9f773..893d06def6 100644
--- a/bfd/tekhex.c
+++ b/bfd/tekhex.c
@@ -981,6 +981,7 @@ tekhex_print_symbol (bfd *abfd,
 #define tekhex_bfd_discard_group		    bfd_generic_discard_group
 #define tekhex_section_already_linked		    _bfd_generic_section_already_linked
 #define tekhex_bfd_define_common_symbol		    bfd_generic_define_common_symbol
+#define tekhex_bfd_link_hide_symbol		    _bfd_generic_link_hide_symbol
 #define tekhex_bfd_define_start_stop		    bfd_generic_define_start_stop
 #define tekhex_bfd_link_hash_table_create	    _bfd_generic_link_hash_table_create
 #define tekhex_bfd_link_add_symbols		    _bfd_generic_link_add_symbols
diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c
index b52f580ad3..11817cfbec 100644
--- a/bfd/vms-alpha.c
+++ b/bfd/vms-alpha.c
@@ -9498,6 +9498,7 @@ bfd_vms_get_data (bfd *abfd)
 #define vms_bfd_discard_group		  bfd_generic_discard_group
 #define vms_section_already_linked	  _bfd_generic_section_already_linked
 #define vms_bfd_define_common_symbol	  bfd_generic_define_common_symbol
+#define vms_bfd_link_hide_symbol	  _bfd_generic_link_hide_symbol
 #define vms_bfd_define_start_stop         bfd_generic_define_start_stop
 #define vms_bfd_copy_private_header_data  _bfd_generic_bfd_copy_private_header_data
 
@@ -9545,6 +9546,7 @@ bfd_vms_get_data (bfd *abfd)
   _bfd_generic_section_already_linked
 
 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
 #define alpha_vms_bfd_copy_link_hash_symbol_type \
diff --git a/bfd/xsym.c b/bfd/xsym.c
index 8ea0e7e71f..56607f026f 100644
--- a/bfd/xsym.c
+++ b/bfd/xsym.c
@@ -51,6 +51,7 @@
 #define bfd_sym_bfd_discard_group		    bfd_generic_discard_group
 #define bfd_sym_section_already_linked		    _bfd_generic_section_already_linked
 #define bfd_sym_bfd_define_common_symbol	    bfd_generic_define_common_symbol
+#define bfd_sym_bfd_link_hide_symbol		    _bfd_generic_link_hide_symbol
 #define bfd_sym_bfd_define_start_stop		    bfd_generic_define_start_stop
 #define bfd_sym_bfd_link_hash_table_create	    _bfd_generic_link_hash_table_create
 #define bfd_sym_bfd_link_add_symbols		    _bfd_generic_link_add_symbols
diff --git a/ld/ldexp.c b/ld/ldexp.c
index f9dc362930..6fa251e79e 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -1200,6 +1200,9 @@ exp_fold_tree_1 (etree_type *tree)
 		  h->u.def.section = expld.result.section;
 		  h->linker_def = ! tree->assign.type.lineno;
 		  h->ldscript_def = 1;
+		  if (tree->assign.hidden)
+		    bfd_link_hide_symbol (link_info.output_bfd,
+					  &link_info, h);
 
 		  /* Copy the symbol type if this is an expression only
 		     referencing a single symbol.  (If the expression
diff --git a/ld/testsuite/ld-elf/provide-hidden-dynabs.nd b/ld/testsuite/ld-elf/provide-hidden-dynabs.nd
deleted file mode 100644
index 86e3adcdf9..0000000000
--- a/ld/testsuite/ld-elf/provide-hidden-dynabs.nd
+++ /dev/null
@@ -1,8 +0,0 @@
-Symbol table '\.dynsym' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +ABS foo
-#...
-Symbol table '\.symtab' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +ABS foo
-#pass
diff --git a/ld/testsuite/ld-elf/provide-hidden-dynsec.nd b/ld/testsuite/ld-elf/provide-hidden-dynsec.nd
deleted file mode 100644
index 716dfa1f71..0000000000
--- a/ld/testsuite/ld-elf/provide-hidden-dynsec.nd
+++ /dev/null
@@ -1,8 +0,0 @@
-Symbol table '\.dynsym' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ foo
-#...
-Symbol table '\.symtab' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ foo
-#pass
diff --git a/ld/testsuite/ld-elf/provide-hidden.exp b/ld/testsuite/ld-elf/provide-hidden.exp
index 1fc4e61a19..4b72134911 100644
--- a/ld/testsuite/ld-elf/provide-hidden.exp
+++ b/ld/testsuite/ld-elf/provide-hidden.exp
@@ -86,7 +86,9 @@ run_ld_link_tests [list \
 	"$LFLAGS -T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \
 	"" \
 	[list provide-hidden-3.s] \
-	[list "readelf -s provide-hidden-dynsec.nd"] \
+	[list \
+	    [list readelf -s provide-hidden-sec.nd] \
+	    [list readelf -s provide-hidden-dyn.nd]] \
 	"provide-hidden-4"] \
     [list \
 	"$testname 5" \
@@ -138,7 +140,9 @@ run_ld_link_tests [list \
 	"$LFLAGS -T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \
 	"" \
 	[list provide-hidden-3.s] \
-	[list "readelf -s provide-hidden-dynabs.nd"] \
+	[list \
+	    [list readelf -s provide-hidden-abs.nd] \
+	    [list readelf -s provide-hidden-dyn.nd]] \
 	"provide-hidden-10"] \
     [list \
 	"$testname 11" \
diff --git a/ld/testsuite/ld-i386/pr23189.d b/ld/testsuite/ld-i386/pr23189.d
index 9345b42bd0..d388830f61 100644
--- a/ld/testsuite/ld-i386/pr23189.d
+++ b/ld/testsuite/ld-i386/pr23189.d
@@ -2,6 +2,4 @@
 #ld: -shared -melf_i386 -T pr23189.t
 #readelf: -r --wide
 
-Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
- Offset     Info    Type                Sym. Value  Symbol's Name
-[0-9a-f]+ +[0-9a-f]+ +R_386_RELATIVE +
+There are no relocations in this file.
diff --git a/ld/testsuite/ld-x86-64/pr23189.d b/ld/testsuite/ld-x86-64/pr23189.d
index 7951c7acc3..6fc4b7ee2c 100644
--- a/ld/testsuite/ld-x86-64/pr23189.d
+++ b/ld/testsuite/ld-x86-64/pr23189.d
@@ -2,6 +2,4 @@
 #ld: -shared -melf_x86_64 -T pr23189.t
 #readelf: -r --wide
 
-Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
-    Offset             Info             Type               Symbol's Value  Symbol's Name \+ Addend
-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9a-f]+
+There are no relocations in this file.
Alan Modra May 22, 2018, 1:26 a.m. | #7
On Sun, May 20, 2018 at 09:02:24PM -0700, H.J. Lu wrote:
> On Sun, May 20, 2018 at 7:11 PM, Alan Modra <amodra@gmail.com> wrote:

> > FAIL: ld-i386/pr23194

> >

> > and a similar result for ld-x86-64/pr23194

> 

> I can't reproduce it on native x86-64 nor i686.


Hmm, the failures disappeared when testing with your latest patch.  I
suppose it might have been fixed by one of the other x86 patches that
have gone in recently.

> Here is the updated patch which avoids making forced local symbol

> dynamic.  There are no regressions on native x86-64 and i686 as

> well as for cross ppc-linux and ppc64-linux.


OK.  It still feels like a hack to me, but trying to run
record_link_assignment earlier will probably have its own set of
problems.

-- 
Alan Modra
Australia Development Lab, IBM
H.J. Lu May 22, 2018, 3:36 a.m. | #8
On Mon, May 21, 2018 at 6:26 PM, Alan Modra <amodra@gmail.com> wrote:
> On Sun, May 20, 2018 at 09:02:24PM -0700, H.J. Lu wrote:

>> On Sun, May 20, 2018 at 7:11 PM, Alan Modra <amodra@gmail.com> wrote:

>> > FAIL: ld-i386/pr23194

>> >

>> > and a similar result for ld-x86-64/pr23194

>>

>> I can't reproduce it on native x86-64 nor i686.

>

> Hmm, the failures disappeared when testing with your latest patch.  I

> suppose it might have been fixed by one of the other x86 patches that

> have gone in recently.

>

>> Here is the updated patch which avoids making forced local symbol

>> dynamic.  There are no regressions on native x86-64 and i686 as

>> well as for cross ppc-linux and ppc64-linux.

>

> OK.  It still feels like a hack to me, but trying to run

> record_link_assignment earlier will probably have its own set of

> problems.

>


I am checking in my patch together with this patch to adjust tic6x tests
for removing local symbol, __c6xabi_DSBT_BASE, defined by
PROVIDE_HIDDEN in linker script from dynamic symbol table.


-- 
H.J.
From b7cd4f836fb98a2d5f5f12ec5be77e38f9797bf0 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 21 May 2018 20:30:18 -0700
Subject: [PATCH] ld: Adjust tic6x tests

Adjust tic6x tests for removing local symbol, __c6xabi_DSBT_BASE, defined
by PROVIDE_HIDDEN in linker script from dynamic symbol table.

	PR ld/23201
	* testsuite/ld-tic6x/shlib-1.rd: Adjusted.
	* testsuite/ld-tic6x/shlib-1b.rd: Likewise.
	* testsuite/ld-tic6x/shlib-1r.rd: Likewise.
	* testsuite/ld-tic6x/shlib-1rb.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1b.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1r.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise.
	* testsuite/ld-tic6x/shlib-noindex.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1b.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1r.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1rb.rd: Likewise.
---
 ld/testsuite/ld-tic6x/shlib-1.rd        | 119 +++++++++++-----------
 ld/testsuite/ld-tic6x/shlib-1b.rd       | 119 +++++++++++-----------
 ld/testsuite/ld-tic6x/shlib-1r.rd       | 119 +++++++++++-----------
 ld/testsuite/ld-tic6x/shlib-1rb.rd      | 119 +++++++++++-----------
 ld/testsuite/ld-tic6x/shlib-app-1.rd    | 121 +++++++++++-----------
 ld/testsuite/ld-tic6x/shlib-app-1b.rd   | 121 +++++++++++-----------
 ld/testsuite/ld-tic6x/shlib-app-1r.rd   | 101 ++++++++++---------
 ld/testsuite/ld-tic6x/shlib-app-1rb.rd  | 101 ++++++++++---------
 ld/testsuite/ld-tic6x/shlib-noindex.rd  | 127 ++++++++++++------------
 ld/testsuite/ld-tic6x/static-app-1.rd   | 111 ++++++++++-----------
 ld/testsuite/ld-tic6x/static-app-1b.rd  | 111 ++++++++++-----------
 ld/testsuite/ld-tic6x/static-app-1r.rd  | 107 ++++++++++----------
 ld/testsuite/ld-tic6x/static-app-1rb.rd | 107 ++++++++++----------
 13 files changed, 735 insertions(+), 748 deletions(-)

diff --git a/ld/testsuite/ld-tic6x/shlib-1.rd b/ld/testsuite/ld-tic6x/shlib-1.rd
index 77ec3d739f..469bce9e34 100644
--- a/ld/testsuite/ld-tic6x/shlib-1.rd
+++ b/ld/testsuite/ld-tic6x/shlib-1.rd
@@ -3,12 +3,12 @@ There are 17 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 000048 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          00008048 001048 0000d0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          00008118 001118 000025 00   A  0   0  1
-  \[ 4\] \.rela\.got         RELA            00008140 001140 000024 0c  AI  2  10  4
-  \[ 5\] \.rela\.neardata    RELA            00008164 001164 000018 0c  AI  2  11  4
-  \[ 6\] \.dynamic          DYNAMIC         0000817c 00117c 0000a8 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000044 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008044 001044 0000c0 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          00008104 001104 000012 00   A  0   0  1
+  \[ 4\] \.rela\.got         RELA            00008118 001118 000024 0c  AI  2  10  4
+  \[ 5\] \.rela\.neardata    RELA            0000813c 00113c 000018 0c  AI  2  11  4
+  \[ 6\] \.dynamic          DYNAMIC         00008154 001154 0000a8 08  WA  3   0  4
   \[ 7\] \.rela\.plt         RELA            10000000 002000 000018 0c  AI  2  10  4
   \[ 8\] \.plt              PROGBITS        10000020 002020 000060 18  AX  0   0 32
   \[ 9\] \.text             PROGBITS        10000080 002080 000080 00  AX  0   0 32
@@ -16,9 +16,9 @@ Section Headers:
   \[11\] \.neardata         PROGBITS        10000128 002128 000008 00  WA  0   0  4
   \[12\] \.bss              NOBITS          10000130 002130 000004 00  WA  0   0  4
   \[13\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 002130 000019 00      0   0  1
-  \[14\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     15  [0-9]+  4
-  \[15\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[16\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 00007b 00      0   0  1
+  \[14\] \.symtab           SYMTAB          00000000 00214c 0001b0 10     15  21  4
+  \[15\] \.strtab           STRTAB          00000000 0022fc 00005c 00      0   0  1
+  \[16\] \.shstrtab         STRTAB          00000000 002358 00007b 00      0   0  1
 Key to Flags:
 #...
 
@@ -28,9 +28,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x00224 0x00224 RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x001fc 0x001fc RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x00130 0x00134 RWE 0x1000
-  DYNAMIC        0x00117c 0x0000817c 0x0000817c 0x000a8 0x000a8 RW  0x4
+  DYNAMIC        0x001154 0x00008154 0x00008154 0x000a8 0x000a8 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -40,12 +40,12 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x117c contains 16 entries:
+Dynamic section at offset 0x1154 contains 16 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x8118
- 0x00000006 \(SYMTAB\)                     0x8048
- 0x0000000a \(STRSZ\)                      37 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x8104
+ 0x00000006 \(SYMTAB\)                     0x8044
+ 0x0000000a \(STRSZ\)                      18 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x70000000 \(C6000_DSBT_BASE\)            0x10000100
  0x70000001 \(C6000_DSBT_SIZE\)            0x3
@@ -54,28 +54,28 @@ Dynamic section at offset 0x117c contains 16 entries:
  0x00000002 \(PLTRELSZ\)                   24 \(bytes\)
  0x00000014 \(PLTREL\)                     RELA
  0x00000017 \(JMPREL\)                     0x10000000
- 0x00000007 \(RELA\)                       0x8140
+ 0x00000007 \(RELA\)                       0x8118
  0x00000008 \(RELASZ\)                     84 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.got' at offset 0x1140 contains 3 entries:
+Relocation section '\.rela\.got' at offset 0x1118 contains 3 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 10000120  00000501 R_C6000_ABS32          10000130   \.bss \+ 0
-1000011c  00000701 R_C6000_ABS32          00000000   b \+ 0
-10000124  00000b01 R_C6000_ABS32          10000128   a \+ 0
+1000011c  00000601 R_C6000_ABS32          00000000   b \+ 0
+10000124  00000a01 R_C6000_ABS32          10000128   a \+ 0
 
-Relocation section '\.rela\.neardata' at offset 0x1164 contains 2 entries:
+Relocation section '\.rela\.neardata' at offset 0x113c contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-10000128  00000a01 R_C6000_ABS32          10000088   sub0 \+ 0
-1000012c  00000801 R_C6000_ABS32          00000000   g1 \+ 0
+10000128  00000901 R_C6000_ABS32          10000088   sub0 \+ 0
+1000012c  00000701 R_C6000_ABS32          00000000   g1 \+ 0
 
 Relocation section '\.rela\.plt' at offset 0x2000 contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-10000114  00000a1b R_C6000_JUMP_SLOT      10000088   sub0 \+ 0
-10000118  00000c1b R_C6000_JUMP_SLOT      100000c0   sub \+ 0
+10000114  0000091b R_C6000_JUMP_SLOT      10000088   sub0 \+ 0
+10000118  00000b1b R_C6000_JUMP_SLOT      100000c0   sub \+ 0
 
-Symbol table '\.dynsym' contains 13 entries:
+Symbol table '\.dynsym' contains 12 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000020     0 SECTION LOCAL  DEFAULT    8 
@@ -83,40 +83,39 @@ Symbol table '\.dynsym' contains 13 entries:
      3: 10000100     0 SECTION LOCAL  DEFAULT   10 
      4: 10000128     0 SECTION LOCAL  DEFAULT   11 
      5: 10000130     0 SECTION LOCAL  DEFAULT   12 
-     6: 10000100     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
-     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
-     8: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-     9: 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
-    10: 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
-    11: 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
-    12: 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
+     6: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
+     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+     8: 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
+     9: 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
+    10: 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
+    11: 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 27 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 00008048     0 SECTION LOCAL  DEFAULT    2 
-.* 00008118     0 SECTION LOCAL  DEFAULT    3 
-.* 00008140     0 SECTION LOCAL  DEFAULT    4 
-.* 00008164     0 SECTION LOCAL  DEFAULT    5 
-.* 0000817c     0 SECTION LOCAL  DEFAULT    6 
-.* 10000000     0 SECTION LOCAL  DEFAULT    7 
-.* 10000020     0 SECTION LOCAL  DEFAULT    8 
-.* 10000080     0 SECTION LOCAL  DEFAULT    9 
-.* 10000100     0 SECTION LOCAL  DEFAULT   10 
-.* 10000128     0 SECTION LOCAL  DEFAULT   11 
-.* 10000130     0 SECTION LOCAL  DEFAULT   12 
-.* 00000000     0 SECTION LOCAL  DEFAULT   13 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000080     0 FUNC    LOCAL  HIDDEN     9 sub1
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS 
-.* 0000817c     0 OBJECT  LOCAL  DEFAULT  ABS _DYNAMIC
-.* 10000130     4 OBJECT  LOCAL  DEFAULT   12 c
-.* 1000010c     0 OBJECT  LOCAL  DEFAULT  ABS _GLOBAL_OFFSET_TABLE_
-.* 10000100     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-.* 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
-.* 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
-.* 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
-.* 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008044     0 SECTION LOCAL  DEFAULT    2 
+     3: 00008104     0 SECTION LOCAL  DEFAULT    3 
+     4: 00008118     0 SECTION LOCAL  DEFAULT    4 
+     5: 0000813c     0 SECTION LOCAL  DEFAULT    5 
+     6: 00008154     0 SECTION LOCAL  DEFAULT    6 
+     7: 10000000     0 SECTION LOCAL  DEFAULT    7 
+     8: 10000020     0 SECTION LOCAL  DEFAULT    8 
+     9: 10000080     0 SECTION LOCAL  DEFAULT    9 
+    10: 10000100     0 SECTION LOCAL  DEFAULT   10 
+    11: 10000128     0 SECTION LOCAL  DEFAULT   11 
+    12: 10000130     0 SECTION LOCAL  DEFAULT   12 
+    13: 00000000     0 SECTION LOCAL  DEFAULT   13 
+    14: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-1\.o
+    15: 10000080     0 FUNC    LOCAL  HIDDEN     9 sub1
+    16: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    17: 00008154     0 OBJECT  LOCAL  DEFAULT  ABS _DYNAMIC
+    18: 10000130     4 OBJECT  LOCAL  DEFAULT   12 c
+    19: 1000010c     0 OBJECT  LOCAL  DEFAULT  ABS _GLOBAL_OFFSET_TABLE_
+    20: 10000100     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
+    21: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
+    22: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+    23: 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
+    24: 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
+    25: 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
+    26: 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
diff --git a/ld/testsuite/ld-tic6x/shlib-1b.rd b/ld/testsuite/ld-tic6x/shlib-1b.rd
index 77ec3d739f..469bce9e34 100644
--- a/ld/testsuite/ld-tic6x/shlib-1b.rd
+++ b/ld/testsuite/ld-tic6x/shlib-1b.rd
@@ -3,12 +3,12 @@ There are 17 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 000048 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          00008048 001048 0000d0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          00008118 001118 000025 00   A  0   0  1
-  \[ 4\] \.rela\.got         RELA            00008140 001140 000024 0c  AI  2  10  4
-  \[ 5\] \.rela\.neardata    RELA            00008164 001164 000018 0c  AI  2  11  4
-  \[ 6\] \.dynamic          DYNAMIC         0000817c 00117c 0000a8 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000044 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008044 001044 0000c0 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          00008104 001104 000012 00   A  0   0  1
+  \[ 4\] \.rela\.got         RELA            00008118 001118 000024 0c  AI  2  10  4
+  \[ 5\] \.rela\.neardata    RELA            0000813c 00113c 000018 0c  AI  2  11  4
+  \[ 6\] \.dynamic          DYNAMIC         00008154 001154 0000a8 08  WA  3   0  4
   \[ 7\] \.rela\.plt         RELA            10000000 002000 000018 0c  AI  2  10  4
   \[ 8\] \.plt              PROGBITS        10000020 002020 000060 18  AX  0   0 32
   \[ 9\] \.text             PROGBITS        10000080 002080 000080 00  AX  0   0 32
@@ -16,9 +16,9 @@ Section Headers:
   \[11\] \.neardata         PROGBITS        10000128 002128 000008 00  WA  0   0  4
   \[12\] \.bss              NOBITS          10000130 002130 000004 00  WA  0   0  4
   \[13\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 002130 000019 00      0   0  1
-  \[14\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     15  [0-9]+  4
-  \[15\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[16\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 00007b 00      0   0  1
+  \[14\] \.symtab           SYMTAB          00000000 00214c 0001b0 10     15  21  4
+  \[15\] \.strtab           STRTAB          00000000 0022fc 00005c 00      0   0  1
+  \[16\] \.shstrtab         STRTAB          00000000 002358 00007b 00      0   0  1
 Key to Flags:
 #...
 
@@ -28,9 +28,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x00224 0x00224 RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x001fc 0x001fc RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x00130 0x00134 RWE 0x1000
-  DYNAMIC        0x00117c 0x0000817c 0x0000817c 0x000a8 0x000a8 RW  0x4
+  DYNAMIC        0x001154 0x00008154 0x00008154 0x000a8 0x000a8 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -40,12 +40,12 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x117c contains 16 entries:
+Dynamic section at offset 0x1154 contains 16 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x8118
- 0x00000006 \(SYMTAB\)                     0x8048
- 0x0000000a \(STRSZ\)                      37 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x8104
+ 0x00000006 \(SYMTAB\)                     0x8044
+ 0x0000000a \(STRSZ\)                      18 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x70000000 \(C6000_DSBT_BASE\)            0x10000100
  0x70000001 \(C6000_DSBT_SIZE\)            0x3
@@ -54,28 +54,28 @@ Dynamic section at offset 0x117c contains 16 entries:
  0x00000002 \(PLTRELSZ\)                   24 \(bytes\)
  0x00000014 \(PLTREL\)                     RELA
  0x00000017 \(JMPREL\)                     0x10000000
- 0x00000007 \(RELA\)                       0x8140
+ 0x00000007 \(RELA\)                       0x8118
  0x00000008 \(RELASZ\)                     84 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.got' at offset 0x1140 contains 3 entries:
+Relocation section '\.rela\.got' at offset 0x1118 contains 3 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 10000120  00000501 R_C6000_ABS32          10000130   \.bss \+ 0
-1000011c  00000701 R_C6000_ABS32          00000000   b \+ 0
-10000124  00000b01 R_C6000_ABS32          10000128   a \+ 0
+1000011c  00000601 R_C6000_ABS32          00000000   b \+ 0
+10000124  00000a01 R_C6000_ABS32          10000128   a \+ 0
 
-Relocation section '\.rela\.neardata' at offset 0x1164 contains 2 entries:
+Relocation section '\.rela\.neardata' at offset 0x113c contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-10000128  00000a01 R_C6000_ABS32          10000088   sub0 \+ 0
-1000012c  00000801 R_C6000_ABS32          00000000   g1 \+ 0
+10000128  00000901 R_C6000_ABS32          10000088   sub0 \+ 0
+1000012c  00000701 R_C6000_ABS32          00000000   g1 \+ 0
 
 Relocation section '\.rela\.plt' at offset 0x2000 contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-10000114  00000a1b R_C6000_JUMP_SLOT      10000088   sub0 \+ 0
-10000118  00000c1b R_C6000_JUMP_SLOT      100000c0   sub \+ 0
+10000114  0000091b R_C6000_JUMP_SLOT      10000088   sub0 \+ 0
+10000118  00000b1b R_C6000_JUMP_SLOT      100000c0   sub \+ 0
 
-Symbol table '\.dynsym' contains 13 entries:
+Symbol table '\.dynsym' contains 12 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000020     0 SECTION LOCAL  DEFAULT    8 
@@ -83,40 +83,39 @@ Symbol table '\.dynsym' contains 13 entries:
      3: 10000100     0 SECTION LOCAL  DEFAULT   10 
      4: 10000128     0 SECTION LOCAL  DEFAULT   11 
      5: 10000130     0 SECTION LOCAL  DEFAULT   12 
-     6: 10000100     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
-     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
-     8: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-     9: 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
-    10: 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
-    11: 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
-    12: 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
+     6: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
+     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+     8: 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
+     9: 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
+    10: 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
+    11: 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 27 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 00008048     0 SECTION LOCAL  DEFAULT    2 
-.* 00008118     0 SECTION LOCAL  DEFAULT    3 
-.* 00008140     0 SECTION LOCAL  DEFAULT    4 
-.* 00008164     0 SECTION LOCAL  DEFAULT    5 
-.* 0000817c     0 SECTION LOCAL  DEFAULT    6 
-.* 10000000     0 SECTION LOCAL  DEFAULT    7 
-.* 10000020     0 SECTION LOCAL  DEFAULT    8 
-.* 10000080     0 SECTION LOCAL  DEFAULT    9 
-.* 10000100     0 SECTION LOCAL  DEFAULT   10 
-.* 10000128     0 SECTION LOCAL  DEFAULT   11 
-.* 10000130     0 SECTION LOCAL  DEFAULT   12 
-.* 00000000     0 SECTION LOCAL  DEFAULT   13 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000080     0 FUNC    LOCAL  HIDDEN     9 sub1
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS 
-.* 0000817c     0 OBJECT  LOCAL  DEFAULT  ABS _DYNAMIC
-.* 10000130     4 OBJECT  LOCAL  DEFAULT   12 c
-.* 1000010c     0 OBJECT  LOCAL  DEFAULT  ABS _GLOBAL_OFFSET_TABLE_
-.* 10000100     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-.* 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
-.* 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
-.* 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
-.* 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008044     0 SECTION LOCAL  DEFAULT    2 
+     3: 00008104     0 SECTION LOCAL  DEFAULT    3 
+     4: 00008118     0 SECTION LOCAL  DEFAULT    4 
+     5: 0000813c     0 SECTION LOCAL  DEFAULT    5 
+     6: 00008154     0 SECTION LOCAL  DEFAULT    6 
+     7: 10000000     0 SECTION LOCAL  DEFAULT    7 
+     8: 10000020     0 SECTION LOCAL  DEFAULT    8 
+     9: 10000080     0 SECTION LOCAL  DEFAULT    9 
+    10: 10000100     0 SECTION LOCAL  DEFAULT   10 
+    11: 10000128     0 SECTION LOCAL  DEFAULT   11 
+    12: 10000130     0 SECTION LOCAL  DEFAULT   12 
+    13: 00000000     0 SECTION LOCAL  DEFAULT   13 
+    14: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-1\.o
+    15: 10000080     0 FUNC    LOCAL  HIDDEN     9 sub1
+    16: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    17: 00008154     0 OBJECT  LOCAL  DEFAULT  ABS _DYNAMIC
+    18: 10000130     4 OBJECT  LOCAL  DEFAULT   12 c
+    19: 1000010c     0 OBJECT  LOCAL  DEFAULT  ABS _GLOBAL_OFFSET_TABLE_
+    20: 10000100     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
+    21: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
+    22: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+    23: 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
+    24: 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
+    25: 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
+    26: 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
diff --git a/ld/testsuite/ld-tic6x/shlib-1r.rd b/ld/testsuite/ld-tic6x/shlib-1r.rd
index 77ec3d739f..469bce9e34 100644
--- a/ld/testsuite/ld-tic6x/shlib-1r.rd
+++ b/ld/testsuite/ld-tic6x/shlib-1r.rd
@@ -3,12 +3,12 @@ There are 17 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 000048 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          00008048 001048 0000d0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          00008118 001118 000025 00   A  0   0  1
-  \[ 4\] \.rela\.got         RELA            00008140 001140 000024 0c  AI  2  10  4
-  \[ 5\] \.rela\.neardata    RELA            00008164 001164 000018 0c  AI  2  11  4
-  \[ 6\] \.dynamic          DYNAMIC         0000817c 00117c 0000a8 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000044 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008044 001044 0000c0 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          00008104 001104 000012 00   A  0   0  1
+  \[ 4\] \.rela\.got         RELA            00008118 001118 000024 0c  AI  2  10  4
+  \[ 5\] \.rela\.neardata    RELA            0000813c 00113c 000018 0c  AI  2  11  4
+  \[ 6\] \.dynamic          DYNAMIC         00008154 001154 0000a8 08  WA  3   0  4
   \[ 7\] \.rela\.plt         RELA            10000000 002000 000018 0c  AI  2  10  4
   \[ 8\] \.plt              PROGBITS        10000020 002020 000060 18  AX  0   0 32
   \[ 9\] \.text             PROGBITS        10000080 002080 000080 00  AX  0   0 32
@@ -16,9 +16,9 @@ Section Headers:
   \[11\] \.neardata         PROGBITS        10000128 002128 000008 00  WA  0   0  4
   \[12\] \.bss              NOBITS          10000130 002130 000004 00  WA  0   0  4
   \[13\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 002130 000019 00      0   0  1
-  \[14\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     15  [0-9]+  4
-  \[15\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[16\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 00007b 00      0   0  1
+  \[14\] \.symtab           SYMTAB          00000000 00214c 0001b0 10     15  21  4
+  \[15\] \.strtab           STRTAB          00000000 0022fc 00005c 00      0   0  1
+  \[16\] \.shstrtab         STRTAB          00000000 002358 00007b 00      0   0  1
 Key to Flags:
 #...
 
@@ -28,9 +28,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x00224 0x00224 RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x001fc 0x001fc RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x00130 0x00134 RWE 0x1000
-  DYNAMIC        0x00117c 0x0000817c 0x0000817c 0x000a8 0x000a8 RW  0x4
+  DYNAMIC        0x001154 0x00008154 0x00008154 0x000a8 0x000a8 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -40,12 +40,12 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x117c contains 16 entries:
+Dynamic section at offset 0x1154 contains 16 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x8118
- 0x00000006 \(SYMTAB\)                     0x8048
- 0x0000000a \(STRSZ\)                      37 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x8104
+ 0x00000006 \(SYMTAB\)                     0x8044
+ 0x0000000a \(STRSZ\)                      18 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x70000000 \(C6000_DSBT_BASE\)            0x10000100
  0x70000001 \(C6000_DSBT_SIZE\)            0x3
@@ -54,28 +54,28 @@ Dynamic section at offset 0x117c contains 16 entries:
  0x00000002 \(PLTRELSZ\)                   24 \(bytes\)
  0x00000014 \(PLTREL\)                     RELA
  0x00000017 \(JMPREL\)                     0x10000000
- 0x00000007 \(RELA\)                       0x8140
+ 0x00000007 \(RELA\)                       0x8118
  0x00000008 \(RELASZ\)                     84 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.got' at offset 0x1140 contains 3 entries:
+Relocation section '\.rela\.got' at offset 0x1118 contains 3 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 10000120  00000501 R_C6000_ABS32          10000130   \.bss \+ 0
-1000011c  00000701 R_C6000_ABS32          00000000   b \+ 0
-10000124  00000b01 R_C6000_ABS32          10000128   a \+ 0
+1000011c  00000601 R_C6000_ABS32          00000000   b \+ 0
+10000124  00000a01 R_C6000_ABS32          10000128   a \+ 0
 
-Relocation section '\.rela\.neardata' at offset 0x1164 contains 2 entries:
+Relocation section '\.rela\.neardata' at offset 0x113c contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-10000128  00000a01 R_C6000_ABS32          10000088   sub0 \+ 0
-1000012c  00000801 R_C6000_ABS32          00000000   g1 \+ 0
+10000128  00000901 R_C6000_ABS32          10000088   sub0 \+ 0
+1000012c  00000701 R_C6000_ABS32          00000000   g1 \+ 0
 
 Relocation section '\.rela\.plt' at offset 0x2000 contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-10000114  00000a1b R_C6000_JUMP_SLOT      10000088   sub0 \+ 0
-10000118  00000c1b R_C6000_JUMP_SLOT      100000c0   sub \+ 0
+10000114  0000091b R_C6000_JUMP_SLOT      10000088   sub0 \+ 0
+10000118  00000b1b R_C6000_JUMP_SLOT      100000c0   sub \+ 0
 
-Symbol table '\.dynsym' contains 13 entries:
+Symbol table '\.dynsym' contains 12 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000020     0 SECTION LOCAL  DEFAULT    8 
@@ -83,40 +83,39 @@ Symbol table '\.dynsym' contains 13 entries:
      3: 10000100     0 SECTION LOCAL  DEFAULT   10 
      4: 10000128     0 SECTION LOCAL  DEFAULT   11 
      5: 10000130     0 SECTION LOCAL  DEFAULT   12 
-     6: 10000100     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
-     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
-     8: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-     9: 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
-    10: 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
-    11: 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
-    12: 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
+     6: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
+     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+     8: 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
+     9: 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
+    10: 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
+    11: 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 27 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 00008048     0 SECTION LOCAL  DEFAULT    2 
-.* 00008118     0 SECTION LOCAL  DEFAULT    3 
-.* 00008140     0 SECTION LOCAL  DEFAULT    4 
-.* 00008164     0 SECTION LOCAL  DEFAULT    5 
-.* 0000817c     0 SECTION LOCAL  DEFAULT    6 
-.* 10000000     0 SECTION LOCAL  DEFAULT    7 
-.* 10000020     0 SECTION LOCAL  DEFAULT    8 
-.* 10000080     0 SECTION LOCAL  DEFAULT    9 
-.* 10000100     0 SECTION LOCAL  DEFAULT   10 
-.* 10000128     0 SECTION LOCAL  DEFAULT   11 
-.* 10000130     0 SECTION LOCAL  DEFAULT   12 
-.* 00000000     0 SECTION LOCAL  DEFAULT   13 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000080     0 FUNC    LOCAL  HIDDEN     9 sub1
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS 
-.* 0000817c     0 OBJECT  LOCAL  DEFAULT  ABS _DYNAMIC
-.* 10000130     4 OBJECT  LOCAL  DEFAULT   12 c
-.* 1000010c     0 OBJECT  LOCAL  DEFAULT  ABS _GLOBAL_OFFSET_TABLE_
-.* 10000100     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-.* 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
-.* 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
-.* 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
-.* 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008044     0 SECTION LOCAL  DEFAULT    2 
+     3: 00008104     0 SECTION LOCAL  DEFAULT    3 
+     4: 00008118     0 SECTION LOCAL  DEFAULT    4 
+     5: 0000813c     0 SECTION LOCAL  DEFAULT    5 
+     6: 00008154     0 SECTION LOCAL  DEFAULT    6 
+     7: 10000000     0 SECTION LOCAL  DEFAULT    7 
+     8: 10000020     0 SECTION LOCAL  DEFAULT    8 
+     9: 10000080     0 SECTION LOCAL  DEFAULT    9 
+    10: 10000100     0 SECTION LOCAL  DEFAULT   10 
+    11: 10000128     0 SECTION LOCAL  DEFAULT   11 
+    12: 10000130     0 SECTION LOCAL  DEFAULT   12 
+    13: 00000000     0 SECTION LOCAL  DEFAULT   13 
+    14: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-1\.o
+    15: 10000080     0 FUNC    LOCAL  HIDDEN     9 sub1
+    16: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    17: 00008154     0 OBJECT  LOCAL  DEFAULT  ABS _DYNAMIC
+    18: 10000130     4 OBJECT  LOCAL  DEFAULT   12 c
+    19: 1000010c     0 OBJECT  LOCAL  DEFAULT  ABS _GLOBAL_OFFSET_TABLE_
+    20: 10000100     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
+    21: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
+    22: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+    23: 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
+    24: 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
+    25: 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
+    26: 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
diff --git a/ld/testsuite/ld-tic6x/shlib-1rb.rd b/ld/testsuite/ld-tic6x/shlib-1rb.rd
index 77ec3d739f..469bce9e34 100644
--- a/ld/testsuite/ld-tic6x/shlib-1rb.rd
+++ b/ld/testsuite/ld-tic6x/shlib-1rb.rd
@@ -3,12 +3,12 @@ There are 17 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 000048 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          00008048 001048 0000d0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          00008118 001118 000025 00   A  0   0  1
-  \[ 4\] \.rela\.got         RELA            00008140 001140 000024 0c  AI  2  10  4
-  \[ 5\] \.rela\.neardata    RELA            00008164 001164 000018 0c  AI  2  11  4
-  \[ 6\] \.dynamic          DYNAMIC         0000817c 00117c 0000a8 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000044 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008044 001044 0000c0 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          00008104 001104 000012 00   A  0   0  1
+  \[ 4\] \.rela\.got         RELA            00008118 001118 000024 0c  AI  2  10  4
+  \[ 5\] \.rela\.neardata    RELA            0000813c 00113c 000018 0c  AI  2  11  4
+  \[ 6\] \.dynamic          DYNAMIC         00008154 001154 0000a8 08  WA  3   0  4
   \[ 7\] \.rela\.plt         RELA            10000000 002000 000018 0c  AI  2  10  4
   \[ 8\] \.plt              PROGBITS        10000020 002020 000060 18  AX  0   0 32
   \[ 9\] \.text             PROGBITS        10000080 002080 000080 00  AX  0   0 32
@@ -16,9 +16,9 @@ Section Headers:
   \[11\] \.neardata         PROGBITS        10000128 002128 000008 00  WA  0   0  4
   \[12\] \.bss              NOBITS          10000130 002130 000004 00  WA  0   0  4
   \[13\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 002130 000019 00      0   0  1
-  \[14\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     15  [0-9]+  4
-  \[15\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[16\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 00007b 00      0   0  1
+  \[14\] \.symtab           SYMTAB          00000000 00214c 0001b0 10     15  21  4
+  \[15\] \.strtab           STRTAB          00000000 0022fc 00005c 00      0   0  1
+  \[16\] \.shstrtab         STRTAB          00000000 002358 00007b 00      0   0  1
 Key to Flags:
 #...
 
@@ -28,9 +28,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x00224 0x00224 RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x001fc 0x001fc RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x00130 0x00134 RWE 0x1000
-  DYNAMIC        0x00117c 0x0000817c 0x0000817c 0x000a8 0x000a8 RW  0x4
+  DYNAMIC        0x001154 0x00008154 0x00008154 0x000a8 0x000a8 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -40,12 +40,12 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x117c contains 16 entries:
+Dynamic section at offset 0x1154 contains 16 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x8118
- 0x00000006 \(SYMTAB\)                     0x8048
- 0x0000000a \(STRSZ\)                      37 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x8104
+ 0x00000006 \(SYMTAB\)                     0x8044
+ 0x0000000a \(STRSZ\)                      18 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x70000000 \(C6000_DSBT_BASE\)            0x10000100
  0x70000001 \(C6000_DSBT_SIZE\)            0x3
@@ -54,28 +54,28 @@ Dynamic section at offset 0x117c contains 16 entries:
  0x00000002 \(PLTRELSZ\)                   24 \(bytes\)
  0x00000014 \(PLTREL\)                     RELA
  0x00000017 \(JMPREL\)                     0x10000000
- 0x00000007 \(RELA\)                       0x8140
+ 0x00000007 \(RELA\)                       0x8118
  0x00000008 \(RELASZ\)                     84 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.got' at offset 0x1140 contains 3 entries:
+Relocation section '\.rela\.got' at offset 0x1118 contains 3 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 10000120  00000501 R_C6000_ABS32          10000130   \.bss \+ 0
-1000011c  00000701 R_C6000_ABS32          00000000   b \+ 0
-10000124  00000b01 R_C6000_ABS32          10000128   a \+ 0
+1000011c  00000601 R_C6000_ABS32          00000000   b \+ 0
+10000124  00000a01 R_C6000_ABS32          10000128   a \+ 0
 
-Relocation section '\.rela\.neardata' at offset 0x1164 contains 2 entries:
+Relocation section '\.rela\.neardata' at offset 0x113c contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-10000128  00000a01 R_C6000_ABS32          10000088   sub0 \+ 0
-1000012c  00000801 R_C6000_ABS32          00000000   g1 \+ 0
+10000128  00000901 R_C6000_ABS32          10000088   sub0 \+ 0
+1000012c  00000701 R_C6000_ABS32          00000000   g1 \+ 0
 
 Relocation section '\.rela\.plt' at offset 0x2000 contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-10000114  00000a1b R_C6000_JUMP_SLOT      10000088   sub0 \+ 0
-10000118  00000c1b R_C6000_JUMP_SLOT      100000c0   sub \+ 0
+10000114  0000091b R_C6000_JUMP_SLOT      10000088   sub0 \+ 0
+10000118  00000b1b R_C6000_JUMP_SLOT      100000c0   sub \+ 0
 
-Symbol table '\.dynsym' contains 13 entries:
+Symbol table '\.dynsym' contains 12 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000020     0 SECTION LOCAL  DEFAULT    8 
@@ -83,40 +83,39 @@ Symbol table '\.dynsym' contains 13 entries:
      3: 10000100     0 SECTION LOCAL  DEFAULT   10 
      4: 10000128     0 SECTION LOCAL  DEFAULT   11 
      5: 10000130     0 SECTION LOCAL  DEFAULT   12 
-     6: 10000100     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
-     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
-     8: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-     9: 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
-    10: 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
-    11: 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
-    12: 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
+     6: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
+     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+     8: 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
+     9: 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
+    10: 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
+    11: 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 27 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 00008048     0 SECTION LOCAL  DEFAULT    2 
-.* 00008118     0 SECTION LOCAL  DEFAULT    3 
-.* 00008140     0 SECTION LOCAL  DEFAULT    4 
-.* 00008164     0 SECTION LOCAL  DEFAULT    5 
-.* 0000817c     0 SECTION LOCAL  DEFAULT    6 
-.* 10000000     0 SECTION LOCAL  DEFAULT    7 
-.* 10000020     0 SECTION LOCAL  DEFAULT    8 
-.* 10000080     0 SECTION LOCAL  DEFAULT    9 
-.* 10000100     0 SECTION LOCAL  DEFAULT   10 
-.* 10000128     0 SECTION LOCAL  DEFAULT   11 
-.* 10000130     0 SECTION LOCAL  DEFAULT   12 
-.* 00000000     0 SECTION LOCAL  DEFAULT   13 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000080     0 FUNC    LOCAL  HIDDEN     9 sub1
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS 
-.* 0000817c     0 OBJECT  LOCAL  DEFAULT  ABS _DYNAMIC
-.* 10000130     4 OBJECT  LOCAL  DEFAULT   12 c
-.* 1000010c     0 OBJECT  LOCAL  DEFAULT  ABS _GLOBAL_OFFSET_TABLE_
-.* 10000100     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-.* 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
-.* 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
-.* 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
-.* 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008044     0 SECTION LOCAL  DEFAULT    2 
+     3: 00008104     0 SECTION LOCAL  DEFAULT    3 
+     4: 00008118     0 SECTION LOCAL  DEFAULT    4 
+     5: 0000813c     0 SECTION LOCAL  DEFAULT    5 
+     6: 00008154     0 SECTION LOCAL  DEFAULT    6 
+     7: 10000000     0 SECTION LOCAL  DEFAULT    7 
+     8: 10000020     0 SECTION LOCAL  DEFAULT    8 
+     9: 10000080     0 SECTION LOCAL  DEFAULT    9 
+    10: 10000100     0 SECTION LOCAL  DEFAULT   10 
+    11: 10000128     0 SECTION LOCAL  DEFAULT   11 
+    12: 10000130     0 SECTION LOCAL  DEFAULT   12 
+    13: 00000000     0 SECTION LOCAL  DEFAULT   13 
+    14: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-1\.o
+    15: 10000080     0 FUNC    LOCAL  HIDDEN     9 sub1
+    16: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    17: 00008154     0 OBJECT  LOCAL  DEFAULT  ABS _DYNAMIC
+    18: 10000130     4 OBJECT  LOCAL  DEFAULT   12 c
+    19: 1000010c     0 OBJECT  LOCAL  DEFAULT  ABS _GLOBAL_OFFSET_TABLE_
+    20: 10000100     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
+    21: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
+    22: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+    23: 1000012c     4 OBJECT  GLOBAL DEFAULT   11 g2
+    24: 10000088    52 FUNC    GLOBAL DEFAULT    9 sub0
+    25: 10000128     4 OBJECT  GLOBAL DEFAULT   11 a
+    26: 100000c0    52 FUNC    GLOBAL DEFAULT    9 sub
diff --git a/ld/testsuite/ld-tic6x/shlib-app-1.rd b/ld/testsuite/ld-tic6x/shlib-app-1.rd
index 30086ed0cf..ad181eb036 100644
--- a/ld/testsuite/ld-tic6x/shlib-app-1.rd
+++ b/ld/testsuite/ld-tic6x/shlib-app-1.rd
@@ -3,13 +3,13 @@ There are 18 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 000044 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          00008044 001044 0000c0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          00008104 001104 000035 00   A  0   0  1
-  \[ 4\] \.rela\.got         RELA            0000813c 00113c 000018 0c  AI  2  11  4
-  \[ 5\] \.rela\.neardata    RELA            00008154 001154 000018 0c  AI  2  12  4
-  \[ 6\] \.rela\.bss         RELA            0000816c 00116c 00000c 0c  AI  2  13  4
-  \[ 7\] \.dynamic          DYNAMIC         00008178 001178 0000b8 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000040 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008040 001040 0000b0 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          000080f0 0010f0 000022 00   A  0   0  1
+  \[ 4\] \.rela\.got         RELA            00008114 001114 000018 0c  AI  2  11  4
+  \[ 5\] \.rela\.neardata    RELA            0000812c 00112c 000018 0c  AI  2  12  4
+  \[ 6\] \.rela\.bss         RELA            00008144 001144 00000c 0c  AI  2  13  4
+  \[ 7\] \.dynamic          DYNAMIC         00008150 001150 0000b8 08  WA  3   0  4
   \[ 8\] \.rela\.plt         RELA            10000000 002000 00000c 0c  AI  2  11  4
   \[ 9\] \.plt              PROGBITS        10000020 002020 000040 18  AX  0   0 32
   \[10\] \.text             PROGBITS        10000060 002060 000040 00  AX  0   0 32
@@ -17,9 +17,9 @@ Section Headers:
   \[12\] \.neardata         PROGBITS        100000c0 0020c0 00000c 00  WA  0   0  4
   \[13\] \.bss              NOBITS          100000cc 0020cc 000004 00  WA  0   0  4
   \[14\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 0020cc 000019 00      0   0  1
-  \[15\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     16  [0-9]+  4
-  \[16\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[17\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 000080 00      0   0  1
+  \[15\] \.symtab           SYMTAB          00000000 0020e8 0001b0 10     16  22  4
+  \[16\] \.strtab           STRTAB          00000000 002298 00005e 00      0   0  1
+  \[17\] \.shstrtab         STRTAB          00000000 0022f6 000080 00      0   0  1
 Key to Flags:
 #...
 
@@ -29,9 +29,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x00230 0x00230 RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x00208 0x00208 RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x000cc 0x000d0 RWE 0x1000
-  DYNAMIC        0x001178 0x00008178 0x00008178 0x000b8 0x000b8 RW  0x4
+  DYNAMIC        0x001150 0x00008150 0x00008150 0x000b8 0x000b8 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -41,13 +41,13 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x1178 contains 18 entries:
+Dynamic section at offset 0x1150 contains 18 entries:
   Tag        Type                         Name/Value
  0x00000001 \(NEEDED\)                     Shared library: \[tmpdir/libtest\.so\]
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x8104
- 0x00000006 \(SYMTAB\)                     0x8044
- 0x0000000a \(STRSZ\)                      53 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x80f0
+ 0x00000006 \(SYMTAB\)                     0x8040
+ 0x0000000a \(STRSZ\)                      34 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x00000015 \(DEBUG\)                      0x0
  0x70000000 \(C6000_DSBT_BASE\)            0x100000a0
@@ -57,30 +57,30 @@ Dynamic section at offset 0x1178 contains 18 entries:
  0x00000002 \(PLTRELSZ\)                   12 \(bytes\)
  0x00000014 \(PLTREL\)                     RELA
  0x00000017 \(JMPREL\)                     0x10000000
- 0x00000007 \(RELA\)                       0x813c
+ 0x00000007 \(RELA\)                       0x8114
  0x00000008 \(RELASZ\)                     72 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.got' at offset 0x113c contains 2 entries:
+Relocation section '\.rela\.got' at offset 0x1114 contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000b8  00000701 R_C6000_ABS32          100000c0   b \+ 0
-100000bc  00000b01 R_C6000_ABS32          100000cc   a \+ 0
+100000b8  00000601 R_C6000_ABS32          100000c0   b \+ 0
+100000bc  00000a01 R_C6000_ABS32          100000cc   a \+ 0
 
-Relocation section '\.rela\.neardata' at offset 0x1154 contains 2 entries:
+Relocation section '\.rela\.neardata' at offset 0x112c contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000c4  00000801 R_C6000_ABS32          00000000   g1 \+ 0
-100000c8  00000901 R_C6000_ABS32          00000000   g2 \+ 0
+100000c4  00000701 R_C6000_ABS32          00000000   g1 \+ 0
+100000c8  00000801 R_C6000_ABS32          00000000   g2 \+ 0
 
-Relocation section '\.rela\.bss' at offset 0x116c contains 1 entry:
+Relocation section '\.rela\.bss' at offset 0x1144 contains 1 entry:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000cc  00000b1a R_C6000_COPY           100000cc   a \+ 0
+100000cc  00000a1a R_C6000_COPY           100000cc   a \+ 0
 
 Relocation section '\.rela\.plt' at offset 0x2000 contains 1 entry:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000b4  00000a1b R_C6000_JUMP_SLOT      00000000   sub0 \+ 0
+100000b4  0000091b R_C6000_JUMP_SLOT      00000000   sub0 \+ 0
 
-Symbol table '\.dynsym' contains 12 entries:
+Symbol table '\.dynsym' contains 11 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000020     0 SECTION LOCAL  DEFAULT    9 
@@ -88,39 +88,38 @@ Symbol table '\.dynsym' contains 12 entries:
      3: 100000a0     0 SECTION LOCAL  DEFAULT   11 
      4: 100000c0     0 SECTION LOCAL  DEFAULT   12 
      5: 100000cc     0 SECTION LOCAL  DEFAULT   13 
-     6: 100000a0     0 NOTYPE  LOCAL  DEFAULT   11 __c6xabi_DSBT_BASE
-     7: 100000c0     4 OBJECT  GLOBAL DEFAULT   12 b
-     8: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-     9: 00000000     0 OBJECT  WEAK   DEFAULT  UND g2
-    10: 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
-    11: 100000cc     4 OBJECT  GLOBAL DEFAULT   13 a
+     6: 100000c0     4 OBJECT  GLOBAL DEFAULT   12 b
+     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+     8: 00000000     0 OBJECT  WEAK   DEFAULT  UND g2
+     9: 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
+    10: 100000cc     4 OBJECT  GLOBAL DEFAULT   13 a
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 27 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 00008044     0 SECTION LOCAL  DEFAULT    2 
-.* 00008104     0 SECTION LOCAL  DEFAULT    3 
-.* 0000813c     0 SECTION LOCAL  DEFAULT    4 
-.* 00008154     0 SECTION LOCAL  DEFAULT    5 
-.* 0000816c     0 SECTION LOCAL  DEFAULT    6 
-.* 00008178     0 SECTION LOCAL  DEFAULT    7 
-.* 10000000     0 SECTION LOCAL  DEFAULT    8 
-.* 10000020     0 SECTION LOCAL  DEFAULT    9 
-.* 10000060     0 SECTION LOCAL  DEFAULT   10 
-.* 100000a0     0 SECTION LOCAL  DEFAULT   11 
-.* 100000c0     0 SECTION LOCAL  DEFAULT   12 
-.* 100000cc     0 SECTION LOCAL  DEFAULT   13 
-.* 00000000     0 SECTION LOCAL  DEFAULT   14 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000060     0 NOTYPE  LOCAL  DEFAULT   10 fish
-.* 100000c4     8 OBJECT  LOCAL  DEFAULT   12 w
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 00008178     0 OBJECT  LOCAL  DEFAULT    7 _DYNAMIC
-.* 100000ac     0 OBJECT  LOCAL  DEFAULT   11 _GLOBAL_OFFSET_TABLE_
-.* 100000a0     0 NOTYPE  LOCAL  DEFAULT   11 __c6xabi_DSBT_BASE
-.* 100000c0     4 OBJECT  GLOBAL DEFAULT   12 b
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-.* 00000000     0 OBJECT  WEAK   DEFAULT  UND g2
-.* 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
-.* 100000cc     4 OBJECT  GLOBAL DEFAULT   13 a
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008040     0 SECTION LOCAL  DEFAULT    2 
+     3: 000080f0     0 SECTION LOCAL  DEFAULT    3 
+     4: 00008114     0 SECTION LOCAL  DEFAULT    4 
+     5: 0000812c     0 SECTION LOCAL  DEFAULT    5 
+     6: 00008144     0 SECTION LOCAL  DEFAULT    6 
+     7: 00008150     0 SECTION LOCAL  DEFAULT    7 
+     8: 10000000     0 SECTION LOCAL  DEFAULT    8 
+     9: 10000020     0 SECTION LOCAL  DEFAULT    9 
+    10: 10000060     0 SECTION LOCAL  DEFAULT   10 
+    11: 100000a0     0 SECTION LOCAL  DEFAULT   11 
+    12: 100000c0     0 SECTION LOCAL  DEFAULT   12 
+    13: 100000cc     0 SECTION LOCAL  DEFAULT   13 
+    14: 00000000     0 SECTION LOCAL  DEFAULT   14 
+    15: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-app-1\.o
+    16: 10000060     0 NOTYPE  LOCAL  DEFAULT   10 fish
+    17: 100000c4     8 OBJECT  LOCAL  DEFAULT   12 w
+    18: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    19: 00008150     0 OBJECT  LOCAL  DEFAULT    7 _DYNAMIC
+    20: 100000ac     0 OBJECT  LOCAL  DEFAULT   11 _GLOBAL_OFFSET_TABLE_
+    21: 100000a0     0 NOTYPE  LOCAL  DEFAULT   11 __c6xabi_DSBT_BASE
+    22: 100000c0     4 OBJECT  GLOBAL DEFAULT   12 b
+    23: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+    24: 00000000     0 OBJECT  WEAK   DEFAULT  UND g2
+    25: 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
+    26: 100000cc     4 OBJECT  GLOBAL DEFAULT   13 a
diff --git a/ld/testsuite/ld-tic6x/shlib-app-1b.rd b/ld/testsuite/ld-tic6x/shlib-app-1b.rd
index 3833b884d3..6390a5da8e 100644
--- a/ld/testsuite/ld-tic6x/shlib-app-1b.rd
+++ b/ld/testsuite/ld-tic6x/shlib-app-1b.rd
@@ -3,13 +3,13 @@ There are 18 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 000044 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          00008044 001044 0000c0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          00008104 001104 000036 00   A  0   0  1
-  \[ 4\] \.rela\.got         RELA            0000813c 00113c 000018 0c  AI  2  11  4
-  \[ 5\] \.rela\.neardata    RELA            00008154 001154 000018 0c  AI  2  12  4
-  \[ 6\] \.rela\.bss         RELA            0000816c 00116c 00000c 0c  AI  2  13  4
-  \[ 7\] \.dynamic          DYNAMIC         00008178 001178 0000b8 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000040 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008040 001040 0000b0 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          000080f0 0010f0 000023 00   A  0   0  1
+  \[ 4\] \.rela\.got         RELA            00008114 001114 000018 0c  AI  2  11  4
+  \[ 5\] \.rela\.neardata    RELA            0000812c 00112c 000018 0c  AI  2  12  4
+  \[ 6\] \.rela\.bss         RELA            00008144 001144 00000c 0c  AI  2  13  4
+  \[ 7\] \.dynamic          DYNAMIC         00008150 001150 0000b8 08  WA  3   0  4
   \[ 8\] \.rela\.plt         RELA            10000000 002000 00000c 0c  AI  2  11  4
   \[ 9\] \.plt              PROGBITS        10000020 002020 000040 18  AX  0   0 32
   \[10\] \.text             PROGBITS        10000060 002060 000040 00  AX  0   0 32
@@ -17,9 +17,9 @@ Section Headers:
   \[12\] \.neardata         PROGBITS        100000c0 0020c0 00000c 00  WA  0   0  4
   \[13\] \.bss              NOBITS          100000cc 0020cc 000004 00  WA  0   0  4
   \[14\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 0020cc 000019 00      0   0  1
-  \[15\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     16  [0-9]+  4
-  \[16\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[17\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 000080 00      0   0  1
+  \[15\] \.symtab           SYMTAB          00000000 0020e8 0001b0 10     16  22  4
+  \[16\] \.strtab           STRTAB          00000000 002298 00005e 00      0   0  1
+  \[17\] \.shstrtab         STRTAB          00000000 0022f6 000080 00      0   0  1
 Key to Flags:
 #...
 
@@ -29,9 +29,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x00230 0x00230 RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x00208 0x00208 RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x000cc 0x000d0 RWE 0x1000
-  DYNAMIC        0x001178 0x00008178 0x00008178 0x000b8 0x000b8 RW  0x4
+  DYNAMIC        0x001150 0x00008150 0x00008150 0x000b8 0x000b8 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -41,13 +41,13 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x1178 contains 18 entries:
+Dynamic section at offset 0x1150 contains 18 entries:
   Tag        Type                         Name/Value
  0x00000001 \(NEEDED\)                     Shared library: \[tmpdir/libtestb\.so\]
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x8104
- 0x00000006 \(SYMTAB\)                     0x8044
- 0x0000000a \(STRSZ\)                      54 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x80f0
+ 0x00000006 \(SYMTAB\)                     0x8040
+ 0x0000000a \(STRSZ\)                      35 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x00000015 \(DEBUG\)                      0x0
  0x70000000 \(C6000_DSBT_BASE\)            0x100000a0
@@ -57,30 +57,30 @@ Dynamic section at offset 0x1178 contains 18 entries:
  0x00000002 \(PLTRELSZ\)                   12 \(bytes\)
  0x00000014 \(PLTREL\)                     RELA
  0x00000017 \(JMPREL\)                     0x10000000
- 0x00000007 \(RELA\)                       0x813c
+ 0x00000007 \(RELA\)                       0x8114
  0x00000008 \(RELASZ\)                     72 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.got' at offset 0x113c contains 2 entries:
+Relocation section '\.rela\.got' at offset 0x1114 contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000b8  00000701 R_C6000_ABS32          100000c0   b \+ 0
-100000bc  00000b01 R_C6000_ABS32          100000cc   a \+ 0
+100000b8  00000601 R_C6000_ABS32          100000c0   b \+ 0
+100000bc  00000a01 R_C6000_ABS32          100000cc   a \+ 0
 
-Relocation section '\.rela\.neardata' at offset 0x1154 contains 2 entries:
+Relocation section '\.rela\.neardata' at offset 0x112c contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000c4  00000801 R_C6000_ABS32          00000000   g1 \+ 0
-100000c8  00000901 R_C6000_ABS32          00000000   g2 \+ 0
+100000c4  00000701 R_C6000_ABS32          00000000   g1 \+ 0
+100000c8  00000801 R_C6000_ABS32          00000000   g2 \+ 0
 
-Relocation section '\.rela\.bss' at offset 0x116c contains 1 entry:
+Relocation section '\.rela\.bss' at offset 0x1144 contains 1 entry:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000cc  00000b1a R_C6000_COPY           100000cc   a \+ 0
+100000cc  00000a1a R_C6000_COPY           100000cc   a \+ 0
 
 Relocation section '\.rela\.plt' at offset 0x2000 contains 1 entry:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000b4  00000a1b R_C6000_JUMP_SLOT      00000000   sub0 \+ 0
+100000b4  0000091b R_C6000_JUMP_SLOT      00000000   sub0 \+ 0
 
-Symbol table '\.dynsym' contains 12 entries:
+Symbol table '\.dynsym' contains 11 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000020     0 SECTION LOCAL  DEFAULT    9 
@@ -88,39 +88,38 @@ Symbol table '\.dynsym' contains 12 entries:
      3: 100000a0     0 SECTION LOCAL  DEFAULT   11 
      4: 100000c0     0 SECTION LOCAL  DEFAULT   12 
      5: 100000cc     0 SECTION LOCAL  DEFAULT   13 
-     6: 100000a0     0 NOTYPE  LOCAL  DEFAULT   11 __c6xabi_DSBT_BASE
-     7: 100000c0     4 OBJECT  GLOBAL DEFAULT   12 b
-     8: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-     9: 00000000     0 OBJECT  WEAK   DEFAULT  UND g2
-    10: 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
-    11: 100000cc     4 OBJECT  GLOBAL DEFAULT   13 a
+     6: 100000c0     4 OBJECT  GLOBAL DEFAULT   12 b
+     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+     8: 00000000     0 OBJECT  WEAK   DEFAULT  UND g2
+     9: 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
+    10: 100000cc     4 OBJECT  GLOBAL DEFAULT   13 a
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 27 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 00008044     0 SECTION LOCAL  DEFAULT    2 
-.* 00008104     0 SECTION LOCAL  DEFAULT    3 
-.* 0000813c     0 SECTION LOCAL  DEFAULT    4 
-.* 00008154     0 SECTION LOCAL  DEFAULT    5 
-.* 0000816c     0 SECTION LOCAL  DEFAULT    6 
-.* 00008178     0 SECTION LOCAL  DEFAULT    7 
-.* 10000000     0 SECTION LOCAL  DEFAULT    8 
-.* 10000020     0 SECTION LOCAL  DEFAULT    9 
-.* 10000060     0 SECTION LOCAL  DEFAULT   10 
-.* 100000a0     0 SECTION LOCAL  DEFAULT   11 
-.* 100000c0     0 SECTION LOCAL  DEFAULT   12 
-.* 100000cc     0 SECTION LOCAL  DEFAULT   13 
-.* 00000000     0 SECTION LOCAL  DEFAULT   14 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000060     0 NOTYPE  LOCAL  DEFAULT   10 fish
-.* 100000c4     8 OBJECT  LOCAL  DEFAULT   12 w
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 00008178     0 OBJECT  LOCAL  DEFAULT    7 _DYNAMIC
-.* 100000ac     0 OBJECT  LOCAL  DEFAULT   11 _GLOBAL_OFFSET_TABLE_
-.* 100000a0     0 NOTYPE  LOCAL  DEFAULT   11 __c6xabi_DSBT_BASE
-.* 100000c0     4 OBJECT  GLOBAL DEFAULT   12 b
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-.* 00000000     0 OBJECT  WEAK   DEFAULT  UND g2
-.* 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
-.* 100000cc     4 OBJECT  GLOBAL DEFAULT   13 a
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008040     0 SECTION LOCAL  DEFAULT    2 
+     3: 000080f0     0 SECTION LOCAL  DEFAULT    3 
+     4: 00008114     0 SECTION LOCAL  DEFAULT    4 
+     5: 0000812c     0 SECTION LOCAL  DEFAULT    5 
+     6: 00008144     0 SECTION LOCAL  DEFAULT    6 
+     7: 00008150     0 SECTION LOCAL  DEFAULT    7 
+     8: 10000000     0 SECTION LOCAL  DEFAULT    8 
+     9: 10000020     0 SECTION LOCAL  DEFAULT    9 
+    10: 10000060     0 SECTION LOCAL  DEFAULT   10 
+    11: 100000a0     0 SECTION LOCAL  DEFAULT   11 
+    12: 100000c0     0 SECTION LOCAL  DEFAULT   12 
+    13: 100000cc     0 SECTION LOCAL  DEFAULT   13 
+    14: 00000000     0 SECTION LOCAL  DEFAULT   14 
+    15: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-app-1\.o
+    16: 10000060     0 NOTYPE  LOCAL  DEFAULT   10 fish
+    17: 100000c4     8 OBJECT  LOCAL  DEFAULT   12 w
+    18: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    19: 00008150     0 OBJECT  LOCAL  DEFAULT    7 _DYNAMIC
+    20: 100000ac     0 OBJECT  LOCAL  DEFAULT   11 _GLOBAL_OFFSET_TABLE_
+    21: 100000a0     0 NOTYPE  LOCAL  DEFAULT   11 __c6xabi_DSBT_BASE
+    22: 100000c0     4 OBJECT  GLOBAL DEFAULT   12 b
+    23: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+    24: 00000000     0 OBJECT  WEAK   DEFAULT  UND g2
+    25: 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
+    26: 100000cc     4 OBJECT  GLOBAL DEFAULT   13 a
diff --git a/ld/testsuite/ld-tic6x/shlib-app-1r.rd b/ld/testsuite/ld-tic6x/shlib-app-1r.rd
index a952a32201..4a38da9dba 100644
--- a/ld/testsuite/ld-tic6x/shlib-app-1r.rd
+++ b/ld/testsuite/ld-tic6x/shlib-app-1r.rd
@@ -3,12 +3,12 @@ There are 17 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 00003c 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          0000803c 00103c 0000a0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          000080dc 0010dc 000030 00   A  0   0  1
-  \[ 4\] \.rela\.got         RELA            0000810c 00110c 000018 0c  AI  2  10  4
-  \[ 5\] \.rela\.bss         RELA            00008124 001124 00000c 0c  AI  2  12  4
-  \[ 6\] \.dynamic          DYNAMIC         00008130 001130 0000b8 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000038 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008038 001038 000090 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          000080c8 0010c8 00001d 00   A  0   0  1
+  \[ 4\] \.rela\.got         RELA            000080e8 0010e8 000018 0c  AI  2  10  4
+  \[ 5\] \.rela\.bss         RELA            00008100 001100 00000c 0c  AI  2  12  4
+  \[ 6\] \.dynamic          DYNAMIC         0000810c 00110c 0000b8 08  WA  3   0  4
   \[ 7\] \.rela\.plt         RELA            10000000 002000 00000c 0c  AI  2  10  4
   \[ 8\] \.plt              PROGBITS        10000020 002020 000040 18  AX  0   0 32
   \[ 9\] \.text             PROGBITS        10000060 002060 000040 00  AX  0   0 32
@@ -16,9 +16,9 @@ Section Headers:
   \[11\] \.neardata         PROGBITS        100000c0 0020c0 000004 00  WA  0   0  4
   \[12\] \.bss              NOBITS          100000c4 0020c4 000004 00  WA  0   0  4
   \[13\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 0020c4 000019 00      0   0  1
-  \[14\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     15  [0-9]+  4
-  \[15\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[16\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 00007b 00      0   0  1
+  \[14\] \.symtab           SYMTAB          00000000 0020e0 000170 10     15  20  4
+  \[15\] \.strtab           STRTAB          00000000 002250 000057 00      0   0  1
+  \[16\] \.shstrtab         STRTAB          00000000 0022a7 00007b 00      0   0  1
 Key to Flags:
 #...
 
@@ -28,9 +28,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x001e8 0x001e8 RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x001c4 0x001c4 RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x000c4 0x000c8 RWE 0x1000
-  DYNAMIC        0x001130 0x00008130 0x00008130 0x000b8 0x000b8 RW  0x4
+  DYNAMIC        0x00110c 0x0000810c 0x0000810c 0x000b8 0x000b8 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -40,13 +40,13 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x1130 contains 18 entries:
+Dynamic section at offset 0x110c contains 18 entries:
   Tag        Type                         Name/Value
  0x00000001 \(NEEDED\)                     Shared library: \[tmpdir/libtestr\.so\]
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x80dc
- 0x00000006 \(SYMTAB\)                     0x803c
- 0x0000000a \(STRSZ\)                      48 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x80c8
+ 0x00000006 \(SYMTAB\)                     0x8038
+ 0x0000000a \(STRSZ\)                      29 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x00000015 \(DEBUG\)                      0x0
  0x70000000 \(C6000_DSBT_BASE\)            0x100000a0
@@ -56,25 +56,25 @@ Dynamic section at offset 0x1130 contains 18 entries:
  0x00000002 \(PLTRELSZ\)                   12 \(bytes\)
  0x00000014 \(PLTREL\)                     RELA
  0x00000017 \(JMPREL\)                     0x10000000
- 0x00000007 \(RELA\)                       0x810c
+ 0x00000007 \(RELA\)                       0x80e8
  0x00000008 \(RELASZ\)                     48 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.got' at offset 0x110c contains 2 entries:
+Relocation section '\.rela\.got' at offset 0x10e8 contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000b8  00000701 R_C6000_ABS32          100000c0   b \+ 0
-100000bc  00000901 R_C6000_ABS32          100000c4   a \+ 0
+100000b8  00000601 R_C6000_ABS32          100000c0   b \+ 0
+100000bc  00000801 R_C6000_ABS32          100000c4   a \+ 0
 
-Relocation section '\.rela\.bss' at offset 0x1124 contains 1 entry:
+Relocation section '\.rela\.bss' at offset 0x1100 contains 1 entry:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000c4  0000091a R_C6000_COPY           100000c4   a \+ 0
+100000c4  0000081a R_C6000_COPY           100000c4   a \+ 0
 
 Relocation section '\.rela\.plt' at offset 0x2000 contains 1 entry:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000b4  0000081b R_C6000_JUMP_SLOT      00000000   sub0 \+ 0
+100000b4  0000071b R_C6000_JUMP_SLOT      00000000   sub0 \+ 0
 
-Symbol table '\.dynsym' contains 10 entries:
+Symbol table '\.dynsym' contains 9 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000020     0 SECTION LOCAL  DEFAULT    8 
@@ -82,33 +82,32 @@ Symbol table '\.dynsym' contains 10 entries:
      3: 100000a0     0 SECTION LOCAL  DEFAULT   10 
      4: 100000c0     0 SECTION LOCAL  DEFAULT   11 
      5: 100000c4     0 SECTION LOCAL  DEFAULT   12 
-     6: 100000a0     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
-     7: 100000c0     4 OBJECT  GLOBAL DEFAULT   11 b
-     8: 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
-     9: 100000c4     4 OBJECT  GLOBAL DEFAULT   12 a
+     6: 100000c0     4 OBJECT  GLOBAL DEFAULT   11 b
+     7: 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
+     8: 100000c4     4 OBJECT  GLOBAL DEFAULT   12 a
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 23 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 0000803c     0 SECTION LOCAL  DEFAULT    2 
-.* 000080dc     0 SECTION LOCAL  DEFAULT    3 
-.* 0000810c     0 SECTION LOCAL  DEFAULT    4 
-.* 00008124     0 SECTION LOCAL  DEFAULT    5 
-.* 00008130     0 SECTION LOCAL  DEFAULT    6 
-.* 10000000     0 SECTION LOCAL  DEFAULT    7 
-.* 10000020     0 SECTION LOCAL  DEFAULT    8 
-.* 10000060     0 SECTION LOCAL  DEFAULT    9 
-.* 100000a0     0 SECTION LOCAL  DEFAULT   10 
-.* 100000c0     0 SECTION LOCAL  DEFAULT   11 
-.* 100000c4     0 SECTION LOCAL  DEFAULT   12 
-.* 00000000     0 SECTION LOCAL  DEFAULT   13 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000060     0 NOTYPE  LOCAL  DEFAULT    9 fish
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 00008130     0 OBJECT  LOCAL  DEFAULT    6 _DYNAMIC
-.* 100000ac     0 OBJECT  LOCAL  DEFAULT   10 _GLOBAL_OFFSET_TABLE_
-.* 100000a0     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
-.* 100000c0     4 OBJECT  GLOBAL DEFAULT   11 b
-.* 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
-.* 100000c4     4 OBJECT  GLOBAL DEFAULT   12 a
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008038     0 SECTION LOCAL  DEFAULT    2 
+     3: 000080c8     0 SECTION LOCAL  DEFAULT    3 
+     4: 000080e8     0 SECTION LOCAL  DEFAULT    4 
+     5: 00008100     0 SECTION LOCAL  DEFAULT    5 
+     6: 0000810c     0 SECTION LOCAL  DEFAULT    6 
+     7: 10000000     0 SECTION LOCAL  DEFAULT    7 
+     8: 10000020     0 SECTION LOCAL  DEFAULT    8 
+     9: 10000060     0 SECTION LOCAL  DEFAULT    9 
+    10: 100000a0     0 SECTION LOCAL  DEFAULT   10 
+    11: 100000c0     0 SECTION LOCAL  DEFAULT   11 
+    12: 100000c4     0 SECTION LOCAL  DEFAULT   12 
+    13: 00000000     0 SECTION LOCAL  DEFAULT   13 
+    14: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-app-1r\.o
+    15: 10000060     0 NOTYPE  LOCAL  DEFAULT    9 fish
+    16: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    17: 0000810c     0 OBJECT  LOCAL  DEFAULT    6 _DYNAMIC
+    18: 100000ac     0 OBJECT  LOCAL  DEFAULT   10 _GLOBAL_OFFSET_TABLE_
+    19: 100000a0     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
+    20: 100000c0     4 OBJECT  GLOBAL DEFAULT   11 b
+    21: 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
+    22: 100000c4     4 OBJECT  GLOBAL DEFAULT   12 a
diff --git a/ld/testsuite/ld-tic6x/shlib-app-1rb.rd b/ld/testsuite/ld-tic6x/shlib-app-1rb.rd
index 0260d0e7d6..2ad86cb187 100644
--- a/ld/testsuite/ld-tic6x/shlib-app-1rb.rd
+++ b/ld/testsuite/ld-tic6x/shlib-app-1rb.rd
@@ -3,12 +3,12 @@ There are 17 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 00003c 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          0000803c 00103c 0000a0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          000080dc 0010dc 000031 00   A  0   0  1
-  \[ 4\] \.rela\.got         RELA            00008110 001110 000018 0c  AI  2  10  4
-  \[ 5\] \.rela\.bss         RELA            00008128 001128 00000c 0c  AI  2  12  4
-  \[ 6\] \.dynamic          DYNAMIC         00008134 001134 0000b8 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000038 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008038 001038 000090 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          000080c8 0010c8 00001e 00   A  0   0  1
+  \[ 4\] \.rela\.got         RELA            000080e8 0010e8 000018 0c  AI  2  10  4
+  \[ 5\] \.rela\.bss         RELA            00008100 001100 00000c 0c  AI  2  12  4
+  \[ 6\] \.dynamic          DYNAMIC         0000810c 00110c 0000b8 08  WA  3   0  4
   \[ 7\] \.rela\.plt         RELA            10000000 002000 00000c 0c  AI  2  10  4
   \[ 8\] \.plt              PROGBITS        10000020 002020 000040 18  AX  0   0 32
   \[ 9\] \.text             PROGBITS        10000060 002060 000040 00  AX  0   0 32
@@ -16,9 +16,9 @@ Section Headers:
   \[11\] \.neardata         PROGBITS        100000c0 0020c0 000004 00  WA  0   0  4
   \[12\] \.bss              NOBITS          100000c4 0020c4 000004 00  WA  0   0  4
   \[13\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 0020c4 000019 00      0   0  1
-  \[14\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     15  [0-9]+  4
-  \[15\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[16\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 00007b 00      0   0  1
+  \[14\] \.symtab           SYMTAB          00000000 0020e0 000170 10     15  20  4
+  \[15\] \.strtab           STRTAB          00000000 002250 000057 00      0   0  1
+  \[16\] \.shstrtab         STRTAB          00000000 0022a7 00007b 00      0   0  1
 Key to Flags:
 #...
 
@@ -28,9 +28,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x001ec 0x001ec RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x001c4 0x001c4 RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x000c4 0x000c8 RWE 0x1000
-  DYNAMIC        0x001134 0x00008134 0x00008134 0x000b8 0x000b8 RW  0x4
+  DYNAMIC        0x00110c 0x0000810c 0x0000810c 0x000b8 0x000b8 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -40,13 +40,13 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x1134 contains 18 entries:
+Dynamic section at offset 0x110c contains 18 entries:
   Tag        Type                         Name/Value
  0x00000001 \(NEEDED\)                     Shared library: \[tmpdir/libtestrb\.so\]
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x80dc
- 0x00000006 \(SYMTAB\)                     0x803c
- 0x0000000a \(STRSZ\)                      49 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x80c8
+ 0x00000006 \(SYMTAB\)                     0x8038
+ 0x0000000a \(STRSZ\)                      30 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x00000015 \(DEBUG\)                      0x0
  0x70000000 \(C6000_DSBT_BASE\)            0x100000a0
@@ -56,25 +56,25 @@ Dynamic section at offset 0x1134 contains 18 entries:
  0x00000002 \(PLTRELSZ\)                   12 \(bytes\)
  0x00000014 \(PLTREL\)                     RELA
  0x00000017 \(JMPREL\)                     0x10000000
- 0x00000007 \(RELA\)                       0x8110
+ 0x00000007 \(RELA\)                       0x80e8
  0x00000008 \(RELASZ\)                     48 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.got' at offset 0x1110 contains 2 entries:
+Relocation section '\.rela\.got' at offset 0x10e8 contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000b8  00000701 R_C6000_ABS32          100000c0   b \+ 0
-100000bc  00000901 R_C6000_ABS32          100000c4   a \+ 0
+100000b8  00000601 R_C6000_ABS32          100000c0   b \+ 0
+100000bc  00000801 R_C6000_ABS32          100000c4   a \+ 0
 
-Relocation section '\.rela\.bss' at offset 0x1128 contains 1 entry:
+Relocation section '\.rela\.bss' at offset 0x1100 contains 1 entry:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000c4  0000091a R_C6000_COPY           100000c4   a \+ 0
+100000c4  0000081a R_C6000_COPY           100000c4   a \+ 0
 
 Relocation section '\.rela\.plt' at offset 0x2000 contains 1 entry:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-100000b4  0000081b R_C6000_JUMP_SLOT      00000000   sub0 \+ 0
+100000b4  0000071b R_C6000_JUMP_SLOT      00000000   sub0 \+ 0
 
-Symbol table '\.dynsym' contains 10 entries:
+Symbol table '\.dynsym' contains 9 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000020     0 SECTION LOCAL  DEFAULT    8 
@@ -82,33 +82,32 @@ Symbol table '\.dynsym' contains 10 entries:
      3: 100000a0     0 SECTION LOCAL  DEFAULT   10 
      4: 100000c0     0 SECTION LOCAL  DEFAULT   11 
      5: 100000c4     0 SECTION LOCAL  DEFAULT   12 
-     6: 100000a0     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
-     7: 100000c0     4 OBJECT  GLOBAL DEFAULT   11 b
-     8: 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
-     9: 100000c4     4 OBJECT  GLOBAL DEFAULT   12 a
+     6: 100000c0     4 OBJECT  GLOBAL DEFAULT   11 b
+     7: 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
+     8: 100000c4     4 OBJECT  GLOBAL DEFAULT   12 a
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 23 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 0000803c     0 SECTION LOCAL  DEFAULT    2 
-.* 000080dc     0 SECTION LOCAL  DEFAULT    3 
-.* 00008110     0 SECTION LOCAL  DEFAULT    4 
-.* 00008128     0 SECTION LOCAL  DEFAULT    5 
-.* 00008134     0 SECTION LOCAL  DEFAULT    6 
-.* 10000000     0 SECTION LOCAL  DEFAULT    7 
-.* 10000020     0 SECTION LOCAL  DEFAULT    8 
-.* 10000060     0 SECTION LOCAL  DEFAULT    9 
-.* 100000a0     0 SECTION LOCAL  DEFAULT   10 
-.* 100000c0     0 SECTION LOCAL  DEFAULT   11 
-.* 100000c4     0 SECTION LOCAL  DEFAULT   12 
-.* 00000000     0 SECTION LOCAL  DEFAULT   13 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000060     0 NOTYPE  LOCAL  DEFAULT    9 fish
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 00008134     0 OBJECT  LOCAL  DEFAULT    6 _DYNAMIC
-.* 100000ac     0 OBJECT  LOCAL  DEFAULT   10 _GLOBAL_OFFSET_TABLE_
-.* 100000a0     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
-.* 100000c0     4 OBJECT  GLOBAL DEFAULT   11 b
-.* 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
-.* 100000c4     4 OBJECT  GLOBAL DEFAULT   12 a
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008038     0 SECTION LOCAL  DEFAULT    2 
+     3: 000080c8     0 SECTION LOCAL  DEFAULT    3 
+     4: 000080e8     0 SECTION LOCAL  DEFAULT    4 
+     5: 00008100     0 SECTION LOCAL  DEFAULT    5 
+     6: 0000810c     0 SECTION LOCAL  DEFAULT    6 
+     7: 10000000     0 SECTION LOCAL  DEFAULT    7 
+     8: 10000020     0 SECTION LOCAL  DEFAULT    8 
+     9: 10000060     0 SECTION LOCAL  DEFAULT    9 
+    10: 100000a0     0 SECTION LOCAL  DEFAULT   10 
+    11: 100000c0     0 SECTION LOCAL  DEFAULT   11 
+    12: 100000c4     0 SECTION LOCAL  DEFAULT   12 
+    13: 00000000     0 SECTION LOCAL  DEFAULT   13 
+    14: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-app-1r\.o
+    15: 10000060     0 NOTYPE  LOCAL  DEFAULT    9 fish
+    16: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    17: 0000810c     0 OBJECT  LOCAL  DEFAULT    6 _DYNAMIC
+    18: 100000ac     0 OBJECT  LOCAL  DEFAULT   10 _GLOBAL_OFFSET_TABLE_
+    19: 100000a0     0 NOTYPE  LOCAL  DEFAULT   10 __c6xabi_DSBT_BASE
+    20: 100000c0     4 OBJECT  GLOBAL DEFAULT   11 b
+    21: 00000000     0 FUNC    GLOBAL DEFAULT  UND sub0
+    22: 100000c4     4 OBJECT  GLOBAL DEFAULT   12 a
diff --git a/ld/testsuite/ld-tic6x/shlib-noindex.rd b/ld/testsuite/ld-tic6x/shlib-noindex.rd
index be06125128..ea515be556 100644
--- a/ld/testsuite/ld-tic6x/shlib-noindex.rd
+++ b/ld/testsuite/ld-tic6x/shlib-noindex.rd
@@ -3,13 +3,13 @@ There are 18 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 000048 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          00008048 001048 0000d0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          00008118 001118 000025 00   A  0   0  1
-  \[ 4\] \.rela\.text        RELA            00008140 001140 00000c 0c  AI  2  10  4
-  \[ 5\] \.rela\.got         RELA            0000814c 00114c 000024 0c  AI  2  11  4
-  \[ 6\] \.rela\.neardata    RELA            00008170 001170 000018 0c  AI  2  12  4
-  \[ 7\] \.dynamic          DYNAMIC         00008188 001188 0000b0 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000044 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008044 001044 0000c0 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          00008104 001104 000012 00   A  0   0  1
+  \[ 4\] \.rela\.text        RELA            00008118 001118 00000c 0c  AI  2  10  4
+  \[ 5\] \.rela\.got         RELA            00008124 001124 000024 0c  AI  2  11  4
+  \[ 6\] \.rela\.neardata    RELA            00008148 001148 000018 0c  AI  2  12  4
+  \[ 7\] \.dynamic          DYNAMIC         00008160 001160 0000b0 08  WA  3   0  4
   \[ 8\] \.rela\.plt         RELA            10000000 002000 000018 0c  AI  2  11  4
   \[ 9\] \.plt              PROGBITS        10000020 002020 000060 18  AX  0   0 32
   \[10\] \.text             PROGBITS        10000080 002080 000080 00  AX  0   0 32
@@ -17,9 +17,9 @@ Section Headers:
   \[12\] \.neardata         PROGBITS        10000128 002128 000008 00  WA  0   0  4
   \[13\] \.bss              NOBITS          10000130 002130 000004 00  WA  0   0  4
   \[14\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 002130 000019 00      0   0  1
-  \[15\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     16  [0-9]+  4
-  \[16\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[17\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 000080 00      0   0  1
+  \[15\] \.symtab           SYMTAB          00000000 00214c 0001c0 10     16  22  4
+  \[16\] \.strtab           STRTAB          00000000 00230c 00005c 00      0   0  1
+  \[17\] \.shstrtab         STRTAB          00000000 002368 000080 00      0   0  1
 Key to Flags:
 #...
 
@@ -29,9 +29,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x00238 0x00238 RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x00210 0x00210 RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x00130 0x00134 RWE 0x1000
-  DYNAMIC        0x001188 0x00008188 0x00008188 0x000b0 0x000b0 RW  0x4
+  DYNAMIC        0x001160 0x00008160 0x00008160 0x000b0 0x000b0 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -41,12 +41,12 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x1188 contains 17 entries:
+Dynamic section at offset 0x1160 contains 17 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x8118
- 0x00000006 \(SYMTAB\)                     0x8048
- 0x0000000a \(STRSZ\)                      37 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x8104
+ 0x00000006 \(SYMTAB\)                     0x8044
+ 0x0000000a \(STRSZ\)                      18 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x70000000 \(C6000_DSBT_BASE\)            0x10000100
  0x70000001 \(C6000_DSBT_SIZE\)            0x3
@@ -55,33 +55,33 @@ Dynamic section at offset 0x1188 contains 17 entries:
  0x00000002 \(PLTRELSZ\)                   24 \(bytes\)
  0x00000014 \(PLTREL\)                     RELA
  0x00000017 \(JMPREL\)                     0x10000000
- 0x00000007 \(RELA\)                       0x8140
+ 0x00000007 \(RELA\)                       0x8118
  0x00000008 \(RELASZ\)                     96 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000016 \(TEXTREL\)                    0x0
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.text' at offset 0x1140 contains 1 entry:
+Relocation section '\.rela\.text' at offset 0x1118 contains 1 entry:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-10000094  00000618 R_C6000_DSBT_INDEX     10000100   __c6xabi_DSBT_BASE \+ 0
+10000094  00000318 R_C6000_DSBT_INDEX     10000100   \.got - 10000100
 
-Relocation section '\.rela\.got' at offset 0x114c contains 3 entries:
+Relocation section '\.rela\.got' at offset 0x1124 contains 3 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 10000120  00000501 R_C6000_ABS32          10000130   \.bss \+ 0
-1000011c  00000701 R_C6000_ABS32          00000000   b \+ 0
-10000124  00000b01 R_C6000_ABS32          10000128   a \+ 0
+1000011c  00000601 R_C6000_ABS32          00000000   b \+ 0
+10000124  00000a01 R_C6000_ABS32          10000128   a \+ 0
 
-Relocation section '\.rela\.neardata' at offset 0x1170 contains 2 entries:
+Relocation section '\.rela\.neardata' at offset 0x1148 contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-10000128  00000a01 R_C6000_ABS32          10000088   sub0 \+ 0
-1000012c  00000801 R_C6000_ABS32          00000000   g1 \+ 0
+10000128  00000901 R_C6000_ABS32          10000088   sub0 \+ 0
+1000012c  00000701 R_C6000_ABS32          00000000   g1 \+ 0
 
 Relocation section '\.rela\.plt' at offset 0x2000 contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
-10000114  00000a1b R_C6000_JUMP_SLOT      10000088   sub0 \+ 0
-10000118  00000c1b R_C6000_JUMP_SLOT      100000c0   sub \+ 0
+10000114  0000091b R_C6000_JUMP_SLOT      10000088   sub0 \+ 0
+10000118  00000b1b R_C6000_JUMP_SLOT      100000c0   sub \+ 0
 
-Symbol table '\.dynsym' contains 13 entries:
+Symbol table '\.dynsym' contains 12 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000020     0 SECTION LOCAL  DEFAULT    9 
@@ -89,41 +89,40 @@ Symbol table '\.dynsym' contains 13 entries:
      3: 10000100     0 SECTION LOCAL  DEFAULT   11 
      4: 10000128     0 SECTION LOCAL  DEFAULT   12 
      5: 10000130     0 SECTION LOCAL  DEFAULT   13 
-     6: 10000100     0 NOTYPE  LOCAL  DEFAULT   11 __c6xabi_DSBT_BASE
-     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
-     8: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-     9: 1000012c     4 OBJECT  GLOBAL DEFAULT   12 g2
-    10: 10000088    52 FUNC    GLOBAL DEFAULT   10 sub0
-    11: 10000128     4 OBJECT  GLOBAL DEFAULT   12 a
-    12: 100000c0    52 FUNC    GLOBAL DEFAULT   10 sub
+     6: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
+     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+     8: 1000012c     4 OBJECT  GLOBAL DEFAULT   12 g2
+     9: 10000088    52 FUNC    GLOBAL DEFAULT   10 sub0
+    10: 10000128     4 OBJECT  GLOBAL DEFAULT   12 a
+    11: 100000c0    52 FUNC    GLOBAL DEFAULT   10 sub
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 28 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 00008048     0 SECTION LOCAL  DEFAULT    2 
-.* 00008118     0 SECTION LOCAL  DEFAULT    3 
-.* 00008140     0 SECTION LOCAL  DEFAULT    4 
-.* 0000814c     0 SECTION LOCAL  DEFAULT    5 
-.* 00008170     0 SECTION LOCAL  DEFAULT    6 
-.* 00008188     0 SECTION LOCAL  DEFAULT    7 
-.* 10000000     0 SECTION LOCAL  DEFAULT    8 
-.* 10000020     0 SECTION LOCAL  DEFAULT    9 
-.* 10000080     0 SECTION LOCAL  DEFAULT   10 
-.* 10000100     0 SECTION LOCAL  DEFAULT   11 
-.* 10000128     0 SECTION LOCAL  DEFAULT   12 
-.* 10000130     0 SECTION LOCAL  DEFAULT   13 
-.* 00000000     0 SECTION LOCAL  DEFAULT   14 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000080     0 FUNC    LOCAL  HIDDEN    10 sub1
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS 
-.* 00008188     0 OBJECT  LOCAL  DEFAULT  ABS _DYNAMIC
-.* 10000130     4 OBJECT  LOCAL  DEFAULT   13 c
-.* 1000010c     0 OBJECT  LOCAL  DEFAULT  ABS _GLOBAL_OFFSET_TABLE_
-.* 10000100     0 NOTYPE  LOCAL  DEFAULT   11 __c6xabi_DSBT_BASE
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-.* 1000012c     4 OBJECT  GLOBAL DEFAULT   12 g2
-.* 10000088    52 FUNC    GLOBAL DEFAULT   10 sub0
-.* 10000128     4 OBJECT  GLOBAL DEFAULT   12 a
-.* 100000c0    52 FUNC    GLOBAL DEFAULT   10 sub
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008044     0 SECTION LOCAL  DEFAULT    2 
+     3: 00008104     0 SECTION LOCAL  DEFAULT    3 
+     4: 00008118     0 SECTION LOCAL  DEFAULT    4 
+     5: 00008124     0 SECTION LOCAL  DEFAULT    5 
+     6: 00008148     0 SECTION LOCAL  DEFAULT    6 
+     7: 00008160     0 SECTION LOCAL  DEFAULT    7 
+     8: 10000000     0 SECTION LOCAL  DEFAULT    8 
+     9: 10000020     0 SECTION LOCAL  DEFAULT    9 
+    10: 10000080     0 SECTION LOCAL  DEFAULT   10 
+    11: 10000100     0 SECTION LOCAL  DEFAULT   11 
+    12: 10000128     0 SECTION LOCAL  DEFAULT   12 
+    13: 10000130     0 SECTION LOCAL  DEFAULT   13 
+    14: 00000000     0 SECTION LOCAL  DEFAULT   14 
+    15: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-1\.o
+    16: 10000080     0 FUNC    LOCAL  HIDDEN    10 sub1
+    17: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    18: 00008160     0 OBJECT  LOCAL  DEFAULT  ABS _DYNAMIC
+    19: 10000130     4 OBJECT  LOCAL  DEFAULT   13 c
+    20: 1000010c     0 OBJECT  LOCAL  DEFAULT  ABS _GLOBAL_OFFSET_TABLE_
+    21: 10000100     0 NOTYPE  LOCAL  DEFAULT   11 __c6xabi_DSBT_BASE
+    22: 00000000     0 NOTYPE  WEAK   DEFAULT  UND b
+    23: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+    24: 1000012c     4 OBJECT  GLOBAL DEFAULT   12 g2
+    25: 10000088    52 FUNC    GLOBAL DEFAULT   10 sub0
+    26: 10000128     4 OBJECT  GLOBAL DEFAULT   12 a
+    27: 100000c0    52 FUNC    GLOBAL DEFAULT   10 sub
diff --git a/ld/testsuite/ld-tic6x/static-app-1.rd b/ld/testsuite/ld-tic6x/static-app-1.rd
index 27d2d235f0..8fa34377e3 100644
--- a/ld/testsuite/ld-tic6x/static-app-1.rd
+++ b/ld/testsuite/ld-tic6x/static-app-1.rd
@@ -3,20 +3,20 @@ There are 15 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 00003c 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          0000803c 00103c 0000a0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          000080dc 0010dc 00001d 00   A  0   0  1
-  \[ 4\] \.rela\.got         RELA            000080fc 0010fc 000024 0c  AI  2   8  4
-  \[ 5\] \.rela\.neardata    RELA            00008120 001120 000030 0c  AI  2   9  4
-  \[ 6\] \.dynamic          DYNAMIC         00008150 001150 000090 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000038 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008038 001038 000090 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          000080c8 0010c8 00000a 00   A  0   0  1
+  \[ 4\] \.rela\.got         RELA            000080d4 0010d4 000024 0c  AI  2   8  4
+  \[ 5\] \.rela\.neardata    RELA            000080f8 0010f8 000030 0c  AI  2   9  4
+  \[ 6\] \.dynamic          DYNAMIC         00008128 001128 000090 08  WA  3   0  4
   \[ 7\] \.text             PROGBITS        10000000 002000 0000c0 00  AX  0   0 32
   \[ 8\] \.got              PROGBITS        100000c0 0020c0 000020 00  WA  0   0  4
   \[ 9\] \.neardata         PROGBITS        100000e0 0020e0 000014 00  WA  0   0  4
   \[10\] \.bss              NOBITS          100000f4 0020f4 000004 00  WA  0   0  4
   \[11\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 0020f4 000019 00      0   0  1
-  \[12\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     13  [0-9]+  4
-  \[13\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[14\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 000071 00      0   0  1
+  \[12\] \.symtab           SYMTAB          00000000 002110 0001c0 10     13  22  4
+  \[13\] \.strtab           STRTAB          00000000 0022d0 000078 00      0   0  1
+  \[14\] \.shstrtab         STRTAB          00000000 002348 000071 00      0   0  1
 Key to Flags:
 #...
 
@@ -26,9 +26,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x001e0 0x001e0 RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x001b8 0x001b8 RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x000f4 0x000f8 RWE 0x1000
-  DYNAMIC        0x001150 0x00008150 0x00008150 0x00090 0x00090 RW  0x4
+  DYNAMIC        0x001128 0x00008128 0x00008128 0x00090 0x00090 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -38,36 +38,36 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x1150 contains 13 entries:
+Dynamic section at offset 0x1128 contains 13 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x80dc
- 0x00000006 \(SYMTAB\)                     0x803c
- 0x0000000a \(STRSZ\)                      29 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x80c8
+ 0x00000006 \(SYMTAB\)                     0x8038
+ 0x0000000a \(STRSZ\)                      10 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x00000015 \(DEBUG\)                      0x0
  0x70000000 \(C6000_DSBT_BASE\)            0x100000c0
  0x70000001 \(C6000_DSBT_SIZE\)            0x3
  0x70000003 \(C6000_DSBT_INDEX\)           0x0
- 0x00000007 \(RELA\)                       0x80fc
+ 0x00000007 \(RELA\)                       0x80d4
  0x00000008 \(RELASZ\)                     84 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.got' at offset 0x10fc contains 3 entries:
+Relocation section '\.rela\.got' at offset 0x10d4 contains 3 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 100000d8  00000401 R_C6000_ABS32          100000f4   \.bss \+ 0
-100000d4  00000701 R_C6000_ABS32          100000e8   b \+ 0
-100000dc  00000901 R_C6000_ABS32          100000e0   a \+ 0
+100000d4  00000601 R_C6000_ABS32          100000e8   b \+ 0
+100000dc  00000801 R_C6000_ABS32          100000e0   a \+ 0
 
-Relocation section '\.rela\.neardata' at offset 0x1120 contains 4 entries:
+Relocation section '\.rela\.neardata' at offset 0x10f8 contains 4 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 100000e0  00000101 R_C6000_ABS32          10000000   \.text \+ 8
-100000e4  00000801 R_C6000_ABS32          00000000   g1 \+ 0
-100000ec  00000801 R_C6000_ABS32          00000000   g1 \+ 0
+100000e4  00000701 R_C6000_ABS32          00000000   g1 \+ 0
+100000ec  00000701 R_C6000_ABS32          00000000   g1 \+ 0
 100000f0  00000301 R_C6000_ABS32          100000e0   \.neardata \+ 4
 
-Symbol table '\.dynsym' contains 10 entries:
+Symbol table '\.dynsym' contains 9 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000000     0 SECTION LOCAL  DEFAULT    7 
@@ -75,38 +75,37 @@ Symbol table '\.dynsym' contains 10 entries:
      3: 100000e0     0 SECTION LOCAL  DEFAULT    9 
      4: 100000f4     0 SECTION LOCAL  DEFAULT   10 
      5: 100000f4     4 OBJECT  LOCAL  DEFAULT   10 c
-     6: 100000c0     0 NOTYPE  LOCAL  DEFAULT    8 __c6xabi_DSBT_BASE
-     7: 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
-     8: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-     9: 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
+     6: 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
+     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+     8: 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 28 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 0000803c     0 SECTION LOCAL  DEFAULT    2 
-.* 000080dc     0 SECTION LOCAL  DEFAULT    3 
-.* 000080fc     0 SECTION LOCAL  DEFAULT    4 
-.* 00008120     0 SECTION LOCAL  DEFAULT    5 
-.* 00008150     0 SECTION LOCAL  DEFAULT    6 
-.* 10000000     0 SECTION LOCAL  DEFAULT    7 
-.* 100000c0     0 SECTION LOCAL  DEFAULT    8 
-.* 100000e0     0 SECTION LOCAL  DEFAULT    9 
-.* 100000f4     0 SECTION LOCAL  DEFAULT   10 
-.* 00000000     0 SECTION LOCAL  DEFAULT   11 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000000     0 FUNC    LOCAL  HIDDEN     7 sub1
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000080     0 NOTYPE  LOCAL  DEFAULT    7 fish
-.* 100000ec     8 OBJECT  LOCAL  DEFAULT    9 w
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 00008150     0 OBJECT  LOCAL  DEFAULT    6 _DYNAMIC
-.* 100000f4     4 OBJECT  LOCAL  DEFAULT   10 c
-.* 100000cc     0 OBJECT  LOCAL  DEFAULT    8 _GLOBAL_OFFSET_TABLE_
-.* 100000c0     0 NOTYPE  LOCAL  DEFAULT    8 __c6xabi_DSBT_BASE
-.* 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-.* 100000e4     4 OBJECT  GLOBAL DEFAULT    9 g2
-.* 10000008    52 FUNC    GLOBAL DEFAULT    7 sub0
-.* 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
-.* 10000040    52 FUNC    GLOBAL DEFAULT    7 sub
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008038     0 SECTION LOCAL  DEFAULT    2 
+     3: 000080c8     0 SECTION LOCAL  DEFAULT    3 
+     4: 000080d4     0 SECTION LOCAL  DEFAULT    4 
+     5: 000080f8     0 SECTION LOCAL  DEFAULT    5 
+     6: 00008128     0 SECTION LOCAL  DEFAULT    6 
+     7: 10000000     0 SECTION LOCAL  DEFAULT    7 
+     8: 100000c0     0 SECTION LOCAL  DEFAULT    8 
+     9: 100000e0     0 SECTION LOCAL  DEFAULT    9 
+    10: 100000f4     0 SECTION LOCAL  DEFAULT   10 
+    11: 00000000     0 SECTION LOCAL  DEFAULT   11 
+    12: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-1\.o
+    13: 10000000     0 FUNC    LOCAL  HIDDEN     7 sub1
+    14: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-app-1\.o
+    15: 10000080     0 NOTYPE  LOCAL  DEFAULT    7 fish
+    16: 100000ec     8 OBJECT  LOCAL  DEFAULT    9 w
+    17: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    18: 00008128     0 OBJECT  LOCAL  DEFAULT    6 _DYNAMIC
+    19: 100000f4     4 OBJECT  LOCAL  DEFAULT   10 c
+    20: 100000cc     0 OBJECT  LOCAL  DEFAULT    8 _GLOBAL_OFFSET_TABLE_
+    21: 100000c0     0 NOTYPE  LOCAL  DEFAULT    8 __c6xabi_DSBT_BASE
+    22: 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
+    23: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+    24: 100000e4     4 OBJECT  GLOBAL DEFAULT    9 g2
+    25: 10000008    52 FUNC    GLOBAL DEFAULT    7 sub0
+    26: 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
+    27: 10000040    52 FUNC    GLOBAL DEFAULT    7 sub
diff --git a/ld/testsuite/ld-tic6x/static-app-1b.rd b/ld/testsuite/ld-tic6x/static-app-1b.rd
index 27d2d235f0..8fa34377e3 100644
--- a/ld/testsuite/ld-tic6x/static-app-1b.rd
+++ b/ld/testsuite/ld-tic6x/static-app-1b.rd
@@ -3,20 +3,20 @@ There are 15 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 00003c 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          0000803c 00103c 0000a0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          000080dc 0010dc 00001d 00   A  0   0  1
-  \[ 4\] \.rela\.got         RELA            000080fc 0010fc 000024 0c  AI  2   8  4
-  \[ 5\] \.rela\.neardata    RELA            00008120 001120 000030 0c  AI  2   9  4
-  \[ 6\] \.dynamic          DYNAMIC         00008150 001150 000090 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000038 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008038 001038 000090 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          000080c8 0010c8 00000a 00   A  0   0  1
+  \[ 4\] \.rela\.got         RELA            000080d4 0010d4 000024 0c  AI  2   8  4
+  \[ 5\] \.rela\.neardata    RELA            000080f8 0010f8 000030 0c  AI  2   9  4
+  \[ 6\] \.dynamic          DYNAMIC         00008128 001128 000090 08  WA  3   0  4
   \[ 7\] \.text             PROGBITS        10000000 002000 0000c0 00  AX  0   0 32
   \[ 8\] \.got              PROGBITS        100000c0 0020c0 000020 00  WA  0   0  4
   \[ 9\] \.neardata         PROGBITS        100000e0 0020e0 000014 00  WA  0   0  4
   \[10\] \.bss              NOBITS          100000f4 0020f4 000004 00  WA  0   0  4
   \[11\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 0020f4 000019 00      0   0  1
-  \[12\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     13  [0-9]+  4
-  \[13\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[14\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 000071 00      0   0  1
+  \[12\] \.symtab           SYMTAB          00000000 002110 0001c0 10     13  22  4
+  \[13\] \.strtab           STRTAB          00000000 0022d0 000078 00      0   0  1
+  \[14\] \.shstrtab         STRTAB          00000000 002348 000071 00      0   0  1
 Key to Flags:
 #...
 
@@ -26,9 +26,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x001e0 0x001e0 RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x001b8 0x001b8 RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x000f4 0x000f8 RWE 0x1000
-  DYNAMIC        0x001150 0x00008150 0x00008150 0x00090 0x00090 RW  0x4
+  DYNAMIC        0x001128 0x00008128 0x00008128 0x00090 0x00090 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -38,36 +38,36 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x1150 contains 13 entries:
+Dynamic section at offset 0x1128 contains 13 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x80dc
- 0x00000006 \(SYMTAB\)                     0x803c
- 0x0000000a \(STRSZ\)                      29 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x80c8
+ 0x00000006 \(SYMTAB\)                     0x8038
+ 0x0000000a \(STRSZ\)                      10 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x00000015 \(DEBUG\)                      0x0
  0x70000000 \(C6000_DSBT_BASE\)            0x100000c0
  0x70000001 \(C6000_DSBT_SIZE\)            0x3
  0x70000003 \(C6000_DSBT_INDEX\)           0x0
- 0x00000007 \(RELA\)                       0x80fc
+ 0x00000007 \(RELA\)                       0x80d4
  0x00000008 \(RELASZ\)                     84 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.got' at offset 0x10fc contains 3 entries:
+Relocation section '\.rela\.got' at offset 0x10d4 contains 3 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 100000d8  00000401 R_C6000_ABS32          100000f4   \.bss \+ 0
-100000d4  00000701 R_C6000_ABS32          100000e8   b \+ 0
-100000dc  00000901 R_C6000_ABS32          100000e0   a \+ 0
+100000d4  00000601 R_C6000_ABS32          100000e8   b \+ 0
+100000dc  00000801 R_C6000_ABS32          100000e0   a \+ 0
 
-Relocation section '\.rela\.neardata' at offset 0x1120 contains 4 entries:
+Relocation section '\.rela\.neardata' at offset 0x10f8 contains 4 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 100000e0  00000101 R_C6000_ABS32          10000000   \.text \+ 8
-100000e4  00000801 R_C6000_ABS32          00000000   g1 \+ 0
-100000ec  00000801 R_C6000_ABS32          00000000   g1 \+ 0
+100000e4  00000701 R_C6000_ABS32          00000000   g1 \+ 0
+100000ec  00000701 R_C6000_ABS32          00000000   g1 \+ 0
 100000f0  00000301 R_C6000_ABS32          100000e0   \.neardata \+ 4
 
-Symbol table '\.dynsym' contains 10 entries:
+Symbol table '\.dynsym' contains 9 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000000     0 SECTION LOCAL  DEFAULT    7 
@@ -75,38 +75,37 @@ Symbol table '\.dynsym' contains 10 entries:
      3: 100000e0     0 SECTION LOCAL  DEFAULT    9 
      4: 100000f4     0 SECTION LOCAL  DEFAULT   10 
      5: 100000f4     4 OBJECT  LOCAL  DEFAULT   10 c
-     6: 100000c0     0 NOTYPE  LOCAL  DEFAULT    8 __c6xabi_DSBT_BASE
-     7: 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
-     8: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-     9: 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
+     6: 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
+     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+     8: 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 28 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 0000803c     0 SECTION LOCAL  DEFAULT    2 
-.* 000080dc     0 SECTION LOCAL  DEFAULT    3 
-.* 000080fc     0 SECTION LOCAL  DEFAULT    4 
-.* 00008120     0 SECTION LOCAL  DEFAULT    5 
-.* 00008150     0 SECTION LOCAL  DEFAULT    6 
-.* 10000000     0 SECTION LOCAL  DEFAULT    7 
-.* 100000c0     0 SECTION LOCAL  DEFAULT    8 
-.* 100000e0     0 SECTION LOCAL  DEFAULT    9 
-.* 100000f4     0 SECTION LOCAL  DEFAULT   10 
-.* 00000000     0 SECTION LOCAL  DEFAULT   11 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000000     0 FUNC    LOCAL  HIDDEN     7 sub1
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000080     0 NOTYPE  LOCAL  DEFAULT    7 fish
-.* 100000ec     8 OBJECT  LOCAL  DEFAULT    9 w
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 00008150     0 OBJECT  LOCAL  DEFAULT    6 _DYNAMIC
-.* 100000f4     4 OBJECT  LOCAL  DEFAULT   10 c
-.* 100000cc     0 OBJECT  LOCAL  DEFAULT    8 _GLOBAL_OFFSET_TABLE_
-.* 100000c0     0 NOTYPE  LOCAL  DEFAULT    8 __c6xabi_DSBT_BASE
-.* 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-.* 100000e4     4 OBJECT  GLOBAL DEFAULT    9 g2
-.* 10000008    52 FUNC    GLOBAL DEFAULT    7 sub0
-.* 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
-.* 10000040    52 FUNC    GLOBAL DEFAULT    7 sub
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008038     0 SECTION LOCAL  DEFAULT    2 
+     3: 000080c8     0 SECTION LOCAL  DEFAULT    3 
+     4: 000080d4     0 SECTION LOCAL  DEFAULT    4 
+     5: 000080f8     0 SECTION LOCAL  DEFAULT    5 
+     6: 00008128     0 SECTION LOCAL  DEFAULT    6 
+     7: 10000000     0 SECTION LOCAL  DEFAULT    7 
+     8: 100000c0     0 SECTION LOCAL  DEFAULT    8 
+     9: 100000e0     0 SECTION LOCAL  DEFAULT    9 
+    10: 100000f4     0 SECTION LOCAL  DEFAULT   10 
+    11: 00000000     0 SECTION LOCAL  DEFAULT   11 
+    12: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-1\.o
+    13: 10000000     0 FUNC    LOCAL  HIDDEN     7 sub1
+    14: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-app-1\.o
+    15: 10000080     0 NOTYPE  LOCAL  DEFAULT    7 fish
+    16: 100000ec     8 OBJECT  LOCAL  DEFAULT    9 w
+    17: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    18: 00008128     0 OBJECT  LOCAL  DEFAULT    6 _DYNAMIC
+    19: 100000f4     4 OBJECT  LOCAL  DEFAULT   10 c
+    20: 100000cc     0 OBJECT  LOCAL  DEFAULT    8 _GLOBAL_OFFSET_TABLE_
+    21: 100000c0     0 NOTYPE  LOCAL  DEFAULT    8 __c6xabi_DSBT_BASE
+    22: 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
+    23: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+    24: 100000e4     4 OBJECT  GLOBAL DEFAULT    9 g2
+    25: 10000008    52 FUNC    GLOBAL DEFAULT    7 sub0
+    26: 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
+    27: 10000040    52 FUNC    GLOBAL DEFAULT    7 sub
diff --git a/ld/testsuite/ld-tic6x/static-app-1r.rd b/ld/testsuite/ld-tic6x/static-app-1r.rd
index 9f3ed9bae3..9b05b466ed 100644
--- a/ld/testsuite/ld-tic6x/static-app-1r.rd
+++ b/ld/testsuite/ld-tic6x/static-app-1r.rd
@@ -3,20 +3,20 @@ There are 15 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 00003c 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          0000803c 00103c 0000a0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          000080dc 0010dc 00001d 00   A  0   0  1
-  \[ 4\] \.rela\.got         RELA            000080fc 0010fc 000024 0c  AI  2   8  4
-  \[ 5\] \.rela\.neardata    RELA            00008120 001120 000018 0c  AI  2   9  4
-  \[ 6\] \.dynamic          DYNAMIC         00008138 001138 000090 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000038 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008038 001038 000090 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          000080c8 0010c8 00000a 00   A  0   0  1
+  \[ 4\] \.rela\.got         RELA            000080d4 0010d4 000024 0c  AI  2   8  4
+  \[ 5\] \.rela\.neardata    RELA            000080f8 0010f8 000018 0c  AI  2   9  4
+  \[ 6\] \.dynamic          DYNAMIC         00008110 001110 000090 08  WA  3   0  4
   \[ 7\] \.text             PROGBITS        10000000 002000 0000c0 00  AX  0   0 32
   \[ 8\] \.got              PROGBITS        100000c0 0020c0 000020 00  WA  0   0  4
   \[ 9\] \.neardata         PROGBITS        100000e0 0020e0 00000c 00  WA  0   0  4
   \[10\] \.bss              NOBITS          100000ec 0020ec 000004 00  WA  0   0  4
   \[11\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 0020ec 000019 00      0   0  1
-  \[12\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     13  [0-9]+  4
-  \[13\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[14\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 000071 00      0   0  1
+  \[12\] \.symtab           SYMTAB          00000000 002108 0001b0 10     13  21  4
+  \[13\] \.strtab           STRTAB          00000000 0022b8 000077 00      0   0  1
+  \[14\] \.shstrtab         STRTAB          00000000 00232f 000071 00      0   0  1
 Key to Flags:
 #...
 
@@ -26,9 +26,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x001c8 0x001c8 RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x001a0 0x001a0 RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x000ec 0x000f0 RWE 0x1000
-  DYNAMIC        0x001138 0x00008138 0x00008138 0x00090 0x00090 RW  0x4
+  DYNAMIC        0x001110 0x00008110 0x00008110 0x00090 0x00090 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -38,34 +38,34 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x1138 contains 13 entries:
+Dynamic section at offset 0x1110 contains 13 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x80dc
- 0x00000006 \(SYMTAB\)                     0x803c
- 0x0000000a \(STRSZ\)                      29 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x80c8
+ 0x00000006 \(SYMTAB\)                     0x8038
+ 0x0000000a \(STRSZ\)                      10 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x00000015 \(DEBUG\)                      0x0
  0x70000000 \(C6000_DSBT_BASE\)            0x100000c0
  0x70000001 \(C6000_DSBT_SIZE\)            0x3
  0x70000003 \(C6000_DSBT_INDEX\)           0x0
- 0x00000007 \(RELA\)                       0x80fc
+ 0x00000007 \(RELA\)                       0x80d4
  0x00000008 \(RELASZ\)                     60 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.got' at offset 0x10fc contains 3 entries:
+Relocation section '\.rela\.got' at offset 0x10d4 contains 3 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 100000d8  00000401 R_C6000_ABS32          100000ec   \.bss \+ 0
-100000d4  00000701 R_C6000_ABS32          100000e8   b \+ 0
-100000dc  00000901 R_C6000_ABS32          100000e0   a \+ 0
+100000d4  00000601 R_C6000_ABS32          100000e8   b \+ 0
+100000dc  00000801 R_C6000_ABS32          100000e0   a \+ 0
 
-Relocation section '\.rela\.neardata' at offset 0x1120 contains 2 entries:
+Relocation section '\.rela\.neardata' at offset 0x10f8 contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 100000e0  00000101 R_C6000_ABS32          10000000   \.text \+ 8
-100000e4  00000801 R_C6000_ABS32          00000000   g1 \+ 0
+100000e4  00000701 R_C6000_ABS32          00000000   g1 \+ 0
 
-Symbol table '\.dynsym' contains 10 entries:
+Symbol table '\.dynsym' contains 9 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000000     0 SECTION LOCAL  DEFAULT    7 
@@ -73,37 +73,36 @@ Symbol table '\.dynsym' contains 10 entries:
      3: 100000e0     0 SECTION LOCAL  DEFAULT    9 
      4: 100000ec     0 SECTION LOCAL  DEFAULT   10 
      5: 100000ec     4 OBJECT  LOCAL  DEFAULT   10 c
-     6: 100000c0     0 NOTYPE  LOCAL  DEFAULT    8 __c6xabi_DSBT_BASE
-     7: 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
-     8: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-     9: 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
+     6: 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
+     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+     8: 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 27 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 0000803c     0 SECTION LOCAL  DEFAULT    2 
-.* 000080dc     0 SECTION LOCAL  DEFAULT    3 
-.* 000080fc     0 SECTION LOCAL  DEFAULT    4 
-.* 00008120     0 SECTION LOCAL  DEFAULT    5 
-.* 00008138     0 SECTION LOCAL  DEFAULT    6 
-.* 10000000     0 SECTION LOCAL  DEFAULT    7 
-.* 100000c0     0 SECTION LOCAL  DEFAULT    8 
-.* 100000e0     0 SECTION LOCAL  DEFAULT    9 
-.* 100000ec     0 SECTION LOCAL  DEFAULT   10 
-.* 00000000     0 SECTION LOCAL  DEFAULT   11 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000000     0 FUNC    LOCAL  HIDDEN     7 sub1
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000080     0 NOTYPE  LOCAL  DEFAULT    7 fish
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 00008138     0 OBJECT  LOCAL  DEFAULT    6 _DYNAMIC
-.* 100000ec     4 OBJECT  LOCAL  DEFAULT   10 c
-.* 100000cc     0 OBJECT  LOCAL  DEFAULT    8 _GLOBAL_OFFSET_TABLE_
-.* 100000c0     0 NOTYPE  LOCAL  DEFAULT    8 __c6xabi_DSBT_BASE
-.* 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-.* 100000e4     4 OBJECT  GLOBAL DEFAULT    9 g2
-.* 10000008    52 FUNC    GLOBAL DEFAULT    7 sub0
-.* 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
-.* 10000040    52 FUNC    GLOBAL DEFAULT    7 sub
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008038     0 SECTION LOCAL  DEFAULT    2 
+     3: 000080c8     0 SECTION LOCAL  DEFAULT    3 
+     4: 000080d4     0 SECTION LOCAL  DEFAULT    4 
+     5: 000080f8     0 SECTION LOCAL  DEFAULT    5 
+     6: 00008110     0 SECTION LOCAL  DEFAULT    6 
+     7: 10000000     0 SECTION LOCAL  DEFAULT    7 
+     8: 100000c0     0 SECTION LOCAL  DEFAULT    8 
+     9: 100000e0     0 SECTION LOCAL  DEFAULT    9 
+    10: 100000ec     0 SECTION LOCAL  DEFAULT   10 
+    11: 00000000     0 SECTION LOCAL  DEFAULT   11 
+    12: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-1\.o
+    13: 10000000     0 FUNC    LOCAL  HIDDEN     7 sub1
+    14: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-app-1r\.o
+    15: 10000080     0 NOTYPE  LOCAL  DEFAULT    7 fish
+    16: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    17: 00008110     0 OBJECT  LOCAL  DEFAULT    6 _DYNAMIC
+    18: 100000ec     4 OBJECT  LOCAL  DEFAULT   10 c
+    19: 100000cc     0 OBJECT  LOCAL  DEFAULT    8 _GLOBAL_OFFSET_TABLE_
+    20: 100000c0     0 NOTYPE  LOCAL  DEFAULT    8 __c6xabi_DSBT_BASE
+    21: 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
+    22: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+    23: 100000e4     4 OBJECT  GLOBAL DEFAULT    9 g2
+    24: 10000008    52 FUNC    GLOBAL DEFAULT    7 sub0
+    25: 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
+    26: 10000040    52 FUNC    GLOBAL DEFAULT    7 sub
diff --git a/ld/testsuite/ld-tic6x/static-app-1rb.rd b/ld/testsuite/ld-tic6x/static-app-1rb.rd
index 9f3ed9bae3..9b05b466ed 100644
--- a/ld/testsuite/ld-tic6x/static-app-1rb.rd
+++ b/ld/testsuite/ld-tic6x/static-app-1rb.rd
@@ -3,20 +3,20 @@ There are 15 section headers, starting at offset .*:
 Section Headers:
   \[Nr\] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            00000000 000000 000000 00      0   0  0
-  \[ 1\] \.hash             HASH            00008000 001000 00003c 04   A  2   0  4
-  \[ 2\] \.dynsym           DYNSYM          0000803c 00103c 0000a0 10   A  3   7  4
-  \[ 3\] \.dynstr           STRTAB          000080dc 0010dc 00001d 00   A  0   0  1
-  \[ 4\] \.rela\.got         RELA            000080fc 0010fc 000024 0c  AI  2   8  4
-  \[ 5\] \.rela\.neardata    RELA            00008120 001120 000018 0c  AI  2   9  4
-  \[ 6\] \.dynamic          DYNAMIC         00008138 001138 000090 08  WA  3   0  4
+  \[ 1\] \.hash             HASH            00008000 001000 000038 04   A  2   0  4
+  \[ 2\] \.dynsym           DYNSYM          00008038 001038 000090 10   A  3   6  4
+  \[ 3\] \.dynstr           STRTAB          000080c8 0010c8 00000a 00   A  0   0  1
+  \[ 4\] \.rela\.got         RELA            000080d4 0010d4 000024 0c  AI  2   8  4
+  \[ 5\] \.rela\.neardata    RELA            000080f8 0010f8 000018 0c  AI  2   9  4
+  \[ 6\] \.dynamic          DYNAMIC         00008110 001110 000090 08  WA  3   0  4
   \[ 7\] \.text             PROGBITS        10000000 002000 0000c0 00  AX  0   0 32
   \[ 8\] \.got              PROGBITS        100000c0 0020c0 000020 00  WA  0   0  4
   \[ 9\] \.neardata         PROGBITS        100000e0 0020e0 00000c 00  WA  0   0  4
   \[10\] \.bss              NOBITS          100000ec 0020ec 000004 00  WA  0   0  4
   \[11\] \.c6xabi\.attributes C6000_ATTRIBUTES 00000000 0020ec 000019 00      0   0  1
-  \[12\] \.symtab           SYMTAB          00000000 [0-9a-f]+ [0-9a-f]+ 10     13  [0-9]+  4
-  \[13\] \.strtab           STRTAB          00000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1
-  \[14\] \.shstrtab         STRTAB          00000000 [0-9a-f]+ 000071 00      0   0  1
+  \[12\] \.symtab           SYMTAB          00000000 002108 0001b0 10     13  21  4
+  \[13\] \.strtab           STRTAB          00000000 0022b8 000077 00      0   0  1
+  \[14\] \.shstrtab         STRTAB          00000000 00232f 000071 00      0   0  1
 Key to Flags:
 #...
 
@@ -26,9 +26,9 @@ There are 4 program headers, starting at offset 52
 
 Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  LOAD           0x001000 0x00008000 0x00008000 0x001c8 0x001c8 RW  0x1000
+  LOAD           0x001000 0x00008000 0x00008000 0x001a0 0x001a0 RW  0x1000
   LOAD           0x002000 0x10000000 0x10000000 0x000ec 0x000f0 RWE 0x1000
-  DYNAMIC        0x001138 0x00008138 0x00008138 0x00090 0x00090 RW  0x4
+  DYNAMIC        0x001110 0x00008110 0x00008110 0x00090 0x00090 RW  0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
 
  Section to Segment mapping:
@@ -38,34 +38,34 @@ Program Headers:
    02     \.dynamic 
    03     
 
-Dynamic section at offset 0x1138 contains 13 entries:
+Dynamic section at offset 0x1110 contains 13 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       0x8000
- 0x00000005 \(STRTAB\)                     0x80dc
- 0x00000006 \(SYMTAB\)                     0x803c
- 0x0000000a \(STRSZ\)                      29 \(bytes\)
+ 0x00000005 \(STRTAB\)                     0x80c8
+ 0x00000006 \(SYMTAB\)                     0x8038
+ 0x0000000a \(STRSZ\)                      10 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x00000015 \(DEBUG\)                      0x0
  0x70000000 \(C6000_DSBT_BASE\)            0x100000c0
  0x70000001 \(C6000_DSBT_SIZE\)            0x3
  0x70000003 \(C6000_DSBT_INDEX\)           0x0
- 0x00000007 \(RELA\)                       0x80fc
+ 0x00000007 \(RELA\)                       0x80d4
  0x00000008 \(RELASZ\)                     60 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
  0x00000000 \(NULL\)                       0x0
 
-Relocation section '\.rela\.got' at offset 0x10fc contains 3 entries:
+Relocation section '\.rela\.got' at offset 0x10d4 contains 3 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 100000d8  00000401 R_C6000_ABS32          100000ec   \.bss \+ 0
-100000d4  00000701 R_C6000_ABS32          100000e8   b \+ 0
-100000dc  00000901 R_C6000_ABS32          100000e0   a \+ 0
+100000d4  00000601 R_C6000_ABS32          100000e8   b \+ 0
+100000dc  00000801 R_C6000_ABS32          100000e0   a \+ 0
 
-Relocation section '\.rela\.neardata' at offset 0x1120 contains 2 entries:
+Relocation section '\.rela\.neardata' at offset 0x10f8 contains 2 entries:
  Offset     Info    Type                Sym\. Value  Symbol's Name \+ Addend
 100000e0  00000101 R_C6000_ABS32          10000000   \.text \+ 8
-100000e4  00000801 R_C6000_ABS32          00000000   g1 \+ 0
+100000e4  00000701 R_C6000_ABS32          00000000   g1 \+ 0
 
-Symbol table '\.dynsym' contains 10 entries:
+Symbol table '\.dynsym' contains 9 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 10000000     0 SECTION LOCAL  DEFAULT    7 
@@ -73,37 +73,36 @@ Symbol table '\.dynsym' contains 10 entries:
      3: 100000e0     0 SECTION LOCAL  DEFAULT    9 
      4: 100000ec     0 SECTION LOCAL  DEFAULT   10 
      5: 100000ec     4 OBJECT  LOCAL  DEFAULT   10 c
-     6: 100000c0     0 NOTYPE  LOCAL  DEFAULT    8 __c6xabi_DSBT_BASE
-     7: 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
-     8: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-     9: 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
+     6: 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
+     7: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+     8: 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
 
-Symbol table '\.symtab' contains [0-9]+ entries:
+Symbol table '\.symtab' contains 27 entries:
    Num:    Value  Size Type    Bind   Vis      Ndx Name
-.* 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
-.* 00008000     0 SECTION LOCAL  DEFAULT    1 
-.* 0000803c     0 SECTION LOCAL  DEFAULT    2 
-.* 000080dc     0 SECTION LOCAL  DEFAULT    3 
-.* 000080fc     0 SECTION LOCAL  DEFAULT    4 
-.* 00008120     0 SECTION LOCAL  DEFAULT    5 
-.* 00008138     0 SECTION LOCAL  DEFAULT    6 
-.* 10000000     0 SECTION LOCAL  DEFAULT    7 
-.* 100000c0     0 SECTION LOCAL  DEFAULT    8 
-.* 100000e0     0 SECTION LOCAL  DEFAULT    9 
-.* 100000ec     0 SECTION LOCAL  DEFAULT   10 
-.* 00000000     0 SECTION LOCAL  DEFAULT   11 
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000000     0 FUNC    LOCAL  HIDDEN     7 sub1
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 10000080     0 NOTYPE  LOCAL  DEFAULT    7 fish
-.* 00000000     0 FILE    LOCAL  DEFAULT  ABS .*
-.* 00008138     0 OBJECT  LOCAL  DEFAULT    6 _DYNAMIC
-.* 100000ec     4 OBJECT  LOCAL  DEFAULT   10 c
-.* 100000cc     0 OBJECT  LOCAL  DEFAULT    8 _GLOBAL_OFFSET_TABLE_
-.* 100000c0     0 NOTYPE  LOCAL  DEFAULT    8 __c6xabi_DSBT_BASE
-.* 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
-.* 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
-.* 100000e4     4 OBJECT  GLOBAL DEFAULT    9 g2
-.* 10000008    52 FUNC    GLOBAL DEFAULT    7 sub0
-.* 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
-.* 10000040    52 FUNC    GLOBAL DEFAULT    7 sub
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00008000     0 SECTION LOCAL  DEFAULT    1 
+     2: 00008038     0 SECTION LOCAL  DEFAULT    2 
+     3: 000080c8     0 SECTION LOCAL  DEFAULT    3 
+     4: 000080d4     0 SECTION LOCAL  DEFAULT    4 
+     5: 000080f8     0 SECTION LOCAL  DEFAULT    5 
+     6: 00008110     0 SECTION LOCAL  DEFAULT    6 
+     7: 10000000     0 SECTION LOCAL  DEFAULT    7 
+     8: 100000c0     0 SECTION LOCAL  DEFAULT    8 
+     9: 100000e0     0 SECTION LOCAL  DEFAULT    9 
+    10: 100000ec     0 SECTION LOCAL  DEFAULT   10 
+    11: 00000000     0 SECTION LOCAL  DEFAULT   11 
+    12: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-1\.o
+    13: 10000000     0 FUNC    LOCAL  HIDDEN     7 sub1
+    14: 00000000     0 FILE    LOCAL  DEFAULT  ABS tmpdir/shlib-app-1r\.o
+    15: 10000080     0 NOTYPE  LOCAL  DEFAULT    7 fish
+    16: 00000000     0 FILE    LOCAL  DEFAULT  ABS 
+    17: 00008110     0 OBJECT  LOCAL  DEFAULT    6 _DYNAMIC
+    18: 100000ec     4 OBJECT  LOCAL  DEFAULT   10 c
+    19: 100000cc     0 OBJECT  LOCAL  DEFAULT    8 _GLOBAL_OFFSET_TABLE_
+    20: 100000c0     0 NOTYPE  LOCAL  DEFAULT    8 __c6xabi_DSBT_BASE
+    21: 100000e8     4 OBJECT  GLOBAL DEFAULT    9 b
+    22: 00000000     0 NOTYPE  WEAK   DEFAULT  UND g1
+    23: 100000e4     4 OBJECT  GLOBAL DEFAULT    9 g2
+    24: 10000008    52 FUNC    GLOBAL DEFAULT    7 sub0
+    25: 100000e0     4 OBJECT  GLOBAL DEFAULT    9 a
+    26: 10000040    52 FUNC    GLOBAL DEFAULT    7 sub

Patch

diff --git a/bfd/aout-target.h b/bfd/aout-target.h
index f245b1e885..9123afcef6 100644
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -512,6 +512,9 @@  MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 #ifndef MY_bfd_define_common_symbol
 #define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
 #endif
+#ifndef MY_bfd_link_hide_symbol
+#define MY_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
+#endif
 #ifndef MY_bfd_define_start_stop
 #define MY_bfd_define_start_stop bfd_generic_define_start_stop
 #endif
diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c
index 31248ecd91..ddeaaaa98f 100644
--- a/bfd/aout-tic30.c
+++ b/bfd/aout-tic30.c
@@ -967,6 +967,9 @@  tic30_aout_set_arch_mach (bfd *abfd,
 #ifndef MY_bfd_define_common_symbol
 #define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
 #endif
+#ifndef MY_bfd_link_hide_symbol
+#define MY_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
+#endif
 #ifndef MY_bfd_define_start_stop
 #define MY_bfd_define_start_stop bfd_generic_define_start_stop
 #endif
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 9d11dd0c39..62a2c249b4 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7685,6 +7685,7 @@  typedef struct bfd_target
   NAME##_bfd_discard_group, \
   NAME##_section_already_linked, \
   NAME##_bfd_define_common_symbol, \
+  NAME##_bfd_link_hide_symbol, \
   NAME##_bfd_define_start_stop
 
   int         (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
@@ -7751,6 +7752,10 @@  typedef struct bfd_target
   bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
                                             struct bfd_link_hash_entry *);
 
+  /* Hide a symbol.  */
+  void (*_bfd_link_hide_symbol) (bfd *, struct bfd_link_info *,
+                                 struct bfd_link_hash_entry *);
+
   /* Define a __start, __stop, .startof. or .sizeof. symbol.  */
   struct bfd_link_hash_entry *
               (*_bfd_define_start_stop) (struct bfd_link_info *, const char *,
@@ -7834,6 +7839,13 @@  bfd_boolean bfd_generic_define_common_symbol
 #define bfd_define_common_symbol(output_bfd, info, h) \
        BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h))
 
+void _bfd_generic_link_hide_symbol
+   (bfd *output_bfd, struct bfd_link_info *info,
+    struct bfd_link_hash_entry *h);
+
+#define bfd_link_hide_symbol(output_bfd, info, h) \
+       BFD_SEND (output_bfd, _bfd_link_hide_symbol, (output_bfd, info, h))
+
 struct bfd_link_hash_entry *bfd_generic_define_start_stop
    (struct bfd_link_info *info,
     const char *symbol, asection *sec);
diff --git a/bfd/binary.c b/bfd/binary.c
index 0713f5a496..c467b429f6 100644
--- a/bfd/binary.c
+++ b/bfd/binary.c
@@ -310,6 +310,7 @@  binary_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define binary_bfd_discard_group		   bfd_generic_discard_group
 #define binary_section_already_linked		  _bfd_generic_section_already_linked
 #define binary_bfd_define_common_symbol		   bfd_generic_define_common_symbol
+#define binary_bfd_link_hide_symbol		   _bfd_generic_link_hide_symbol
 #define binary_bfd_define_start_stop		   bfd_generic_define_start_stop
 #define binary_bfd_link_hash_table_create	  _bfd_generic_link_hash_table_create
 #define binary_bfd_link_just_syms		  _bfd_generic_link_just_syms
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index 0e39f317ed..699398f494 100644
--- a/bfd/coff-alpha.c
+++ b/bfd/coff-alpha.c
@@ -2394,6 +2394,7 @@  static const struct ecoff_backend_data alpha_ecoff_backend_data =
 #define _bfd_ecoff_section_already_linked \
   _bfd_coff_section_already_linked
 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define _bfd_ecoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define _bfd_ecoff_bfd_define_start_stop    bfd_generic_define_start_stop
 #define _bfd_ecoff_bfd_link_check_relocs    _bfd_generic_link_check_relocs
 
diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c
index 3a0163a256..d83e10d4b7 100644
--- a/bfd/coff-mips.c
+++ b/bfd/coff-mips.c
@@ -1420,6 +1420,7 @@  static const struct ecoff_backend_data mips_ecoff_backend_data =
 #define _bfd_ecoff_section_already_linked \
   _bfd_coff_section_already_linked
 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define _bfd_ecoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define _bfd_ecoff_bfd_define_start_stop bfd_generic_define_start_stop
 #define _bfd_ecoff_set_reloc _bfd_generic_set_reloc
 
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index d8db1f3894..053ab18940 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -4045,6 +4045,7 @@  const struct xcoff_dwsect_name xcoff_dwsect_names[] = {
 #define _bfd_xcoff_bfd_discard_group bfd_generic_discard_group
 #define _bfd_xcoff_section_already_linked _bfd_generic_section_already_linked
 #define _bfd_xcoff_bfd_define_common_symbol _bfd_xcoff_define_common_symbol
+#define _bfd_xcoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define _bfd_xcoff_bfd_define_start_stop    bfd_generic_define_start_stop
 #define _bfd_xcoff_bfd_link_check_relocs    _bfd_generic_link_check_relocs
 
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 78f14a09f4..2135001f19 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -2786,6 +2786,7 @@  const bfd_target rs6000_xcoff64_vec =
     bfd_generic_discard_group,
     _bfd_generic_section_already_linked,
     _bfd_xcoff_define_common_symbol,
+    _bfd_generic_link_hide_symbol,
     bfd_generic_define_start_stop,
 
     /* Dynamic */
@@ -3047,6 +3048,7 @@  const bfd_target rs6000_xcoff64_aix_vec =
     bfd_generic_discard_group,
     _bfd_generic_section_already_linked,
     _bfd_xcoff_define_common_symbol,
+    _bfd_generic_link_hide_symbol,
     bfd_generic_define_start_stop,
 
     /* Dynamic */
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 6ad991cf9d..2ca32059cb 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -5749,6 +5749,10 @@  static bfd_coff_backend_data bigobj_swap_table =
 #define coff_bfd_define_common_symbol	    bfd_generic_define_common_symbol
 #endif
 
+#ifndef coff_bfd_link_hide_symbol
+#define coff_bfd_link_hide_symbol	    _bfd_generic_link_hide_symbol
+#endif
+
 #ifndef coff_bfd_define_start_stop
 #define coff_bfd_define_start_stop	    bfd_generic_define_start_stop
 #endif
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 7b746900ba..e051c9c089 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2086,6 +2086,8 @@  extern void _bfd_elf_link_hash_copy_indirect
    struct elf_link_hash_entry *);
 extern void _bfd_elf_link_hash_hide_symbol
   (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
+extern void _bfd_elf_link_hide_symbol
+  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
 extern bfd_boolean _bfd_elf_link_hash_fixup_symbol
   (struct bfd_link_info *, struct elf_link_hash_entry *);
 extern bfd_boolean _bfd_elf_link_hash_table_init
diff --git a/bfd/elflink.c b/bfd/elflink.c
index ce3765e45b..ff445cf9bc 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -7429,6 +7429,18 @@  _bfd_elf_link_hash_hide_symbol (struct bfd_link_info *info,
     }
 }
 
+/* Hide a symbol. */
+
+void
+_bfd_elf_link_hide_symbol (bfd *output_bfd ATTRIBUTE_UNUSED,
+			   struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			   struct bfd_link_hash_entry *h)
+{
+  _bfd_elf_link_hash_hide_symbol (info,
+				  (struct elf_link_hash_entry *) h,
+				  TRUE);
+}
+
 /* Initialize an ELF linker hash table.  *TABLE has been zeroed by our
    caller.  */
 
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 89efed3a5e..a86ea587a2 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -205,6 +205,10 @@ 
 #define bfd_elfNN_bfd_define_common_symbol bfd_generic_define_common_symbol
 #endif
 
+#ifndef bfd_elfNN_bfd_link_hide_symbol
+#define bfd_elfNN_bfd_link_hide_symbol _bfd_elf_link_hide_symbol
+#endif
+
 #ifndef bfd_elfNN_bfd_lookup_section_flags
 #define bfd_elfNN_bfd_lookup_section_flags bfd_elf_lookup_section_flags
 #endif
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index f4dbddf15e..936b4c67d2 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -2047,11 +2047,7 @@  _bfd_x86_elf_link_symbol_references_local (struct bfd_link_info *info,
       return TRUE;
     }
 
-  /* Symbols created by HIDDEN and PROVIDE_HIDDEN assignments in linker
-     script aren't forced local here yet.  */
-  if (!h->root.ldscript_def)
-    eh->local_ref = 1;
-
+  eh->local_ref = 1;
   return FALSE;
 }
 
diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c
index a47acf4953..77e9880ced 100644
--- a/bfd/i386msdos.c
+++ b/bfd/i386msdos.c
@@ -230,6 +230,7 @@  msdos_set_section_contents (bfd *abfd,
 #define msdos_section_already_linked \
   _bfd_generic_section_already_linked
 #define msdos_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define msdos_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define msdos_bfd_define_start_stop bfd_generic_define_start_stop
 #define msdos_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define msdos_bfd_link_add_symbols _bfd_generic_link_add_symbols
diff --git a/bfd/ihex.c b/bfd/ihex.c
index 096c19ce2e..80bcbe9f90 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -943,6 +943,7 @@  ihex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define ihex_bfd_discard_group			  bfd_generic_discard_group
 #define ihex_section_already_linked		  _bfd_generic_section_already_linked
 #define ihex_bfd_define_common_symbol		  bfd_generic_define_common_symbol
+#define ihex_bfd_link_hide_symbol		  _bfd_generic_link_hide_symbol
 #define ihex_bfd_define_start_stop		  bfd_generic_define_start_stop
 #define ihex_bfd_link_hash_table_create		  _bfd_generic_link_hash_table_create
 #define ihex_bfd_link_add_symbols		  _bfd_generic_link_add_symbols
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index bb3cf48f70..9796f2d67e 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -534,6 +534,8 @@  extern bfd_boolean _bfd_nolink_section_already_linked
 extern bfd_boolean _bfd_nolink_bfd_define_common_symbol
   (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *)
   ATTRIBUTE_HIDDEN;
+#define _bfd_nolink_bfd_link_hide_symbol \
+  _bfd_generic_link_hide_symbol
 extern struct bfd_link_hash_entry *_bfd_nolink_bfd_define_start_stop
   (struct bfd_link_info *, const char *, asection *) ATTRIBUTE_HIDDEN;
 #define _bfd_nolink_bfd_link_check_relocs \
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index b810c40c40..f357e0e4ab 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -539,6 +539,8 @@  extern bfd_boolean _bfd_nolink_section_already_linked
 extern bfd_boolean _bfd_nolink_bfd_define_common_symbol
   (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *)
   ATTRIBUTE_HIDDEN;
+#define _bfd_nolink_bfd_link_hide_symbol \
+  _bfd_generic_link_hide_symbol
 extern struct bfd_link_hash_entry *_bfd_nolink_bfd_define_start_stop
   (struct bfd_link_info *, const char *, asection *) ATTRIBUTE_HIDDEN;
 #define _bfd_nolink_bfd_link_check_relocs \
diff --git a/bfd/linker.c b/bfd/linker.c
index 3019919a91..6b4c8e57e1 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -3110,6 +3110,32 @@  bfd_generic_define_common_symbol (bfd *output_bfd,
   return TRUE;
 }
 
+/*
+FUNCTION
+	_bfd_generic_link_hide_symbol
+
+SYNOPSIS
+	void _bfd_generic_link_hide_symbol
+	  (bfd *output_bfd, struct bfd_link_info *info,
+	   struct bfd_link_hash_entry *h);
+
+DESCRIPTION
+	Hide symbol @var{h}.
+	This is an internal function.  It should not be called from
+	outside the BFD library.
+
+.#define bfd_link_hide_symbol(output_bfd, info, h) \
+.	BFD_SEND (output_bfd, _bfd_link_hide_symbol, (output_bfd, info, h))
+.
+*/
+
+void
+_bfd_generic_link_hide_symbol (bfd *output_bfd ATTRIBUTE_UNUSED,
+			       struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			       struct bfd_link_hash_entry *h ATTRIBUTE_UNUSED)
+{
+}
+
 /*
 FUNCTION
 	bfd_generic_define_start_stop
diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
index 8859b23907..9f3b487b8d 100644
--- a/bfd/mach-o-target.c
+++ b/bfd/mach-o-target.c
@@ -55,6 +55,7 @@ 
 #define bfd_mach_o_bfd_discard_group		      bfd_generic_discard_group
 #define bfd_mach_o_section_already_linked	      _bfd_generic_section_already_linked
 #define bfd_mach_o_bfd_define_common_symbol	      bfd_generic_define_common_symbol
+#define bfd_mach_o_bfd_link_hide_symbol		      _bfd_generic_link_hide_symbol
 #define bfd_mach_o_bfd_define_start_stop	      bfd_generic_define_start_stop
 #define bfd_mach_o_bfd_copy_private_bfd_data	      _bfd_generic_bfd_copy_private_bfd_data
 #define bfd_mach_o_core_file_matches_executable_p     generic_core_file_matches_executable_p
diff --git a/bfd/mmo.c b/bfd/mmo.c
index 4b969c2c03..6a3e255803 100644
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -3318,6 +3318,7 @@  mmo_write_object_contents (bfd *abfd)
 #define mmo_section_already_linked \
   _bfd_generic_section_already_linked
 #define mmo_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define mmo_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define mmo_bfd_define_start_stop bfd_generic_define_start_stop
 
 /* We want to copy time of creation, otherwise we'd use
diff --git a/bfd/pef.c b/bfd/pef.c
index a55ca0693a..5746b96b43 100644
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -59,6 +59,7 @@ 
 #define bfd_pef_bfd_discard_group		    bfd_generic_discard_group
 #define bfd_pef_section_already_linked		    _bfd_generic_section_already_linked
 #define bfd_pef_bfd_define_common_symbol	    bfd_generic_define_common_symbol
+#define bfd_pef_bfd_link_hide_symbol		    _bfd_generic_link_hide_symbol
 #define bfd_pef_bfd_define_start_stop		    bfd_generic_define_start_stop
 #define bfd_pef_bfd_link_hash_table_create	    _bfd_generic_link_hash_table_create
 #define bfd_pef_bfd_link_add_symbols		    _bfd_generic_link_add_symbols
diff --git a/bfd/plugin.c b/bfd/plugin.c
index a2c1bd5776..16a706a548 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -105,6 +105,7 @@  dlerror (void)
 #define bfd_plugin_bfd_discard_group		      bfd_generic_discard_group
 #define bfd_plugin_section_already_linked	      _bfd_generic_section_already_linked
 #define bfd_plugin_bfd_define_common_symbol	      bfd_generic_define_common_symbol
+#define bfd_plugin_bfd_link_hide_symbol		      _bfd_generic_link_hide_symbol
 #define bfd_plugin_bfd_define_start_stop	      bfd_generic_define_start_stop
 #define bfd_plugin_bfd_copy_link_hash_symbol_type     _bfd_generic_copy_link_hash_symbol_type
 #define bfd_plugin_bfd_link_check_relocs	      _bfd_generic_link_check_relocs
diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c
index bbb2cc77d4..0d92fd1c82 100644
--- a/bfd/ppcboot.c
+++ b/bfd/ppcboot.c
@@ -460,6 +460,7 @@  ppcboot_bfd_print_private_bfd_data (bfd *abfd, void * farg)
 #define ppcboot_section_already_linked \
   _bfd_generic_section_already_linked
 #define ppcboot_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define ppcboot_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define ppcboot_bfd_define_start_stop bfd_generic_define_start_stop
 #define ppcboot_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define ppcboot_bfd_link_add_symbols _bfd_generic_link_add_symbols
diff --git a/bfd/som.c b/bfd/som.c
index 6220df7eb8..d2bdc6f5c4 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -6759,6 +6759,7 @@  som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
 #define som_bfd_discard_group			bfd_generic_discard_group
 #define som_section_already_linked		_bfd_generic_section_already_linked
 #define som_bfd_define_common_symbol		bfd_generic_define_common_symbol
+#define som_bfd_link_hide_symbol		_bfd_generic_link_hide_symbol
 #define som_bfd_define_start_stop		bfd_generic_define_start_stop
 #define som_bfd_merge_private_bfd_data		_bfd_generic_bfd_merge_private_bfd_data
 #define som_bfd_copy_private_header_data	_bfd_generic_bfd_copy_private_header_data
diff --git a/bfd/srec.c b/bfd/srec.c
index 4996109ed1..66cc72fea8 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -1278,6 +1278,7 @@  srec_print_symbol (bfd *abfd,
 #define srec_bfd_discard_group			  bfd_generic_discard_group
 #define srec_section_already_linked		  _bfd_generic_section_already_linked
 #define srec_bfd_define_common_symbol		  bfd_generic_define_common_symbol
+#define srec_bfd_link_hide_symbol		  _bfd_generic_link_hide_symbol
 #define srec_bfd_define_start_stop		  bfd_generic_define_start_stop
 #define srec_bfd_link_hash_table_create		  _bfd_generic_link_hash_table_create
 #define srec_bfd_link_add_symbols		  _bfd_generic_link_add_symbols
diff --git a/bfd/targets.c b/bfd/targets.c
index 5a2a684bc8..531703d226 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -465,6 +465,7 @@  BFD_JUMP_TABLE macros.
 .  NAME##_bfd_discard_group, \
 .  NAME##_section_already_linked, \
 .  NAME##_bfd_define_common_symbol, \
+.  NAME##_bfd_link_hide_symbol, \
 .  NAME##_bfd_define_start_stop
 .
 .  int	       (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
@@ -531,6 +532,10 @@  BFD_JUMP_TABLE macros.
 .  bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
 .					     struct bfd_link_hash_entry *);
 .
+.  {* Hide a symbol.  *}
+.  void (*_bfd_link_hide_symbol) (bfd *, struct bfd_link_info *,
+.				  struct bfd_link_hash_entry *);
+.
 .  {* Define a __start, __stop, .startof. or .sizeof. symbol.  *}
 .  struct bfd_link_hash_entry *
 .	       (*_bfd_define_start_stop) (struct bfd_link_info *, const char *,
diff --git a/bfd/tekhex.c b/bfd/tekhex.c
index 6a00c9f773..893d06def6 100644
--- a/bfd/tekhex.c
+++ b/bfd/tekhex.c
@@ -981,6 +981,7 @@  tekhex_print_symbol (bfd *abfd,
 #define tekhex_bfd_discard_group		    bfd_generic_discard_group
 #define tekhex_section_already_linked		    _bfd_generic_section_already_linked
 #define tekhex_bfd_define_common_symbol		    bfd_generic_define_common_symbol
+#define tekhex_bfd_link_hide_symbol		    _bfd_generic_link_hide_symbol
 #define tekhex_bfd_define_start_stop		    bfd_generic_define_start_stop
 #define tekhex_bfd_link_hash_table_create	    _bfd_generic_link_hash_table_create
 #define tekhex_bfd_link_add_symbols		    _bfd_generic_link_add_symbols
diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c
index b52f580ad3..11817cfbec 100644
--- a/bfd/vms-alpha.c
+++ b/bfd/vms-alpha.c
@@ -9498,6 +9498,7 @@  bfd_vms_get_data (bfd *abfd)
 #define vms_bfd_discard_group		  bfd_generic_discard_group
 #define vms_section_already_linked	  _bfd_generic_section_already_linked
 #define vms_bfd_define_common_symbol	  bfd_generic_define_common_symbol
+#define vms_bfd_link_hide_symbol	  _bfd_generic_link_hide_symbol
 #define vms_bfd_define_start_stop         bfd_generic_define_start_stop
 #define vms_bfd_copy_private_header_data  _bfd_generic_bfd_copy_private_header_data
 
@@ -9545,6 +9546,7 @@  bfd_vms_get_data (bfd *abfd)
   _bfd_generic_section_already_linked
 
 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
 #define alpha_vms_bfd_copy_link_hash_symbol_type \
diff --git a/bfd/xsym.c b/bfd/xsym.c
index 8ea0e7e71f..56607f026f 100644
--- a/bfd/xsym.c
+++ b/bfd/xsym.c
@@ -51,6 +51,7 @@ 
 #define bfd_sym_bfd_discard_group		    bfd_generic_discard_group
 #define bfd_sym_section_already_linked		    _bfd_generic_section_already_linked
 #define bfd_sym_bfd_define_common_symbol	    bfd_generic_define_common_symbol
+#define bfd_sym_bfd_link_hide_symbol		    _bfd_generic_link_hide_symbol
 #define bfd_sym_bfd_define_start_stop		    bfd_generic_define_start_stop
 #define bfd_sym_bfd_link_hash_table_create	    _bfd_generic_link_hash_table_create
 #define bfd_sym_bfd_link_add_symbols		    _bfd_generic_link_add_symbols
diff --git a/ld/ldexp.c b/ld/ldexp.c
index f9dc362930..6fa251e79e 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -1200,6 +1200,9 @@  exp_fold_tree_1 (etree_type *tree)
 		  h->u.def.section = expld.result.section;
 		  h->linker_def = ! tree->assign.type.lineno;
 		  h->ldscript_def = 1;
+		  if (tree->assign.hidden)
+		    bfd_link_hide_symbol (link_info.output_bfd,
+					  &link_info, h);
 
 		  /* Copy the symbol type if this is an expression only
 		     referencing a single symbol.  (If the expression
diff --git a/ld/testsuite/ld-elf/provide-hidden-dynabs.nd b/ld/testsuite/ld-elf/provide-hidden-dynabs.nd
deleted file mode 100644
index 86e3adcdf9..0000000000
--- a/ld/testsuite/ld-elf/provide-hidden-dynabs.nd
+++ /dev/null
@@ -1,8 +0,0 @@ 
-Symbol table '\.dynsym' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +ABS foo
-#...
-Symbol table '\.symtab' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +ABS foo
-#pass
diff --git a/ld/testsuite/ld-elf/provide-hidden-dynsec.nd b/ld/testsuite/ld-elf/provide-hidden-dynsec.nd
deleted file mode 100644
index 716dfa1f71..0000000000
--- a/ld/testsuite/ld-elf/provide-hidden-dynsec.nd
+++ /dev/null
@@ -1,8 +0,0 @@ 
-Symbol table '\.dynsym' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ foo
-#...
-Symbol table '\.symtab' contains [0-9]+ entries:
-#...
- *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ foo
-#pass
diff --git a/ld/testsuite/ld-elf/provide-hidden.exp b/ld/testsuite/ld-elf/provide-hidden.exp
index 1fc4e61a19..4b72134911 100644
--- a/ld/testsuite/ld-elf/provide-hidden.exp
+++ b/ld/testsuite/ld-elf/provide-hidden.exp
@@ -86,7 +86,9 @@  run_ld_link_tests [list \
 	"$LFLAGS -T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \
 	"" \
 	[list provide-hidden-3.s] \
-	[list "readelf -s provide-hidden-dynsec.nd"] \
+	[list \
+	    [list readelf -s provide-hidden-sec.nd] \
+	    [list readelf -s provide-hidden-dyn.nd]] \
 	"provide-hidden-4"] \
     [list \
 	"$testname 5" \
@@ -138,7 +140,9 @@  run_ld_link_tests [list \
 	"$LFLAGS -T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \
 	"" \
 	[list provide-hidden-3.s] \
-	[list "readelf -s provide-hidden-dynabs.nd"] \
+	[list \
+	    [list readelf -s provide-hidden-abs.nd] \
+	    [list readelf -s provide-hidden-dyn.nd]] \
 	"provide-hidden-10"] \
     [list \
 	"$testname 11" \
diff --git a/ld/testsuite/ld-i386/pr23189.d b/ld/testsuite/ld-i386/pr23189.d
index 9345b42bd0..d388830f61 100644
--- a/ld/testsuite/ld-i386/pr23189.d
+++ b/ld/testsuite/ld-i386/pr23189.d
@@ -2,6 +2,4 @@ 
 #ld: -shared -melf_i386 -T pr23189.t
 #readelf: -r --wide
 
-Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
- Offset     Info    Type                Sym. Value  Symbol's Name
-[0-9a-f]+ +[0-9a-f]+ +R_386_RELATIVE +
+There are no relocations in this file.
diff --git a/ld/testsuite/ld-x86-64/pr23189.d b/ld/testsuite/ld-x86-64/pr23189.d
index 7951c7acc3..6fc4b7ee2c 100644
--- a/ld/testsuite/ld-x86-64/pr23189.d
+++ b/ld/testsuite/ld-x86-64/pr23189.d
@@ -2,6 +2,4 @@ 
 #ld: -shared -melf_x86_64 -T pr23189.t
 #readelf: -r --wide
 
-Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
-    Offset             Info             Type               Symbol's Value  Symbol's Name \+ Addend
-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9a-f]+
+There are no relocations in this file.