aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elf64-aarch64.c19
-rw-r--r--ld/testsuite/ld-aarch64/aarch64-elf.exp4
-rw-r--r--ld/testsuite/ld-aarch64/gc-got-relocs.d32
-rw-r--r--ld/testsuite/ld-aarch64/gc-relocs-309.s7
-rw-r--r--ld/testsuite/ld-aarch64/gc-relocs-311.s5
-rw-r--r--ld/testsuite/ld-aarch64/gc-relocs-312.s7
-rw-r--r--ld/testsuite/ld-aarch64/gc-relocs-tlsdesc.s38
-rw-r--r--ld/testsuite/ld-aarch64/gc-relocs-tlsgd.s30
-rw-r--r--ld/testsuite/ld-aarch64/gc-relocs-tlsie.s29
-rw-r--r--ld/testsuite/ld-aarch64/gc-relocs-tlsle.s36
-rw-r--r--ld/testsuite/ld-aarch64/gc-start.s4
-rw-r--r--ld/testsuite/ld-aarch64/gc-tls-relocs.d34
13 files changed, 239 insertions, 11 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index d854fd0..bbcb8b5 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-03 Venkataramanan Kumar <venkataramanan.kumar@linaro.org>
+
+ * elf64-aarch64.c (elf64_aarch64_gc_sweep_hook): Use
+ elf64_aarch64_locals to get local GOT reference counts.
+
2013-04-02 DJ Delorie <dj@redhat.com>
* elf32-rl78.c (GET_RELOC): Assert that there are relocs to get.
diff --git a/bfd/elf64-aarch64.c b/bfd/elf64-aarch64.c
index c3b9fc8..540b275 100644
--- a/bfd/elf64-aarch64.c
+++ b/bfd/elf64-aarch64.c
@@ -4869,16 +4869,15 @@ elf64_aarch64_print_private_bfd_data (bfd *abfd, void *ptr)
/* Update the got entry reference counts for the section being removed. */
static bfd_boolean
-elf64_aarch64_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
- struct bfd_link_info *info ATTRIBUTE_UNUSED,
- asection *sec ATTRIBUTE_UNUSED,
- const Elf_Internal_Rela *
- relocs ATTRIBUTE_UNUSED)
+elf64_aarch64_gc_sweep_hook (bfd *abfd,
+ struct bfd_link_info *info,
+ asection *sec,
+ const Elf_Internal_Rela * relocs)
{
struct elf64_aarch64_link_hash_table *htab;
Elf_Internal_Shdr *symtab_hdr;
struct elf_link_hash_entry **sym_hashes;
- bfd_signed_vma *local_got_refcounts;
+ struct elf_aarch64_local_symbol *locals;
const Elf_Internal_Rela *rel, *relend;
if (info->relocatable)
@@ -4894,7 +4893,7 @@ elf64_aarch64_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
- local_got_refcounts = elf_local_got_refcounts (abfd);
+ locals = elf64_aarch64_locals (abfd);
relend = relocs + sec->reloc_count;
for (rel = relocs; rel < relend; rel++)
@@ -4965,10 +4964,10 @@ elf64_aarch64_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
if (h->got.refcount > 0)
h->got.refcount -= 1;
}
- else if (local_got_refcounts != NULL)
+ else if (locals != NULL)
{
- if (local_got_refcounts[r_symndx] > 0)
- local_got_refcounts[r_symndx] -= 1;
+ if (locals[r_symndx].got_refcount > 0)
+ locals[r_symndx].got_refcount -= 1;
}
break;
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index d4f6235..f913fe6 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -1,5 +1,5 @@
# Expect script for various AARCH64 ELF tests.
-# Copyright 2009-2012 Free Software Foundation, Inc.
+# Copyright 2009-2013 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
@@ -109,3 +109,5 @@ run_dump_test "tls-relax-gdesc-le-2"
run_dump_test "tls-relax-ie-le-2"
run_dump_test "tls-relax-ie-le-3"
run_dump_test "tlsle-symbol-offset"
+run_dump_test "gc-got-relocs"
+run_dump_test "gc-tls-relocs"
diff --git a/ld/testsuite/ld-aarch64/gc-got-relocs.d b/ld/testsuite/ld-aarch64/gc-got-relocs.d
new file mode 100644
index 0000000..c636fbf
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/gc-got-relocs.d
@@ -0,0 +1,32 @@
+#source: gc-start.s
+#source: gc-relocs-309.s
+#source: gc-relocs-311.s
+#source: gc-relocs-312.s
+#ld: --gc-sections -T aarch64.ld
+#objdump: -s -t -d
+
+# Executable with got related relocs against global sysmbol gced.
+# After gc-section removal we are cheking that symbol does not exit
+# got section is empty and text section contains only start function.
+
+.*: file format elf64-littleaarch64
+
+SYMBOL TABLE:
+0+8000 l d \.text 0+ \.text
+0+9000 l d \.got 0+ \.got
+0+0000 l df \*ABS\* 0+ .*
+0+0000 l df \*ABS\* 0+
+0+9000 l O \.got 0+ _GLOBAL_OFFSET_TABLE_
+0+8000 g \.text 0+ _start
+
+Contents of section .text:
+ 8000 1f2003d5 .*
+Contents of section .got:
+ 9000 0+ 0+ 0+ 0+ .*
+ 9010 0+ 0+ .*
+
+Disassembly of section .text:
+
+0+8000 \<_start>:
+ 8000: d503201f nop
+
diff --git a/ld/testsuite/ld-aarch64/gc-relocs-309.s b/ld/testsuite/ld-aarch64/gc-relocs-309.s
new file mode 100644
index 0000000..06901bf
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/gc-relocs-309.s
@@ -0,0 +1,7 @@
+#R_AARCH64_GOT_LD_PREL19
+ .comm sym309_notused,1,8
+.text
+_test_gc_rel309:
+ nop
+ ldr x1, :got_prel19:sym309_notused
+
diff --git a/ld/testsuite/ld-aarch64/gc-relocs-311.s b/ld/testsuite/ld-aarch64/gc-relocs-311.s
new file mode 100644
index 0000000..46df7d7
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/gc-relocs-311.s
@@ -0,0 +1,5 @@
+#R_AARCH64_ADR_GOT_PAGE
+.comm gempy,4,4
+.text
+_test_gc_rel311:
+ adrp x3,:got:gempy
diff --git a/ld/testsuite/ld-aarch64/gc-relocs-312.s b/ld/testsuite/ld-aarch64/gc-relocs-312.s
new file mode 100644
index 0000000..7a2f370
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/gc-relocs-312.s
@@ -0,0 +1,7 @@
+#R_AARCH64_GOT_LD_PREL19
+ .comm sym312_notused,4
+.text
+_test_gc_rel312:
+ nop
+ ldr x3, [x2, #:got_lo12:sym312_notused]
+
diff --git a/ld/testsuite/ld-aarch64/gc-relocs-tlsdesc.s b/ld/testsuite/ld-aarch64/gc-relocs-tlsdesc.s
new file mode 100644
index 0000000..413c513
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/gc-relocs-tlsdesc.s
@@ -0,0 +1,38 @@
+ .global tlsdescvar
+ .section .tbss,"awT",%nobits
+ .align 2
+ .type tlsdescvar, %object
+ .size tlsdescvar, 4
+tlsdescvar:
+ .zero 4
+
+ .align 2
+ .type l_tlsdescvar, %object
+ .size l_tlsdescvar, 4
+l_tlsdescvar:
+ .zero 4
+.text
+_test_tls_desc:
+
+ // R_AARCH64_TLSDESC_ADR_PAGE tlsdescvar
+ adrp x0, :tlsdesc:tlsdescvar
+ // R_AARCH64_TLSDESC_LD64_LO12 tlsdescvar
+ ldr x1, [x0, :tlsdesc_lo12:tlsdescvar]
+ // R_AARCH64_TLSDESC_ADD_LO12 tlsdescvar
+ add x0, x0, :tlsdesc_lo12:tlsdescvar
+ // R_AARCH64_TLSDESC_CALL tlsdescvar
+ .tlsdesccall tlsdescvar
+ blr x1
+
+_test_tls_desc_local:
+
+ // R_AARCH64_TLSDESC_ADR_PAGE l_tlsdescvar
+ adrp x0, :tlsdesc:l_tlsdescvar
+ // R_AARCH64_TLSDESC_LD64_LO12 l_tlsdescvar
+ ldr x1, [x0, :tlsdesc_lo12:l_tlsdescvar]
+ // R_AARCH64_TLSDESC_ADD_LO12 l_tlsdescvar
+ add x0, x0, :tlsdesc_lo12:l_tlsdescvar
+ // R_AARCH64_TLSDESC_CALL l_tlsdescvar
+ .tlsdesccall l_tlsdescvar
+ blr x1
+
diff --git a/ld/testsuite/ld-aarch64/gc-relocs-tlsgd.s b/ld/testsuite/ld-aarch64/gc-relocs-tlsgd.s
new file mode 100644
index 0000000..ac90475
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/gc-relocs-tlsgd.s
@@ -0,0 +1,30 @@
+ .global tlsgdvar
+ .section .tbss,"awT",%nobits
+ .align 2
+ .type tlsgdvar, %object
+ .size tlsgdvar, 4
+tlsgdvar:
+ .zero 4
+ .align 2
+ .type l_tlsgdvar, %object
+ .size l_tlsgdvar, 4
+l_tlsgdvar:
+ .zero 4
+
+.text
+_test_tls_gd:
+ // R_AARCH64_TLSGD_ADR_PAGE21 tldgdvar
+ adrp x0, :tlsgd:tlsgdvar
+ // R_AARCH64_TLSGD_ADD_LO12_NC tlsgdvar
+ add x0, x0, :tlsgd_lo12:tlsgdvar
+ // R_AARCH64_CALL26
+ bl __tls_get_addr
+
+_test_tls_gd_local:
+ // R_AARCH64_TLSGD_ADR_PAGE21 l_tldgdvar
+ adrp x0, :tlsgd:l_tlsgdvar
+ // R_AARCH64_TLSGD_ADD_LO12_NC l_tlsgdvar
+ add x0, x0, :tlsgd_lo12:l_tlsgdvar
+ // R_AARCH64_CALL26
+ bl __tls_get_addr
+
diff --git a/ld/testsuite/ld-aarch64/gc-relocs-tlsie.s b/ld/testsuite/ld-aarch64/gc-relocs-tlsie.s
new file mode 100644
index 0000000..e647b89
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/gc-relocs-tlsie.s
@@ -0,0 +1,29 @@
+ .global tlsievar
+ .section .tbss,"awT",%nobits
+ .align 2
+ .type tlsievar, %object
+ .size tlsievar, 4
+tlsievar:
+ .zero 4
+
+ .align 2
+ .type l_tlsievar, %object
+ .size l_tlsievar, 4
+l_tlsievar:
+ .zero 4
+
+.text
+_test_tls_IE:
+
+ // R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 tlsievar
+ adrp x0, :gottprel:tlsievar
+ // R_AARCH64_TLSIE_GOTTPREL_LO12_NC tlsievar
+ ldr x0, [x0, :gottprel_lo12:tlsievar]
+
+_test_tls_IE_local:
+
+ // R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 l_tlsievar
+ adrp x0, :gottprel:l_tlsievar
+ // R_AARCH64_TLSIE_GOTTPREL_LO12_NC l_tlsievar
+ ldr x0, [x0, :gottprel_lo12:l_tlsievar]
+
diff --git a/ld/testsuite/ld-aarch64/gc-relocs-tlsle.s b/ld/testsuite/ld-aarch64/gc-relocs-tlsle.s
new file mode 100644
index 0000000..cca7ef0
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/gc-relocs-tlsle.s
@@ -0,0 +1,36 @@
+ .global tlslevar
+ .section .tbss,"awT",%nobits
+ .align 2
+ .type tlslevar, %object
+ .size tlslevar, 4
+tlslevar:
+ .zero 4
+
+ .align 2
+ .type l_tlslevar, %object
+ .size l_tlslevar, 4
+l_tlslevar:
+ .zero 4
+
+.text
+l_test_tls_le:
+
+ // R_AARCH64_TLSLE_ADD_TPREL_LO12 tlslevar
+ add x0, x1, :tprel_lo12:tlslevar
+ // R_AARCH64_TLSLE_ADD_TPREL_HI12 tlslevar
+ add x0, x1, :tprel_hi12:tlslevar
+ // R_AARCH64_TLSLE_ADD_TPREL_HI12 tlslevar
+ add x0, x1, :tprel_hi12:tlslevar, lsl #12
+ // R_AARCH64_TLSLE_ADD_TPREL_LO12_NC tlslevar
+ add x0, x1, :tprel_lo12_nc:tlslevar
+
+l_test_tls_le_local:
+
+ // R_AARCH64_TLSLE_ADD_TPREL_LO12 l_tlslevar
+ add x0, x1, :tprel_lo12:l_tlslevar
+ // R_AARCH64_TLSLE_ADD_TPREL_HI12 l_tlslevar
+ add x0, x1, :tprel_hi12:l_tlslevar
+ // R_AARCH64_TLSLE_ADD_TPREL_HI12 l_tlslevar
+ add x0, x1, :tprel_hi12:l_tlslevar, lsl #12
+ // R_AARCH64_TLSLE_ADD_TPREL_LO12_NC l_tlslevar
+ add x0, x1, :tprel_lo12_nc:l_tlslevar
diff --git a/ld/testsuite/ld-aarch64/gc-start.s b/ld/testsuite/ld-aarch64/gc-start.s
new file mode 100644
index 0000000..58d42a6
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/gc-start.s
@@ -0,0 +1,4 @@
+ .global _start
+ .text
+_start:
+ nop
diff --git a/ld/testsuite/ld-aarch64/gc-tls-relocs.d b/ld/testsuite/ld-aarch64/gc-tls-relocs.d
new file mode 100644
index 0000000..50d23e5
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/gc-tls-relocs.d
@@ -0,0 +1,34 @@
+#source: gc-start.s
+#source: gc-relocs-tlsgd.s
+#source: gc-relocs-tlsdesc.s
+#source: gc-relocs-tlsie.s
+#source: gc-relocs-tlsle.s
+#ld: --gc-sections -T aarch64.ld
+#objdump: -s -t -d
+
+# Executable with tls related relocs against global and local symbol gced.
+# After gc-section removal we are cheking that symbols does not exit
+# got section is empty and text section contains only start function.
+
+.*: file format elf64-littleaarch64
+
+SYMBOL TABLE:
+0+8000 l d \.text 0+ \.text
+0+9000 l d \.got 0+ \.got
+0+0000 l df \*ABS\* 0+ .*
+0+0000 l \*UND\* 0+ __tls_get_addr
+0+0000 l df \*ABS\* 0+
+0+9000 l O \.got 0+ _GLOBAL_OFFSET_TABLE_
+0+8000 g \.text 0+ _start
+
+Contents of section .text:
+ 8000 1f2003d5 .*
+Contents of section .got:
+ 9000 0+ 0+ 0+ 0+ .*
+ 9010 0+ 0+ .*
+
+Disassembly of section .text:
+
+0+8000 \<_start>:
+ 8000: d503201f nop
+