tic6x FAIL: ld-elf/pr3455

Message ID apSsUx-lhw2ktfAp@squeak.grove.modra.org
State New
Headers
Series tic6x FAIL: ld-elf/pr3455 |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Alan Modra Aug. 30, 2026, 10:18 p.m. UTC
  This fixes a fail for a recently added testcase, the underlying cause
being that tic6x-ld target defaults to "elf32-tic6x-elf-le", while
tic6x-as target defaults to "elf32-tic6x-le".  I don't know why that
is the case, so rather than reconciling the difference I decided to
tackle the reason why tic6x-ld --shared doesn't create dynamic sections
unless an input object contains relocations.  The fix is to relax the
input object test where this normally occurs to match other places
that test object suitability for dynamic sections.

bfd/
	* elflink.c (elf_link_add_object_symbols): Use compatible_format
	rather than requiring an exact target match when creating
	dynamic sections for a dynamic output object.
ld/
	* testsuite/ld-elf/elf.exp: Use append.
	* testsuite/ld-elf/pr24718-1.d: Don't xfail tic6x.
	* testsuite/ld-elf/pr27128a.d: Likewise.
	* testsuite/ld-elf/pr27128b.d: Likewise.
	* testsuite/ld-elf/pr27128c.d: Likewise.
	* testsuite/ld-elf/pr27128d.d: Likewise.
	* testsuite/ld-elf/pr27128e.d: Likewise.
  

Comments

Alan Modra Aug. 30, 2026, 10:47 p.m. UTC | #1
On Mon, Aug 31, 2026 at 07:48:59AM +0930, Alan Modra wrote:
> This fixes a fail for a recently added testcase

Oops, subject should have been "tic6x FAIL: ld-elf/pr34550".
  
