darwin.c (machopic_symbol_defined_p): In addition to being SYMBOL_REF_LOCAL_P...
authorMike Stump <mrs@apple.com>
Wed, 1 Sep 2004 17:18:02 +0000 (17:18 +0000)
committerMike Stump <mrs@gcc.gnu.org>
Wed, 1 Sep 2004 17:18:02 +0000 (17:18 +0000)
* config/darwin.c (machopic_symbol_defined_p): In addition to
being SYMBOL_REF_LOCAL_P, a symbol must also be
! SYMBOL_REF_EXTERNAL_P, as only those are _always_ locally
defined in this output file, or translation unit in the case
of IMA not being used.
(machopic_output_indirection): SYMBOL_REF_LOCAL_P symbols
never need .indirect_symbol when indirecting.

From-SVN: r86915

gcc/ChangeLog
gcc/config/darwin.c
gcc/testsuite/gcc.dg/visibility-b.c [new file with mode: 0644]

index 8494de515476b9da69084f77e15b5e9192623fe4..658bfe4575f8c3193aea4903abb5e181b24b9c57 100644 (file)
@@ -1,3 +1,13 @@
+2004-09-01  Mike Stump  <mrs@apple.com>
+
+       * config/darwin.c (machopic_symbol_defined_p): In addition to
+       being SYMBOL_REF_LOCAL_P, a symbol must also be
+       ! SYMBOL_REF_EXTERNAL_P, as only those are _always_ locally
+       defined in this output file, or translation unit in the case
+       of IMA not being used.
+       (machopic_output_indirection): SYMBOL_REF_LOCAL_P symbols
+       never need .indirect_symbol when indirecting.
+
 2004-09-01  Jakub Jelinek  <jakub@redhat.com>
 
        * Makefile.in (bb-reorder.o): Add several dependencies.
index e9e509cece44f8bca4dde3eaeeba52c187b2fa64..c2353e30912d29f29d51348ffb63cb15c2020a8a 100644 (file)
@@ -97,9 +97,8 @@ name_needs_quotes (const char *name)
 static int
 machopic_symbol_defined_p (rtx sym_ref)
 {
-  return ((SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_DEFINED)
-         /* Local symbols must always be defined.  */
-         || SYMBOL_REF_LOCAL_P (sym_ref));
+  return (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_DEFINED)
+    || (SYMBOL_REF_LOCAL_P (sym_ref) && ! SYMBOL_REF_EXTERNAL_P (sym_ref));
 }
 
 /* This module assumes that (const (symbol_ref "foo")) is a legal pic
@@ -874,7 +873,8 @@ machopic_output_indirection (void **slot, void *data)
       machopic_output_stub (asm_out_file, sym, stub);    
     }
   else if (! indirect_data (symbol)
-          && machopic_symbol_defined_p (symbol))
+          && (machopic_symbol_defined_p (symbol)
+              || SYMBOL_REF_LOCAL_P (symbol)))
     {
       data_section ();
       assemble_align (GET_MODE_ALIGNMENT (Pmode));
diff --git a/gcc/testsuite/gcc.dg/visibility-b.c b/gcc/testsuite/gcc.dg/visibility-b.c
new file mode 100644 (file)
index 0000000..b1f1575
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do assemble { target *-*-darwin* } } */
+
+#define __private_extern__ extern __attribute__((visibility ("hidden")))
+
+__private_extern__ int n;
+
+int
+mach_error_type(int sub)
+{
+ if (sub >= n)
+     return 1;
+ return 0;
+}