aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn David Anglin <danglin@gcc.gnu.org>2020-04-21 16:33:23 +0000
committerJohn David Anglin <danglin@gcc.gnu.org>2020-04-21 16:33:23 +0000
commit1d4a3bfa8311a26814d60165b3e850cce850b61a (patch)
treec12d09afaaa357e936a9c515c8a29fa78dc3d248
parent85353e24ca90282e1d3620682841f524de20475c (diff)
downloadgcc-1d4a3bfa8311a26814d60165b3e850cce850b61a.zip
gcc-1d4a3bfa8311a26814d60165b3e850cce850b61a.tar.gz
gcc-1d4a3bfa8311a26814d60165b3e850cce850b61a.tar.bz2
Fix weakening of external declarations.
2020-04-21 John David Anglin <danglin@gcc.gnu.org> * config/pa/som.h (ASM_WEAKEN_LABEL): Delete. (ASM_WEAKEN_DECL): New define. (HAVE_GAS_WEAKREF): Undefine.
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/pa/som.h45
2 files changed, 44 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 98ad2b2..8595d0e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2020-04-21 John David Anglin <danglin@gcc.gnu.org>
+
+ * config/pa/som.h (ASM_WEAKEN_LABEL): Delete.
+ (ASM_WEAKEN_DECL): New define.
+ (HAVE_GAS_WEAKREF): Undefine.
+
2020-04-21 Richard Sandiford <richard.sandiford@arm.com>
PR tree-optimization/94683
diff --git a/gcc/config/pa/som.h b/gcc/config/pa/som.h
index 505fdd6..81aee86 100644
--- a/gcc/config/pa/som.h
+++ b/gcc/config/pa/som.h
@@ -277,7 +277,7 @@ do { \
/* If GAS supports weak, we can support weak when we have working linker
support for secondary definitions and are generating code for GAS.
This is primarily for one-only support as SOM doesn't allow undefined
- weak symbols. */
+ weak symbols or weak aliases. */
#ifdef HAVE_GAS_WEAK
#define TARGET_SUPPORTS_WEAK (TARGET_SOM_SDEF && TARGET_GAS)
#else
@@ -328,12 +328,43 @@ do { \
be used to remove dead procedures. Thus, support for named sections
is not needed and in previous testing caused problems with various
HP tools. */
-#define ASM_WEAKEN_LABEL(FILE,NAME) \
- do { fputs ("\t.weak\t", FILE); \
- assemble_name (FILE, NAME); \
- fputc ('\n', FILE); \
- targetm.asm_out.globalize_label (FILE, NAME); \
- } while (0)
+#if defined HAVE_GAS_WEAK
+#define ASM_WEAKEN_DECL(FILE,DECL,NAME,VALUE) \
+ do \
+ { \
+ if ((VALUE) != NULL) \
+ error_at (DECL_SOURCE_LOCATION (DECL), \
+ "weak aliases are not supported"); \
+ fputs ("\t.weak\t", FILE); \
+ assemble_name (FILE, NAME); \
+ fputc ('\n', FILE); \
+ \
+ /* Import external objects. */ \
+ if (DECL_EXTERNAL (DECL)) \
+ { \
+ fputs ("\t.IMPORT ", FILE); \
+ assemble_name (FILE, NAME); \
+ if (TREE_CODE (DECL) == FUNCTION_DECL) \
+ fputs (",CODE\n", FILE); \
+ else \
+ fputs (",DATA\n", FILE); \
+ } \
+ /* Functions are globalized by ASM_DECLARE_FUNCTION_NAME. */ \
+ else if (TREE_CODE (DECL) != FUNCTION_DECL) \
+ { \
+ fputs ("\t.EXPORT ", FILE); \
+ assemble_name (FILE, NAME); \
+ fputs (",DATA\n", FILE); \
+ } \
+ } \
+ while (0)
+#endif
+
+/* Although gas accepts .weakref, it doesn't provide the correct symbol
+ type for function references. For now, we use ASM_WEAKEN_DECL instead.
+ We have to undefine HAVE_GAS_WEAKREF to prevent default.h from defining
+ ASM_OUTPUT_WEAKREF. */
+#undef HAVE_GAS_WEAKREF
/* We can't handle weak aliases, and therefore can't support pragma weak.
Suppress the use of pragma weak in gthr-dce.h and gthr-posix.h. */