Alan Modra Sept. 3, 2026, 6:57 a.m. UTC | #2
In commit ee7896781dc7 I moved a !htab->dynamic_sections_created test
earlier, thinking "let's do the easy test first".  Bad idea.  We might
not have an elf hash table, eg. ld-elf/pr21884.  So that test must
come after verifying the type of hash table (in compatible_format).
In fact, we might as well let bfd_elf_link_create_dynamic_sections run
as it will return early if dynamic sections are already created.

	* elflink.c (elf_link_add_object_symbols): Don't test for
	dynamic sections already created.

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 172cb439b6b..d5956b8bd2f 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -4633,7 +4633,6 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 	 are no input BFD's of the same format as the output, we can't
 	 make a shared library.  */
       if (!just_syms
-	  && !htab->dynamic_sections_created
 	  && (bfd_link_pic (info)
 	      || (!bfd_link_relocatable (info)
 		  && info->nointerp
  

Patch

diff --git a/bfd/elflink.c b/bfd/elflink.c
index e7348901b8c..172cb439b6b 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -4633,13 +4633,12 @@  elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 	 are no input BFD's of the same format as the output, we can't
 	 make a shared library.  */
       if (!just_syms
+	  && !htab->dynamic_sections_created
 	  && (bfd_link_pic (info)
 	      || (!bfd_link_relocatable (info)
 		  && info->nointerp
 		  && (info->export_dynamic || info->dynamic)))
-	  && is_elf_hash_table (&htab->root)
-	  && info->output_bfd->xvec == abfd->xvec
-	  && !htab->dynamic_sections_created)
+	  && compatible_format (info, abfd))
 	{
 	  if (!bfd_elf_link_create_dynamic_sections (info))
 	    goto error_return;
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index 2500d90e8f2..819b17ef4fc 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -40,7 +40,7 @@  proc riscv_little_endian { } {
 
 set old_ldflags $LDFLAGS
 if { [istarget spu*-*-*] } {
-    set LDFLAGS "$LDFLAGS --local-store 0:0"
+    append LDFLAGS " --local-store 0:0"
 }
 
 # hpux .comm differs from everyone else
@@ -48,7 +48,7 @@  set hpux ""
 set old_asflags $ASFLAGS
 if [istarget "*-*-hpux*"] {
     set hpux "--defsym HPUX=1"
-    set ASFLAGS "$ASFLAGS --defsym HPUX=1"
+    append ASFLAGS " --defsym HPUX=1"
 }
 
 # Some tests expect 32-bit addresses.  Force the executable to low addresses.
@@ -60,7 +60,7 @@  proc alpha_ld_flags { } {
 }
 
 if { [istarget alpha*-*-* ] } {
-    set ASFLAGS "$ASFLAGS --defsym NO_SET=1"
+    append ASFLAGS " --defsym NO_SET=1"
 }
 
 if [istarget "tic6x-*-*"] {
diff --git a/ld/testsuite/ld-elf/pr24718-1.d b/ld/testsuite/ld-elf/pr24718-1.d
index 767cf740ee0..9af9c3e9fc3 100644
--- a/ld/testsuite/ld-elf/pr24718-1.d
+++ b/ld/testsuite/ld-elf/pr24718-1.d
@@ -1,8 +1,6 @@ 
 #ld: -shared -version-script pr24718-1.t
 #readelf: -V
 #target: [check_shared_lib_support]
-#xfail: tic6x-*-*
-# tic6x requires a non-default emulation.
 
 #...
 Version definition section '\.gnu\.version_d' contains 3 entries:
diff --git a/ld/testsuite/ld-elf/pr27128a.d b/ld/testsuite/ld-elf/pr27128a.d
index 314b000b561..8675d18d50a 100644
--- a/ld/testsuite/ld-elf/pr27128a.d
+++ b/ld/testsuite/ld-elf/pr27128a.d
@@ -4,8 +4,6 @@ 
 #target: [check_shared_lib_support]
 #notarget: [is_underscore_target]
 # _Zrm1XS_ doesn't have an extra underscore.
-#xfail: tic6x-*-*
-# tic6x DYN lacks dynamic sections for this testcase
 
 #...
 VERS_2\.0 A 0+ 
diff --git a/ld/testsuite/ld-elf/pr27128b.d b/ld/testsuite/ld-elf/pr27128b.d
index 0721117edfa..af208ebd3c3 100644
--- a/ld/testsuite/ld-elf/pr27128b.d
+++ b/ld/testsuite/ld-elf/pr27128b.d
@@ -4,8 +4,8 @@ 
 #target: [check_shared_lib_support]
 #notarget: [is_underscore_target]
 # _Zrm1XS_ doesn't have an extra underscore.
-#xfail: hppa64-*-* tic6x-*-*
-# hppa64 uses dot-symbols, tic6x DYN lacks dynamic sections for this testcase
+#xfail: hppa64-*-*
+# hppa64 uses dot-symbols
 
 #...
 VERS_2\.0 A 0+ 
diff --git a/ld/testsuite/ld-elf/pr27128c.d b/ld/testsuite/ld-elf/pr27128c.d
index 1367bebb6ac..b7fa79bb300 100644
--- a/ld/testsuite/ld-elf/pr27128c.d
+++ b/ld/testsuite/ld-elf/pr27128c.d
@@ -4,8 +4,6 @@ 
 #target: [check_shared_lib_support]
 #notarget: [is_underscore_target]
 # _Zrm1XS_ doesn't have an extra underscore.
-#xfail: tic6x-*-*
-# tic6x DYN lacks dynamic sections for this testcase
 
 #...
 VERS_2\.0 +\|0+\| +A +\| +OBJECT\| +\| +\|\*ABS\*
diff --git a/ld/testsuite/ld-elf/pr27128d.d b/ld/testsuite/ld-elf/pr27128d.d
index 45d19729483..970dba22305 100644
--- a/ld/testsuite/ld-elf/pr27128d.d
+++ b/ld/testsuite/ld-elf/pr27128d.d
@@ -4,8 +4,8 @@ 
 #target: [check_shared_lib_support]
 #notarget: [is_underscore_target]
 # _Zrm1XS_ doesn't have an extra underscore.
-#xfail: hppa64-*-* tic6x-*-*
-# hppa64 uses dot-symbols, tic6x DYN lacks dynamic sections for this testcase
+#xfail: hppa64-*-*
+# hppa64 uses dot-symbols
 
 #...
 VERS_2\.0 +\|0+\| +A +\| +OBJECT\| +\| +\|\*ABS\*
diff --git a/ld/testsuite/ld-elf/pr27128e.d b/ld/testsuite/ld-elf/pr27128e.d
index 4263a059b57..5af787c6735 100644
--- a/ld/testsuite/ld-elf/pr27128e.d
+++ b/ld/testsuite/ld-elf/pr27128e.d
@@ -4,8 +4,8 @@ 
 #target: [check_shared_lib_support]
 #notarget: [is_underscore_target]
 # _Zrm1XS_ doesn't have an extra underscore.
-#xfail: hppa64-*-* tic6x-*-*
-# hppa64 uses dot-symbols, tic6x DYN lacks dynamic sections for this testcase
+#xfail: hppa64-*-*
+# hppa64 uses dot-symbols
 
 #...
 VERS_2\.0 A 0+