diff options
author | Alan Modra <amodra@gmail.com> | 2022-03-31 07:41:03 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-05-04 14:41:56 +0930 |
commit | 7a9361c00d53bb41c9ae331780226a99b9339920 (patch) | |
tree | 54c42f93b44a60e8956f9b628a3af2072b8010bd /ld/testsuite/ld-powerpc | |
parent | 24ef0d41ac9632ff85d3781e5852371e39661558 (diff) | |
download | binutils-7a9361c00d53bb41c9ae331780226a99b9339920.zip binutils-7a9361c00d53bb41c9ae331780226a99b9339920.tar.gz binutils-7a9361c00d53bb41c9ae331780226a99b9339920.tar.bz2 |
PowerPC32 treatment of absolute symbols
As already done for PowerPC64, fix dynamic relocs for absolute symbols.
The patch also tidies the dynamic reloc handling code in check_relocs,
removing leftover comments and code from when check_relocs was called
as each object file was read in.
bfd/
* elf32-ppc.c (ppc_elf_check_relocs): Set isym and ifunc earlier.
Rearrange tests for dynamic relocs, handling absolute symbols.
(allocate_dynrelocs): Don't allocate dynamic relocs for locally
defined absolute symbols.
(ppc_elf_size_dynamic_sections): Similarly.
(ppc_elf_relocate_section): Similarly.
ld/
* testsuite/ld-powerpc/abs32-pie.d,
* testsuite/ld-powerpc/abs32-pie.r,
* testsuite/ld-powerpc/abs32-reloc.s,
* testsuite/ld-powerpc/abs32-shared.d,
* testsuite/ld-powerpc/abs32-shared.r,
* testsuite/ld-powerpc/abs32-static.d,
* testsuite/ld-powerpc/abs32-static.r: New tests.
* testsuite/ld-powerpc/powerpc.exp: Run them.
Diffstat (limited to 'ld/testsuite/ld-powerpc')
-rw-r--r-- | ld/testsuite/ld-powerpc/abs32-pie.d | 26 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/abs32-pie.r | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/abs32-reloc.s | 22 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/abs32-shared.d | 24 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/abs32-shared.r | 13 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/abs32-static.d | 26 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/abs32-static.r | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/powerpc.exp | 12 |
8 files changed, 138 insertions, 0 deletions
diff --git a/ld/testsuite/ld-powerpc/abs32-pie.d b/ld/testsuite/ld-powerpc/abs32-pie.d new file mode 100644 index 0000000..7f99121 --- /dev/null +++ b/ld/testsuite/ld-powerpc/abs32-pie.d @@ -0,0 +1,26 @@ +#source: abs32-reloc.s +#as: -a32 +#ld: -melf32ppc -pie --hash-style=sysv --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x12345678 +#objdump: -dr + +.*: file format .* + +Disassembly of section \.text: + +00000138 <_start>: + 138: (80 fe ff f0|f0 ff fe 80) lwz r7,-16\(r30\) + 13c: (81 1e ff f8|f8 ff 1e 81) lwz r8,-8\(r30\) + 140: (81 3e ff ec|ec ff 3e 81) lwz r9,-20\(r30\) + 144: (81 5e ff f4|f4 ff 5e 81) lwz r10,-12\(r30\) + +Disassembly of section \.got: + +000101d8 <\.got>: + 101d8: (00 00 00 02|02 00 00 00) .* + 101dc: (00 00 00 00|00 00 00 00) .* + 101e0: (12 34 56 78|78 56 34 12) .* + 101e4: (00 00 00 01|01 00 00 00) .* + 101e8: (4e 80 00 21|21 00 80 4e) blrl + +000101ec <_GLOBAL_OFFSET_TABLE_>: + 101ec: (00 01 01 48|48 01 01 00) 00 00 00 00 00 00 00 00 .* diff --git a/ld/testsuite/ld-powerpc/abs32-pie.r b/ld/testsuite/ld-powerpc/abs32-pie.r new file mode 100644 index 0000000..6a45fbf --- /dev/null +++ b/ld/testsuite/ld-powerpc/abs32-pie.r @@ -0,0 +1,9 @@ +#source: abs32-reloc.s +#as: -a32 +#ld: -melf32ppc -pie --hash-style=sysv --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x12345678 +#readelf: -rW + +Relocation section '\.rela\.dyn' at offset .* contains 2 entries: + Offset Info Type Sym\. Value Symbol's Name \+ Addend +000101c8 00000016 R_PPC_RELATIVE 101c8 +000101dc 00000016 R_PPC_RELATIVE 101c8 diff --git a/ld/testsuite/ld-powerpc/abs32-reloc.s b/ld/testsuite/ld-powerpc/abs32-reloc.s new file mode 100644 index 0000000..70776c8 --- /dev/null +++ b/ld/testsuite/ld-powerpc/abs32-reloc.s @@ -0,0 +1,22 @@ + .globl x + .hidden x + + .data + .p2align 2 +x: + .long x + .long a + .long b + .long c + + .text + .p2align 2 + .globl _start + .type _start,@function +_start: +0: + lwz 7,x@got(30) + lwz 8,a@got(30) + lwz 9,b@got(30) + lwz 10,c@got(30) + .size _start,.-_start diff --git a/ld/testsuite/ld-powerpc/abs32-shared.d b/ld/testsuite/ld-powerpc/abs32-shared.d new file mode 100644 index 0000000..a08930b --- /dev/null +++ b/ld/testsuite/ld-powerpc/abs32-shared.d @@ -0,0 +1,24 @@ +#source: abs32-reloc.s +#as: -a32 +#ld: -melf32ppc -shared --hash-style=sysv --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x12345678 +#objdump: -dr + +.*: file format .* + +Disassembly of section \.text: + +00000160 <_start>: + 160: (80 fe ff f0|f0 ff fe 80) lwz r7,-16\(r30\) + 164: (81 1e ff f8|f8 ff 1e 81) lwz r8,-8\(r30\) + 168: (81 3e ff ec|ec ff 3e 81) lwz r9,-20\(r30\) + 16c: (81 5e ff f4|f4 ff 5e 81) lwz r10,-12\(r30\) + +Disassembly of section \.got: + +000101f0 <\.got>: + 101f0: (00 00 00 02|02 00 00 00) .* + .\.\. + 10200: (4e 80 00 21|21 00 80 4e) blrl + +00010204 <_GLOBAL_OFFSET_TABLE_>: + 10204: (00 01 01 70|70 01 01 00) 00 00 00 00 00 00 00 00 .* diff --git a/ld/testsuite/ld-powerpc/abs32-shared.r b/ld/testsuite/ld-powerpc/abs32-shared.r new file mode 100644 index 0000000..d0cd80f --- /dev/null +++ b/ld/testsuite/ld-powerpc/abs32-shared.r @@ -0,0 +1,13 @@ +#source: abs32-reloc.s +#as: -a32 +#ld: -melf32ppc -shared --hash-style=sysv --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x12345678 +#readelf: -rW + +Relocation section '\.rela\.dyn' at offset .* contains 6 entries: + Offset Info Type Sym\. Value Symbol's Name \+ Addend +000101e0 00000016 R_PPC_RELATIVE 101e0 +000101f4 00000016 R_PPC_RELATIVE 101e0 +000101e4 00000401 R_PPC_ADDR32 00000001 a \+ 0 +000101fc 00000414 R_PPC_GLOB_DAT 00000001 a \+ 0 +000101ec 00000301 R_PPC_ADDR32 12345678 c \+ 0 +000101f8 00000314 R_PPC_GLOB_DAT 12345678 c \+ 0 diff --git a/ld/testsuite/ld-powerpc/abs32-static.d b/ld/testsuite/ld-powerpc/abs32-static.d new file mode 100644 index 0000000..f37f104 --- /dev/null +++ b/ld/testsuite/ld-powerpc/abs32-static.d @@ -0,0 +1,26 @@ +#source: abs32-reloc.s +#as: -a32 +#ld: -melf32ppc -static --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x12345678 +#objdump: -dr + +.*: file format .* + +Disassembly of section \.text: + +01800074 <_start>: + 1800074: (80 fe ff f0|f0 ff fe 80) lwz r7,-16\(r30\) + 1800078: (81 1e ff f8|f8 ff 1e 81) lwz r8,-8\(r30\) + 180007c: (81 3e ff ec|ec ff 3e 81) lwz r9,-20\(r30\) + 1800080: (81 5e ff f4|f4 ff 5e 81) lwz r10,-12\(r30\) + +Disassembly of section \.got: + +01810094 <\.got>: + 1810094: (00 00 00 02|02 00 00 00) .* + 1810098: (01 81 00 84|84 00 81 01) .* + 181009c: (12 34 56 78|78 56 34 12) .* + 18100a0: (00 00 00 01|01 00 00 00) .* + 18100a4: (4e 80 00 21|21 00 80 4e) blrl + +018100a8 <_GLOBAL_OFFSET_TABLE_>: + \.\.\. diff --git a/ld/testsuite/ld-powerpc/abs32-static.r b/ld/testsuite/ld-powerpc/abs32-static.r new file mode 100644 index 0000000..3eca877 --- /dev/null +++ b/ld/testsuite/ld-powerpc/abs32-static.r @@ -0,0 +1,6 @@ +#source: abs32-reloc.s +#as: -a32 +#ld: -melf32ppc -static --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x12345678 +#readelf: -rW + +There are no relocations in this file. diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp index 9eff14f..1c7a378 100644 --- a/ld/testsuite/ld-powerpc/powerpc.exp +++ b/ld/testsuite/ld-powerpc/powerpc.exp @@ -173,6 +173,18 @@ set ppcelftests { {{objdump -dr relaxrl.d}} "rrelax"} {"build empty shared library" "-shared" "" "" "empty.s" {} "empty.so"} + {"abs32-static" "-melf32ppc -static --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x12345678" "" + "-a32" {abs32-reloc.s} + {{objdump {-dr} abs32-static.d} + {readelf {-rW} abs32-static.r}} "abs32-static"} + {"abs32-pie" "-melf32ppc -pie --hash-style=sysv --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x12345678" "" + "-a32" {abs32-reloc.s} + {{objdump {-dr} abs32-pie.d} + {readelf {-rW} abs32-pie.r}} "abs32-pie"} + {"abs32-shared" "-melf32ppc -shared --hash-style=sysv --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x12345678" "" + "-a32" {abs32-reloc.s} + {{objdump {-dr} abs32-shared.d} + {readelf {-rW} abs32-shared.r}} "abs32-shared"} } set ppc64elftests { |