public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] PR 28447: implement multiple parameters for .file on XCOFF
@ 2021-10-18 11:37 CHIGOT, CLEMENT
  2021-10-20 10:09 ` Alan Modra
  2021-11-26 17:47 ` Mike Frysinger
  0 siblings, 2 replies; 12+ messages in thread
From: CHIGOT, CLEMENT @ 2021-10-18 11:37 UTC (permalink / raw)
  To: binutils; +Cc: David Edelsohn

[-- Attachment #1: Type: text/plain, Size: 2324 bytes --]

On XCOFF, ".file" pseudo-op allows 3 extras parameters to provide
additional information to AIX linker, or its debugger. These are
stored in auxiliary entries of the C_FILE symbol.

PR 28447
bfd/Changelog

        * coffcode.h (combined_entry_type): Add extrap field.
        (coff_bigobj_swap_aux_in): Adjust names of x_file fields.
        (coff_bigobj_swap_aux_out): Likewise.
        * coffgen.c (coff_write_auxent_fname): New function.
        (coff_fix_symbol_name): Write x_file using
         coff_write_auxent_fname.
        (coff_write_symbol): Likewise.
        (coff_write_symbols): Add C_FILE auxiliary entries to
        string table if needed.
        (coff_get_normalized_symtab): Adjust names of x_file fields.
        Normalize C_FILE auxiliary entries.
        (coff_print_symbol): Print C_FILE auxiliary entries.
        * coff-rs6000.c (_bfd_xcoff_swap_aux_in): Adjust names of
        x_file fields.
        (_bfd_xcoff_swap_aux_out): Likewise.
        * coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Likewise.
        (_bfd_xcoff64_swap_aux_out): Likewise.
        * cofflink.c (_bfd_coff_final_link): Likewise.
        (_bfd_coff_link_input_bfd): Likewise.
        * coffswap.h (coff_swap_aux_in): Likewise.
        * peXXigen.c (_bfd_XXi_swap_aux_in): Likewise.
        (_bfd_XXi_swap_aux_out): Likewise.
        * xcofflink.c (xcoff_link_input_bfd): Likewise.
        * libcoff.h: Regenerate.

gas/ChangeLog:

        * config/tc-ppc.c (ppc_file): New function.
        * config/tc-ppc.h (OBJ_COFF_MAX_AUXENTRIES): Change to 4.
        * testsuite/gas/ppc/aix.exp: Add tests.
        * testsuite/gas/ppc/xcoff-file-32.d: New test.
        * testsuite/gas/ppc/xcoff-file-64.d: New test.
        * testsuite/gas/ppc/xcoff-file.s: New test.

include/ChangeLog:

        * coff/internal.h (union internal_auxent): Change x_file to be a
          struct instead of a union. Add x_ftype field.
        * coff/rs6000.h (union external_auxent): Add x_resv field.
        * coff/xcoff.h (XFT_FN): New define.
        (XFT_CT): Likewise.
        (XFT_CV): Likewise.
        (XFT_CD): Likewise.


I would be glad if someone can test it on Windows and maybe on other
COFF formats too. It shouldn't impact but we never know. 

Thanks, 
Clément







[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-PR-28447-implement-multiple-parameters-for-.file-on-.patch --]
[-- Type: text/x-patch; name="0001-PR-28447-implement-multiple-parameters-for-.file-on-.patch", Size: 27402 bytes --]

From 3e62b357db44dbadda251ce820e24269690db3c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Fri, 15 Oct 2021 16:12:39 +0200
Subject: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF

On XCOFF, ".file" pseudo-op allows 3 extras parameters to provide
additional information to AIX linker, or its debugger. These are
stored in auxiliary entries of the C_FILE symbol.

PR 28447
bfd/Changelog

	* coffcode.h (combined_entry_type): Add extrap field.
	(coff_bigobj_swap_aux_in): Adjust names of x_file fields.
	(coff_bigobj_swap_aux_out): Likewise.
	* coffgen.c (coff_write_auxent_fname): New function.
	(coff_fix_symbol_name): Write x_file using
	 coff_write_auxent_fname.
	(coff_write_symbol): Likewise.
	(coff_write_symbols): Add C_FILE auxiliary entries to
	string table if needed.
	(coff_get_normalized_symtab): Adjust names of x_file fields.
	Normalize C_FILE auxiliary entries.
	(coff_print_symbol): Print C_FILE auxiliary entries.
	* coff-rs6000.c (_bfd_xcoff_swap_aux_in): Adjust names of
	x_file fields.
	(_bfd_xcoff_swap_aux_out): Likewise.
	* coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Likewise.
	(_bfd_xcoff64_swap_aux_out): Likewise.
	* cofflink.c (_bfd_coff_final_link): Likewise.
	(_bfd_coff_link_input_bfd): Likewise.
	* coffswap.h (coff_swap_aux_in): Likewise.
	* peXXigen.c (_bfd_XXi_swap_aux_in): Likewise.
	(_bfd_XXi_swap_aux_out): Likewise.
	* xcofflink.c (xcoff_link_input_bfd): Likewise.
	* libcoff.h: Regenerate.

gas/ChangeLog:

	* config/tc-ppc.c (ppc_file): New function.
	* config/tc-ppc.h (OBJ_COFF_MAX_AUXENTRIES): Change to 4.
	* testsuite/gas/ppc/aix.exp: Add tests.
	* testsuite/gas/ppc/xcoff-file-32.d: New test.
	* testsuite/gas/ppc/xcoff-file-64.d: New test.
	* testsuite/gas/ppc/xcoff-file.s: New test.

include/ChangeLog:

	* coff/internal.h (union internal_auxent): Change x_file to be a
	  struct instead of a union. Add x_ftype field.
	* coff/rs6000.h (union external_auxent): Add x_resv field.
	* coff/xcoff.h (XFT_FN): New define.
	(XFT_CT): Likewise.
	(XFT_CV): Likewise.
	(XFT_CD): Likewise.
---
 bfd/coff-rs6000.c                     |  14 +--
 bfd/coff64-rs6000.c                   |  14 +--
 bfd/coffcode.h                        |  10 +-
 bfd/coffgen.c                         | 132 ++++++++++++++++++++------
 bfd/cofflink.c                        |  14 +--
 bfd/coffswap.h                        |  14 +--
 bfd/libcoff.h                         |   4 +
 bfd/peXXigen.c                        |  12 +--
 bfd/xcofflink.c                       |  12 +--
 gas/config/tc-ppc.c                   |  63 ++++++++++++
 gas/config/tc-ppc.h                   |   2 +-
 gas/testsuite/gas/ppc/aix.exp         |   3 +
 gas/testsuite/gas/ppc/xcoff-file-32.d |  13 +++
 gas/testsuite/gas/ppc/xcoff-file-64.d |  13 +++
 gas/testsuite/gas/ppc/xcoff-file.s    |   1 +
 include/coff/internal.h               |  25 ++---
 include/coff/rs6000.h                 |   1 +
 include/coff/xcoff.h                  |   6 ++
 18 files changed, 271 insertions(+), 82 deletions(-)
 create mode 100644 gas/testsuite/gas/ppc/xcoff-file-32.d
 create mode 100644 gas/testsuite/gas/ppc/xcoff-file-64.d
 create mode 100644 gas/testsuite/gas/ppc/xcoff-file.s

diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 31d91190103..1cc2162e7d8 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -489,12 +489,13 @@ _bfd_xcoff_swap_aux_in (bfd *abfd, void * ext1, int type ATTRIBUTE_UNUSED,
     case C_FILE:
       if (ext->x_file.x_n.x_fname[0] == 0)
 	{
-	  in->x_file.x_n.x_zeroes = 0;
-	  in->x_file.x_n.x_offset =
+	  in->x_file.x_n.x_n.x_zeroes = 0;
+	  in->x_file.x_n.x_n.x_offset =
 	    H_GET_32 (abfd, ext->x_file.x_n.x_n.x_offset);
 	}
       else
-	memcpy (in->x_file.x_fname, ext->x_file.x_n.x_fname, FILNMLEN);
+	memcpy (in->x_file.x_n.x_fname, ext->x_file.x_n.x_fname, FILNMLEN);
+      in->x_file.x_ftype = H_GET_8 (abfd, ext->x_file.x_ftype);
       break;
 
       /* RS/6000 "csect" auxents.
@@ -573,14 +574,15 @@ _bfd_xcoff_swap_aux_out (bfd *abfd, void * inp, int type ATTRIBUTE_UNUSED,
       break;
 
     case C_FILE:
-      if (in->x_file.x_fname[0] == 0)
+      if (in->x_file.x_n.x_fname[0] == 0)
 	{
 	  H_PUT_32 (abfd, 0, ext->x_file.x_n.x_n.x_zeroes);
-	  H_PUT_32 (abfd, in->x_file.x_n.x_offset,
+	  H_PUT_32 (abfd, in->x_file.x_n.x_n.x_offset,
 		    ext->x_file.x_n.x_n.x_offset);
 	}
       else
-	memcpy (ext->x_file.x_n.x_fname, in->x_file.x_fname, FILNMLEN);
+	memcpy (ext->x_file.x_n.x_fname, in->x_file.x_n.x_fname, FILNMLEN);
+      H_PUT_8 (abfd, in->x_file.x_ftype, ext->x_file.x_ftype);
       break;
 
       /* RS/6000 "csect" auxents */
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 04e0798bf69..4689c9ed5fe 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -386,12 +386,13 @@ _bfd_xcoff64_swap_aux_in (bfd *abfd, void *ext1, int type ATTRIBUTE_UNUSED,
 
       if (ext->x_file.x_n.x_n.x_zeroes[0] == 0)
 	{
-	  in->x_file.x_n.x_zeroes = 0;
-	  in->x_file.x_n.x_offset =
+	  in->x_file.x_n.x_n.x_zeroes = 0;
+	  in->x_file.x_n.x_n.x_offset =
 	    H_GET_32 (abfd, ext->x_file.x_n.x_n.x_offset);
 	}
       else
-	memcpy (in->x_file.x_fname, ext->x_file.x_n.x_fname, FILNMLEN);
+	memcpy (in->x_file.x_n.x_fname, ext->x_file.x_n.x_fname, FILNMLEN);
+      in->x_file.x_ftype = H_GET_8 (abfd, ext->x_file.x_ftype);
       break;
 
       /* RS/6000 "csect" auxents.
@@ -502,14 +503,15 @@ _bfd_xcoff64_swap_aux_out (bfd *abfd, void *inp, int type ATTRIBUTE_UNUSED,
       break;
 
     case C_FILE:
-      if (in->x_file.x_n.x_zeroes == 0)
+      if (in->x_file.x_n.x_n.x_zeroes == 0)
 	{
 	  H_PUT_32 (abfd, 0, ext->x_file.x_n.x_n.x_zeroes);
-	  H_PUT_32 (abfd, in->x_file.x_n.x_offset,
+	  H_PUT_32 (abfd, in->x_file.x_n.x_n.x_offset,
 		    ext->x_file.x_n.x_n.x_offset);
 	}
       else
-	memcpy (ext->x_file.x_n.x_fname, in->x_file.x_fname, FILNMLEN);
+	memcpy (ext->x_file.x_n.x_fname, in->x_file.x_n.x_fname, FILNMLEN);
+      H_PUT_8 (abfd, in->x_file.x_ftype, ext->x_file.x_ftype);
       H_PUT_8 (abfd, _AUX_FILE, ext->x_file.x_auxtype);
       break;
 
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index a2b1fe69ce3..dac4ed17f01 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -326,6 +326,10 @@ CODE_FRAGMENT
 .
 . {* Selector for the union above.  *}
 . bool is_sym;
+.
+. {* An extra pointer which can used by format based on COFF (like XCOFF)
+.    to provide extra information to their backend.  *}
+. void *extrap;
 .} combined_entry_type;
 .
 .
@@ -5668,11 +5672,11 @@ coff_bigobj_swap_aux_in (bfd *abfd,
       if (numaux > 1)
 	{
 	  if (indx == 0)
-	    memcpy (in->x_file.x_fname, ext->File.Name,
+	    memcpy (in->x_file.x_n.x_fname, ext->File.Name,
 		    numaux * sizeof (AUXENT_BIGOBJ));
 	}
       else
-	memcpy (in->x_file.x_fname, ext->File.Name, sizeof (ext->File.Name));
+	memcpy (in->x_file.x_n.x_fname, ext->File.Name, sizeof (ext->File.Name));
       break;
 
     case C_STAT:
@@ -5717,7 +5721,7 @@ coff_bigobj_swap_aux_out (bfd * abfd,
   switch (in_class)
     {
     case C_FILE:
-      memcpy (ext->File.Name, in->x_file.x_fname, sizeof (ext->File.Name));
+      memcpy (ext->File.Name, in->x_file.x_n.x_fname, sizeof (ext->File.Name));
 
       return AUXESZ;
 
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 77bda9e9947..f69dca06af4 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -847,6 +847,34 @@ coff_mangle_symbols (bfd *bfd_ptr)
     }
 }
 
+static void
+coff_write_auxent_fname (bfd *abfd,
+			 char *str,
+			 union internal_auxent *auxent,
+			 bfd_size_type *string_size_p)
+{
+  unsigned int str_length = strlen (str);
+  unsigned int filnmlen = bfd_coff_filnmlen (abfd);
+
+  if (bfd_coff_long_filenames (abfd))
+    {
+      if (str_length <= filnmlen)
+	strncpy (auxent->x_file.x_n.x_fname, str, filnmlen);
+      else
+	{
+	  auxent->x_file.x_n.x_n.x_offset = *string_size_p + STRING_SIZE_SIZE;
+	  auxent->x_file.x_n.x_n.x_zeroes = 0;
+	  *string_size_p += str_length + 1;
+	}
+    }
+  else
+    {
+      strncpy (auxent->x_file.x_n.x_fname, str, filnmlen);
+      if (str_length > filnmlen)
+	str[filnmlen] = '\0';
+    }
+}
+
 static void
 coff_fix_symbol_name (bfd *abfd,
 		      asymbol *symbol,
@@ -856,7 +884,6 @@ coff_fix_symbol_name (bfd *abfd,
 		      bfd_size_type *debug_string_size_p)
 {
   unsigned int name_length;
-  union internal_auxent *auxent;
   char *name = (char *) (symbol->name);
 
   if (name == NULL)
@@ -871,8 +898,6 @@ coff_fix_symbol_name (bfd *abfd,
   if (native->u.syment.n_sclass == C_FILE
       && native->u.syment.n_numaux > 0)
     {
-      unsigned int filnmlen;
-
       if (bfd_coff_force_symnames_in_strings (abfd))
 	{
 	  native->u.syment._n._n_n._n_offset =
@@ -884,27 +909,8 @@ coff_fix_symbol_name (bfd *abfd,
 	strncpy (native->u.syment._n._n_name, ".file", SYMNMLEN);
 
       BFD_ASSERT (! (native + 1)->is_sym);
-      auxent = &(native + 1)->u.auxent;
-
-      filnmlen = bfd_coff_filnmlen (abfd);
-
-      if (bfd_coff_long_filenames (abfd))
-	{
-	  if (name_length <= filnmlen)
-	    strncpy (auxent->x_file.x_fname, name, filnmlen);
-	  else
-	    {
-	      auxent->x_file.x_n.x_offset = *string_size_p + STRING_SIZE_SIZE;
-	      auxent->x_file.x_n.x_zeroes = 0;
-	      *string_size_p += name_length + 1;
-	    }
-	}
-      else
-	{
-	  strncpy (auxent->x_file.x_fname, name, filnmlen);
-	  if (name_length > filnmlen)
-	    name[filnmlen] = '\0';
-	}
+      coff_write_auxent_fname (abfd, name, &(native + 1)->u.auxent,
+			       string_size_p);
     }
   else
     {
@@ -1029,6 +1035,11 @@ coff_write_symbol (bfd *abfd,
       for (j = 0; j < native->u.syment.n_numaux; j++)
 	{
 	  BFD_ASSERT (! (native + j + 1)->is_sym);
+
+	  if (native->u.syment.n_sclass == C_FILE && j > 0)
+	    coff_write_auxent_fname (abfd, (char *) (native + j + 1)->extrap,
+				     &(native + j + 1)->u.auxent, string_size_p);
+
 	  bfd_coff_swap_aux_out (abfd,
 				 &((native + j + 1)->u.auxent),
 				 type, n_sclass, (int) j,
@@ -1400,6 +1411,30 @@ coff_write_symbols (bfd *abfd)
 			     abfd) != name_length + 1)
 		return false;
 	    }
+
+	  /* Add strings for C_FILE aux entries. */
+	  if (c_symbol->native->u.syment.n_sclass == C_FILE
+		   && c_symbol->native->u.syment.n_numaux > 1)
+	    {
+	      for (int j = 1; j < c_symbol->native->u.syment.n_numaux; j++)
+		{
+		  char *str;
+		  size_t str_length;
+
+		  if (c_symbol->native[j + 1].u.auxent.x_file.x_n.x_fname[0] != 0)
+		    continue;
+
+		  str = (char *) c_symbol->native[j + 1].extrap;
+		  str_length = strlen (str);
+		  if (str_length > maxlen)
+		    {
+		      if (bfd_bwrite ((void *) (str), (bfd_size_type) str_length + 1,
+				      abfd) != str_length + 1)
+			return false;
+		    }
+
+		}
+	    }
 	}
     }
   else
@@ -1872,7 +1907,7 @@ coff_get_normalized_symtab (bfd *abfd)
 	     the text ".file" is redundant.  */
 	  BFD_ASSERT (! aux->is_sym);
 
-	  if (aux->u.auxent.x_file.x_n.x_zeroes == 0)
+	  if (aux->u.auxent.x_file.x_n.x_n.x_zeroes == 0)
 	    {
 	      /* The filename is a long one, point into the string table.  */
 	      if (string_table == NULL)
@@ -1882,12 +1917,12 @@ coff_get_normalized_symtab (bfd *abfd)
 		    return NULL;
 		}
 
-	      if ((bfd_size_type)(aux->u.auxent.x_file.x_n.x_offset)
+	      if ((bfd_size_type)(aux->u.auxent.x_file.x_n.x_n.x_offset)
 		  >= obj_coff_strings_len (abfd))
 		internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) _("<corrupt>");
 	      else
 		internal_ptr->u.syment._n._n_n._n_offset =
-		  (bfd_hostptr_t) (string_table + (aux->u.auxent.x_file.x_n.x_offset));
+		  (bfd_hostptr_t) (string_table + (aux->u.auxent.x_file.x_n.x_n.x_offset));
 	    }
 	  else
 	    {
@@ -1899,15 +1934,48 @@ coff_get_normalized_symtab (bfd *abfd)
 		internal_ptr->u.syment._n._n_n._n_offset =
 		  (bfd_hostptr_t)
 		  copy_name (abfd,
-			     aux->u.auxent.x_file.x_fname,
+			     aux->u.auxent.x_file.x_n.x_fname,
 			     internal_ptr->u.syment.n_numaux * symesz);
 	      else
 		internal_ptr->u.syment._n._n_n._n_offset =
 		  ((bfd_hostptr_t)
 		   copy_name (abfd,
-			      aux->u.auxent.x_file.x_fname,
+			      aux->u.auxent.x_file.x_n.x_fname,
 			      (size_t) bfd_coff_filnmlen (abfd)));
 	    }
