diff options
author | Faraz Shahbazker <fshahbazker@wavecomp.com> | 2019-05-18 01:19:03 -0700 |
---|---|---|
committer | Faraz Shahbazker <fshahbazker@wavecomp.com> | 2019-05-21 11:55:08 -0700 |
commit | 304f09d0d4b519f143144d213e1280a0691de8ba (patch) | |
tree | d5baa5160d5ed5001a91c77672f14a95ce5abde3 /ld | |
parent | ba6cd17f0a28e54d9b4ef46397d448f1d208d9a0 (diff) | |
download | gdb-304f09d0d4b519f143144d213e1280a0691de8ba.zip gdb-304f09d0d4b519f143144d213e1280a0691de8ba.tar.gz gdb-304f09d0d4b519f143144d213e1280a0691de8ba.tar.bz2 |
MIPS/LD: Fix memory fault linking non-PIC object in to shared library
bfd/
* elfxx-mips.c (_bfd_mips_elf_check_relocs): Add NULL pointer
checks. Search the RELA table for n64 relocations.
ld/
* 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.
* testsuite/ld-mips-elf/pic-reloc-5.s: New test source.
* testsuite/ld-mips-elf/pic-reloc-6.s: New test source.
* testsuite/ld-mips-elf/pic-reloc-7.s: New test source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/mips-elf.exp | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pic-reloc-5.d | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pic-reloc-5.s | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pic-reloc-6.d | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pic-reloc-6.s | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pic-reloc-7.d | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pic-reloc-7.s | 10 |
8 files changed, 68 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 6896a72..beba62e 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,13 @@ +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. + * testsuite/ld-mips-elf/pic-reloc-5.s: New test source. + * testsuite/ld-mips-elf/pic-reloc-6.s: New test source. + * testsuite/ld-mips-elf/pic-reloc-7.s: New test source. + * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests. + 2019-05-21 Matthew Fortune <matthew.fortune@mips.com> Faraz Shahbazker <fshahbazker@wavecomp.com> diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index cbbd9ad..07d1dc3 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -1649,3 +1649,10 @@ run_dump_test "pic-reloc-1" run_dump_test "pic-reloc-2" run_dump_test "pic-reloc-3" run_dump_test "pic-reloc-4" +run_dump_test_o32 "pic-reloc-5" +run_dump_test_o32 "pic-reloc-5" [list [list name (microMIPS)] \ + [list as "-mmicromips"]] +run_dump_test_o32 "pic-reloc-6" +run_dump_test_n64 "pic-reloc-7" +run_dump_test_n64 "pic-reloc-7" [list [list name (microMIPS)] \ + [list as "-mmicromips"]] diff --git a/ld/testsuite/ld-mips-elf/pic-reloc-5.d b/ld/testsuite/ld-mips-elf/pic-reloc-5.d new file mode 100644 index 0000000..1b9d07e --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pic-reloc-5.d @@ -0,0 +1,6 @@ +#name: MIPS PIC relocation 5 +#ld: -shared -T pic-reloc-ordinary.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 diff --git a/ld/testsuite/ld-mips-elf/pic-reloc-5.s b/ld/testsuite/ld-mips-elf/pic-reloc-5.s new file mode 100644 index 0000000..b8ebd8c --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pic-reloc-5.s @@ -0,0 +1,10 @@ + .text + .globl foo + .ent foo +foo: +$LCL: + lui $2, %hi($LCL) + addiu $2, %lo($LCL) + lui $2, %hi(bar) + addiu $2, %lo(bar) + .end foo diff --git a/ld/testsuite/ld-mips-elf/pic-reloc-6.d b/ld/testsuite/ld-mips-elf/pic-reloc-6.d new file mode 100644 index 0000000..68be687 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pic-reloc-6.d @@ -0,0 +1,7 @@ +#name: MIPS PIC relocation 6 (MIPS16) +#ld: -shared -T pic-reloc-ordinary.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 diff --git a/ld/testsuite/ld-mips-elf/pic-reloc-6.s b/ld/testsuite/ld-mips-elf/pic-reloc-6.s new file mode 100644 index 0000000..777ea26 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pic-reloc-6.s @@ -0,0 +1,10 @@ + .text + .globl foo + .ent foo +foo: +$LCL: + li $2, %hi($LCL) + addiu $2, %lo($LCL) + li $2, %hi(bar) + addiu $2, %lo(bar) + .end foo diff --git a/ld/testsuite/ld-mips-elf/pic-reloc-7.d b/ld/testsuite/ld-mips-elf/pic-reloc-7.d new file mode 100644 index 0000000..e5dfa58 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pic-reloc-7.d @@ -0,0 +1,8 @@ +#name: MIPS PIC relocation 7 +#ld: -shared -T pic-reloc-ordinary.ld +#target: [check_shared_lib_support] +#error: \A[^\n]*: in function `foo':\n +#error: \(\.text\+0x0\): relocation R_(MICRO|)MIPS_HIGHEST against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n +#error: \(\.text\+0x4\): relocation R_(MICRO|)MIPS_HIGHER against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n +#error: \(\.text\+0x8\): relocation R_(MICRO|)MIPS_HIGHEST against `bar' cannot be used when making a shared object; recompile with -fPIC\n +#error: \(\.text\+0xc\): relocation R_(MICRO|)MIPS_HIGHER against `bar' cannot be used when making a shared object; recompile with -fPIC\Z diff --git a/ld/testsuite/ld-mips-elf/pic-reloc-7.s b/ld/testsuite/ld-mips-elf/pic-reloc-7.s new file mode 100644 index 0000000..3ad55f0 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pic-reloc-7.s @@ -0,0 +1,10 @@ + .text + .globl foo + .ent foo +foo: +$LCL: + lui $2, %highest($LCL) + addiu $2, %higher($LCL) + lui $2, %highest(bar) + addiu $2, %higher(bar) + .end foo |