diff options
author | David Edelsohn <dje.gcc@gmail.com> | 2021-04-06 11:41:49 -0400 |
---|---|---|
committer | David Edelsohn <dje.gcc@gmail.com> | 2021-05-02 15:16:49 -0400 |
commit | 92f59e47f5a468b96b12b15233a6729904b1a1ee (patch) | |
tree | 6387debcf41b07488ef0f6ef7707ecc130dbff26 /gcc/varasm.c | |
parent | a13a50047ef1814a7bda2392f728bf28f81b17ce (diff) | |
download | gcc-92f59e47f5a468b96b12b15233a6729904b1a1ee.zip gcc-92f59e47f5a468b96b12b15233a6729904b1a1ee.tar.gz gcc-92f59e47f5a468b96b12b15233a6729904b1a1ee.tar.bz2 |
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.
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index ac256ef..97c1e6f 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1202,6 +1202,25 @@ get_variable_align (tree decl) return align; } +/* Compute reloc for get_variable_section. The return value + is a mask for which bit 1 indicates a global relocation, and bit 0 + indicates a local relocation. */ + +int +compute_reloc_for_var (tree decl) +{ + int reloc; + + if (DECL_INITIAL (decl) == error_mark_node) + reloc = contains_pointers_p (TREE_TYPE (decl)) ? 3 : 0; + else if (DECL_INITIAL (decl)) + reloc = compute_reloc_for_constant (DECL_INITIAL (decl)); + else + reloc = 0; + + return reloc; +} + /* Return the section into which the given VAR_DECL or CONST_DECL should be placed. PREFER_NOSWITCH_P is true if a noswitch section should be used wherever possible. */ @@ -1239,12 +1258,7 @@ get_variable_section (tree decl, bool prefer_noswitch_p) return comm_section; } - if (DECL_INITIAL (decl) == error_mark_node) - reloc = contains_pointers_p (TREE_TYPE (decl)) ? 3 : 0; - else if (DECL_INITIAL (decl)) - reloc = compute_reloc_for_constant (DECL_INITIAL (decl)); - else - reloc = 0; + reloc = compute_reloc_for_var (decl); resolve_unique_section (decl, reloc, flag_data_sections); if (IN_NAMED_SECTION (decl)) @@ -7252,7 +7266,8 @@ compute_reloc_for_rtx_1 (const_rtx x) /* Like compute_reloc_for_constant, except for an RTX. The return value is a mask for which bit 1 indicates a global relocation, and bit 0 - indicates a local relocation. */ + indicates a local relocation. Used by default_select_rtx_section + and default_elf_select_rtx_section. */ static int compute_reloc_for_rtx (const_rtx x) |