This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PowerPC64 Linux sym visibility fixes
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: gcc-patches at gcc dot gnu dot org
- Cc: David Edelsohn <dje at watson dot ibm dot com>
- Date: Fri, 6 Sep 2002 12:34:52 +0930
- Subject: PowerPC64 Linux sym visibility fixes
PowerPC64 Linux symbol visibility is a little broken at the moment due
to the visibility directives only being emitted for function descriptor
syms, and not the function entry syms. I could also fix this with
more hacks to backend macros, but targetm seems the way to go.
There's also a couple of formatting fixes thrown in for good measure.
* doc/tm.texi (TARGET_ASM_ASSEMBLE_VISIBILITY): Describe.
* target-def.h (TARGET_ASM_ASSEMBLE_VISIBILITY): Define.
(TARGET_ASM_OUT): Add the above here.
* target.h (struct gcc_target): Add "visibility" field.
* varasm.c (maybe_assemble_visibility): Call targetm visibility func.
* config/rs6000/rs6000.c (rs6000_assemble_visibility): New function.
(TARGET_ASM_ASSEMBLE_VISIBILITY): Define.
(rs6000_legitimize_reload_address, first_reg_to_save): Formatting.
OK mainline?
Index: gcc/target-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target-def.h,v
retrieving revision 1.31
diff -u -p -r1.31 target-def.h
--- gcc/target-def.h 4 Sep 2002 18:11:17 -0000 1.31
+++ gcc/target-def.h 6 Sep 2002 01:13:27 -0000
@@ -58,6 +58,10 @@ Foundation, 59 Temple Place - Suite 330,
#define TARGET_ASM_GLOBALIZE_LABEL default_globalize_label
#endif
+#ifndef TARGET_ASM_ASSEMBLE_VISIBILITY
+#define TARGET_ASM_ASSEMBLE_VISIBILITY assemble_visibility
+#endif
+
#define TARGET_ASM_FUNCTION_PROLOGUE default_function_pro_epilogue
#define TARGET_ASM_FUNCTION_EPILOGUE default_function_pro_epilogue
#define TARGET_ASM_FUNCTION_END_PROLOGUE no_asm_to_stream
@@ -149,6 +153,7 @@ Foundation, 59 Temple Place - Suite 330,
TARGET_ASM_UNALIGNED_INT_OP, \
TARGET_ASM_INTEGER, \
TARGET_ASM_GLOBALIZE_LABEL, \
+ TARGET_ASM_ASSEMBLE_VISIBILITY, \
TARGET_ASM_FUNCTION_PROLOGUE, \
TARGET_ASM_FUNCTION_END_PROLOGUE, \
TARGET_ASM_FUNCTION_BEGIN_EPILOGUE, \
Index: gcc/target.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target.h,v
retrieving revision 1.34
diff -u -p -r1.34 target.h
--- gcc/target.h 4 Sep 2002 18:11:18 -0000 1.34
+++ gcc/target.h 6 Sep 2002 01:13:28 -0000
@@ -72,6 +72,10 @@ struct gcc_target
/* Output code that will globalize a label. */
void (* globalize_label) PARAMS ((FILE *, const char *));
+ /* Emit an assembler directive to set visibility for the symbol
+ associated with the tree decl. */
+ void (* visibility) PARAMS ((tree, const char *));
+
/* Output the assembler code for entry to a function. */
void (* function_prologue) PARAMS ((FILE *, HOST_WIDE_INT));
Index: gcc/varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.306
diff -u -p -r1.306 varasm.c
--- gcc/varasm.c 4 Sep 2002 23:59:56 -0000 1.306
+++ gcc/varasm.c 6 Sep 2002 01:13:31 -0000
@@ -4624,7 +4624,7 @@ maybe_assemble_visibility (decl)
{
const char *type
= TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (visibility)));
- assemble_visibility (decl, type);
+ (* targetm.asm_out.visibility) (decl, type);
}
}
Index: gcc/config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.370
diff -u -p -r1.370 rs6000.c
--- gcc/config/rs6000/rs6000.c 5 Sep 2002 16:25:49 -0000 1.370
+++ gcc/config/rs6000/rs6000.c 6 Sep 2002 01:43:17 -0000
@@ -186,6 +186,7 @@ static void toc_hash_mark_table PARAMS (
static int constant_pool_expr_1 PARAMS ((rtx, int *, int *));
static struct machine_function * rs6000_init_machine_status PARAMS ((void));
static bool rs6000_assemble_integer PARAMS ((rtx, unsigned int, int));
+static void rs6000_assemble_visibility PARAMS ((tree, const char *));
static int rs6000_ra_ever_killed PARAMS ((void));
static tree rs6000_handle_longcall_attribute PARAMS ((tree *, tree, tree, int, bool *));
const struct attribute_spec rs6000_attribute_table[];
@@ -344,6 +345,11 @@ static const char alt_reg_names[][8] =
#undef TARGET_ASM_INTEGER
#define TARGET_ASM_INTEGER rs6000_assemble_integer
+#ifdef HAVE_GAS_HIDDEN
+#undef TARGET_ASM_ASSEMBLE_VISIBILITY
+#define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility
+#endif
+
#undef TARGET_ASM_FUNCTION_PROLOGUE
#define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
#undef TARGET_ASM_FUNCTION_EPILOGUE
@@ -2249,7 +2256,7 @@ rs6000_legitimize_reload_address (x, mod
&& REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER
&& REG_MODE_OK_FOR_BASE_P (XEXP (x, 0), mode)
&& GET_CODE (XEXP (x, 1)) == CONST_INT
- && !SPE_VECTOR_MODE (mode)
+ && !SPE_VECTOR_MODE (mode)
&& !ALTIVEC_VECTOR_MODE (mode))
{
HOST_WIDE_INT val = INTVAL (XEXP (x, 1));
@@ -8152,6 +8160,31 @@ rs6000_assemble_integer (x, size, aligne
#endif /* RELOCATABLE_NEEDS_FIXUP */
return default_assemble_integer (x, size, aligned_p);
}
+
+#ifdef HAVE_GAS_HIDDEN
+/* Emit an assembler directive to set symbol visibility for DECL to
+ VISIBILITY_TYPE. */
+
+void
+rs6000_assemble_visibility (decl, visibility_type)
+ tree decl;
+ const char *visibility_type;
+{
+ assemble_visibility (decl, visibility_type);
+
+ /* Functions need to have their entry point symbol visibility set as
+ well as their descriptor symbol visibility. */
+ if (DEFAULT_ABI == ABI_AIX && TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ const char *name;
+
+ name = ((* targetm.strip_name_encoding)
+ (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
+
+ fprintf (asm_out_file, "\t.%s\t.%s\n", visibility_type, name);
+ }
+}
+#endif
enum rtx_code
rs6000_reverse_condition (mode, code)
@@ -8787,8 +8820,9 @@ first_reg_to_save ()
break;
#if TARGET_MACHO
- if (flag_pic && current_function_uses_pic_offset_table &&
- (first_reg > RS6000_PIC_OFFSET_TABLE_REGNUM))
+ if (flag_pic
+ && current_function_uses_pic_offset_table
+ && first_reg > RS6000_PIC_OFFSET_TABLE_REGNUM)
return RS6000_PIC_OFFSET_TABLE_REGNUM;
#endif
Index: gcc/doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.163
diff -u -p -r1.163 tm.texi
--- gcc/doc/tm.texi 4 Sep 2002 17:35:59 -0000 1.163
+++ gcc/doc/tm.texi 6 Sep 2002 01:14:01 -0000
@@ -6663,6 +6663,12 @@ you want to control one-only symbol supp
setting the @code{DECL_ONE_ONLY} flag is enough to mark a declaration to
be emitted as one-only.
+@deftypefn {Target Hook} void TARGET_ASM_ASSEMBLE_VISIBILITY (tree @var{decl}, const char *@var{visibility})
+This target hook is a function to output to @var{asm_out_file} some
+commands that will make the symbol(s) associated with @var{decl} have
+hidden, protected or internal visibility as specified by @var{visibility}.
+@end deftypefn
+
@findex ASM_OUTPUT_EXTERNAL
@item ASM_OUTPUT_EXTERNAL (@var{stream}, @var{decl}, @var{name})
A C statement (sans semicolon) to output to the stdio stream
--
Alan Modra
IBM OzLabs - Linux Technology Centre