2_22-branch'.
Cherrypick from master 2011-09-30 05:11:04 UTC Alan Modra <amodra@gmail.com> ' PR ld/13235':
ld/testsuite/ld-elf/pr13195.c
ld/testsuite/ld-elf/pr13195.d
ld/testsuite/ld-elf/pr13195.s
ld/testsuite/ld-elf/pr13195.t
ld/testsuite/ld-powerpc/tocopt5.d
ld/testsuite/ld-powerpc/tocopt5.s
--- /dev/null
+int
+main ()
+{
+ return 0;
+}
--- /dev/null
+#ld: --gc-sections -shared -version-script pr13195.t
+#readelf: -s --wide -D
+#target: *-*-linux* *-*-gnu*
+#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-*
+#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+# generic linker targets don't support --gc-sections, nor do a bunch of others
+
+#...
+ +[0-9]+ +[0-9]+: +[0-9a-f]+ +[0-9]+ +FUNC +GLOBAL +DEFAULT +[1-9]+ foo
+#pass
--- /dev/null
+ .section .text.new_foo,"ax",%progbits
+ .globl new_foo
+ .type new_foo, %function
+new_foo:
+ .byte 0
+ .symver new_foo,foo@@VERS_2.0
--- /dev/null
+VERS_2.0 {
+global:
+ foo;
+local:
+ *;
+};
--- /dev/null
+
+.*: file format .*
+
+Contents of section \.text:
+ 100000b0 60000000 e9228018 60000000 38a28020 .*
+ 100000c0 e8c50000 60000000 3922802b 60000000 .*
+ 100000d0 38a28008 e8c50000 .*
+Contents of section \.got:
+ 100100d8 00000000 100180d8 00000000 10010104 .*
+ 100100e8 00000000 10010105 00000000 10010100 .*
+ 100100f8 00000000 10010101 .*
+Contents of section \.sdata:
+ 10010100 01020304 0506 .*
--- /dev/null
+ .section .toc,"aw"
+x4t:
+ .quad x4
+x5t:
+ .quad x5
+x6t:
+ .quad x6
+
+ .section .sdata,"aw"
+x1:
+ .byte 1
+x2:
+ .byte 2
+x3:
+ .byte 3
+x4:
+ .byte 4
+x5:
+ .byte 5
+x6:
+ .byte 6
+
+ .globl _start
+ .text
+_start:
+# no need for got entry, optimise to nop,addi
+# note: ld doesn't yet do got optimisation, so we get nop,ld
+ addis 9,2,x1@got@ha
+ ld 9,x1@got@l(9)
+# must keep got entry, optimise to nop,addi,ld
+ addis 4,2,x2@got@ha
+ addi 5,4,x2@got@l
+ ld 6,0(5)
+
+# no need for toc entry, optimise to nop,addi
+ addis 9,2,x4t@toc@ha
+ ld 9,x4t@toc@l(9)
+# must keep toc entry, optimise to nop,addi,ld
+# if we had a reloc tying the ld to x5/x5t then we could throw away
+# the toc entry and optimise to nop,nop,addi
+ addis 4,2,x5t@toc@ha
+ addi 5,4,x5t@toc@l
+ ld 6,0(5)