PR 14962 testcase xcoff failure

Message ID ZcWNcCVyvAPOKV3k@squeak.grove.modra.org
State New
Headers
Series PR 14962 testcase xcoff failure |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm warning Patch is already merged
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 warning Patch is already merged

Commit Message

Alan Modra Feb. 9, 2024, 2:26 a.m. UTC
  Like https://sourceware.org/pipermail/binutils/2002-August/021279.html
but for symbols defined in an xcoff object but then made absolute by a
linker script.

	* xcofflink.c (xcoff_link_input_bfd): Set n_scnum correctly
	for symbols made absolute by a linker script.
  

Patch

diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index 6ef9abcd883..49ac8efd1e8 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -5482,7 +5482,13 @@  xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
 		   && isym.n_sclass != C_DECL
 		   && isym.n_scnum > 0)
 	    {
-	      isym.n_scnum = (*csectpp)->output_section->target_index;
+	      if (*sym_hash != NULL
+		  && ((*sym_hash)->root.type == bfd_link_hash_defined
+		      || (*sym_hash)->root.type == bfd_link_hash_defweak)
+		  && (*sym_hash)->root.u.def.section == bfd_abs_section_ptr)
+		isym.n_scnum = N_ABS;
+	      else
+		isym.n_scnum = (*csectpp)->output_section->target_index;
 	      isym.n_value += ((*csectpp)->output_section->vma
 			       + (*csectpp)->output_offset
 			       - (*csectpp)->vma);