+
+	  /* Normalize other strings available in C_FILE aux entries.  */
+	  if (!coff_data (abfd)->pe)
+	    for (int numaux = 1; numaux < internal_ptr->u.syment.n_numaux; numaux++)
+	      {
+		aux = internal_ptr + numaux + 1;
+		BFD_ASSERT (! aux->is_sym);
+
+		if (aux->u.auxent.x_file.x_n.x_n.x_zeroes == 0)
+		  {
+		    /* The string information is a long one, point into the string table.  */
+		    if (string_table == NULL)
+		      {
+			string_table = _bfd_coff_read_string_table (abfd);
+			if (string_table == NULL)
+			  return NULL;
+		      }
+
+		    if ((bfd_size_type)(aux->u.auxent.x_file.x_n.x_n.x_offset)
+			>= obj_coff_strings_len (abfd))
+		      aux->u.auxent.x_file.x_n.x_n.x_offset = (bfd_hostptr_t) _("<corrupt>");
+		    else
+		      aux->u.auxent.x_file.x_n.x_n.x_offset =
+			(bfd_hostptr_t) (string_table + (aux->u.auxent.x_file.x_n.x_n.x_offset));
+		  }
+		else
+		  aux->u.auxent.x_file.x_n.x_n.x_offset =
+		    ((bfd_hostptr_t)
+		     copy_name (abfd,
+				aux->u.auxent.x_file.x_n.x_fname,
+				(size_t) bfd_coff_filnmlen (abfd)));
+	      }
+
 	}
       else
 	{
@@ -2135,6 +2203,12 @@ coff_print_symbol (bfd *abfd,
 		{
 		case C_FILE:
 		  fprintf (file, "File ");
+		  /* Add additional information if this isn't the filename
+		     auxiliary entry.  */
+		  if (aux)
+		    fprintf (file, "ftype %d fname \"%s\"",
+			     auxp->u.auxent.x_file.x_ftype,
+			     (char *) auxp->u.auxent.x_file.x_n.x_n.x_offset);
 		  break;
 
 		case C_DWARF:
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index b8a370933be..67d9c62b0b4 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -963,7 +963,7 @@ _bfd_coff_final_link (bfd *abfd,
 		  else
 		    {
 		      BFD_ASSERT (isym.n_numaux == 1);
-		      iaux.x_file.x_n.x_offset = STRING_SIZE_SIZE + indx;
+		      iaux.x_file.x_n.x_n.x_offset = STRING_SIZE_SIZE + indx;
 		      bfd_coff_swap_aux_out (abfd, &iaux, isym.n_type, C_FILE,
 					     0, 1, flaginfo.outsyms + symesz);
 		      if (bfd_seek (abfd, pos + symesz, SEEK_SET) != 0
@@ -2006,13 +2006,13 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd)
 		{
 		  /* If this is a long filename, we must put it in the
 		     string table.  */
-		  if (auxp->x_file.x_n.x_zeroes == 0
-		      && auxp->x_file.x_n.x_offset != 0)
+		  if (auxp->x_file.x_n.x_n.x_zeroes == 0
+		      && auxp->x_file.x_n.x_n.x_offset != 0)
 		    {
 		      const char *filename;
 		      bfd_size_type indx;
 
-		      BFD_ASSERT (auxp->x_file.x_n.x_offset
+		      BFD_ASSERT (auxp->x_file.x_n.x_n.x_offset
 				  >= STRING_SIZE_SIZE);
 		      if (strings == NULL)
 			{
@@ -2020,15 +2020,15 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd)
 			  if (strings == NULL)
 			    return false;
 			}
-		      if ((bfd_size_type) auxp->x_file.x_n.x_offset >= obj_coff_strings_len (input_bfd))
+		      if ((bfd_size_type) auxp->x_file.x_n.x_n.x_offset >= obj_coff_strings_len (input_bfd))
 			filename = _("<corrupt>");
 		      else
-			filename = strings + auxp->x_file.x_n.x_offset;
+			filename = strings + auxp->x_file.x_n.x_n.x_offset;
 		      indx = _bfd_stringtab_add (flaginfo->strtab, filename,
 						 hash, copy);
 		      if (indx == (bfd_size_type) -1)
 			return false;
-		      auxp->x_file.x_n.x_offset = STRING_SIZE_SIZE + indx;
+		      auxp->x_file.x_n.x_n.x_offset = STRING_SIZE_SIZE + indx;
 		    }
 		}
 	      else if ((isymp->n_sclass != C_STAT || isymp->n_type != T_NULL)
diff --git a/bfd/coffswap.h b/bfd/coffswap.h
index 63a0026a669..2dcfc205319 100644
--- a/bfd/coffswap.h
+++ b/bfd/coffswap.h
@@ -391,8 +391,8 @@ coff_swap_aux_in (bfd *abfd,
     case C_FILE:
       if (ext->x_file.x_fname[0] == 0)
 	{
-	  in->x_file.x_n.x_zeroes = 0;
-	  in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
+	  in->x_file.x_n.x_n.x_zeroes = 0;
+	  in->x_file.x_n.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
 	}
       else
 	{
@@ -402,11 +402,11 @@ coff_swap_aux_in (bfd *abfd,
 	  if (numaux > 1 && coff_data (abfd)->pe)
 	    {
 	      if (indx == 0)
-		memcpy (in->x_file.x_fname, ext->x_file.x_fname,
+		memcpy (in->x_file.x_n.x_fname, ext->x_file.x_fname,
 			numaux * sizeof (AUXENT));
 	    }
 	  else
-	    memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
+	    memcpy (in->x_file.x_n.x_fname, ext->x_file.x_fname, FILNMLEN);
 #endif
 	}
       goto end;
@@ -495,17 +495,17 @@ coff_swap_aux_out (bfd * abfd,
   switch (in_class)
     {
     case C_FILE:
-      if (in->x_file.x_fname[0] == 0)
+      if (in->x_file.x_n.x_fname[0] == 0)
 	{
 	  H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
-	  H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
+	  H_PUT_32 (abfd, in->x_file.x_n.x_n.x_offset, ext->x_file.x_n.x_offset);
 	}
       else
 	{
 #if FILNMLEN != E_FILNMLEN
 #error we need to cope with truncating or extending FILNMLEN
 #else
-	  memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
+	  memcpy (ext->x_file.x_fname, in->x_file.x_n.x_fname, FILNMLEN);
 #endif
 	}
       goto end;
diff --git a/bfd/libcoff.h b/bfd/libcoff.h
index 6dc68d1a398..1b4f988bb0b 100644
--- a/bfd/libcoff.h
+++ b/bfd/libcoff.h
@@ -658,6 +658,10 @@ typedef struct coff_ptr_struct
 
  /* Selector for the union above.  */
  bool is_sym;
+
+ /* An extra pointer which can used by format based on COFF (like XCOFF)
+    to provide extra information to their backend.  */
+ void *extrap;
 } combined_entry_type;
 
 
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index c41c3299277..e2a9cbb65c1 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -298,11 +298,11 @@ _bfd_XXi_swap_aux_in (bfd *	abfd,
     case C_FILE:
       if (ext->x_file.x_fname[0] == 0)
 	{
-	  in->x_file.x_n.x_zeroes = 0;
-	  in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
+	  in->x_file.x_n.x_n.x_zeroes = 0;
+	  in->x_file.x_n.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
 	}
       else
-	memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
+	memcpy (in->x_file.x_n.x_fname, ext->x_file.x_fname, FILNMLEN);
       return;
 
     case C_STAT:
@@ -370,13 +370,13 @@ _bfd_XXi_swap_aux_out (bfd *  abfd,
   switch (in_class)
     {
     case C_FILE:
-      if (in->x_file.x_fname[0] == 0)
+      if (in->x_file.x_n.x_fname[0] == 0)
 	{
 	  H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
-	  H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
+	  H_PUT_32 (abfd, in->x_file.x_n.x_n.x_offset, ext->x_file.x_n.x_offset);
 	}
       else
-	memcpy (ext->x_file.x_fname, in->x_file.x_fname, sizeof (ext->x_file.x_fname));
+	memcpy (ext->x_file.x_fname, in->x_file.x_n.x_fname, sizeof (ext->x_file.x_fname));
 
       return AUXESZ;
 
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index d29766fcbc5..ba2e6c1e5b9 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -4584,13 +4584,13 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
 		  /* This is the file name (or some comment put in by
 		     the compiler).  If it is long, we must put it in
 		     the string table.  */
-		  if (aux.x_file.x_n.x_zeroes == 0
-		      && aux.x_file.x_n.x_offset != 0)
+		  if (aux.x_file.x_n.x_n.x_zeroes == 0
+		      && aux.x_file.x_n.x_n.x_offset != 0)
 		    {
 		      const char *filename;
 		      bfd_size_type indx;
 
-		      BFD_ASSERT (aux.x_file.x_n.x_offset
+		      BFD_ASSERT (aux.x_file.x_n.x_n.x_offset
 				  >= STRING_SIZE_SIZE);
 		      if (strings == NULL)
 			{
@@ -4602,10 +4602,10 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
 			      return false;
 			    }
 			}
-		      if ((bfd_size_type) aux.x_file.x_n.x_offset >= obj_coff_strings_len (input_bfd))
+		      if ((bfd_size_type) aux.x_file.x_n.x_n.x_offset >= obj_coff_strings_len (input_bfd))
 			filename = _("<corrupt>");
 		      else
-			filename = strings + aux.x_file.x_n.x_offset;
+			filename = strings + aux.x_file.x_n.x_n.x_offset;
 		      indx = _bfd_stringtab_add (flinfo->strtab, filename,
 						 hash, copy);
 		      if (indx == (bfd_size_type) -1)
@@ -4615,7 +4615,7 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
 			       "failed \n"));
 			  return false;
 			}
-		      aux.x_file.x_n.x_offset = STRING_SIZE_SIZE + indx;
+		      aux.x_file.x_n.x_n.x_offset = STRING_SIZE_SIZE + indx;
 		    }
 		}
 	      else if (CSECT_SYM_P (isymp->n_sclass)
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index 28948cc4cd5..8dc7dd60c21 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -107,6 +107,7 @@ static void ppc_es (int);
 static void ppc_csect (int);
 static void ppc_dwsect (int);
 static void ppc_change_csect (symbolS *, offsetT);
+static void ppc_file (int);
 static void ppc_function (int);
 static void ppc_extern (int);
 static void ppc_xcoff_globl (int);
@@ -228,6 +229,7 @@ const pseudo_typeS md_pseudo_table[] =
   { "ei",	ppc_biei,	1 },
   { "es",	ppc_es,		0 },
   { "extern",	ppc_extern,	0 },
+  { "file",	ppc_file,	0 },
   { "function",	ppc_function,	0 },
   { "globl",	ppc_xcoff_globl, 0 },
   { "lglobl",	ppc_lglobl,	0 },
@@ -5128,6 +5130,67 @@ ppc_stabx (int ignore ATTRIBUTE_UNUSED)
   demand_empty_rest_of_line ();
 }
 
+/* The .file pseudo-op. On XCOFF, .file can have several parameters
+   which are being added to the symbol table to provide additional
+   information.  */
+
+static void
+ppc_file (int ignore ATTRIBUTE_UNUSED)
+{
+  char *sfname, *s1 = NULL, *s2 = NULL, *s3 = NULL;
+  int length, auxnb = 1;
+
+  /* Some assemblers tolerate immediately following '"'.  */
+  if ((sfname = demand_copy_string (&length)) != 0)
+    {
+      coff_symbol_type *coffsym;
+      if (*input_line_pointer == ',')
+	{
+	  ++input_line_pointer;
+	  s1 = demand_copy_string (&length);
+	  auxnb++;
+
+	  if (*input_line_pointer == ',')
+	    {
+	      ++input_line_pointer;
+	      s2 = demand_copy_string (&length);
+	      auxnb++;
+
+	      if (*input_line_pointer == ',')
+		{
+		  ++input_line_pointer;
+		  s3 = demand_copy_string (&length);
+		  auxnb++;
+		}
+	    }
+	}
+
+      /* Use coff dot_file creation and adjust auxiliary entries.  */
+      c_dot_file_symbol (sfname, 0);
+      S_SET_NUMBER_AUXILIARY (symbol_rootP, auxnb);
+      coffsym = coffsymbol (symbol_get_bfdsym (symbol_rootP));
+      coffsym->native[1].u.auxent.x_file.x_ftype = XFT_FN;
+
+      if (s1)
+	{
+	  coffsym->native[2].u.auxent.x_file.x_ftype = XFT_CT;
+	  coffsym->native[2].extrap = s1;
+	}
+      if (s2)
+	{
+	  coffsym->native[3].u.auxent.x_file.x_ftype = XFT_CV;
+	  coffsym->native[3].extrap = s2;
+	}
+      if (s3)
+	{
+	  coffsym->native[4].u.auxent.x_file.x_ftype = XFT_CD;
+	  coffsym->native[4].extrap = s3;
+	}
+
+      demand_empty_rest_of_line ();
+    }
+}
+
 /* The .function pseudo-op.  This takes several arguments.  The first
    argument seems to be the external name of the symbol.  The second
    argument seems to be the label for the start of the function.  gcc
diff --git a/gas/config/tc-ppc.h b/gas/config/tc-ppc.h
index fb18730db3c..2d0a8865d98 100644
--- a/gas/config/tc-ppc.h
+++ b/gas/config/tc-ppc.h
@@ -146,7 +146,7 @@ struct ppc_tc_sy
 #define TC_SYMFIELD_TYPE struct ppc_tc_sy
 
 /* We need an additional auxent for function symbols.  */
-#define OBJ_COFF_MAX_AUXENTRIES 2
+#define OBJ_COFF_MAX_AUXENTRIES 4
 
 /* Square and curly brackets are permitted in symbol names.  */
 #define LEX_BR 3
diff --git a/gas/testsuite/gas/ppc/aix.exp b/gas/testsuite/gas/ppc/aix.exp
index 176be6ac630..31cbb4b1bf0 100644
--- a/gas/testsuite/gas/ppc/aix.exp
+++ b/gas/testsuite/gas/ppc/aix.exp
@@ -87,4 +87,7 @@ if { [istarget "powerpc*-*-aix*"] || [istarget "rs6000-*-aix*"] } then {
 
     run_dump_test "xcoff-visibility-32"
     run_dump_test "xcoff-visibility-64"
+
+    run_dump_test "xcoff-file-32"
+    run_dump_test "xcoff-file-64"
 }
diff --git a/gas/testsuite/gas/ppc/xcoff-file-32.d b/gas/testsuite/gas/ppc/xcoff-file-32.d
new file mode 100644
index 00000000000..a831b3b4587
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-file-32.d
@@ -0,0 +1,13 @@
+#as: -a32
+#source: xcoff-file.s
+#objdump: -t
+#name: XCOFF file test (32-bit)
+
+.*
+
+SYMBOL TABLE:
+\[  0\].*\(scl 103\) \(nx 4\) .* file.s
+File 
+File ftype 1 fname "A long string"
+File ftype 2 fname "short"
+File ftype 128 fname "Another long string inside the strign table."
diff --git a/gas/testsuite/gas/ppc/xcoff-file-64.d b/gas/testsuite/gas/ppc/xcoff-file-64.d
new file mode 100644
index 00000000000..12bb6efc93b
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-file-64.d
@@ -0,0 +1,13 @@
+#as: -a64
+#source: xcoff-file.s
+#objdump: -t
+#name: XCOFF file test (64-bit)
+
+.*
+
+SYMBOL TABLE:
+\[  0\].*\(scl 103\) \(nx 4\) .* file.s
+File 
+File ftype 1 fname "A long string"
+File ftype 2 fname "short"
+File ftype 128 fname "Another long string inside the strign table."
diff --git a/gas/testsuite/gas/ppc/xcoff-file.s b/gas/testsuite/gas/ppc/xcoff-file.s
new file mode 100644
index 00000000000..229ab889f49
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-file.s
@@ -0,0 +1 @@
+.file "file.s", "A long string", "short", "Another long string inside the strign table."
diff --git a/include/coff/internal.h b/include/coff/internal.h
index b65829159ea..68a801e78f8 100644
--- a/include/coff/internal.h
+++ b/include/coff/internal.h
@@ -589,18 +589,21 @@ union internal_auxent
     unsigned short x_tvndx;	/* tv index */
   }      x_sym;
 
-  union
+  struct
   {
-    /* PR 17754: We use to FILNMLEN for the size of the x_fname
-       array, but that causes problems as PE targets use a larger
-       value.  We cannot use their definition of E_FILNMLEN as this
-       header can be used without including any PE headers.  */
-    char x_fname[20];
-    struct
-    {
-      long x_zeroes;
-      long x_offset;
-    }      x_n;
+    union {
+      /* PR 17754: We use to FILNMLEN for the size of the x_fname
+	 array, but that causes problems as PE targets use a larger
+	 value.  We cannot use their definition of E_FILNMLEN as this
+	 header can be used without including any PE headers.  */
+      char x_fname[20];
+      struct
+      {
+	long x_zeroes;
+	long x_offset;
+      }      x_n;
+    } x_n;
+    unsigned char x_ftype;
   }     x_file;
 
   struct
diff --git a/include/coff/rs6000.h b/include/coff/rs6000.h
index e60efff23b6..fd3f01dccbc 100644
--- a/include/coff/rs6000.h
+++ b/include/coff/rs6000.h
@@ -176,6 +176,7 @@ union external_auxent {
       } x_n;
     } x_n;
     char x_ftype[1];
+    char x_resv[3];
   } x_file;
 
   struct {
diff --git a/include/coff/xcoff.h b/include/coff/xcoff.h
index ff3cb79fbbc..6ab55aba006 100644
--- a/include/coff/xcoff.h
+++ b/include/coff/xcoff.h
@@ -190,6 +190,12 @@
 #define XMC_UL     21          /* Read-write uninitialized TLS data */
 #define XMC_TE     22          /* Same as XMC_TC but mapped after it */
 
+/* x_ftype values:  */
+#define XFT_FN 0    /* Specifies the source-file name */
+#define XFT_CT 1    /* Specifies the compiler time stamp */
+#define XFT_CV 2    /* Specifies the compiler version number */
+#define XFT_CD 128  /*Specifies compiler-defined information */
+
 /* The ldhdr structure.  This appears at the start of the .loader
    section.  */
 
-- 
2.33.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF
  2021-10-18 11:37 [PATCH] PR 28447: implement multiple parameters for .file on XCOFF CHIGOT, CLEMENT
@ 2021-10-20 10:09 ` Alan Modra
  2021-10-20 12:01   ` CHIGOT, CLEMENT
  2021-11-26 17:47 ` Mike Frysinger
  1 sibling, 1 reply; 12+ messages in thread
From: Alan Modra @ 2021-10-20 10:09 UTC (permalink / raw)
  To: CHIGOT, CLEMENT; +Cc: binutils, David Edelsohn

On Mon, Oct 18, 2021 at 11:37:25AM +0000, CHIGOT, CLEMENT via Binutils wrote:
> I would be glad if someone can test it on Windows and maybe on other
> COFF formats too. It shouldn't impact but we never know. 

There is quite a lot of testing that you can do yourself without
having access to machines running natively.  For example, configuring
binutils with something like the following

~/src/binutils-gdb/configure \
--disable-nls \
--disable-gdb --disable-gdbserver --disable-gdbsupport \
--disable-libbacktrace --disable-libdecnumber \
--disable-readline --disable-sim \
--target=x86_64-w64-mingw32

then "make && make check" with some relevant targets such as
x86_64-w64-mingw32 above will catch errors.  I built with your patch
and ran into segfaults.  On a few I looked at, they were on the
following lines added to coffgen.c

	  /* Add strings for C_FILE aux entries. */
	  if (c_symbol->native->u.syment.n_sclass == C_FILE

c_symbol->native was NULL.

(BTW, please do post patches against current mainline, not mainline
plus other patches of yours.  I had to edit the diff to get it to
apply.  Also build and test with just the patch you are posting!)

The list of failing targets/tests I found is:

arm-pe  +FAIL: dlltool (version.dll)
arm-pe  +FAIL: dlltool -p (execution)
arm-pe  +FAIL: ld-pe/pr19803
arm-wince-pe  +FAIL: dlltool (version.dll)
arm-wince-pe  +FAIL: dlltool -p (execution)
arm-wince-pe  +FAIL: ld-pe/pr19803
i686-pe  +FAIL: dlltool (version.dll)
i686-pe  +FAIL: dlltool -p (execution)
i686-pe  +FAIL: ld-pe/pr19803
sh-pe  +FAIL: ld-pe/pr19803
tic30-unknown-coff  +FAIL: ld-scripts/align2a
tic30-unknown-coff  +FAIL: ld-scripts/align2b
tic30-unknown-coff  +FAIL: ld-scripts/empty-address-3a
tic30-unknown-coff  +FAIL: ld-scripts/empty-address-3b
tic30-unknown-coff  +FAIL: ld-scripts/empty-address-3c
tic30-unknown-coff  +FAIL: ld-scripts/sane1
tic30-unknown-coff  +FAIL: ld-scripts/assign-loc
tic30-unknown-coff  +FAIL: ld-scripts/provide-10
tic30-unknown-coff  +FAIL: ld-scripts/provide-11
tic30-unknown-coff  +FAIL: ld-scripts/provide-12
tic30-unknown-coff  +FAIL: ld-scripts/provide-9
tic30-unknown-coff  +FAIL: script
tic30-unknown-coff  +FAIL: MRI script
tic30-unknown-coff  +FAIL: MEMORY
tic30-unknown-coff  +FAIL: MEMORY with symbols
tic30-unknown-coff  +FAIL: SEGMENT_START expression not absolute (default)
tic30-unknown-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
tic30-unknown-coff  +FAIL: SIZEOF
tic4x-coff  +FAIL: check sections 1
tic4x-coff  +FAIL: ld-misc/defsym1
tic4x-coff  +FAIL: ld-scripts/align2a
tic4x-coff  +FAIL: ld-scripts/align2b
tic4x-coff  +FAIL: ld-scripts/empty-address-3a
tic4x-coff  +FAIL: ld-scripts/empty-address-3b
tic4x-coff  +FAIL: ld-scripts/empty-address-3c
tic4x-coff  +FAIL: ld-scripts/sane1
tic4x-coff  +FAIL: ld-scripts/assign-loc
tic4x-coff  +FAIL: ld-scripts/provide-10
tic4x-coff  +FAIL: ld-scripts/provide-11
tic4x-coff  +FAIL: ld-scripts/provide-12
tic4x-coff  +FAIL: ld-scripts/provide-9
tic4x-coff  +FAIL: script
tic4x-coff  +FAIL: MRI script
tic4x-coff  +FAIL: MEMORY
tic4x-coff  +FAIL: MEMORY with symbols
tic4x-coff  +FAIL: SEGMENT_START expression not absolute (default)
tic4x-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
tic4x-coff  +FAIL: SIZEOF
tic4x-coff  +FAIL: sysroot-prefix common plain -Lpath, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain -Lpath, unquoted
tic4x-coff  +FAIL: sysroot-prefix common full-path, quoted
tic4x-coff  +FAIL: sysroot-prefix common full-path, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted
tic4x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, quoted
tic4x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted
tic4x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted
tic4x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted
tic4x-coff  +FAIL: --entry foo archive
tic4x-coff  +FAIL: --entry foo -u foo archive
tic4x-coff  +FAIL: --entry foo
tic4x-coff  +FAIL: --entry foo -u foo
tic4x-coff  +FAIL: --entry 0x0
tic54x-coff  +FAIL: check sections 1
tic54x-coff  +FAIL: ld-misc/defsym1
tic54x-coff  +FAIL: ld-scripts/align2a
tic54x-coff  +FAIL: ld-scripts/align2b
tic54x-coff  +FAIL: ld-scripts/empty-address-3a
tic54x-coff  +FAIL: ld-scripts/empty-address-3b
tic54x-coff  +FAIL: ld-scripts/empty-address-3c
tic54x-coff  +FAIL: ld-scripts/sane1
tic54x-coff  +FAIL: ld-scripts/assign-loc
tic54x-coff  +FAIL: ld-scripts/provide-10
tic54x-coff  +FAIL: ld-scripts/provide-11
tic54x-coff  +FAIL: ld-scripts/provide-12
tic54x-coff  +FAIL: ld-scripts/provide-9
tic54x-coff  +FAIL: script
tic54x-coff  +FAIL: MRI script
tic54x-coff  +FAIL: MEMORY
tic54x-coff  +FAIL: MEMORY with symbols
tic54x-coff  +FAIL: SIZEOF
tic54x-coff  +FAIL: sysroot-prefix common plain -Lpath, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain -Lpath, unquoted
tic54x-coff  +FAIL: sysroot-prefix common full-path, quoted
tic54x-coff  +FAIL: sysroot-prefix common full-path, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted
tic54x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, quoted
tic54x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted
tic54x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted
tic54x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted
tic54x-coff  +FAIL: --entry foo archive
tic54x-coff  +FAIL: --entry foo -u foo archive
tic54x-coff  +FAIL: --entry foo
tic54x-coff  +FAIL: --entry foo -u foo
tic54x-coff  +FAIL: --entry 0x0
x86_64-w64-mingw32  +FAIL: dlltool (version.dll)
x86_64-w64-mingw32  +FAIL: dlltool -p (execution)
x86_64-w64-mingw32  +FAIL: ld-pe/pr19803
x86_64-w64-mingw32  +FAIL: PR ld/20070
z80-coff  +FAIL: ld-scripts/align2a
z80-coff  +FAIL: ld-scripts/align2b
z80-coff  +FAIL: ld-scripts/empty-address-3a
z80-coff  +FAIL: ld-scripts/empty-address-3b
z80-coff  +FAIL: ld-scripts/empty-address-3c
z80-coff  +FAIL: ld-scripts/sane1
z80-coff  +FAIL: ld-scripts/assign-loc
z80-coff  +FAIL: ld-scripts/provide-10
z80-coff  +FAIL: ld-scripts/provide-11
z80-coff  +FAIL: ld-scripts/provide-12
z80-coff  +FAIL: ld-scripts/provide-9
z80-coff  +FAIL: script
z80-coff  +FAIL: MRI script
z80-coff  +FAIL: MEMORY
z80-coff  +FAIL: MEMORY with symbols
z80-coff  +FAIL: SEGMENT_START expression not absolute (default)
z80-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
z80-coff  +FAIL: SIZEOF
z8k-coff  +FAIL: check sections 1
z8k-coff  +FAIL: ld-misc/defsym1
z8k-coff  +FAIL: ld-scripts/align2a
z8k-coff  +FAIL: ld-scripts/align2b
z8k-coff  +FAIL: ld-scripts/empty-address-3a
z8k-coff  +FAIL: ld-scripts/empty-address-3b
z8k-coff  +FAIL: ld-scripts/empty-address-3c
z8k-coff  +FAIL: ld-scripts/sane1
z8k-coff  +FAIL: ld-scripts/assign-loc
z8k-coff  +FAIL: ld-scripts/provide-10
z8k-coff  +FAIL: ld-scripts/provide-11
z8k-coff  +FAIL: ld-scripts/provide-12
z8k-coff  +FAIL: ld-scripts/provide-9
z8k-coff  +FAIL: script
z8k-coff  +FAIL: MRI script
z8k-coff  +FAIL: MEMORY
z8k-coff  +FAIL: MEMORY with symbols
z8k-coff  +FAIL: SEGMENT_START expression not absolute (default)
z8k-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
z8k-coff  +FAIL: SIZEOF
z8k-coff  +FAIL: sysroot-prefix common plain -Lpath, quoted
z8k-coff  +FAIL: sysroot-prefix common plain -Lpath, unquoted
z8k-coff  +FAIL: sysroot-prefix common full-path, quoted
z8k-coff  +FAIL: sysroot-prefix common full-path, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted
z8k-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, quoted
z8k-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted
z8k-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted
z8k-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted
z8k-coff  +FAIL: --entry foo archive
z8k-coff  +FAIL: --entry foo -u foo archive
z8k-coff  +FAIL: --entry foo
z8k-coff  +FAIL: --entry foo -u foo
z8k-coff  +FAIL: --entry 0x0


-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF
  2021-10-20 10:09 ` Alan Modra
@ 2021-10-20 12:01   ` CHIGOT, CLEMENT
  2021-10-21  7:51     ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 12+ messages in thread
From: CHIGOT, CLEMENT @ 2021-10-20 12:01 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils, David Edelsohn

HI Alan,

Thanks for providing me how to test without the machine.
It would help me a lot !

And sorry about the patch not being based on the mainline.
I forget that I've a WIP which is impacting it... But don't hesitate
to reject my patch sooner, if it happens again. I'll try not to though !

Thanks and sorry,
Clément

________________________________
From: Alan Modra <amodra@gmail.com>
Sent: Wednesday, October 20, 2021 12:09 PM
To: CHIGOT, CLEMENT <clement.chigot@atos.net>
Cc: binutils@sourceware.org <binutils@sourceware.org>; David Edelsohn <dje.gcc@gmail.com>
Subject: Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF

Caution! External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.

On Mon, Oct 18, 2021 at 11:37:25AM +0000, CHIGOT, CLEMENT via Binutils wrote:
> I would be glad if someone can test it on Windows and maybe on other
> COFF formats too. It shouldn't impact but we never know.

There is quite a lot of testing that you can do yourself without
having access to machines running natively.  For example, configuring
binutils with something like the following

~/src/binutils-gdb/configure \
--disable-nls \
--disable-gdb --disable-gdbserver --disable-gdbsupport \
--disable-libbacktrace --disable-libdecnumber \
--disable-readline --disable-sim \
--target=x86_64-w64-mingw32

then "make && make check" with some relevant targets such as
x86_64-w64-mingw32 above will catch errors.  I built with your patch
and ran into segfaults.  On a few I looked at, they were on the
following lines added to coffgen.c

          /* Add strings for C_FILE aux entries. */
          if (c_symbol->native->u.syment.n_sclass == C_FILE

c_symbol->native was NULL.

(BTW, please do post patches against current mainline, not mainline
plus other patches of yours.  I had to edit the diff to get it to
apply.  Also build and test with just the patch you are posting!)

The list of failing targets/tests I found is:

arm-pe  +FAIL: dlltool (version.dll)
arm-pe  +FAIL: dlltool -p (execution)
arm-pe  +FAIL: ld-pe/pr19803
arm-wince-pe  +FAIL: dlltool (version.dll)
arm-wince-pe  +FAIL: dlltool -p (execution)
arm-wince-pe  +FAIL: ld-pe/pr19803
i686-pe  +FAIL: dlltool (version.dll)
i686-pe  +FAIL: dlltool -p (execution)
i686-pe  +FAIL: ld-pe/pr19803
sh-pe  +FAIL: ld-pe/pr19803
tic30-unknown-coff  +FAIL: ld-scripts/align2a
tic30-unknown-coff  +FAIL: ld-scripts/align2b
tic30-unknown-coff  +FAIL: ld-scripts/empty-address-3a
tic30-unknown-coff  +FAIL: ld-scripts/empty-address-3b
tic30-unknown-coff  +FAIL: ld-scripts/empty-address-3c
tic30-unknown-coff  +FAIL: ld-scripts/sane1
tic30-unknown-coff  +FAIL: ld-scripts/assign-loc
tic30-unknown-coff  +FAIL: ld-scripts/provide-10
tic30-unknown-coff  +FAIL: ld-scripts/provide-11
tic30-unknown-coff  +FAIL: ld-scripts/provide-12
tic30-unknown-coff  +FAIL: ld-scripts/provide-9
tic30-unknown-coff  +FAIL: script
tic30-unknown-coff  +FAIL: MRI script
tic30-unknown-coff  +FAIL: MEMORY
tic30-unknown-coff  +FAIL: MEMORY with symbols
tic30-unknown-coff  +FAIL: SEGMENT_START expression not absolute (default)
tic30-unknown-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
tic30-unknown-coff  +FAIL: SIZEOF
tic4x-coff  +FAIL: check sections 1
tic4x-coff  +FAIL: ld-misc/defsym1
tic4x-coff  +FAIL: ld-scripts/align2a
tic4x-coff  +FAIL: ld-scripts/align2b
tic4x-coff  +FAIL: ld-scripts/empty-address-3a
tic4x-coff  +FAIL: ld-scripts/empty-address-3b
tic4x-coff  +FAIL: ld-scripts/empty-address-3c
tic4x-coff  +FAIL: ld-scripts/sane1
tic4x-coff  +FAIL: ld-scripts/assign-loc
tic4x-coff  +FAIL: ld-scripts/provide-10
tic4x-coff  +FAIL: ld-scripts/provide-11
tic4x-coff  +FAIL: ld-scripts/provide-12
tic4x-coff  +FAIL: ld-scripts/provide-9
tic4x-coff  +FAIL: script
tic4x-coff  +FAIL: MRI script
tic4x-coff  +FAIL: MEMORY
tic4x-coff  +FAIL: MEMORY with symbols
tic4x-coff  +FAIL: SEGMENT_START expression not absolute (default)
tic4x-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
tic4x-coff  +FAIL: SIZEOF
tic4x-coff  +FAIL: sysroot-prefix common plain -Lpath, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain -Lpath, unquoted
tic4x-coff  +FAIL: sysroot-prefix common full-path, quoted
tic4x-coff  +FAIL: sysroot-prefix common full-path, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted
tic4x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, quoted
tic4x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted
tic4x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted
tic4x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted
tic4x-coff  +FAIL: --entry foo archive
tic4x-coff  +FAIL: --entry foo -u foo archive
tic4x-coff  +FAIL: --entry foo
tic4x-coff  +FAIL: --entry foo -u foo
tic4x-coff  +FAIL: --entry 0x0
tic54x-coff  +FAIL: check sections 1
tic54x-coff  +FAIL: ld-misc/defsym1
tic54x-coff  +FAIL: ld-scripts/align2a
tic54x-coff  +FAIL: ld-scripts/align2b
tic54x-coff  +FAIL: ld-scripts/empty-address-3a
tic54x-coff  +FAIL: ld-scripts/empty-address-3b
tic54x-coff  +FAIL: ld-scripts/empty-address-3c
tic54x-coff  +FAIL: ld-scripts/sane1
tic54x-coff  +FAIL: ld-scripts/assign-loc
tic54x-coff  +FAIL: ld-scripts/provide-10
tic54x-coff  +FAIL: ld-scripts/provide-11
tic54x-coff  +FAIL: ld-scripts/provide-12
tic54x-coff  +FAIL: ld-scripts/provide-9
tic54x-coff  +FAIL: script
tic54x-coff  +FAIL: MRI script
tic54x-coff  +FAIL: MEMORY
tic54x-coff  +FAIL: MEMORY with symbols
tic54x-coff  +FAIL: SIZEOF
tic54x-coff  +FAIL: sysroot-prefix common plain -Lpath, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain -Lpath, unquoted
tic54x-coff  +FAIL: sysroot-prefix common full-path, quoted
tic54x-coff  +FAIL: sysroot-prefix common full-path, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted
tic54x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, quoted
tic54x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted
tic54x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted
tic54x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted
tic54x-coff  +FAIL: --entry foo archive
tic54x-coff  +FAIL: --entry foo -u foo archive
tic54x-coff  +FAIL: --entry foo
tic54x-coff  +FAIL: --entry foo -u foo
tic54x-coff  +FAIL: --entry 0x0
x86_64-w64-mingw32  +FAIL: dlltool (version.dll)
x86_64-w64-mingw32  +FAIL: dlltool -p (execution)
x86_64-w64-mingw32  +FAIL: ld-pe/pr19803
x86_64-w64-mingw32  +FAIL: PR ld/20070
z80-coff  +FAIL: ld-scripts/align2a
z80-coff  +FAIL: ld-scripts/align2b
z80-coff  +FAIL: ld-scripts/empty-address-3a
z80-coff  +FAIL: ld-scripts/empty-address-3b
z80-coff  +FAIL: ld-scripts/empty-address-3c
z80-coff  +FAIL: ld-scripts/sane1
z80-coff  +FAIL: ld-scripts/assign-loc
z80-coff  +FAIL: ld-scripts/provide-10
z80-coff  +FAIL: ld-scripts/provide-11
z80-coff  +FAIL: ld-scripts/provide-12
z80-coff  +FAIL: ld-scripts/provide-9
z80-coff  +FAIL: script
z80-coff  +FAIL: MRI script
z80-coff  +FAIL: MEMORY
z80-coff  +FAIL: MEMORY with symbols
z80-coff  +FAIL: SEGMENT_START expression not absolute (default)
z80-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
z80-coff  +FAIL: SIZEOF
z8k-coff  +FAIL: check sections 1
z8k-coff  +FAIL: ld-misc/defsym1
z8k-coff  +FAIL: ld-scripts/align2a
z8k-coff  +FAIL: ld-scripts/align2b
z8k-coff  +FAIL: ld-scripts/empty-address-3a
z8k-coff  +FAIL: ld-scripts/empty-address-3b
z8k-coff  +FAIL: ld-scripts/empty-address-3c
z8k-coff  +FAIL: ld-scripts/sane1
z8k-coff  +FAIL: ld-scripts/assign-loc
z8k-coff  +FAIL: ld-scripts/provide-10
z8k-coff  +FAIL: ld-scripts/provide-11
z8k-coff  +FAIL: ld-scripts/provide-12
z8k-coff  +FAIL: ld-scripts/provide-9
z8k-coff  +FAIL: script
z8k-coff  +FAIL: MRI script
z8k-coff  +FAIL: MEMORY
z8k-coff  +FAIL: MEMORY with symbols
z8k-coff  +FAIL: SEGMENT_START expression not absolute (default)
z8k-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
z8k-coff  +FAIL: SIZEOF
z8k-coff  +FAIL: sysroot-prefix common plain -Lpath, quoted
z8k-coff  +FAIL: sysroot-prefix common plain -Lpath, unquoted
z8k-coff  +FAIL: sysroot-prefix common full-path, quoted
z8k-coff  +FAIL: sysroot-prefix common full-path, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted
z8k-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, quoted
z8k-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted
z8k-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted
z8k-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted
z8k-coff  +FAIL: --entry foo archive
z8k-coff  +FAIL: --entry foo -u foo archive
z8k-coff  +FAIL: --entry foo
z8k-coff  +FAIL: --entry foo -u foo
z8k-coff  +FAIL: --entry 0x0


--
Alan Modra
Australia Development Lab, IBM


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF
  2021-10-20 12:01   ` CHIGOT, CLEMENT
@ 2021-10-21  7:51     ` CHIGOT, CLEMENT
  2021-11-09 13:24       ` CHIGOT, CLEMENT
  2021-11-10  4:38       ` Alan Modra
  0 siblings, 2 replies; 12+ messages in thread
From: CHIGOT, CLEMENT @ 2021-10-21  7:51 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils, David Edelsohn

[-- Attachment #1: Type: text/plain, Size: 12009 bytes --]

Hi Alan,

The issue was indeed linked to the coffgen.c code you pointed out.
I've tested on "arm-pe", "arm-wince-pe", "i686-pe", "sh-pe",
"tic30-unknown-coff", "tic4x-coff", "tic54x-coff", "x86_64-w64-mingw32"
and "z80-coff", the results are fine.
Is there any other coff targets which should be tested ?

Moreover, as I've changed the structure of "combined_entry_type", the
documentation needs to be updated at "https://sourceware.org/binutils/docs/bfd/coff.html".
Is this done automatically or should I do something myself ?

Thanks,
Clément

________________________________
From: Binutils <binutils-bounces+clement.chigot=atos.net@sourceware.org> on behalf of CHIGOT, CLEMENT via Binutils <binutils@sourceware.org>
Sent: Wednesday, October 20, 2021 2:01 PM
To: Alan Modra <amodra@gmail.com>
Cc: binutils@sourceware.org <binutils@sourceware.org>; David Edelsohn <dje.gcc@gmail.com>
Subject: Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF

Caution! External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.

HI Alan,

Thanks for providing me how to test without the machine.
It would help me a lot !

And sorry about the patch not being based on the mainline.
I forget that I've a WIP which is impacting it... But don't hesitate
to reject my patch sooner, if it happens again. I'll try not to though !

Thanks and sorry,
Clément

________________________________
From: Alan Modra <amodra@gmail.com>
Sent: Wednesday, October 20, 2021 12:09 PM
To: CHIGOT, CLEMENT <clement.chigot@atos.net>
Cc: binutils@sourceware.org <binutils@sourceware.org>; David Edelsohn <dje.gcc@gmail.com>
Subject: Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF

Caution! External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.

On Mon, Oct 18, 2021 at 11:37:25AM +0000, CHIGOT, CLEMENT via Binutils wrote:
> I would be glad if someone can test it on Windows and maybe on other
> COFF formats too. It shouldn't impact but we never know.

There is quite a lot of testing that you can do yourself without
having access to machines running natively.  For example, configuring
binutils with something like the following

~/src/binutils-gdb/configure \
--disable-nls \
--disable-gdb --disable-gdbserver --disable-gdbsupport \
--disable-libbacktrace --disable-libdecnumber \
--disable-readline --disable-sim \
--target=x86_64-w64-mingw32

then "make && make check" with some relevant targets such as
x86_64-w64-mingw32 above will catch errors.  I built with your patch
and ran into segfaults.  On a few I looked at, they were on the
following lines added to coffgen.c

          /* Add strings for C_FILE aux entries. */
          if (c_symbol->native->u.syment.n_sclass == C_FILE

c_symbol->native was NULL.

(BTW, please do post patches against current mainline, not mainline
plus other patches of yours.  I had to edit the diff to get it to
apply.  Also build and test with just the patch you are posting!)

The list of failing targets/tests I found is:

arm-pe  +FAIL: dlltool (version.dll)
arm-pe  +FAIL: dlltool -p (execution)
arm-pe  +FAIL: ld-pe/pr19803
arm-wince-pe  +FAIL: dlltool (version.dll)
arm-wince-pe  +FAIL: dlltool -p (execution)
arm-wince-pe  +FAIL: ld-pe/pr19803
i686-pe  +FAIL: dlltool (version.dll)
i686-pe  +FAIL: dlltool -p (execution)
i686-pe  +FAIL: ld-pe/pr19803
sh-pe  +FAIL: ld-pe/pr19803
tic30-unknown-coff  +FAIL: ld-scripts/align2a
tic30-unknown-coff  +FAIL: ld-scripts/align2b
tic30-unknown-coff  +FAIL: ld-scripts/empty-address-3a
tic30-unknown-coff  +FAIL: ld-scripts/empty-address-3b
tic30-unknown-coff  +FAIL: ld-scripts/empty-address-3c
tic30-unknown-coff  +FAIL: ld-scripts/sane1
tic30-unknown-coff  +FAIL: ld-scripts/assign-loc
tic30-unknown-coff  +FAIL: ld-scripts/provide-10
tic30-unknown-coff  +FAIL: ld-scripts/provide-11
tic30-unknown-coff  +FAIL: ld-scripts/provide-12
tic30-unknown-coff  +FAIL: ld-scripts/provide-9
tic30-unknown-coff  +FAIL: script
tic30-unknown-coff  +FAIL: MRI script
tic30-unknown-coff  +FAIL: MEMORY
tic30-unknown-coff  +FAIL: MEMORY with symbols
tic30-unknown-coff  +FAIL: SEGMENT_START expression not absolute (default)
tic30-unknown-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
tic30-unknown-coff  +FAIL: SIZEOF
tic4x-coff  +FAIL: check sections 1
tic4x-coff  +FAIL: ld-misc/defsym1
tic4x-coff  +FAIL: ld-scripts/align2a
tic4x-coff  +FAIL: ld-scripts/align2b
tic4x-coff  +FAIL: ld-scripts/empty-address-3a
tic4x-coff  +FAIL: ld-scripts/empty-address-3b
tic4x-coff  +FAIL: ld-scripts/empty-address-3c
tic4x-coff  +FAIL: ld-scripts/sane1
tic4x-coff  +FAIL: ld-scripts/assign-loc
tic4x-coff  +FAIL: ld-scripts/provide-10
tic4x-coff  +FAIL: ld-scripts/provide-11
tic4x-coff  +FAIL: ld-scripts/provide-12
tic4x-coff  +FAIL: ld-scripts/provide-9
tic4x-coff  +FAIL: script
tic4x-coff  +FAIL: MRI script
tic4x-coff  +FAIL: MEMORY
tic4x-coff  +FAIL: MEMORY with symbols
tic4x-coff  +FAIL: SEGMENT_START expression not absolute (default)
tic4x-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
tic4x-coff  +FAIL: SIZEOF
tic4x-coff  +FAIL: sysroot-prefix common plain -Lpath, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain -Lpath, unquoted
tic4x-coff  +FAIL: sysroot-prefix common full-path, quoted
tic4x-coff  +FAIL: sysroot-prefix common full-path, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted
tic4x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, quoted
tic4x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted
tic4x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted
tic4x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted
tic4x-coff  +FAIL: --entry foo archive
tic4x-coff  +FAIL: --entry foo -u foo archive
tic4x-coff  +FAIL: --entry foo
tic4x-coff  +FAIL: --entry foo -u foo
tic4x-coff  +FAIL: --entry 0x0
tic54x-coff  +FAIL: check sections 1
tic54x-coff  +FAIL: ld-misc/defsym1
tic54x-coff  +FAIL: ld-scripts/align2a
tic54x-coff  +FAIL: ld-scripts/align2b
tic54x-coff  +FAIL: ld-scripts/empty-address-3a
tic54x-coff  +FAIL: ld-scripts/empty-address-3b
tic54x-coff  +FAIL: ld-scripts/empty-address-3c
tic54x-coff  +FAIL: ld-scripts/sane1
tic54x-coff  +FAIL: ld-scripts/assign-loc
tic54x-coff  +FAIL: ld-scripts/provide-10
tic54x-coff  +FAIL: ld-scripts/provide-11
tic54x-coff  +FAIL: ld-scripts/provide-12
tic54x-coff  +FAIL: ld-scripts/provide-9
tic54x-coff  +FAIL: script
tic54x-coff  +FAIL: MRI script
tic54x-coff  +FAIL: MEMORY
tic54x-coff  +FAIL: MEMORY with symbols
tic54x-coff  +FAIL: SIZEOF
tic54x-coff  +FAIL: sysroot-prefix common plain -Lpath, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain -Lpath, unquoted
tic54x-coff  +FAIL: sysroot-prefix common full-path, quoted
tic54x-coff  +FAIL: sysroot-prefix common full-path, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted
tic54x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, quoted
tic54x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted
tic54x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted
tic54x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted
tic54x-coff  +FAIL: --entry foo archive
tic54x-coff  +FAIL: --entry foo -u foo archive
tic54x-coff  +FAIL: --entry foo
tic54x-coff  +FAIL: --entry foo -u foo
tic54x-coff  +FAIL: --entry 0x0
x86_64-w64-mingw32  +FAIL: dlltool (version.dll)
x86_64-w64-mingw32  +FAIL: dlltool -p (execution)
x86_64-w64-mingw32  +FAIL: ld-pe/pr19803
x86_64-w64-mingw32  +FAIL: PR ld/20070
z80-coff  +FAIL: ld-scripts/align2a
z80-coff  +FAIL: ld-scripts/align2b
z80-coff  +FAIL: ld-scripts/empty-address-3a
z80-coff  +FAIL: ld-scripts/empty-address-3b
z80-coff  +FAIL: ld-scripts/empty-address-3c
z80-coff  +FAIL: ld-scripts/sane1
z80-coff  +FAIL: ld-scripts/assign-loc
z80-coff  +FAIL: ld-scripts/provide-10
z80-coff  +FAIL: ld-scripts/provide-11
z80-coff  +FAIL: ld-scripts/provide-12
z80-coff  +FAIL: ld-scripts/provide-9
z80-coff  +FAIL: script
z80-coff  +FAIL: MRI script
z80-coff  +FAIL: MEMORY
z80-coff  +FAIL: MEMORY with symbols
z80-coff  +FAIL: SEGMENT_START expression not absolute (default)
z80-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
z80-coff  +FAIL: SIZEOF
z8k-coff  +FAIL: check sections 1
z8k-coff  +FAIL: ld-misc/defsym1
z8k-coff  +FAIL: ld-scripts/align2a
z8k-coff  +FAIL: ld-scripts/align2b
z8k-coff  +FAIL: ld-scripts/empty-address-3a
z8k-coff  +FAIL: ld-scripts/empty-address-3b
z8k-coff  +FAIL: ld-scripts/empty-address-3c
z8k-coff  +FAIL: ld-scripts/sane1
z8k-coff  +FAIL: ld-scripts/assign-loc
z8k-coff  +FAIL: ld-scripts/provide-10
z8k-coff  +FAIL: ld-scripts/provide-11
z8k-coff  +FAIL: ld-scripts/provide-12
z8k-coff  +FAIL: ld-scripts/provide-9
z8k-coff  +FAIL: script
z8k-coff  +FAIL: MRI script
z8k-coff  +FAIL: MEMORY
z8k-coff  +FAIL: MEMORY with symbols
z8k-coff  +FAIL: SEGMENT_START expression not absolute (default)
z8k-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
z8k-coff  +FAIL: SIZEOF
z8k-coff  +FAIL: sysroot-prefix common plain -Lpath, quoted
z8k-coff  +FAIL: sysroot-prefix common plain -Lpath, unquoted
z8k-coff  +FAIL: sysroot-prefix common full-path, quoted
z8k-coff  +FAIL: sysroot-prefix common full-path, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted
z8k-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, quoted
z8k-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted
z8k-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted
z8k-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted
z8k-coff  +FAIL: --entry foo archive
z8k-coff  +FAIL: --entry foo -u foo archive
z8k-coff  +FAIL: --entry foo
z8k-coff  +FAIL: --entry foo -u foo
z8k-coff  +FAIL: --entry 0x0


--
Alan Modra
Australia Development Lab, IBM



[-- Attachment #2: 0001-PR-28447-implement-multiple-parameters-for-.file-on-.patch --]
[-- Type: application/octet-stream, Size: 27884 bytes --]

From aa08068a90ee22630eed32d67e627a7712778fb6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Fri, 15 Oct 2021 16:12:39 +0200
Subject: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF

On XCOFF, ".file" pseudo-op allows 3 extras parameters to provide
additional information to AIX linker, or its debugger. These are
stored in auxiliary entries of the C_FILE symbol.

PR 28447
bfd/Changelog

	* coffcode.h (combined_entry_type): Add extrap field.
	(coff_bigobj_swap_aux_in): Adjust names of x_file fields.
	(coff_bigobj_swap_aux_out): Likewise.
	* coffgen.c (coff_write_auxent_fname): New function.
	(coff_fix_symbol_name): Write x_file using
	 coff_write_auxent_fname.
	(coff_write_symbol): Likewise.
	(coff_write_symbols): Add C_FILE auxiliary entries to
	string table if needed.
	(coff_get_normalized_symtab): Adjust names of x_file fields.
	Normalize C_FILE auxiliary entries.
	(coff_print_symbol): Print C_FILE auxiliary entries.
	* coff-rs6000.c (_bfd_xcoff_swap_aux_in): Adjust names of
	x_file fields.
	(_bfd_xcoff_swap_aux_out): Likewise.
	* coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Likewise.
	(_bfd_xcoff64_swap_aux_out): Likewise.
	* cofflink.c (_bfd_coff_final_link): Likewise.
	(_bfd_coff_link_input_bfd): Likewise.
	* coffswap.h (coff_swap_aux_in): Likewise.
	* peXXigen.c (_bfd_XXi_swap_aux_in): Likewise.
	(_bfd_XXi_swap_aux_out): Likewise.
	* xcofflink.c (xcoff_link_input_bfd): Likewise.
	* libcoff.h: Regenerate.

gas/ChangeLog:

	* config/tc-ppc.c (ppc_file): New function.
	* config/tc-ppc.h (OBJ_COFF_MAX_AUXENTRIES): Change to 4.
	* testsuite/gas/ppc/aix.exp: Add tests.
	* testsuite/gas/ppc/xcoff-file-32.d: New test.
	* testsuite/gas/ppc/xcoff-file-64.d: New test.
	* testsuite/gas/ppc/xcoff-file.s: New test.

include/ChangeLog:

	* coff/internal.h (union internal_auxent): Change x_file to be a
	  struct instead of a union. Add x_ftype field.
	* coff/rs6000.h (union external_auxent): Add x_resv field.
	* coff/xcoff.h (XFT_FN): New define.
	(XFT_CT): Likewise.
	(XFT_CV): Likewise.
	(XFT_CD): Likewise.
---
 bfd/coff-rs6000.c                     |  14 +--
 bfd/coff64-rs6000.c                   |  14 +--
 bfd/coffcode.h                        |  10 +-
 bfd/coffgen.c                         | 134 ++++++++++++++++++++------
 bfd/cofflink.c                        |  14 +--
 bfd/coffswap.h                        |  14 +--
 bfd/libcoff.h                         |   4 +
 bfd/peXXigen.c                        |  12 +--
 bfd/xcofflink.c                       |  12 +--
 gas/config/tc-ppc.c                   |  63 ++++++++++++
 gas/config/tc-ppc.h                   |   2 +-
 gas/testsuite/gas/ppc/aix.exp         |   3 +
 gas/testsuite/gas/ppc/xcoff-file-32.d |  13 +++
 gas/testsuite/gas/ppc/xcoff-file-64.d |  13 +++
 gas/testsuite/gas/ppc/xcoff-file.s    |   1 +
 include/coff/internal.h               |  25 ++---
 include/coff/rs6000.h                 |   1 +
 include/coff/xcoff.h                  |   6 ++
 18 files changed, 273 insertions(+), 82 deletions(-)
 create mode 100644 gas/testsuite/gas/ppc/xcoff-file-32.d
 create mode 100644 gas/testsuite/gas/ppc/xcoff-file-64.d
 create mode 100644 gas/testsuite/gas/ppc/xcoff-file.s

diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 31d91190103..1cc2162e7d8 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -489,12 +489,13 @@ _bfd_xcoff_swap_aux_in (bfd *abfd, void * ext1, int type ATTRIBUTE_UNUSED,
     case C_FILE:
       if (ext->x_file.x_n.x_fname[0] == 0)
 	{
-	  in->x_file.x_n.x_zeroes = 0;
-	  in->x_file.x_n.x_offset =
+	  in->x_file.x_n.x_n.x_zeroes = 0;
+	  in->x_file.x_n.x_n.x_offset =
 	    H_GET_32 (abfd, ext->x_file.x_n.x_n.x_offset);
 	}
       else
-	memcpy (in->x_file.x_fname, ext->x_file.x_n.x_fname, FILNMLEN);
+	memcpy (in->x_file.x_n.x_fname, ext->x_file.x_n.x_fname, FILNMLEN);
+      in->x_file.x_ftype = H_GET_8 (abfd, ext->x_file.x_ftype);
       break;
 
       /* RS/6000 "csect" auxents.
@@ -573,14 +574,15 @@ _bfd_xcoff_swap_aux_out (bfd *abfd, void * inp, int type ATTRIBUTE_UNUSED,
       break;
 
     case C_FILE:
-      if (in->x_file.x_fname[0] == 0)
+      if (in->x_file.x_n.x_fname[0] == 0)
 	{
 	  H_PUT_32 (abfd, 0, ext->x_file.x_n.x_n.x_zeroes);
-	  H_PUT_32 (abfd, in->x_file.x_n.x_offset,
+	  H_PUT_32 (abfd, in->x_file.x_n.x_n.x_offset,
 		    ext->x_file.x_n.x_n.x_offset);
 	}
       else
-	memcpy (ext->x_file.x_n.x_fname, in->x_file.x_fname, FILNMLEN);
+	memcpy (ext->x_file.x_n.x_fname, in->x_file.x_n.x_fname, FILNMLEN);
+      H_PUT_8 (abfd, in->x_file.x_ftype, ext->x_file.x_ftype);
       break;
 
       /* RS/6000 "csect" auxents */
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 04e0798bf69..4689c9ed5fe 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -386,12 +386,13 @@ _bfd_xcoff64_swap_aux_in (bfd *abfd, void *ext1, int type ATTRIBUTE_UNUSED,
 
       if (ext->x_file.x_n.x_n.x_zeroes[0] == 0)
 	{
-	  in->x_file.x_n.x_zeroes = 0;
-	  in->x_file.x_n.x_offset =
+	  in->x_file.x_n.x_n.x_zeroes = 0;
+	  in->x_file.x_n.x_n.x_offset =
 	    H_GET_32 (abfd, ext->x_file.x_n.x_n.x_offset);
 	}
       else
-	memcpy (in->x_file.x_fname, ext->x_file.x_n.x_fname, FILNMLEN);
+	memcpy (in->x_file.x_n.x_fname, ext->x_file.x_n.x_fname, FILNMLEN);
+      in->x_file.x_ftype = H_GET_8 (abfd, ext->x_file.x_ftype);
       break;
 
       /* RS/6000 "csect" auxents.
@@ -502,14 +503,15 @@ _bfd_xcoff64_swap_aux_out (bfd *abfd, void *inp, int type ATTRIBUTE_UNUSED,
       break;
 
     case C_FILE:
-      if (in->x_file.x_n.x_zeroes == 0)
+      if (in->x_file.x_n.x_n.x_zeroes == 0)
 	{
 	  H_PUT_32 (abfd, 0, ext->x_file.x_n.x_n.x_zeroes);
-	  H_PUT_32 (abfd, in->x_file.x_n.x_offset,
+	  H_PUT_32 (abfd, in->x_file.x_n.x_n.x_offset,
 		    ext->x_file.x_n.x_n.x_offset);
 	}
       else
-	memcpy (ext->x_file.x_n.x_fname, in->x_file.x_fname, FILNMLEN);
+	memcpy (ext->x_file.x_n.x_fname, in->x_file.x_n.x_fname, FILNMLEN);
+      H_PUT_8 (abfd, in->x_file.x_ftype, ext->x_file.x_ftype);
       H_PUT_8 (abfd, _AUX_FILE, ext->x_file.x_auxtype);
       break;
 
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index c28d753011a..a051bd084e2 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -326,6 +326,10 @@ CODE_FRAGMENT
 .
 . {* Selector for the union above.  *}
 . bool is_sym;
+.
+. {* An extra pointer which can used by format based on COFF (like XCOFF)
+.    to provide extra information to their backend.  *}
+. void *extrap;
 .} combined_entry_type;
 .
 .
@@ -5663,11 +5667,11 @@ coff_bigobj_swap_aux_in (bfd *abfd,
       if (numaux > 1)
 	{
 	  if (indx == 0)
-	    memcpy (in->x_file.x_fname, ext->File.Name,
+	    memcpy (in->x_file.x_n.x_fname, ext->File.Name,
 		    numaux * sizeof (AUXENT_BIGOBJ));
 	}
       else
-	memcpy (in->x_file.x_fname, ext->File.Name, sizeof (ext->File.Name));
+	memcpy (in->x_file.x_n.x_fname, ext->File.Name, sizeof (ext->File.Name));
       break;
 
     case C_STAT:
@@ -5712,7 +5716,7 @@ coff_bigobj_swap_aux_out (bfd * abfd,
   switch (in_class)
     {
     case C_FILE:
-      memcpy (ext->File.Name, in->x_file.x_fname, sizeof (ext->File.Name));
+      memcpy (ext->File.Name, in->x_file.x_n.x_fname, sizeof (ext->File.Name));
 
       return AUXESZ;
 
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 77bda9e9947..1136bc2a753 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -847,6 +847,34 @@ coff_mangle_symbols (bfd *bfd_ptr)
     }
 }
 
+static void
+coff_write_auxent_fname (bfd *abfd,
+			 char *str,
+			 union internal_auxent *auxent,
+			 bfd_size_type *string_size_p)
+{
+  unsigned int str_length = strlen (str);
+  unsigned int filnmlen = bfd_coff_filnmlen (abfd);
+
+  if (bfd_coff_long_filenames (abfd))
+    {
+      if (str_length <= filnmlen)
+	strncpy (auxent->x_file.x_n.x_fname, str, filnmlen);
+      else
+	{
+	  auxent->x_file.x_n.x_n.x_offset = *string_size_p + STRING_SIZE_SIZE;
+	  auxent->x_file.x_n.x_n.x_zeroes = 0;
+	  *string_size_p += str_length + 1;
+	}
+    }
+  else
+    {
+      strncpy (auxent->x_file.x_n.x_fname, str, filnmlen);
+      if (str_length > filnmlen)
+	str[filnmlen] = '\0';
+    }
+}
+
 static void
 coff_fix_symbol_name (bfd *abfd,
 		      asymbol *symbol,
@@ -856,7 +884,6 @@ coff_fix_symbol_name (bfd *abfd,
 		      bfd_size_type *debug_string_size_p)
 {
   unsigned int name_length;
-  union internal_auxent *auxent;
   char *name = (char *) (symbol->name);
 
   if (name == NULL)
@@ -871,8 +898,6 @@ coff_fix_symbol_name (bfd *abfd,
   if (native->u.syment.n_sclass == C_FILE
       && native->u.syment.n_numaux > 0)
     {
-      unsigned int filnmlen;
-
       if (bfd_coff_force_symnames_in_strings (abfd))
 	{
 	  native->u.syment._n._n_n._n_offset =
@@ -884,27 +909,8 @@ coff_fix_symbol_name (bfd *abfd,
 	strncpy (native->u.syment._n._n_name, ".file", SYMNMLEN);
 
       BFD_ASSERT (! (native + 1)->is_sym);
-      auxent = &(native + 1)->u.auxent;
-
-      filnmlen = bfd_coff_filnmlen (abfd);
-
-      if (bfd_coff_long_filenames (abfd))
-	{
-	  if (name_length <= filnmlen)
-	    strncpy (auxent->x_file.x_fname, name, filnmlen);
-	  else
-	    {
-	      auxent->x_file.x_n.x_offset = *string_size_p + STRING_SIZE_SIZE;
-	      auxent->x_file.x_n.x_zeroes = 0;
-	      *string_size_p += name_length + 1;
-	    }
-	}
-      else
-	{
-	  strncpy (auxent->x_file.x_fname, name, filnmlen);
-	  if (name_length > filnmlen)
-	    name[filnmlen] = '\0';
-	}
+      coff_write_auxent_fname (abfd, name, &(native + 1)->u.auxent,
+			       string_size_p);
     }
   else
     {
@@ -1029,6 +1035,11 @@ coff_write_symbol (bfd *abfd,
       for (j = 0; j < native->u.syment.n_numaux; j++)
 	{
 	  BFD_ASSERT (! (native + j + 1)->is_sym);
+
+	  if (native->u.syment.n_sclass == C_FILE && j > 0)
+	    coff_write_auxent_fname (abfd, (char *) (native + j + 1)->extrap,
+				     &(native + j + 1)->u.auxent, string_size_p);
+
 	  bfd_coff_swap_aux_out (abfd,
 				 &((native + j + 1)->u.auxent),
 				 type, n_sclass, (int) j,
@@ -1358,6 +1369,7 @@ coff_write_symbols (bfd *abfd)
 	  size_t name_length = strlen (q->name);
 	  coff_symbol_type *c_symbol = coff_symbol_from (q);
 	  size_t maxlen;
+	  bool is_c_file = false;
 
 	  /* Figure out whether the symbol name should go in the string
 	     table.  Symbol names that are short enough are stored
@@ -1384,6 +1396,7 @@ coff_write_symbols (bfd *abfd)
 	  else if (c_symbol->native->u.syment.n_sclass == C_FILE
 		   && c_symbol->native->u.syment.n_numaux > 0)
 	    {
+	      is_c_file=true;
 	      if (bfd_coff_force_symnames_in_strings (abfd))
 		{
 		  if (bfd_bwrite (".file", (bfd_size_type) 6, abfd) != 6)
@@ -1400,6 +1413,30 @@ coff_write_symbols (bfd *abfd)
 			     abfd) != name_length + 1)
 		return false;
 	    }
+
+	  /* Add strings for C_FILE aux entries. */
+	  if (is_c_file
+	      && c_symbol->native->u.syment.n_numaux > 1)
+	    {
+	      for (int j = 1; j < c_symbol->native->u.syment.n_numaux; j++)
+		{
+		  char *str;
+		  size_t str_length;
+
+		  if (c_symbol->native[j + 1].u.auxent.x_file.x_n.x_fname[0] != 0)
+		    continue;
+
+		  str = (char *) c_symbol->native[j + 1].extrap;
+		  str_length = strlen (str);
+		  if (str_length > maxlen)
+		    {
+		      if (bfd_bwrite ((void *) (str), (bfd_size_type) str_length + 1,
+				      abfd) != str_length + 1)
+			return false;
+		    }
+
+		}
+	    }
 	}
     }
   else
@@ -1872,7 +1909,7 @@ coff_get_normalized_symtab (bfd *abfd)
 	     the text ".file" is redundant.  */
 	  BFD_ASSERT (! aux->is_sym);
 
-	  if (aux->u.auxent.x_file.x_n.x_zeroes == 0)
+	  if (aux->u.auxent.x_file.x_n.x_n.x_zeroes == 0)
 	    {
 	      /* The filename is a long one, point into the string table.  */
 	      if (string_table == NULL)
@@ -1882,12 +1919,12 @@ coff_get_normalized_symtab (bfd *abfd)
 		    return NULL;
 		}
 
-	      if ((bfd_size_type)(aux->u.auxent.x_file.x_n.x_offset)
+	      if ((bfd_size_type)(aux->u.auxent.x_file.x_n.x_n.x_offset)
 		  >= obj_coff_strings_len (abfd))
 		internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) _("<corrupt>");
 	      else
 		internal_ptr->u.syment._n._n_n._n_offset =
-		  (bfd_hostptr_t) (string_table + (aux->u.auxent.x_file.x_n.x_offset));
+		  (bfd_hostptr_t) (string_table + (aux->u.auxent.x_file.x_n.x_n.x_offset));
 	    }
 	  else
 	    {
@@ -1899,15 +1936,48 @@ coff_get_normalized_symtab (bfd *abfd)
 		internal_ptr->u.syment._n._n_n._n_offset =
 		  (bfd_hostptr_t)
 		  copy_name (abfd,
-			     aux->u.auxent.x_file.x_fname,
+			     aux->u.auxent.x_file.x_n.x_fname,
 			     internal_ptr->u.syment.n_numaux * symesz);
 	      else
 		internal_ptr->u.syment._n._n_n._n_offset =
 		  ((bfd_hostptr_t)
 		   copy_name (abfd,
-			      aux->u.auxent.x_file.x_fname,
+			      aux->u.auxent.x_file.x_n.x_fname,
 			      (size_t) bfd_coff_filnmlen (abfd)));
 	    }
+
+	  /* Normalize other strings available in C_FILE aux entries.  */
+	  if (!coff_data (abfd)->pe)
+	    for (int numaux = 1; numaux < internal_ptr->u.syment.n_numaux; numaux++)
+	      {
+		aux = internal_ptr + numaux + 1;
+		BFD_ASSERT (! aux->is_sym);
+
+		if (aux->u.auxent.x_file.x_n.x_n.x_zeroes == 0)
+		  {
+		    /* The string information is a long one, point into the string table.  */
+		    if (string_table == NULL)
+		      {
+			string_table = _bfd_coff_read_string_table (abfd);
+			if (string_table == NULL)
+			  return NULL;
+		      }
+
+		    if ((bfd_size_type)(aux->u.auxent.x_file.x_n.x_n.x_offset)
+			>= obj_coff_strings_len (abfd))
+		      aux->u.auxent.x_file.x_n.x_n.x_offset = (bfd_hostptr_t) _("<corrupt>");
+		    else
+		      aux->u.auxent.x_file.x_n.x_n.x_offset =
+			(bfd_hostptr_t) (string_table + (aux->u.auxent.x_file.x_n.x_n.x_offset));
+		  }
+		else
+		  aux->u.auxent.x_file.x_n.x_n.x_offset =
+		    ((bfd_hostptr_t)
+		     copy_name (abfd,
+				aux->u.auxent.x_file.x_n.x_fname,
+				(size_t) bfd_coff_filnmlen (abfd)));
+	      }
+
 	}
       else
 	{
@@ -2135,6 +2205,12 @@ coff_print_symbol (bfd *abfd,
 		{
 		case C_FILE:
 		  fprintf (file, "File ");
+		  /* Add additional information if this isn't the filename
+		     auxiliary entry.  */
+		  if (aux)
+		    fprintf (file, "ftype %d fname \"%s\"",
+			     auxp->u.auxent.x_file.x_ftype,
+			     (char *) auxp->u.auxent.x_file.x_n.x_n.x_offset);
 		  break;
 
 		case C_DWARF:
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index b8a370933be..67d9c62b0b4 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -963,7 +963,7 @@ _bfd_coff_final_link (bfd *abfd,
 		  else
 		    {
 		      BFD_ASSERT (isym.n_numaux == 1);
-		      iaux.x_file.x_n.x_offset = STRING_SIZE_SIZE + indx;
+		      iaux.x_file.x_n.x_n.x_offset = STRING_SIZE_SIZE + indx;
 		      bfd_coff_swap_aux_out (abfd, &iaux, isym.n_type, C_FILE,
 					     0, 1, flaginfo.outsyms + symesz);
 		      if (bfd_seek (abfd, pos + symesz, SEEK_SET) != 0
@@ -2006,13 +2006,13 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd)
 		{
 		  /* If this is a long filename, we must put it in the
 		     string table.  */
-		  if (auxp->x_file.x_n.x_zeroes == 0
-		      && auxp->x_file.x_n.x_offset != 0)
+		  if (auxp->x_file.x_n.x_n.x_zeroes == 0
+		      && auxp->x_file.x_n.x_n.x_offset != 0)
 		    {
 		      const char *filename;
 		      bfd_size_type indx;
 
-		      BFD_ASSERT (auxp->x_file.x_n.x_offset
+		      BFD_ASSERT (auxp->x_file.x_n.x_n.x_offset
 				  >= STRING_SIZE_SIZE);
 		      if (strings == NULL)
 			{
@@ -2020,15 +2020,15 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd)
 			  if (strings == NULL)
 			    return false;
 			}
-		      if ((bfd_size_type) auxp->x_file.x_n.x_offset >= obj_coff_strings_len (input_bfd))
+		      if ((bfd_size_type) auxp->x_file.x_n.x_n.x_offset >= obj_coff_strings_len (input_bfd))
 			filename = _("<corrupt>");
 		      else
-			filename = strings + auxp->x_file.x_n.x_offset;
+			filename = strings + auxp->x_file.x_n.x_n.x_offset;
 		      indx = _bfd_stringtab_add (flaginfo->strtab, filename,
 						 hash, copy);
 		      if (indx == (bfd_size_type) -1)
 			return false;
-		      auxp->x_file.x_n.x_offset = STRING_SIZE_SIZE + indx;
+		      auxp->x_file.x_n.x_n.x_offset = STRING_SIZE_SIZE + indx;
 		    }
 		}
 	      else if ((isymp->n_sclass != C_STAT || isymp->n_type != T_NULL)
diff --git a/bfd/coffswap.h b/bfd/coffswap.h
index 63a0026a669..2dcfc205319 100644
--- a/bfd/coffswap.h
+++ b/bfd/coffswap.h
@@ -391,8 +391,8 @@ coff_swap_aux_in (bfd *abfd,
     case C_FILE:
       if (ext->x_file.x_fname[0] == 0)
 	{
-	  in->x_file.x_n.x_zeroes = 0;
-	  in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
+	  in->x_file.x_n.x_n.x_zeroes = 0;
+	  in->x_file.x_n.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
 	}
       else
 	{
@@ -402,11 +402,11 @@ coff_swap_aux_in (bfd *abfd,
 	  if (numaux > 1 && coff_data (abfd)->pe)
 	    {
 	      if (indx == 0)
-		memcpy (in->x_file.x_fname, ext->x_file.x_fname,
+		memcpy (in->x_file.x_n.x_fname, ext->x_file.x_fname,
 			numaux * sizeof (AUXENT));
 	    }
 	  else
-	    memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
+	    memcpy (in->x_file.x_n.x_fname, ext->x_file.x_fname, FILNMLEN);
 #endif
 	}
       goto end;
@@ -495,17 +495,17 @@ coff_swap_aux_out (bfd * abfd,
   switch (in_class)
     {
     case C_FILE:
-      if (in->x_file.x_fname[0] == 0)
+      if (in->x_file.x_n.x_fname[0] == 0)
 	{
 	  H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
-	  H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
+	  H_PUT_32 (abfd, in->x_file.x_n.x_n.x_offset, ext->x_file.x_n.x_offset);
 	}
       else
 	{
 #if FILNMLEN != E_FILNMLEN
 #error we need to cope with truncating or extending FILNMLEN
 #else
-	  memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
+	  memcpy (ext->x_file.x_fname, in->x_file.x_n.x_fname, FILNMLEN);
 #endif
 	}
       goto end;
diff --git a/bfd/libcoff.h b/bfd/libcoff.h
index 6dc68d1a398..1b4f988bb0b 100644
--- a/bfd/libcoff.h
+++ b/bfd/libcoff.h
@@ -658,6 +658,10 @@ typedef struct coff_ptr_struct
 
  /* Selector for the union above.  */
  bool is_sym;
+
+ /* An extra pointer which can used by format based on COFF (like XCOFF)
+    to provide extra information to their backend.  */
+ void *extrap;
 } combined_entry_type;
 
 
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index c41c3299277..e2a9cbb65c1 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -298,11 +298,11 @@ _bfd_XXi_swap_aux_in (bfd *	abfd,
     case C_FILE:
       if (ext->x_file.x_fname[0] == 0)
 	{
-	  in->x_file.x_n.x_zeroes = 0;
-	  in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
+	  in->x_file.x_n.x_n.x_zeroes = 0;
+	  in->x_file.x_n.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
 	}
       else
-	memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
+	memcpy (in->x_file.x_n.x_fname, ext->x_file.x_fname, FILNMLEN);
       return;
 
     case C_STAT:
@@ -370,13 +370,13 @@ _bfd_XXi_swap_aux_out (bfd *  abfd,
   switch (in_class)
     {
     case C_FILE:
-      if (in->x_file.x_fname[0] == 0)
+      if (in->x_file.x_n.x_fname[0] == 0)
 	{
 	  H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
-	  H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
+	  H_PUT_32 (abfd, in->x_file.x_n.x_n.x_offset, ext->x_file.x_n.x_offset);
 	}
       else
-	memcpy (ext->x_file.x_fname, in->x_file.x_fname, sizeof (ext->x_file.x_fname));
+	memcpy (ext->x_file.x_fname, in->x_file.x_n.x_fname, sizeof (ext->x_file.x_fname));
 
       return AUXESZ;
 
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index 3ca74ce0277..e87ed0e683b 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -4550,13 +4550,13 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
 		  /* This is the file name (or some comment put in by
 		     the compiler).  If it is long, we must put it in
 		     the string table.  */
-		  if (aux.x_file.x_n.x_zeroes == 0
-		      && aux.x_file.x_n.x_offset != 0)
+		  if (aux.x_file.x_n.x_n.x_zeroes == 0
+		      && aux.x_file.x_n.x_n.x_offset != 0)
 		    {
 		      const char *filename;
 		      bfd_size_type indx;
 
-		      BFD_ASSERT (aux.x_file.x_n.x_offset
+		      BFD_ASSERT (aux.x_file.x_n.x_n.x_offset
 				  >= STRING_SIZE_SIZE);
 		      if (strings == NULL)
 			{
@@ -4564,15 +4564,15 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
 			  if (strings == NULL)
 			    return false;
 			}
-		      if ((bfd_size_type) aux.x_file.x_n.x_offset >= obj_coff_strings_len (input_bfd))
+		      if ((bfd_size_type) aux.x_file.x_n.x_n.x_offset >= obj_coff_strings_len (input_bfd))
 			filename = _("<corrupt>");
 		      else
-			filename = strings + aux.x_file.x_n.x_offset;
+			filename = strings + aux.x_file.x_n.x_n.x_offset;
 		      indx = _bfd_stringtab_add (flinfo->strtab, filename,
 						 hash, copy);
 		      if (indx == (bfd_size_type) -1)
 			return false;
-		      aux.x_file.x_n.x_offset = STRING_SIZE_SIZE + indx;
+		      aux.x_file.x_n.x_n.x_offset = STRING_SIZE_SIZE + indx;
 		    }
 		}
 	      else if (CSECT_SYM_P (isymp->n_sclass)
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index af025af32ff..8750e379158 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -107,6 +107,7 @@ static void ppc_es (int);
 static void ppc_csect (int);
 static void ppc_dwsect (int);
 static void ppc_change_csect (symbolS *, offsetT);
+static void ppc_file (int);
 static void ppc_function (int);
 static void ppc_extern (int);
 static void ppc_lglobl (int);
@@ -227,6 +228,7 @@ const pseudo_typeS md_pseudo_table[] =
   { "ei",	ppc_biei,	1 },
   { "es",	ppc_es,		0 },
   { "extern",	ppc_extern,	0 },
+  { "file",	ppc_file,	0 },
   { "function",	ppc_function,	0 },
   { "lglobl",	ppc_lglobl,	0 },
   { "ref",	ppc_ref,	0 },
@@ -5073,6 +5075,67 @@ ppc_stabx (int ignore ATTRIBUTE_UNUSED)
   demand_empty_rest_of_line ();
 }
 
+/* The .file pseudo-op. On XCOFF, .file can have several parameters
+   which are being added to the symbol table to provide additional
+   information.  */
+
+static void
+ppc_file (int ignore ATTRIBUTE_UNUSED)
+{
+  char *sfname, *s1 = NULL, *s2 = NULL, *s3 = NULL;
+  int length, auxnb = 1;
+
+  /* Some assemblers tolerate immediately following '"'.  */
+  if ((sfname = demand_copy_string (&length)) != 0)
+    {
+      coff_symbol_type *coffsym;
+      if (*input_line_pointer == ',')
+	{
+	  ++input_line_pointer;
+	  s1 = demand_copy_string (&length);
+	  auxnb++;
+
+	  if (*input_line_pointer == ',')
+	    {
+	      ++input_line_pointer;
+	      s2 = demand_copy_string (&length);
+	      auxnb++;
+
+	      if (*input_line_pointer == ',')
+		{
+		  ++input_line_pointer;
+		  s3 = demand_copy_string (&length);
+		  auxnb++;
+		}
+	    }
+	}
+
+      /* Use coff dot_file creation and adjust auxiliary entries.  */
+      c_dot_file_symbol (sfname, 0);
+      S_SET_NUMBER_AUXILIARY (symbol_rootP, auxnb);
+      coffsym = coffsymbol (symbol_get_bfdsym (symbol_rootP));
+      coffsym->native[1].u.auxent.x_file.x_ftype = XFT_FN;
+
+      if (s1)
+	{
+	  coffsym->native[2].u.auxent.x_file.x_ftype = XFT_CT;
+	  coffsym->native[2].extrap = s1;
+	}
+      if (s2)
+	{
+	  coffsym->native[3].u.auxent.x_file.x_ftype = XFT_CV;
+	  coffsym->native[3].extrap = s2;
+	}
+      if (s3)
+	{
+	  coffsym->native[4].u.auxent.x_file.x_ftype = XFT_CD;
+	  coffsym->native[4].extrap = s3;
+	}
+
+      demand_empty_rest_of_line ();
+    }
+}
+
 /* The .function pseudo-op.  This takes several arguments.  The first
    argument seems to be the external name of the symbol.  The second
    argument seems to be the label for the start of the function.  gcc
diff --git a/gas/config/tc-ppc.h b/gas/config/tc-ppc.h
index fb18730db3c..2d0a8865d98 100644
--- a/gas/config/tc-ppc.h
+++ b/gas/config/tc-ppc.h
@@ -146,7 +146,7 @@ struct ppc_tc_sy
 #define TC_SYMFIELD_TYPE struct ppc_tc_sy
 
 /* We need an additional auxent for function symbols.  */
-#define OBJ_COFF_MAX_AUXENTRIES 2
+#define OBJ_COFF_MAX_AUXENTRIES 4
 
 /* Square and curly brackets are permitted in symbol names.  */
 #define LEX_BR 3
diff --git a/gas/testsuite/gas/ppc/aix.exp b/gas/testsuite/gas/ppc/aix.exp
index aef295bc3b9..c6d10d5fb84 100644
--- a/gas/testsuite/gas/ppc/aix.exp
+++ b/gas/testsuite/gas/ppc/aix.exp
@@ -84,4 +84,7 @@ if { [istarget "powerpc*-*-aix*"] || [istarget "rs6000-*-aix*"] } then {
 
     run_dump_test "xcoff-stsym-32"
     run_dump_test "xcoff-stsym-64"
+
+    run_dump_test "xcoff-file-32"
+    run_dump_test "xcoff-file-64"
 }
diff --git a/gas/testsuite/gas/ppc/xcoff-file-32.d b/gas/testsuite/gas/ppc/xcoff-file-32.d
new file mode 100644
index 00000000000..a831b3b4587
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-file-32.d
@@ -0,0 +1,13 @@
+#as: -a32
+#source: xcoff-file.s
+#objdump: -t
+#name: XCOFF file test (32-bit)
+
+.*
+
+SYMBOL TABLE:
+\[  0\].*\(scl 103\) \(nx 4\) .* file.s
+File 
+File ftype 1 fname "A long string"
+File ftype 2 fname "short"
+File ftype 128 fname "Another long string inside the strign table."
diff --git a/gas/testsuite/gas/ppc/xcoff-file-64.d b/gas/testsuite/gas/ppc/xcoff-file-64.d
new file mode 100644
index 00000000000..12bb6efc93b
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-file-64.d
@@ -0,0 +1,13 @@
+#as: -a64
+#source: xcoff-file.s
+#objdump: -t
+#name: XCOFF file test (64-bit)
+
+.*
+
+SYMBOL TABLE:
+\[  0\].*\(scl 103\) \(nx 4\) .* file.s
+File 
+File ftype 1 fname "A long string"
+File ftype 2 fname "short"
+File ftype 128 fname "Another long string inside the strign table."
diff --git a/gas/testsuite/gas/ppc/xcoff-file.s b/gas/testsuite/gas/ppc/xcoff-file.s
new file mode 100644
index 00000000000..229ab889f49
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-file.s
@@ -0,0 +1 @@
+.file "file.s", "A long string", "short", "Another long string inside the strign table."
diff --git a/include/coff/internal.h b/include/coff/internal.h
index 8d757acb333..d01af7380c8 100644
--- a/include/coff/internal.h
+++ b/include/coff/internal.h
@@ -578,18 +578,21 @@ union internal_auxent
     unsigned short x_tvndx;	/* tv index */
   }      x_sym;
 
-  union
+  struct
   {
-    /* PR 17754: We use to FILNMLEN for the size of the x_fname
-       array, but that causes problems as PE targets use a larger
-       value.  We cannot use their definition of E_FILNMLEN as this
-       header can be used without including any PE headers.  */
-    char x_fname[20];
-    struct
-    {
-      long x_zeroes;
-      long x_offset;
-    }      x_n;
+    union {
+      /* PR 17754: We use to FILNMLEN for the size of the x_fname
+	 array, but that causes problems as PE targets use a larger
+	 value.  We cannot use their definition of E_FILNMLEN as this
+	 header can be used without including any PE headers.  */
+      char x_fname[20];
+      struct
+      {
+	long x_zeroes;
+	long x_offset;
+      }      x_n;
+    } x_n;
+    unsigned char x_ftype;
   }     x_file;
 
   struct
diff --git a/include/coff/rs6000.h b/include/coff/rs6000.h
index e60efff23b6..fd3f01dccbc 100644
--- a/include/coff/rs6000.h
+++ b/include/coff/rs6000.h
@@ -176,6 +176,7 @@ union external_auxent {
       } x_n;
     } x_n;
     char x_ftype[1];
+    char x_resv[3];
   } x_file;
 
   struct {
diff --git a/include/coff/xcoff.h b/include/coff/xcoff.h
index 2b61545d611..1cff7dc30d5 100644
--- a/include/coff/xcoff.h
+++ b/include/coff/xcoff.h
@@ -190,6 +190,12 @@
 #define XMC_UL     21          /* Read-write uninitialized TLS data */
 #define XMC_TE     22          /* Same as XMC_TC but mapped after it */
 
+/* x_ftype values:  */
+#define XFT_FN 0    /* Specifies the source-file name */
+#define XFT_CT 1    /* Specifies the compiler time stamp */
+#define XFT_CV 2    /* Specifies the compiler version number */
+#define XFT_CD 128  /*Specifies compiler-defined information */
+
 /* The ldhdr structure.  This appears at the start of the .loader
    section.  */
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF
  2021-10-21  7:51     ` CHIGOT, CLEMENT
@ 2021-11-09 13:24       ` CHIGOT, CLEMENT
  2021-11-10  4:38       ` Alan Modra
  1 sibling, 0 replies; 12+ messages in thread
From: CHIGOT, CLEMENT @ 2021-11-09 13:24 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils, David Edelsohn

Hi Alan,

Gentle ping on this patch.
Nothing urgent though.

Clément
________________________________
From: CHIGOT, CLEMENT <clement.chigot@atos.net>
Sent: Thursday, October 21, 2021 9:51 AM
To: Alan Modra <amodra@gmail.com>
Cc: binutils@sourceware.org <binutils@sourceware.org>; David Edelsohn <dje.gcc@gmail.com>
Subject: Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF

Hi Alan,

The issue was indeed linked to the coffgen.c code you pointed out.
I've tested on "arm-pe", "arm-wince-pe", "i686-pe", "sh-pe",
"tic30-unknown-coff", "tic4x-coff", "tic54x-coff", "x86_64-w64-mingw32"
and "z80-coff", the results are fine.
Is there any other coff targets which should be tested ?

Moreover, as I've changed the structure of "combined_entry_type", the
documentation needs to be updated at "https://sourceware.org/binutils/docs/bfd/coff.html".
Is this done automatically or should I do something myself ?

Thanks,
Clément

________________________________
From: Binutils <binutils-bounces+clement.chigot=atos.net@sourceware.org> on behalf of CHIGOT, CLEMENT via Binutils <binutils@sourceware.org>
Sent: Wednesday, October 20, 2021 2:01 PM
To: Alan Modra <amodra@gmail.com>
Cc: binutils@sourceware.org <binutils@sourceware.org>; David Edelsohn <dje.gcc@gmail.com>
Subject: Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF

Caution! External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.

HI Alan,

Thanks for providing me how to test without the machine.
It would help me a lot !

And sorry about the patch not being based on the mainline.
I forget that I've a WIP which is impacting it... But don't hesitate
to reject my patch sooner, if it happens again. I'll try not to though !

Thanks and sorry,
Clément

________________________________
From: Alan Modra <amodra@gmail.com>
Sent: Wednesday, October 20, 2021 12:09 PM
To: CHIGOT, CLEMENT <clement.chigot@atos.net>
Cc: binutils@sourceware.org <binutils@sourceware.org>; David Edelsohn <dje.gcc@gmail.com>
Subject: Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF

Caution! External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.

On Mon, Oct 18, 2021 at 11:37:25AM +0000, CHIGOT, CLEMENT via Binutils wrote:
> I would be glad if someone can test it on Windows and maybe on other
> COFF formats too. It shouldn't impact but we never know.

There is quite a lot of testing that you can do yourself without
having access to machines running natively.  For example, configuring
binutils with something like the following

~/src/binutils-gdb/configure \
--disable-nls \
--disable-gdb --disable-gdbserver --disable-gdbsupport \
--disable-libbacktrace --disable-libdecnumber \
--disable-readline --disable-sim \
--target=x86_64-w64-mingw32

then "make && make check" with some relevant targets such as
x86_64-w64-mingw32 above will catch errors.  I built with your patch
and ran into segfaults.  On a few I looked at, they were on the
following lines added to coffgen.c

          /* Add strings for C_FILE aux entries. */
          if (c_symbol->native->u.syment.n_sclass == C_FILE

c_symbol->native was NULL.

(BTW, please do post patches against current mainline, not mainline
plus other patches of yours.  I had to edit the diff to get it to
apply.  Also build and test with just the patch you are posting!)

The list of failing targets/tests I found is:

arm-pe  +FAIL: dlltool (version.dll)
arm-pe  +FAIL: dlltool -p (execution)
arm-pe  +FAIL: ld-pe/pr19803
arm-wince-pe  +FAIL: dlltool (version.dll)
arm-wince-pe  +FAIL: dlltool -p (execution)
arm-wince-pe  +FAIL: ld-pe/pr19803
i686-pe  +FAIL: dlltool (version.dll)
i686-pe  +FAIL: dlltool -p (execution)
i686-pe  +FAIL: ld-pe/pr19803
sh-pe  +FAIL: ld-pe/pr19803
tic30-unknown-coff  +FAIL: ld-scripts/align2a
tic30-unknown-coff  +FAIL: ld-scripts/align2b
tic30-unknown-coff  +FAIL: ld-scripts/empty-address-3a
tic30-unknown-coff  +FAIL: ld-scripts/empty-address-3b
tic30-unknown-coff  +FAIL: ld-scripts/empty-address-3c
tic30-unknown-coff  +FAIL: ld-scripts/sane1
tic30-unknown-coff  +FAIL: ld-scripts/assign-loc
tic30-unknown-coff  +FAIL: ld-scripts/provide-10
tic30-unknown-coff  +FAIL: ld-scripts/provide-11
tic30-unknown-coff  +FAIL: ld-scripts/provide-12
tic30-unknown-coff  +FAIL: ld-scripts/provide-9
tic30-unknown-coff  +FAIL: script
tic30-unknown-coff  +FAIL: MRI script
tic30-unknown-coff  +FAIL: MEMORY
tic30-unknown-coff  +FAIL: MEMORY with symbols
tic30-unknown-coff  +FAIL: SEGMENT_START expression not absolute (default)
tic30-unknown-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
tic30-unknown-coff  +FAIL: SIZEOF
tic4x-coff  +FAIL: check sections 1
tic4x-coff  +FAIL: ld-misc/defsym1
tic4x-coff  +FAIL: ld-scripts/align2a
tic4x-coff  +FAIL: ld-scripts/align2b
tic4x-coff  +FAIL: ld-scripts/empty-address-3a
tic4x-coff  +FAIL: ld-scripts/empty-address-3b
tic4x-coff  +FAIL: ld-scripts/empty-address-3c
tic4x-coff  +FAIL: ld-scripts/sane1
tic4x-coff  +FAIL: ld-scripts/assign-loc
tic4x-coff  +FAIL: ld-scripts/provide-10
tic4x-coff  +FAIL: ld-scripts/provide-11
tic4x-coff  +FAIL: ld-scripts/provide-12
tic4x-coff  +FAIL: ld-scripts/provide-9
tic4x-coff  +FAIL: script
tic4x-coff  +FAIL: MRI script
tic4x-coff  +FAIL: MEMORY
tic4x-coff  +FAIL: MEMORY with symbols
tic4x-coff  +FAIL: SEGMENT_START expression not absolute (default)
tic4x-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
tic4x-coff  +FAIL: SIZEOF
tic4x-coff  +FAIL: sysroot-prefix common plain -Lpath, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain -Lpath, unquoted
tic4x-coff  +FAIL: sysroot-prefix common full-path, quoted
tic4x-coff  +FAIL: sysroot-prefix common full-path, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted
tic4x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted
tic4x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, quoted
tic4x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted
tic4x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted
tic4x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted
tic4x-coff  +FAIL: --entry foo archive
tic4x-coff  +FAIL: --entry foo -u foo archive
tic4x-coff  +FAIL: --entry foo
tic4x-coff  +FAIL: --entry foo -u foo
tic4x-coff  +FAIL: --entry 0x0
tic54x-coff  +FAIL: check sections 1
tic54x-coff  +FAIL: ld-misc/defsym1
tic54x-coff  +FAIL: ld-scripts/align2a
tic54x-coff  +FAIL: ld-scripts/align2b
tic54x-coff  +FAIL: ld-scripts/empty-address-3a
tic54x-coff  +FAIL: ld-scripts/empty-address-3b
tic54x-coff  +FAIL: ld-scripts/empty-address-3c
tic54x-coff  +FAIL: ld-scripts/sane1
tic54x-coff  +FAIL: ld-scripts/assign-loc
tic54x-coff  +FAIL: ld-scripts/provide-10
tic54x-coff  +FAIL: ld-scripts/provide-11
tic54x-coff  +FAIL: ld-scripts/provide-12
tic54x-coff  +FAIL: ld-scripts/provide-9
tic54x-coff  +FAIL: script
tic54x-coff  +FAIL: MRI script
tic54x-coff  +FAIL: MEMORY
tic54x-coff  +FAIL: MEMORY with symbols
tic54x-coff  +FAIL: SIZEOF
tic54x-coff  +FAIL: sysroot-prefix common plain -Lpath, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain -Lpath, unquoted
tic54x-coff  +FAIL: sysroot-prefix common full-path, quoted
tic54x-coff  +FAIL: sysroot-prefix common full-path, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted
tic54x-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted
tic54x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, quoted
tic54x-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted
tic54x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted
tic54x-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted
tic54x-coff  +FAIL: --entry foo archive
tic54x-coff  +FAIL: --entry foo -u foo archive
tic54x-coff  +FAIL: --entry foo
tic54x-coff  +FAIL: --entry foo -u foo
tic54x-coff  +FAIL: --entry 0x0
x86_64-w64-mingw32  +FAIL: dlltool (version.dll)
x86_64-w64-mingw32  +FAIL: dlltool -p (execution)
x86_64-w64-mingw32  +FAIL: ld-pe/pr19803
x86_64-w64-mingw32  +FAIL: PR ld/20070
z80-coff  +FAIL: ld-scripts/align2a
z80-coff  +FAIL: ld-scripts/align2b
z80-coff  +FAIL: ld-scripts/empty-address-3a
z80-coff  +FAIL: ld-scripts/empty-address-3b
z80-coff  +FAIL: ld-scripts/empty-address-3c
z80-coff  +FAIL: ld-scripts/sane1
z80-coff  +FAIL: ld-scripts/assign-loc
z80-coff  +FAIL: ld-scripts/provide-10
z80-coff  +FAIL: ld-scripts/provide-11
z80-coff  +FAIL: ld-scripts/provide-12
z80-coff  +FAIL: ld-scripts/provide-9
z80-coff  +FAIL: script
z80-coff  +FAIL: MRI script
z80-coff  +FAIL: MEMORY
z80-coff  +FAIL: MEMORY with symbols
z80-coff  +FAIL: SEGMENT_START expression not absolute (default)
z80-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
z80-coff  +FAIL: SIZEOF
z8k-coff  +FAIL: check sections 1
z8k-coff  +FAIL: ld-misc/defsym1
z8k-coff  +FAIL: ld-scripts/align2a
z8k-coff  +FAIL: ld-scripts/align2b
z8k-coff  +FAIL: ld-scripts/empty-address-3a
z8k-coff  +FAIL: ld-scripts/empty-address-3b
z8k-coff  +FAIL: ld-scripts/empty-address-3c
z8k-coff  +FAIL: ld-scripts/sane1
z8k-coff  +FAIL: ld-scripts/assign-loc
z8k-coff  +FAIL: ld-scripts/provide-10
z8k-coff  +FAIL: ld-scripts/provide-11
z8k-coff  +FAIL: ld-scripts/provide-12
z8k-coff  +FAIL: ld-scripts/provide-9
z8k-coff  +FAIL: script
z8k-coff  +FAIL: MRI script
z8k-coff  +FAIL: MEMORY
z8k-coff  +FAIL: MEMORY with symbols
z8k-coff  +FAIL: SEGMENT_START expression not absolute (default)
z8k-coff  +FAIL: SEGMENT_START expression not absolute (overridden)
z8k-coff  +FAIL: SIZEOF
z8k-coff  +FAIL: sysroot-prefix common plain -Lpath, quoted
z8k-coff  +FAIL: sysroot-prefix common plain -Lpath, unquoted
z8k-coff  +FAIL: sysroot-prefix common full-path, quoted
z8k-coff  +FAIL: sysroot-prefix common full-path, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted
z8k-coff  +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted
z8k-coff  +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted
z8k-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, quoted
z8k-coff  +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted
z8k-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted
z8k-coff  +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted
z8k-coff  +FAIL: --entry foo archive
z8k-coff  +FAIL: --entry foo -u foo archive
z8k-coff  +FAIL: --entry foo
z8k-coff  +FAIL: --entry foo -u foo
z8k-coff  +FAIL: --entry 0x0


--
Alan Modra
Australia Development Lab, IBM



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF
  2021-10-21  7:51     ` CHIGOT, CLEMENT
  2021-11-09 13:24       ` CHIGOT, CLEMENT
@ 2021-11-10  4:38       ` Alan Modra
  2021-11-10 23:11         ` Alan Modra
  1 sibling, 1 reply; 12+ messages in thread
From: Alan Modra @ 2021-11-10  4:38 UTC (permalink / raw)
  To: CHIGOT, CLEMENT; +Cc: binutils, David Edelsohn

On Thu, Oct 21, 2021 at 07:51:36AM +0000, CHIGOT, CLEMENT wrote:
> Hi Alan,
> 
> The issue was indeed linked to the coffgen.c code you pointed out.
> I've tested on "arm-pe", "arm-wince-pe", "i686-pe", "sh-pe",
> "tic30-unknown-coff", "tic4x-coff", "tic54x-coff", "x86_64-w64-mingw32"
> and "z80-coff", the results are fine.
> Is there any other coff targets which should be tested ?

Thanks, I've now committed the patch.

> Moreover, as I've changed the structure of "combined_entry_type", the
> documentation needs to be updated at "https://sourceware.org/binutils/docs/bfd/coff.html".
> Is this done automatically or should I do something myself ?

Those docs are automatically extracted from the source, so no need for
any action on your part.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF
  2021-11-10  4:38       ` Alan Modra
@ 2021-11-10 23:11         ` Alan Modra
  2021-11-15 10:18           ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 12+ messages in thread
From: Alan Modra @ 2021-11-10 23:11 UTC (permalink / raw)
  To: CHIGOT, CLEMENT; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 190 bytes --]

It didn't take long for the fuzzers to find a hole.  Would you please
investigate?  objdump -t and objcopy both segfault on the attached
file.

-- 
Alan Modra
Australia Development Lab, IBM

[-- Attachment #2: clusterfuzz-testcase-minimized-fuzz_objcopy-5651865103106048 --]
[-- Type: application/octet-stream, Size: 8943 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF
  2021-11-10 23:11         ` Alan Modra
@ 2021-11-15 10:18           ` CHIGOT, CLEMENT
  2021-11-15 12:38             ` Alan Modra
  0 siblings, 1 reply; 12+ messages in thread
From: CHIGOT, CLEMENT @ 2021-11-15 10:18 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 796 bytes --]

Hi Alan,

It should be good with this patch now.
I've added some protections over my newly made code. It should protect other targets
not supporting the x_ftype field.

I didn't add the protection for the normalize symtab part. Because, PE is already
avoided here. But also because it doesn't make sense to me to avoid normalizing
the aux entry's string because it's representing a filename entry (which is obviously
a string). However, it might be safer to add it anyway as we have no idea about
what can be stored if the target doesn't support x_ftype field.
Does it look good to you or should I add the protection here too ?
(here: https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/coffgen.c;h=40f1ac718e48c74f1a95576a6ed9aa2c8a79f2af;hb=HEAD#l1950)

Thanks,
Clément

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-bfd-avoid-modifications-over-C_FILE-filename-aux-ent.patch --]
[-- Type: text/x-patch; name="0001-bfd-avoid-modifications-over-C_FILE-filename-aux-ent.patch", Size: 2354 bytes --]

From ce0ab9c3a538003ee9ab82898f022e2d48e96384 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Mon, 15 Nov 2021 10:37:36 +0100
Subject: [PATCH] bfd: avoid modifications over C_FILE filename aux entries.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit e86fc4a5bc37 ("PR 28447: implement multiple parameters for .file
on XCOFF") introduces C_FILE entries which can store additional
information.
However, some modifications are needed by them but not by the original
C_FILE entries, usually representing the filename.
This patch ensures that filename entries are kept as is, in order to
protect targets not supporting the additional entries.

bfd/ChangeLog:
2021-11-15  Clément Chigot  <clement.chigot@atos.net>

	* coffgen.c (coff_write_symbol): Protect filename entries
	(coff_write_symbols): Likewise.
	(coff_print_symbol): Likewise.
---
 bfd/coffgen.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 40f1ac718e4..5474f6c24d8 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -1036,7 +1036,10 @@ coff_write_symbol (bfd *abfd,
 	{
 	  BFD_ASSERT (! (native + j + 1)->is_sym);
 
-	  if (native->u.syment.n_sclass == C_FILE && j > 0)
+	  /* Adjust auxent only if this isn't the filename
+	     auxiliary entry.  */
+	  if (native->u.syment.n_sclass == C_FILE
+	      && (native + j + 1)->u.auxent.x_file.x_ftype)
 	    coff_write_auxent_fname (abfd, (char *) (native + j + 1)->extrap,
 				     &(native + j + 1)->u.auxent, string_size_p);
 
@@ -1423,6 +1426,11 @@ coff_write_symbols (bfd *abfd)
 		  char *str;
 		  size_t str_length;
 
+		  /* Add strings from aux entries only if this isn't the
+		     filename auxiliary entry.  */
+		  if (!c_symbol->native[j + 1].u.auxent.x_file.x_ftype)
+		    continue;
+
 		  if (c_symbol->native[j + 1].u.auxent.x_file.x_n.x_fname[0] != 0)
 		    continue;
 
@@ -2207,7 +2215,7 @@ coff_print_symbol (bfd *abfd,
 		  fprintf (file, "File ");
 		  /* Add additional information if this isn't the filename
 		     auxiliary entry.  */
-		  if (aux)
+		  if (auxp->u.auxent.x_file.x_ftype)
 		    fprintf (file, "ftype %d fname \"%s\"",
 			     auxp->u.auxent.x_file.x_ftype,
 			     (char *) auxp->u.auxent.x_file.x_n.x_n.x_offset);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF
  2021-11-15 10:18           ` CHIGOT, CLEMENT
@ 2021-11-15 12:38             ` Alan Modra
  0 siblings, 0 replies; 12+ messages in thread
From: Alan Modra @ 2021-11-15 12:38 UTC (permalink / raw)
  To: CHIGOT, CLEMENT; +Cc: binutils

On Mon, Nov 15, 2021 at 10:18:10AM +0000, CHIGOT, CLEMENT wrote:
> 	* coffgen.c (coff_write_symbol): Protect filename entries
> 	(coff_write_symbols): Likewise.
> 	(coff_print_symbol): Likewise.

Thanks, committed.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF
  2021-10-18 11:37 [PATCH] PR 28447: implement multiple parameters for .file on XCOFF CHIGOT, CLEMENT
  2021-10-20 10:09 ` Alan Modra
@ 2021-11-26 17:47 ` Mike Frysinger
  2021-11-28 23:10   ` Alan Modra
  1 sibling, 1 reply; 12+ messages in thread
From: Mike Frysinger @ 2021-11-26 17:47 UTC (permalink / raw)
  To: CHIGOT, CLEMENT; +Cc: binutils, David Edelsohn

[-- Attachment #1: Type: text/plain, Size: 1175 bytes --]

On 18 Oct 2021 11:37, CHIGOT, CLEMENT via Binutils wrote:
> On XCOFF, ".file" pseudo-op allows 3 extras parameters to provide
> additional information to AIX linker, or its debugger. These are
> stored in auxiliary entries of the C_FILE symbol.
>
> --- a/bfd/coffgen.c
> +++ b/bfd/coffgen.c
> @@ -2135,6 +2203,12 @@ coff_print_symbol (bfd *abfd,
>  		{
>  		case C_FILE:
>  		  fprintf (file, "File ");
> +		  /* Add additional information if this isn't the filename
> +		     auxiliary entry.  */
> +		  if (aux)
> +		    fprintf (file, "ftype %d fname \"%s\"",
> +			     auxp->u.auxent.x_file.x_ftype,
> +			     (char *) auxp->u.auxent.x_file.x_n.x_n.x_offset);

x_offset is a long and is not safe to directly cast to a pointer.  on LLP64
sytems where sizeof(long) == 4 and sizeof(char*) == 8, this fails, and it's
causing a build failure as a result:

bfd/coffgen.c: In function ‘coff_print_symbol’:
bfd/coffgen.c:2221:30: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
 2221 |                              (char *) auxp->u.auxent.x_file.x_n.x_n.x_offset);
      |                              ^
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF
  2021-11-26 17:47 ` Mike Frysinger
@ 2021-11-28 23:10   ` Alan Modra
  2021-11-30  7:57     ` CHIGOT, CLEMENT
  0 siblings, 1 reply; 12+ messages in thread
From: Alan Modra @ 2021-11-28 23:10 UTC (permalink / raw)
  To: CHIGOT, CLEMENT, binutils, David Edelsohn

On Fri, Nov 26, 2021 at 12:47:32PM -0500, Mike Frysinger via Binutils wrote:
> On 18 Oct 2021 11:37, CHIGOT, CLEMENT via Binutils wrote:
> > On XCOFF, ".file" pseudo-op allows 3 extras parameters to provide
> > additional information to AIX linker, or its debugger. These are
> > stored in auxiliary entries of the C_FILE symbol.
> >
> > --- a/bfd/coffgen.c
> > +++ b/bfd/coffgen.c
> > @@ -2135,6 +2203,12 @@ coff_print_symbol (bfd *abfd,
> >  		{
> >  		case C_FILE:
> >  		  fprintf (file, "File ");
> > +		  /* Add additional information if this isn't the filename
> > +		     auxiliary entry.  */
> > +		  if (aux)
> > +		    fprintf (file, "ftype %d fname \"%s\"",
> > +			     auxp->u.auxent.x_file.x_ftype,
> > +			     (char *) auxp->u.auxent.x_file.x_n.x_n.x_offset);
> 
> x_offset is a long and is not safe to directly cast to a pointer.  on LLP64
> sytems where sizeof(long) == 4 and sizeof(char*) == 8, this fails, and it's
> causing a build failure as a result:
> 
> bfd/coffgen.c: In function ‘coff_print_symbol’:
> bfd/coffgen.c:2221:30: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>  2221 |                              (char *) auxp->u.auxent.x_file.x_n.x_n.x_offset);
>       |                              ^
> -mike

Also reported as PR28630.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR 28447: implement multiple parameters for .file on XCOFF
  2021-11-28 23:10   ` Alan Modra
@ 2021-11-30  7:57     ` CHIGOT, CLEMENT
  0 siblings, 0 replies; 12+ messages in thread
From: CHIGOT, CLEMENT @ 2021-11-30  7:57 UTC (permalink / raw)
  To: Alan Modra, binutils, David Edelsohn, vapier, pexu

> On Fri, Nov 26, 2021 at 12:47:32PM -0500, Mike Frysinger via Binutils wrote:
> > On 18 Oct 2021 11:37, CHIGOT, CLEMENT via Binutils wrote:
> > > On XCOFF, ".file" pseudo-op allows 3 extras parameters to provide
> > > additional information to AIX linker, or its debugger. These are
> > > stored in auxiliary entries of the C_FILE symbol.
> > >
> > > --- a/bfd/coffgen.c
> > > +++ b/bfd/coffgen.c
> > > @@ -2135,6 +2203,12 @@ coff_print_symbol (bfd *abfd,
> > >              {
> > >              case C_FILE:
> > >                fprintf (file, "File ");
> > > +             /* Add additional information if this isn't the filename
> > > +                auxiliary entry.  */
> > > +             if (aux)
> > > +               fprintf (file, "ftype %d fname \"%s\"",
> > > +                        auxp->u.auxent.x_file.x_ftype,
> > > +                        (char *) auxp->u.auxent.x_file.x_n.x_n.x_offset);
> >
> > x_offset is a long and is not safe to directly cast to a pointer.  on LLP64
> > sytems where sizeof(long) == 4 and sizeof(char*) == 8, this fails, and it's
> > causing a build failure as a result:
> >
> > bfd/coffgen.c: In function ‘coff_print_symbol’:
> > bfd/coffgen.c:2221:30: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> >  2221 |                              (char *) auxp->u.auxent.x_file.x_n.x_n.x_offset);
> >       |                              ^
> > -mike
>
> Also reported as PR28630.

Thanks to Pekka, it seems that a fix would be to replace the
type of x_offset from "long" to "bfd_hostptr_t".
I've tried quickly on AIX and with some cross-compilation and it
looks good. However, I'm not mastering enough bfd to ensure that
this is the right fix.
Alan does it look good to you or it might trigger some unwanted
behaviors in some COFF targets ?
Note that this trick is already used by "internal_syment" structure
to store its name.

Thanks,
Clément


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-11-30  7:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18 11:37 [PATCH] PR 28447: implement multiple parameters for .file on XCOFF CHIGOT, CLEMENT
2021-10-20 10:09 ` Alan Modra
2021-10-20 12:01   ` CHIGOT, CLEMENT
2021-10-21  7:51     ` CHIGOT, CLEMENT
2021-11-09 13:24       ` CHIGOT, CLEMENT
2021-11-10  4:38       ` Alan Modra
2021-11-10 23:11         ` Alan Modra
2021-11-15 10:18           ` CHIGOT, CLEMENT
2021-11-15 12:38             ` Alan Modra
2021-11-26 17:47 ` Mike Frysinger
2021-11-28 23:10   ` Alan Modra
2021-11-30  7:57     ` CHIGOT, CLEMENT

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).