gcc.target/i386/pr61599-1.c currently FAILs on 64-bit Solaris/x86 with the native assembler:
FAIL: gcc.target/i386/pr61599-1.c (test for excess errors) WARNING: gcc.target/i386/pr61599-1.c compilation failed to produce executable Assembler: pr61599-1.c "pr61599-1.s", line 2 : Illegal mnemonic Near line: ".largecomm a,1073741824,64" "pr61599-1.s", line 2 : Syntax error gcc emits .largecomm a,1073741824,64 here. The issue is twofold: /bin/as uses the .lbcomm directive instead of .largecomm. In addition, the declaration needs to be prefixed with a section declaration like this: .section .lbss,"wah",@nobits .lbcomm a,1073741824,64 This can be done in gas as well: the resulting object files are identical with or without the .section declaration. The following patch implements this. Because we need the corresponding decl when switching to .lbss, all instances of ASM_OUTPUT_ALIGNED_COMMON need to be changed to ASM_OUTPUT_ALIGNED_DECL_COMMON for the additional decl argument. Besides, this patch depends on the previous one for large section handling with Solaris as: https://gcc.gnu.org/ml/gcc-patches/2016-03/msg01056.html Bootstrapped without regressions on i386-pc-solaris2.12 (with as and gas) and x86_64-pc-linux-gnu. Ok for mainline now or after gcc 6 branches? Thanks. Rainer 2016-03-15 Rainer Orth <r...@cebitec.uni-bielefeld.de> PR target/61821 * config/i386/i386.c (LARGECOMM_SECTION_ASM_OP): Define default. (x86_elf_aligned_common): Rename to ... (x86_elf_aligned_decl_common): ... this. Add decl arg. Switch to .lbss for largecomm object. Use LARGECOMM_SECTION_ASM_OP. * config/i386/i386-protos.h (x86_elf_aligned_common): Reflect renaming. * config/i386/x86-64.h (ASM_OUTPUT_ALIGNED_COMMON): Rename to ... (ASM_OUTPUT_ALIGNED_DECL_COMMON): ... this. Pass new decl arg. * config/i386/sol2.h (ASM_OUTPUT_ALIGNED_COMMON): Likewise. [!USE_GAS] (LARGECOMM_SECTION_ASM_OP): Define.
# HG changeset patch # Parent f2778f1226a58a09af87570a94143ad767c3de2d Support .largecomm with Solaris as (PR target/61821) diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -294,8 +294,8 @@ extern int ix86_decompose_address (rtx, extern int memory_address_length (rtx, bool); extern void x86_output_aligned_bss (FILE *, tree, const char *, unsigned HOST_WIDE_INT, int); -extern void x86_elf_aligned_common (FILE *, const char *, - unsigned HOST_WIDE_INT, int); +extern void x86_elf_aligned_decl_common (FILE *, tree, const char *, + unsigned HOST_WIDE_INT, int); #ifdef RTX_CODE extern void ix86_fp_comparison_codes (enum rtx_code code, enum rtx_code *, diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -6630,19 +6630,27 @@ x86_64_elf_unique_section (tree decl, in } #ifdef COMMON_ASM_OP + +#ifndef LARGECOMM_SECTION_ASM_OP +#define LARGECOMM_SECTION_ASM_OP "\t.largecomm\t" +#endif + /* This says how to output assembler code to declare an uninitialized external linkage data object. - For medium model x86-64 we need to use .largecomm opcode for + For medium model x86-64 we need to use LARGECOMM_SECTION_ASM_OP opcode for large objects. */ void -x86_elf_aligned_common (FILE *file, +x86_elf_aligned_decl_common (FILE *file, tree decl, const char *name, unsigned HOST_WIDE_INT size, int align) { if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC) && size > (unsigned int)ix86_section_threshold) - fputs ("\t.largecomm\t", file); + { + switch_to_section (get_named_section (decl, ".lbss", 0)); + fputs (LARGECOMM_SECTION_ASM_OP, file); + } else fputs (COMMON_ASM_OP, file); assemble_name (file, name); diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h --- a/gcc/config/i386/sol2.h +++ b/gcc/config/i386/sol2.h @@ -183,15 +183,15 @@ along with GCC; see the file COPYING3. /* As in sparc/sol2.h, override the default from i386/x86-64.h to work around Sun as TLS bug. */ -#undef ASM_OUTPUT_ALIGNED_COMMON -#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ +#undef ASM_OUTPUT_ALIGNED_DECL_COMMON +#define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \ do \ { \ if (TARGET_SUN_TLS \ && in_section \ && ((in_section->common.flags & SECTION_TLS) == SECTION_TLS)) \ switch_to_section (bss_section); \ - x86_elf_aligned_common (FILE, NAME, SIZE, ALIGN); \ + x86_elf_aligned_decl_common (FILE, DECL, NAME, SIZE, ALIGN); \ } \ while (0) @@ -229,6 +229,10 @@ along with GCC; see the file COPYING3. #define DTORS_SECTION_ASM_OP "\t.section\t.dtors, \"aw\"" #endif +#ifndef USE_GAS +#define LARGECOMM_SECTION_ASM_OP "\t.lbcomm\t" +#endif + #define USE_IX86_FRAME_POINTER 1 #define USE_X86_64_FRAME_POINTER 1 diff --git a/gcc/config/i386/x86-64.h b/gcc/config/i386/x86-64.h --- a/gcc/config/i386/x86-64.h +++ b/gcc/config/i386/x86-64.h @@ -55,9 +55,9 @@ see the files COPYING3 and COPYING.RUNTI #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ x86_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) -#undef ASM_OUTPUT_ALIGNED_COMMON -#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ - x86_elf_aligned_common (FILE, NAME, SIZE, ALIGN); +#undef ASM_OUTPUT_ALIGNED_DECL_COMMON +#define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \ + x86_elf_aligned_decl_common (FILE, DECL, NAME, SIZE, ALIGN); /* This is used to align code labels according to Intel recommendations. */
-- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University