gas: improve C_BSTAT and C_STSYM symbols handling on XCOFF
authorClément Chigot <clement.chigot@atos.net>
Tue, 27 Jul 2021 12:37:50 +0000 (14:37 +0200)
committerClément Chigot <clement.chigot@atos.net>
Thu, 29 Jul 2021 08:55:22 +0000 (10:55 +0200)
commitcd026728f3bcba878293f9c38f8760512755ed73
treec4ae58abb4e2179b87a068f35b94b4afccf4f099
parentad42014be254b402f7a44e578cc709fe9e30dc1d
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/coff-bfd.c
bfd/coffgen.c
gas/config/tc-ppc.c
gas/config/tc-ppc.h
gas/symbols.c
gas/testsuite/gas/ppc/aix.exp
gas/testsuite/gas/ppc/xcoff-stsym-32.d [new file with mode: 0644]
gas/testsuite/gas/ppc/xcoff-stsym-64.d [new file with mode: 0644]
gas/testsuite/gas/ppc/xcoff-stsym.s [new file with mode: 0644]