elf64_aarch64_locals to get local GOT reference counts.
* ld-aarch64/gc-relocs-tlsle.s: New gc section test.
* ld-aarch64/gc-relocs-tlsle.s: Likewise
* ld-aarch64/gc-relocs-tlsgd.s: Likewise
* ld-aarch64/gc-relocs-tlsdesc.s: Likewise
* ld-aarch64/gc-relocs-312.s: Likewise
* ld-aarch64/gc-relocs-311.s: Likewise
* ld-aarch64/gc-relocs-309.s: Likewise
* ld-aarch64/gc-start.s: Likewise
* ld-aarch64/gc-got-relocs.d: Update expected objdump
* ld-aarch64/gc-tls-relocs.d: Likewise
* ld-aarch64/aarch64-elf.exp: add test
+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.
/* 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)
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++)
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;
# 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.
#
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"
--- /dev/null
+#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
+
--- /dev/null
+#R_AARCH64_GOT_LD_PREL19
+ .comm sym309_notused,1,8
+.text
+_test_gc_rel309:
+ nop
+ ldr x1, :got_prel19:sym309_notused
+
--- /dev/null
+#R_AARCH64_ADR_GOT_PAGE
+.comm gempy,4,4
+.text
+_test_gc_rel311:
+ adrp x3,:got:gempy
--- /dev/null
+#R_AARCH64_GOT_LD_PREL19
+ .comm sym312_notused,4
+.text
+_test_gc_rel312:
+ nop
+ ldr x3, [x2, #:got_lo12:sym312_notused]
+
--- /dev/null
+ .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
+
--- /dev/null
+ .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
+
--- /dev/null
+ .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]
+
--- /dev/null
+ .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
--- /dev/null
+ .global _start
+ .text
+_start:
+ nop
--- /dev/null
+#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
+