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 /bfd/elfxx-mips.c | |
parent | ba6cd17f0a28e54d9b4ef46397d448f1d208d9a0 (diff) | |
download | fsf-binutils-gdb-304f09d0d4b519f143144d213e1280a0691de8ba.zip fsf-binutils-gdb-304f09d0d4b519f143144d213e1280a0691de8ba.tar.gz fsf-binutils-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 'bfd/elfxx-mips.c')
-rw-r--r-- | bfd/elfxx-mips.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 8c1ad72..28e95bc 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -9115,7 +9115,7 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, break; /* Likewise an absolute symbol. */ - if (bfd_is_abs_symbol (&h->root)) + if (h != NULL && bfd_is_abs_symbol (&h->root)) break; /* R_MIPS_HI16 against _gp_disp is used for $gp setup, @@ -9133,13 +9133,16 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_MIPS16_26: case R_MIPS_26: case R_MICROMIPS_26_S1: - howto = MIPS_ELF_RTYPE_TO_HOWTO (abfd, r_type, FALSE); - info->callbacks->einfo - /* xgettext:c-format */ - (_("%X%H: relocation %s against `%s' cannot be used" - " when making a shared object; recompile with -fPIC\n"), - abfd, sec, rel->r_offset, howto->name, - (h) ? h->root.root.string : "a local symbol"); + howto = MIPS_ELF_RTYPE_TO_HOWTO (abfd, r_type, NEWABI_P (abfd)); + /* An error for unsupported relocations is raised as part + of the above search, so we can skip the following. */ + if (howto != NULL) + info->callbacks->einfo + /* xgettext:c-format */ + (_("%X%H: relocation %s against `%s' cannot be used" + " when making a shared object; recompile with -fPIC\n"), + abfd, sec, rel->r_offset, howto->name, + (h) ? h->root.root.string : "a local symbol"); break; default: break; |