aix: Redesign section encoding and selection
commit92f59e47f5a468b96b12b15233a6729904b1a1ee
authorDavid Edelsohn <dje.gcc@gmail.com>
Tue, 6 Apr 2021 15:41:49 +0000 (6 11:41 -0400)
committerDavid Edelsohn <dje.gcc@gmail.com>
Sun, 2 May 2021 19:16:49 +0000 (2 15:16 -0400)
tree6387debcf41b07488ef0f6ef7707ecc130dbff26
parenta13a50047ef1814a7bda2392f728bf28f81b17ce
aix: Redesign section encoding and selection

AIX symbol references can refer to either the symbol (a label) or a
symbol with a qualifier (the storage mapping class).  The storage mapping
class provide information about the underlying COFF section into which the
symbol will be placed, e.g. [RO] for read-only in the text section,
[RW] for read-writer in the data section, or [BS] for the BSS section.
A label is distinct from a qualname in the assembler language, e.g.,
foo and foo[RW] are different, but the symbol table of an object file strips
the storage mapping class from the name, so that it no longer is relevant
when referring to symbols across object files and libraries.

.csect .data[RW]
i:

is a label "i" in the .data CSECT, which has storage mapping class [RW]
so that it is placed in the read-write COFF section.

.csect i[RW]

is a CSECT "i[RW]".  BSS does not allow interior labels.

The AIX port of GCC had been emitting the storage mapping class where
appropriate but not consistently using the storage mapping class on
the DECL or SYM name.  This patch updates the section encoding to properly
place storage mapping class on symbol names and remove the decorations
placed when emitting the symbol.

The mapping classes correspond to sections and the encoding choices must
exactly match the section choices made by get_section, so the logic for
the computation of reloc in get_variable_section is split into its own
function that XCOFF encode section info can call.

gcc/ChangeLog:

* varasm.c (compute_reloc_for_var): Split out from...
(get_variable_section): Use it.
* output.h (compute_reloc_for_var): Declare.
* config/rs6000/rs6000-protos.h
(rs6000_xcoff_asm_output_aligned_decl_common): Change alignment to
unsigned int.
* config/rs6000/rs6000.c (rs6000_legitimize_tls_address_aix):
Don't append storage mapping class to symbol.
(rs6000_xcoff_asm_named_section): Add BS and UL mapping classes.
Don't convert TLS BSS to common.
(rs6000_xcoff_unique_section): Don't fall back to select_secton.
(rs6000_xcoff_section_type_flags): Add SECTION_BSS if DECL is
bss_initializer.
(rs6000_xcoff_asm_globalize_decl_name): Don't strip storage
mapping class.
(rs6000_xcoff_asm_output_aligned_decl_common): Align is unsigned int.
If align is 0 from TLS class, use the same rules as varasm.c
If not common, switch to BSS section manually.
If common, emit appropriate comm or lcomm directive.
(rs6000_xcoff_encode_section_info): Add logic to append all
storage mapping classes.
(rs6000_asm_weaken_decl): Adjust for qualname symbols.
* config/rs6000/xcoff.h (ASM_OUTPUT_ALIGNED_DECL_LOCAL): Use
rs6000_xcoff_asm_output_aligned_decl_common.
(ASM_OUTPUT_ALIGNED_DECL_LOCAL): Use
rs6000_xcoff_asm_output_aligned_decl_common.
(ASM_OUTPUT_TLS_COMMON): Use
rs6000_xcoff_asm_output_aligned_decl_common.

gcc/testsuite/ChangeLog:
* g++.dg/ext/visibility/fvisibility-inlines-hidden-4.C: Expect [BS]
mapping class on AIX.
* gcc.c-torture/compile/pr61159.c: XFAIL on AIX.
* gcc.c-torture/execute/alias-2.c: Same.
* gcc.dg/alias-7.c: Same.
gcc/config/rs6000/rs6000-protos.h
gcc/config/rs6000/rs6000.c
gcc/config/rs6000/xcoff.h
gcc/output.h
gcc/testsuite/g++.dg/ext/visibility/fvisibility-inlines-hidden-4.C
gcc/testsuite/gcc.c-torture/compile/pr61159.c
gcc/testsuite/gcc.c-torture/execute/alias-2.c
gcc/testsuite/gcc.dg/alias-7.c
gcc/varasm.c