Re: gas: add visibility support using GNU syntax on XCOFF
authorAlan Modra <amodra@gmail.com>
Thu, 13 Jan 2022 05:12:13 +0000 (15:42 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 13 Jan 2022 06:20:15 +0000 (16:50 +1030)
tc-ppc.c: In function 'ppc_comm':
tc-ppc.c:4560:40: error: 'visibility' may be used uninitialized in this function [-Werror=maybe-uninitialized]

With that fixed we hit lots of segfaults in the ld testsuite.

PR 22085
bfd/
* xcofflink.c (xcoff_link_input_bfd): Don't segfault on NULL
sym_hash.
gas/
* config/tc-ppc.c (ppc_comm): Init visibility.

bfd/xcofflink.c
gas/config/tc-ppc.c

index 6e994720f6dfcff1ce567aa7b1e6eec97b8651fd..70d371e4aeddf153f8a97d6d1f79a4faf1a1ceb0 100644 (file)
@@ -4615,8 +4615,11 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
            }
 
          /* Update visibility.  */
-         isym.n_type &= ~SYM_V_MASK;
-         isym.n_type |= (*sym_hash)->visibility;
+         if (*sym_hash)
+           {
+             isym.n_type &= ~SYM_V_MASK;
+             isym.n_type |= (*sym_hash)->visibility;
+           }
 
          /* Output the symbol.  */
          bfd_coff_swap_sym_out (output_bfd, (void *) &isym, (void *) outsym);
index ac10772a61ed0c8e87ab5d028eb6c180a9d29062..054f9c72161b75490ed8731a525dc58cbe78a44f 100644 (file)
@@ -4380,7 +4380,7 @@ ppc_comm (int lcomm)
   symbolS *lcomm_sym = NULL;
   symbolS *sym;
   char *pfrag;
-  unsigned short visibility;
+  unsigned short visibility = 0;
   struct ppc_xcoff_section *section;
 
   endc = get_symbol_name (&name);