From cd026728f3bcba878293f9c38f8760512755ed73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= Date: Tue, 27 Jul 2021 14:37:50 +0200 Subject: gas: improve C_BSTAT and C_STSYM symbols handling on XCOFF A C_BSTAT debug symbol specifies the beginning of a static block. Its n_value is the index of the csect containing static symbols. A C_STSYM debug symbol represents the stabstring of a statically allocated symbol. Its n_value is the offset in the csect pointed by the containing C_BSTAT. These two special n_value were not correctly handled both when generating object files with gas or when reading them with objdump. This patch tries to improve that and, above all, to allow gas-generated object files with such symbols to be accepted by AIX ld. bfd/ * coff-bfd.c (bfd_coff_get_syment): Adjust n_value of symbols having fix_value = 1 in order to be an index and not a memory offset. * coffgen.c (coff_get_symbol_info): Likewize. (coff_print_symbol): Likewize. gas/ * config/tc-ppc.c (ppc_frob_label): Don't change within if already set. (ppc_stabx): Remove workaround changing exp.X_add_symbol's within. * config/tc-ppc.h (struct ppc_tc_sy): Update comments. * symbols.c (resolve_symbol_value): Remove symbol update when final_val is 0 and it's an AIX debug symbol. * testsuite/gas/ppc/aix.exp: Add new tests. * testsuite/gas/ppc/xcoff-stsym-32.d: New test. * testsuite/gas/ppc/xcoff-stsym-64.d: New test. * testsuite/gas/ppc/xcoff-stsym.s: New test. --- bfd/coffgen.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bfd/coffgen.c') diff --git a/bfd/coffgen.c b/bfd/coffgen.c index b13e773..017d4c3 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -2043,8 +2043,10 @@ coff_get_symbol_info (bfd *abfd, asymbol *symbol, symbol_info *ret) if (coffsymbol (symbol)->native != NULL && coffsymbol (symbol)->native->fix_value && coffsymbol (symbol)->native->is_sym) - ret->value = coffsymbol (symbol)->native->u.syment.n_value - - (bfd_hostptr_t) obj_raw_syments (abfd); + ret->value = + ((coffsymbol (symbol)->native->u.syment.n_value - + (bfd_hostptr_t) obj_raw_syments (abfd)) + / sizeof (combined_entry_type)); } /* Print out information about COFF symbol. */ @@ -2092,7 +2094,8 @@ coff_print_symbol (bfd *abfd, if (! combined->fix_value) val = (bfd_vma) combined->u.syment.n_value; else - val = combined->u.syment.n_value - (bfd_hostptr_t) root; + val = ((combined->u.syment.n_value - (bfd_hostptr_t) root) + / sizeof (combined_entry_type)); fprintf (file, "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x", combined->u.syment.n_scnum, -- cgit v1.1