This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 0/2] MIPS/LD: Improve error checking for relocations in shared libraries
- From: Faraz Shahbazker <fshahbazker at wavecomp dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Cc: Faraz Shahbazker <fshahbazker at wavecomp dot com>, "paul dot hua dot gm at gmail dot com" <paul dot hua dot gm at gmail dot com>
- Date: Sat, 18 May 2019 08:19:03 +0000
- Subject: [PATCH 0/2] MIPS/LD: Improve error checking for relocations in shared libraries
This patch series improves error checking for unacceptable non-PIC
relocations when linking shared libraries.
Patch 1/2 fixes problems with existing checks. There are 2 possible
sites of memory faults:
1. Applying bfd_is_abs_symbol predicate on a symbol link hash entry
that is NULL, as is the case for statically scoped variables.
2. Trying to dereference a relocation howto pointer for an unsupported
relocation when printing the error message.
Further, the search for relocations should be performed on RELA table
for n64 (%higher and %highest) relocations because these are declared
empty in the REL table for the n64 MIPS backend. The new tests cover
all of the above issues.
Patch 2/2 extends the checks to tprel_hi and tprel_lo relocations.
These relocations represent the Local Exec TLS mode that may be valid
for PIEs but not for shared libraries, regardless of STATIC_TLS.
Notably, GCC will generate such relocations for statically scoped
TLS variables in n64 mode without an explicit -fpic option and linking
them without error creates a shared library which will fail at run-time.
Faraz Shahbazker (2):
MIPS/LD: Fix memory fault linking non-PIC object in to shared library
MIPS/LD: Reject tprel_hi and tprel_lo relocations in shared library
bfd/elfxx-mips.c | 31 +++++++++++++++++++++++--------
ld/testsuite/ld-mips-elf/mips-elf.exp | 7 +++++++
ld/testsuite/ld-mips-elf/pic-reloc-5.d | 10 ++++++++++
ld/testsuite/ld-mips-elf/pic-reloc-5.s | 22 ++++++++++++++++++++++
ld/testsuite/ld-mips-elf/pic-reloc-6.d | 11 +++++++++++
ld/testsuite/ld-mips-elf/pic-reloc-6.s | 22 ++++++++++++++++++++++
ld/testsuite/ld-mips-elf/pic-reloc-7.d | 8 ++++++++
ld/testsuite/ld-mips-elf/pic-reloc-7.s | 10 ++++++++++
ld/testsuite/ld-mips-elf/pic-reloc-tls.ld | 7 +++++++
9 files changed, 120 insertions(+), 8 deletions(-)
create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-5.d
create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-5.s
create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-6.d
create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-6.s
create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-7.d
create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-7.s
create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-tls.ld
--
2.9.5