aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2019-10-07 20:21:50 +0000
committerIain Sandoe <iain@sandoe.co.uk>2019-10-07 20:21:50 +0000
commit13e1da334a49e308f082028d404ef6971bf38322 (patch)
tree7326f49dbe32842f47e93a6bb38ca358a6293717
parent7e76544bf7569408b1a740fa67b4aa28e4dba362 (diff)
[Darwin, machopic 1/n] Consider visibility in indirections.
For weak, hidden vars the indirection should just be as normal, that is that the indirections for such symbols should appear in the non-lazy symbol pointers table, not in the .data section. gcc/ChangeLog: 2019-10-07 Iain Sandoe <iain@sandoe.co.uk> * config/darwin.c (machopic_output_indirection): Don't put hidden symbol indirections into the .data section, use the non-lazy symbol pointers section as normal. (darwin_encode_section_info): Record if a symbol is hidden. * config/darwin.h (MACHO_SYMBOL_FLAG_HIDDEN_VIS): New. (MACHO_SYMBOL_HIDDEN_VIS_P): New. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@276675 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/darwin.c7
-rw-r--r--gcc/config/darwin.h6
3 files changed, 22 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 021d4060397..af5ac090810 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,14 @@
2019-10-07 Iain Sandoe <iain@sandoe.co.uk>
+ * config/darwin.c (machopic_output_indirection): Don't put
+ hidden symbol indirections into the .data section, use the
+ non-lazy symbol pointers section as normal.
+ (darwin_encode_section_info): Record if a symbol is hidden.
+ * config/darwin.h (MACHO_SYMBOL_FLAG_HIDDEN_VIS): New.
+ (MACHO_SYMBOL_HIDDEN_VIS_P): New.
+
+2019-10-07 Iain Sandoe <iain@sandoe.co.uk>
+
* config/darwin.c (machopic_symbol_defined_p): Use symbol flag
predicates instead of accessing bits directly.
(machopic_indirect_call_target): Likewise.
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 45e0d744adb..869e850c575 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -1120,6 +1120,7 @@ machopic_output_indirection (machopic_indirection **slot, FILE *asm_out_file)
machopic_output_stub (asm_out_file, sym, stub);
}
else if (! indirect_data (symbol)
+ && ! MACHO_SYMBOL_HIDDEN_VIS_P (symbol)
&& (machopic_symbol_defined_p (symbol)
|| SYMBOL_REF_LOCAL_P (symbol)))
{
@@ -1237,6 +1238,12 @@ darwin_encode_section_info (tree decl, rtx rtl, int first)
if (VAR_P (decl))
SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_FLAG_VARIABLE;
+ /* For Darwin, if we have specified visibility and it's not the default
+ that's counted 'hidden'. */
+ if (DECL_VISIBILITY_SPECIFIED (decl)
+ && DECL_VISIBILITY (decl) != VISIBILITY_DEFAULT)
+ SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_FLAG_HIDDEN_VIS;
+
if (!DECL_EXTERNAL (decl)
&& (!TREE_PUBLIC (decl) || !DECL_WEAK (decl))
&& ! lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 39c54cc7208..87e1eb63b1c 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -828,6 +828,12 @@ extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS];
#define MACHO_SYMBOL_DEFINED_P(RTX) \
((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_DEFINED) != 0)
+/* Set on a symbol that has specified non-default visibility. */
+
+#define MACHO_SYMBOL_FLAG_HIDDEN_VIS ((SYMBOL_FLAG_SUBT_DEP) << 3)
+#define MACHO_SYMBOL_HIDDEN_VIS_P(RTX) \
+ ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_HIDDEN_VIS) != 0)
+
/* Set on a symbol to indicate when fix-and-continue style code
generation is being used and the symbol refers to a static symbol
that should be rebound from new instances of a translation unit to