diff options
author | Faraz Shahbazker <fshahbazker@wavecomp.com> | 2019-05-18 01:19:04 -0700 |
---|---|---|
committer | Faraz Shahbazker <fshahbazker@wavecomp.com> | 2019-05-21 11:55:08 -0700 |
commit | b474a2022dc14fea0dd8ea4cc66b813486132075 (patch) | |
tree | 0fe5db1c7c9c7dbe2899109aec52a5f63d624539 /ld | |
parent | 304f09d0d4b519f143144d213e1280a0691de8ba (diff) | |
download | gdb-b474a2022dc14fea0dd8ea4cc66b813486132075.zip gdb-b474a2022dc14fea0dd8ea4cc66b813486132075.tar.gz gdb-b474a2022dc14fea0dd8ea4cc66b813486132075.tar.bz2 |
MIPS/LD: Reject tprel_hi and tprel_lo relocations in shared library
bfd/
* elfxx-mips.c (_bfd_mips_elf_check_relocs): Generate error
for TLS_TPREL_HI16(/LO16) relocations in shared library.
ld/
* testsuite/ld-mips-elf/pic-reloc-5.s: Add tests for
%tprel_hi and %tprel_lo relocations.
* testsuite/ld-mips-elf/pic-reloc-6.s: Likewise.
* testsuite/ld-mips-elf/pic-reloc-5.d: Update accordingly.
* testsuite/ld-mips-elf/pic-reloc-6.d: Likewise.
* testsuite/ld-mips-elf/pic-reloc-tls.ld: New test linker
script file.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pic-reloc-5.d | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pic-reloc-5.s | 12 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pic-reloc-6.d | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pic-reloc-6.s | 12 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pic-reloc-tls.ld | 7 |
6 files changed, 53 insertions, 4 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index beba62e..eb0dd9b 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,15 @@ 2019-05-21 Faraz Shahbazker <fshahbazker@wavecomp.com> + * testsuite/ld-mips-elf/pic-reloc-5.s: Add tests for + %tprel_hi and %tprel_lo relocations. + * testsuite/ld-mips-elf/pic-reloc-6.s: Likewise. + * testsuite/ld-mips-elf/pic-reloc-5.d: Update accordingly. + * testsuite/ld-mips-elf/pic-reloc-6.d: Likewise. + * testsuite/ld-mips-elf/pic-reloc-tls.ld: New test linker + script file. + +2019-05-21 Faraz Shahbazker <fshahbazker@wavecomp.com> + * testsuite/ld-mips-elf/pic-reloc-5.d: New test. * testsuite/ld-mips-elf/pic-reloc-6.d: New test. * testsuite/ld-mips-elf/pic-reloc-7.d: New test. diff --git a/ld/testsuite/ld-mips-elf/pic-reloc-5.d b/ld/testsuite/ld-mips-elf/pic-reloc-5.d index 1b9d07e..ecedb6e 100644 --- a/ld/testsuite/ld-mips-elf/pic-reloc-5.d +++ b/ld/testsuite/ld-mips-elf/pic-reloc-5.d @@ -1,6 +1,10 @@ #name: MIPS PIC relocation 5 -#ld: -shared -T pic-reloc-ordinary.ld +#ld: -shared -T pic-reloc-tls.ld #target: [check_shared_lib_support] #error: \A[^\n]*: in function `foo':\n #error: \(\.text\+0x0\): relocation R_(MICRO|)MIPS_HI16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n -#error: \(\.text\+0x8\): relocation R_(MICRO|)MIPS_HI16 against `bar' cannot be used when making a shared object; recompile with -fPIC\Z +#error: \(\.text\+0x8\): relocation R_(MICRO|)MIPS_HI16 against `bar' cannot be used when making a shared object; recompile with -fPIC\n +#error: \(\.text\+0x10\): relocation R_(MICRO|)MIPS_TLS_TPREL_HI16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n +#error: \(\.text\+0x14\): relocation R_(MICRO|)MIPS_TLS_TPREL_LO16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n +#error: \(\.text\+0x18\): relocation R_(MICRO|)MIPS_TLS_TPREL_HI16 against `global_tls' cannot be used when making a shared object; recompile with -fPIC\n +#error: \(\.text\+0x1c\): relocation R_(MICRO|)MIPS_TLS_TPREL_LO16 against `global_tls' cannot be used when making a shared object; recompile with -fPIC\Z diff --git a/ld/testsuite/ld-mips-elf/pic-reloc-5.s b/ld/testsuite/ld-mips-elf/pic-reloc-5.s index b8ebd8c..456d834 100644 --- a/ld/testsuite/ld-mips-elf/pic-reloc-5.s +++ b/ld/testsuite/ld-mips-elf/pic-reloc-5.s @@ -1,5 +1,6 @@ .text .globl foo + .globl global_tls .ent foo foo: $LCL: @@ -7,4 +8,15 @@ $LCL: addiu $2, %lo($LCL) lui $2, %hi(bar) addiu $2, %lo(bar) + lui $a0,%tprel_hi(local_tls) + addiu $a0,$a0,%tprel_lo(local_tls) + lui $a0,%tprel_hi(global_tls) + addiu $a0,$a0,%tprel_lo(global_tls) .end foo + .type local_tls,%object + .type global_tls,%object + .section .tbss,"awT",@nobits +local_tls: + .word +global_tls: + .word diff --git a/ld/testsuite/ld-mips-elf/pic-reloc-6.d b/ld/testsuite/ld-mips-elf/pic-reloc-6.d index 68be687..8a8b550 100644 --- a/ld/testsuite/ld-mips-elf/pic-reloc-6.d +++ b/ld/testsuite/ld-mips-elf/pic-reloc-6.d @@ -1,7 +1,11 @@ #name: MIPS PIC relocation 6 (MIPS16) -#ld: -shared -T pic-reloc-ordinary.ld +#ld: -shared -T pic-reloc-tls.ld #target: [check_shared_lib_support] #as: -mips16 #error: \A[^\n]*: in function `foo':\n #error: \(\.text\+0x0\): relocation R_MIPS16_HI16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n -#error: \(\.text\+0x8\): relocation R_MIPS16_HI16 against `bar' cannot be used when making a shared object; recompile with -fPIC\Z +#error: \(\.text\+0x8\): relocation R_MIPS16_HI16 against `bar' cannot be used when making a shared object; recompile with -fPIC\n +#error: \(\.text\+0x10\): relocation R_MIPS16_TLS_TPREL_HI16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n +#error: \(\.text\+0x14\): relocation R_MIPS16_TLS_TPREL_LO16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n +#error: \(\.text\+0x18\): relocation R_MIPS16_TLS_TPREL_HI16 against `global_tls' cannot be used when making a shared object; recompile with -fPIC\n +#error: \(\.text\+0x1c\): relocation R_MIPS16_TLS_TPREL_LO16 against `global_tls' cannot be used when making a shared object; recompile with -fPIC\Z diff --git a/ld/testsuite/ld-mips-elf/pic-reloc-6.s b/ld/testsuite/ld-mips-elf/pic-reloc-6.s index 777ea26..5cf5e81 100644 --- a/ld/testsuite/ld-mips-elf/pic-reloc-6.s +++ b/ld/testsuite/ld-mips-elf/pic-reloc-6.s @@ -1,5 +1,6 @@ .text .globl foo + .globl global_tls .ent foo foo: $LCL: @@ -7,4 +8,15 @@ $LCL: addiu $2, %lo($LCL) li $2, %hi(bar) addiu $2, %lo(bar) + li $a0,%tprel_hi(local_tls) + lw $a1,%tprel_lo(local_tls)($a0) + li $a0,%tprel_hi(global_tls) + lw $a1,%tprel_lo(global_tls)($a0) .end foo + .type local_tls,%object + .type global_tls,%object + .section .tbss,"awT",@nobits +local_tls: + .word +global_tls: + .word diff --git a/ld/testsuite/ld-mips-elf/pic-reloc-tls.ld b/ld/testsuite/ld-mips-elf/pic-reloc-tls.ld new file mode 100644 index 0000000..85af30c --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pic-reloc-tls.ld @@ -0,0 +1,7 @@ +SECTIONS +{ + bar = foo; + .text : { *(.text) } + .tbss : { *(.tbss) } + /DISCARD/ : { *(*) } +} |