gas: add visibility support using GNU syntax on XCOFF
Alan Modra
amodra@gmail.com
Thu Jan 13 06:25:33 GMT 2022
>From 1ffce3f87dc6e62d49b5aaa0bc29c6d4cfbc6db6 Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Thu, 13 Jan 2022 15:42:13 +1030
Subject:
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. I'm
assuming we leave SYM_V_MASK bits alone if there is no corresponding
symbol in the global hash table. Clement, please fix this if I got
that wrong.
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.
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index 6e994720f6d..70d371e4aed 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -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);
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index ac10772a61e..054f9c72161 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -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);
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list