alpha.c (alpha_encode_section_info): Adjust symbol_str properly when changing "local...
authorRichard Henderson <rth@redhat.com>
Mon, 6 Jan 2003 22:59:25 +0000 (14:59 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Mon, 6 Jan 2003 22:59:25 +0000 (14:59 -0800)
        * config/alpha/alpha.c (alpha_encode_section_info): Adjust symbol_str
        properly when changing "local-ness".
        * config/alpha/alpha.md (movdi_er_high_g): Allow all symbols.

* gcc.dg/tls/alias-1.c: New.

From-SVN: r60961

gcc/ChangeLog
gcc/config/alpha/alpha.c
gcc/config/alpha/alpha.md
gcc/testsuite/gcc.dg/tls/alias-1.c [new file with mode: 0644]

index 4e23a008744c4601a32495f1e5c734af10dd4e9e..90ac3867982fcd839e2989918851d807ad35e8af 100644 (file)
@@ -1,3 +1,9 @@
+2003-01-06  Richard Henderson  <rth@redhat.com>
+
+       * config/alpha/alpha.c (alpha_encode_section_info): Adjust symbol_str
+       properly when changing "local-ness".
+       * config/alpha/alpha.md (movdi_er_high_g): Allow all symbols.
+
 2003-01-06  Dale Johannesen  <dalej@apple.com>
 
        * config/darwin-protos.h:  Add prototypes for new section functions.
index e28f3195b3df4d0b1f14ab3231febd1bb57e38e9..ce0810d0d262cff4b890b2a62a690843a28b1c02 100644 (file)
@@ -1,6 +1,6 @@
 /* Subroutines used for code generation on the DEC Alpha.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002 Free Software Foundation, Inc. 
+   2000, 2001, 2002, 2003 Free Software Foundation, Inc. 
    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
 
 This file is part of GNU CC.
@@ -1974,18 +1974,22 @@ alpha_encode_section_info (decl, first)
     {
       char *newstr;
       size_t len;
+      char want_prefix = (is_local ? '@' : '%');
+      char other_prefix = (is_local ? '%' : '@');
 
-      if (symbol_str[0] == (is_local ? '@' : '%'))
+      if (symbol_str[0] == want_prefix)
        {
          if (symbol_str[1] == encoding)
            return;
          symbol_str += 2;
        }
+      else if (symbol_str[0] == other_prefix)
+       symbol_str += 2;
 
       len = strlen (symbol_str) + 1;
       newstr = alloca (len + 2);
 
-      newstr[0] = (is_local ? '@' : '%');
+      newstr[0] = want_prefix;
       newstr[1] = encoding;
       memcpy (newstr + 2, symbol_str, len);
          
index 523b1d2b3eb267e31a87b93ebe8806d6a6c4c555..ed93441b8f65bfb12cff246a03ed37f1c3caec48 100644 (file)
@@ -1,6 +1,6 @@
 ;; Machine description for DEC Alpha for GNU C compiler
 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-;; 2000, 2001, 2002 Free Software Foundation, Inc.
+;; 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
 ;;
 ;; This file is part of GNU CC.
@@ -5330,10 +5330,12 @@ fadd,fmul,fcpys,fdiv,fsqrt,misc,mvi,ftoi,itof,multi,none"
   [(match_dup 0)]
   "operands[0] = split_small_symbolic_operand (operands[0]);")
 
+;; Accepts any symbolic, not just global, since function calls that
+;; don't go via bsr still use !literal in hopes of linker relaxation.
 (define_insn "movdi_er_high_g"
   [(set (match_operand:DI 0 "register_operand" "=r")
        (unspec:DI [(match_operand:DI 1 "register_operand" "r")
-                   (match_operand:DI 2 "global_symbolic_operand" "")
+                   (match_operand:DI 2 "symbolic_operand" "")
                    (match_operand 3 "const_int_operand" "")]
                   UNSPEC_LITERAL))]
   "TARGET_EXPLICIT_RELOCS"
diff --git a/gcc/testsuite/gcc.dg/tls/alias-1.c b/gcc/testsuite/gcc.dg/tls/alias-1.c
new file mode 100644 (file)
index 0000000..3372da3
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do link } */
+/* Test that encode_section_info handles the change from externally
+   defined to locally defined (via hidden).   Extracted from glibc.  */
+
+struct __res_state {
+       char x[123];
+};
+
+extern __thread struct __res_state bar
+  __attribute__ ((tls_model ("initial-exec")));
+
+int main()
+{
+  bar.x[0] = 0;
+  return 0;
+}
+
+__thread struct __res_state foo;
+extern __thread struct __res_state bar
+  __attribute__ ((alias ("foo")))
+  __attribute__ ((visibility ("hidden")));