From: David Edelsohn <dje.gcc@gmail.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>,
Segher Boessenkool <segher@kernel.crashing.org>,
Jakub Jelinek <jakub@redhat.com>
Subject: [PATCH] AIX visibility
Date: Tue, 01 Nov 2016 15:50:00 -0000 [thread overview]
Message-ID: <CAGWvnyk3JuB00w1rU8+G1PD1HhLbgP47KiHEiPzm5=pLkAKL6Q@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1748 bytes --]
This patch enables visibility support for AIX. AIX of course chose
different syntax, so the default machinery isn't usable. AIX appends
the visibility to the .globl and .comm pseudo-ops.
Within the rs6000 port, this patch only affects AIX / XCOFF.
Also, because visibility support implicitly enables other features in
GCC, some of which conflict with AIX, I had to disable the additional
features. Because AIX uses DWARF for EH but places the DWARF
information in the data section, the use of DWARF references and
force_constant_mem conflicts with the data section. For this reason,
USE_LINKONCE_INDIRECT is disabled in dwarf2asm.c.
This patch also adjusts gcc/configure to set HAVE_GAS_HIDDEN. AIX ld
support for hidden is forced true because the assembler test will
catch if support is present.
A number of testsuite tweaks also are necessary to XFAIL some
visibility tests on AIX.
Bootstrapped on powerpc-ibm-aix7.2.0.0 and powerpc64le-ibm-linux-gnu.
Are the changes to configure and dwarf2asm.c okay?
* configure.ac (.hidden): Change to conftest_s string. Provide string
for AIX assembler.
(gcc_cv_ld_hidden): Yes for AIX.
* configure: Regenerate.
* dwarf2asm.c (USE_LINKONCE_INDIRECT): Don't set for AIX (XCOFF).
* config/rs6000/rs6000-protos.h
(rs6000_xcoff_asm_output_aligned_decl_common): Declare.
* config/rs6000/xcoff.h (TARGET_ASM_GLOBALIZE_DECL_NAME): Define.
(ASM_OUTPUT_ALIGNED_DECL_COMMON): Define.
(ASM_OUTPUT_ALIGNED_COMMON): Delete.
* config/rs6000/rs6000.c (rs6000_xcoff_visibility): New.
(rs6000_xcoff_declare_function_name): Add visibility support.
(rs6000_xcoff_asm_globalize_decl_name): New.
(rs6000_xcoff_asm_output_aligned_decl_common): New.
(rs6000_code_end): Disable HIDDEN_LINKONCE on XCOFF.
Thanks, David
[-- Attachment #2: ZZ --]
[-- Type: application/octet-stream, Size: 7120 bytes --]
Index: configure.ac
===================================================================
--- configure.ac (revision 241708)
+++ configure.ac (working copy)
@@ -2537,10 +2537,17 @@ gcc_GAS_CHECK_FEATURE([.nsubspa comdat], gcc_cv_as
# ld, we don't know its patchlevel version, so we set the baseline at 2.13
# to be safe.
# The gcc_GAS_CHECK_FEATURE call just sets a cache variable.
+case "${target}" in
+ *-*-aix*)
+ conftest_s=' .globl foobar,hidden'
+ ;;
+ *)
+ conftest_s=' .hidden foobar
+foobar:'
+ ;;
+esac
gcc_GAS_CHECK_FEATURE([.hidden], gcc_cv_as_hidden,
- [elf,2,13,0],,
-[ .hidden foobar
-foobar:])
+ [elf,2,13,0],, [$conftest_s])
case "${target}" in
*-*-darwin*)
# Darwin as has some visibility support, though with a different syntax.
@@ -2649,6 +2656,9 @@ else
fi
else
case "${target}" in
+ *-*-aix[[789]]*)
+ gcc_cv_ld_hiden=yes
+ ;;
*-*-darwin*)
# Darwin ld has some visibility support.
gcc_cv_ld_hidden=yes
Index: dwarf2asm.c
===================================================================
--- dwarf2asm.c (revision 241720)
+++ dwarf2asm.c (working copy)
@@ -824,7 +824,7 @@ static GTY(()) hash_map<const char *, tree> *indir
static GTY(()) int dw2_const_labelno;
-#if defined(HAVE_GAS_HIDDEN)
+#if defined(HAVE_GAS_HIDDEN) && !defined(XCOFF_DEBUGGING_INFO)
# define USE_LINKONCE_INDIRECT (SUPPORTS_ONE_ONLY)
#else
# define USE_LINKONCE_INDIRECT 0
Index: config/rs6000/rs6000-protos.h
===================================================================
--- config/rs6000/rs6000-protos.h (revision 241720)
+++ config/rs6000/rs6000-protos.h (working copy)
@@ -189,6 +189,10 @@ extern int function_ok_for_sibcall (tree);
extern int rs6000_reg_parm_stack_space (tree, bool);
extern void rs6000_xcoff_declare_function_name (FILE *, const char *, tree);
extern void rs6000_xcoff_declare_object_name (FILE *, const char *, tree);
+extern void rs6000_xcoff_asm_output_aligned_decl_common (FILE *, tree,
+ const char *,
+ unsigned HOST_WIDE_INT,
+ unsigned HOST_WIDE_INT);
extern void rs6000_elf_declare_function_name (FILE *, const char *, tree);
extern bool rs6000_elf_in_small_data_p (const_tree);
#ifdef ARGS_SIZE_RTX
Index: config/rs6000/xcoff.h
===================================================================
--- config/rs6000/xcoff.h (revision 241720)
+++ config/rs6000/xcoff.h (working copy)
@@ -89,6 +89,7 @@
#undef TARGET_DEBUG_UNWIND_INFO
#define TARGET_DEBUG_UNWIND_INFO rs6000_xcoff_debug_unwind_info
#define TARGET_ASM_OUTPUT_ANCHOR rs6000_xcoff_asm_output_anchor
+#define TARGET_ASM_GLOBALIZE_DECL_NAME rs6000_xcoff_asm_globalize_decl_name
#define TARGET_ASM_GLOBALIZE_LABEL rs6000_xcoff_asm_globalize_label
#define TARGET_ASM_INIT_SECTIONS rs6000_xcoff_asm_init_sections
#define TARGET_ASM_RELOC_RW_MASK rs6000_xcoff_reloc_rw_mask
@@ -102,6 +103,7 @@
#ifdef HAVE_AS_TLS
#define TARGET_ENCODE_SECTION_INFO rs6000_xcoff_encode_section_info
#endif
+#define ASM_OUTPUT_ALIGNED_DECL_COMMON rs6000_xcoff_asm_output_aligned_decl_common
/* FP save and restore routines. */
#define SAVE_FP_PREFIX "._savef"
@@ -217,18 +219,6 @@
#define COMMON_ASM_OP "\t.comm "
-#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
- do { fputs (COMMON_ASM_OP, (FILE)); \
- RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \
- if ((ALIGN) > 32) \
- fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", (SIZE), \
- floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
- else if ((SIZE) > 4) \
- fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",3\n", (SIZE)); \
- else \
- fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE)); \
- } while (0)
-
/* This says how to output an assembler line
to define a local common symbol.
The assembler in AIX 6.1 and later supports an alignment argument.
Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c (revision 241720)
+++ config/rs6000/rs6000.c (working copy)
@@ -35316,6 +35316,31 @@ rs6000_declare_alias (struct symtab_node *n, void
return false;
}
+
+#ifdef HAVE_GAS_HIDDEN
+/* Helper function to calculate visibility of a DECL
+ and return the value as a const string. */
+
+static const char *
+rs6000_xcoff_visibility (tree decl)
+{
+ static const char * const visibility_types[] = {
+ "", ",protected", ",hidden", ",internal"
+ };
+
+ enum symbol_visibility vis = DECL_VISIBILITY (decl);
+
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ && cgraph_node::get (decl)
+ && cgraph_node::get (decl)->instrumentation_clone
+ && cgraph_node::get (decl)->instrumented_version)
+ vis = DECL_VISIBILITY (cgraph_node::get (decl)->instrumented_version->decl);
+
+ return visibility_types[vis];
+}
+#endif
+
+
/* This macro produces the initial definition of a function name.
On the RS/6000, we need to place an extra '.' in the function name and
output the function descriptor.
@@ -35355,6 +35380,9 @@ rs6000_xcoff_declare_function_name (FILE *file, co
}
fputs ("\t.globl .", file);
RS6000_OUTPUT_BASENAME (file, buffer);
+#ifdef HAVE_GAS_HIDDEN
+ fputs (rs6000_xcoff_visibility (decl), file);
+#endif
putc ('\n', file);
}
}
@@ -35399,6 +35427,52 @@ rs6000_xcoff_declare_function_name (FILE *file, co
return;
}
+
+/* Output assembly language to globalize a symbol from a DECL,
+ possibly with visibility. */
+
+void
+rs6000_xcoff_asm_globalize_decl_name (FILE *stream, tree decl)
+{
+ const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
+ fputs (GLOBAL_ASM_OP, stream);
+ RS6000_OUTPUT_BASENAME (stream, name);
+#ifdef HAVE_GAS_HIDDEN
+ fputs (rs6000_xcoff_visibility (decl), stream);
+#endif
+ putc ('\n', stream);
+}
+
+/* Output assembly language to define a symbol as COMMON from a DECL,
+ possibly with visibility. */
+
+void
+rs6000_xcoff_asm_output_aligned_decl_common (FILE *stream,
+ tree decl ATTRIBUTE_UNUSED,
+ const char *name,
+ unsigned HOST_WIDE_INT size,
+ unsigned HOST_WIDE_INT align)
+{
+ unsigned HOST_WIDE_INT align2 = 2;
+
+ if (align > 32)
+ align2 = floor_log2 (align / BITS_PER_UNIT);
+ else if (size > 4)
+ align2 = 3;
+
+ fputs (COMMON_ASM_OP, stream);
+ RS6000_OUTPUT_BASENAME (stream, name);
+
+ fprintf (stream,
+ "," HOST_WIDE_INT_PRINT_UNSIGNED "," HOST_WIDE_INT_PRINT_UNSIGNED,
+ size, align2);
+
+#ifdef HAVE_GAS_HIDDEN
+ fputs (rs6000_xcoff_visibility (decl), stream);
+#endif
+ putc ('\n', stream);
+}
+
/* This macro produces the initial definition of a object (variable) name.
Because AIX assembler's .set command has unexpected semantics, we output
all aliases as alternative labels in front of the definition. */
@@ -38651,7 +38725,7 @@ rs6000_code_end (void)
TREE_STATIC (decl) = 1;
#if RS6000_WEAK
- if (USE_HIDDEN_LINKONCE)
+ if (USE_HIDDEN_LINKONCE && !TARGET_XCOFF)
{
cgraph_node::create (decl)->set_comdat_group (DECL_ASSEMBLER_NAME (decl));
targetm.asm_out.unique_section (decl, 0);
reply other threads:[~2016-11-01 15:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGWvnyk3JuB00w1rU8+G1PD1HhLbgP47KiHEiPzm5=pLkAKL6Q@mail.gmail.com' \
--to=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=segher@kernel.crashing.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).