aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2009-08-26 13:35:37 +0000
committerNick Clifton <nickc@redhat.com>2009-08-26 13:35:37 +0000
commite5f2b1de7c60e55d86dab61eaa3750eca33ef367 (patch)
tree4bc2c1e39f020277f9bdd4e5dad6a0580e54ed53
parentf7922329bf858a53e75d0affc239ce08bea43fb8 (diff)
downloadgdb-e5f2b1de7c60e55d86dab61eaa3750eca33ef367.zip
gdb-e5f2b1de7c60e55d86dab61eaa3750eca33ef367.tar.gz
gdb-e5f2b1de7c60e55d86dab61eaa3750eca33ef367.tar.bz2
* elf32-m68k.c (elf_m68k_copy_indirect_symbol): Propagate non_got_ref
value. (elf_m68k_check_relocs): Handle dynamic TLS relocations. Handle non_got_ref field. (elf_m68k_adjust_dynamic_symbol): Handle non_got_ref field. * tls-def-1.s, tls-def-1.d, tls-gd-1.d2, tls-gd-1.d3, tls-main-1.s, * tls-main-1.d: New files. * m68k.exp: Run new TLS tests.
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/elf32-m68k.c24
-rw-r--r--ld/testsuite/ChangeLog10
-rw-r--r--ld/testsuite/ld-m68k/m68k.exp18
-rw-r--r--ld/testsuite/ld-m68k/tls-def-1.d4
-rw-r--r--ld/testsuite/ld-m68k/tls-def-1.s9
-rw-r--r--ld/testsuite/ld-m68k/tls-gd-1.d25
-rw-r--r--ld/testsuite/ld-m68k/tls-gd-1.d313
-rw-r--r--ld/testsuite/ld-m68k/tls-main-1.d15
-rw-r--r--ld/testsuite/ld-m68k/tls-main-1.s19
10 files changed, 124 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index cae2e2f..12966bc 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2009-08-26 Maxim Kuvyrkov <maxim@codesourcery.com>
+
+ * elf32-m68k.c (elf_m68k_copy_indirect_symbol): Propagate
+ non_got_ref value.
+ (elf_m68k_check_relocs): Handle dynamic TLS relocations.
+ Handle non_got_ref field.
+ (elf_m68k_adjust_dynamic_symbol): Handle non_got_ref field.
+
2009-08-26 Alan Modra <amodra@bigpond.net.au>
PR ld/10515
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 2957db0..ced19a1 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -2487,6 +2487,10 @@ elf_m68k_copy_indirect_symbol (struct bfd_link_info *info,
dir = elf_m68k_hash_entry (_dir);
ind = elf_m68k_hash_entry (_ind);
+ /* Any absolute non-dynamic relocations against an indirect or weak
+ definition will be against the target symbol. */
+ _dir->non_got_ref |= _ind->non_got_ref;
+
/* We might have a direct symbol already having entries in the GOTs.
Update its key only in case indirect symbol has GOT entries and
assert that both indirect and direct symbols don't have GOT entries
@@ -2581,6 +2585,14 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
case R_68K_TLS_IE16:
case R_68K_TLS_IE32:
+ case R_68K_TLS_TPREL32:
+ case R_68K_TLS_DTPREL32:
+
+ if (ELF32_R_TYPE (rel->r_info) == R_68K_TLS_TPREL32
+ && info->shared)
+ /* Do the special chorus for libraries with static TLS. */
+ info->flags |= DF_STATIC_TLS;
+
/* This symbol requires a global offset table entry. */
if (dynobj == NULL)
@@ -2739,6 +2751,10 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
/* Make sure a plt entry is created for this symbol if it
turns out to be a function defined by a dynamic object. */
h->plt.refcount++;
+
+ if (!info->shared)
+ /* This symbol needs a non-GOT reference. */
+ h->non_got_ref = 1;
}
/* If we are creating a shared library, we need to copy the
@@ -2946,6 +2962,9 @@ elf_m68k_gc_sweep_hook (bfd *abfd,
case R_68K_TLS_IE16:
case R_68K_TLS_IE32:
+ case R_68K_TLS_TPREL32:
+ case R_68K_TLS_DTPREL32:
+
if (got == NULL)
{
got = elf_m68k_get_bfd2got_entry (elf_m68k_multi_got (info),
@@ -3159,6 +3178,11 @@ elf_m68k_adjust_dynamic_symbol (info, h)
if (info->shared)
return TRUE;
+ /* If there are no references to this symbol that do not use the
+ GOT, we don't need to generate a copy reloc. */
+ if (!h->non_got_ref)
+ return TRUE;
+
if (h->size == 0)
{
(*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index d57d2f0..aafb869 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2009-08-26 Maxim Kuvyrkov <maxim@codesourcery.com>
+
+ * ld-m68k/tls-def-1.s: New file.
+ * ld-m68k/tls-def-1.d: New file.
+ * ld-m68k/tls-gd-1.d2: New file.
+ * ld-m68k/tls-gd-1.d3: New file.
+ * ld-m68k/tls-main-1.s: New file.
+ * ld-m68k/tls-main-1.d: New file.
+ * ld-m68k/m68k.exp: Run new TLS tests.
+
2009-08-23 Andreas Schwab <schwab@linux-m68k.org>
* ld-powerpc/powerpc.exp: Move relaxing and relocatable relaxing
diff --git a/ld/testsuite/ld-m68k/m68k.exp b/ld/testsuite/ld-m68k/m68k.exp
index 214c640..198a5e2 100644
--- a/ld/testsuite/ld-m68k/m68k.exp
+++ b/ld/testsuite/ld-m68k/m68k.exp
@@ -1,5 +1,5 @@
# Expect script for run_dump_test based ld-m68k tests.
-# Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+# Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
@@ -74,4 +74,20 @@ if { [istarget m68k-*-linux*] } then {
run_dump_test "tls-ie-1"
run_dump_test "tls-ld-1"
run_dump_test "tls-ld-2"
+
+ set m68k_tls_tests {
+ {"TLS definition"
+ "-shared" "" {tls-def-1.s}
+ {{nm -ngD tls-def-1.d}}
+ "tls-def-1.so"}
+ {"TLS direct symbol use"
+ "-shared tmpdir/tls-def-1.so" "" {tls-gd-1.s}
+ {{nm -ngD tls-gd-1.d2} {readelf -d tls-gd-1.d3}}
+ "tls-gd-1.so"}
+ {"TLS indirect symbol use"
+ "tmpdir/tls-gd-1.so -rpath-link ./" "" {tls-main-1.s}
+ {{readelf -d tls-main-1.d}}
+ "tls-main-1"}}
+
+ run_ld_link_tests $m68k_tls_tests
}
diff --git a/ld/testsuite/ld-m68k/tls-def-1.d b/ld/testsuite/ld-m68k/tls-def-1.d
new file mode 100644
index 0000000..59b4397
--- /dev/null
+++ b/ld/testsuite/ld-m68k/tls-def-1.d
@@ -0,0 +1,4 @@
+00000000 B x
+.*
+.*
+.*
diff --git a/ld/testsuite/ld-m68k/tls-def-1.s b/ld/testsuite/ld-m68k/tls-def-1.s
new file mode 100644
index 0000000..3d758a9
--- /dev/null
+++ b/ld/testsuite/ld-m68k/tls-def-1.s
@@ -0,0 +1,9 @@
+#NO_APP
+ .globl x
+ .section .tbss,"awT",@nobits
+ .align 2
+ .type x, @object
+ .size x, 4
+x:
+ .zero 4
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-m68k/tls-gd-1.d2 b/ld/testsuite/ld-m68k/tls-gd-1.d2
new file mode 100644
index 0000000..b6167e3
--- /dev/null
+++ b/ld/testsuite/ld-m68k/tls-gd-1.d2
@@ -0,0 +1,5 @@
+.* U x
+.*
+.*
+.*
+.*
diff --git a/ld/testsuite/ld-m68k/tls-gd-1.d3 b/ld/testsuite/ld-m68k/tls-gd-1.d3
new file mode 100644
index 0000000..4b835d3
--- /dev/null
+++ b/ld/testsuite/ld-m68k/tls-gd-1.d3
@@ -0,0 +1,13 @@
+
+Dynamic section at offset .* contains .*:
+ * Tag * Type * Name/Value
+ 0x00000001 \(NEEDED\) * Shared library: \[tmpdir/tls-def-1.so\]
+ 0x00000004 \(HASH\) .*
+ 0x00000005 \(STRTAB\) .*
+ 0x00000006 \(SYMTAB\) .*
+ 0x0000000a \(STRSZ\) .*
+ 0x0000000b \(SYMENT\) .*
+ 0x00000007 \(RELA\) .*
+ 0x00000008 \(RELASZ\) .*
+ 0x00000009 \(RELAENT\) .*
+ 0x00000000 \(NULL\) .*
diff --git a/ld/testsuite/ld-m68k/tls-main-1.d b/ld/testsuite/ld-m68k/tls-main-1.d
new file mode 100644
index 0000000..7da24ab
--- /dev/null
+++ b/ld/testsuite/ld-m68k/tls-main-1.d
@@ -0,0 +1,15 @@
+
+Dynamic section at offset .* contains .*:
+ * Tag * Type * Name/Value
+ 0x00000001 \(NEEDED\) * Shared library: \[tmpdir/tls-gd-1.so\]
+ 0x00000001 \(NEEDED\) * Shared library: \[tls-def-1.so\]
+ 0x00000004 \(HASH\) .*
+ 0x00000005 \(STRTAB\) .*
+ 0x00000006 \(SYMTAB\) .*
+ 0x0000000a \(STRSZ\) .*
+ 0x0000000b \(SYMENT\) .*
+ 0x00000015 \(DEBUG\) .*
+ 0x00000007 \(RELA\) .*
+ 0x00000008 \(RELASZ\) .*
+ 0x00000009 \(RELAENT\) .*
+ 0x00000000 \(NULL\) .*
diff --git a/ld/testsuite/ld-m68k/tls-main-1.s b/ld/testsuite/ld-m68k/tls-main-1.s
new file mode 100644
index 0000000..75fb6d6
--- /dev/null
+++ b/ld/testsuite/ld-m68k/tls-main-1.s
@@ -0,0 +1,19 @@
+#NO_APP
+ .text
+ .align 2
+ .globl main
+ .type main, @function
+ .globl _start
+ .type _start, @function
+main:
+_start:
+ link.w %fp,#0
+ move.l %a5,-(%sp)
+ move.l #_GLOBAL_OFFSET_TABLE_@GOTPC, %a5
+ lea (-6, %pc, %a5), %a5
+ move.l x@TLSIE(%a5),%a0
+ move.l -4(%fp),%a5
+ unlk %fp
+ rts
+ .size main, .-main
+ .section .note.GNU-stack,"",@progbits