public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] MIPS/LD: Improve error checking for relocations in shared libraries
@ 2019-05-18  8:19 Faraz Shahbazker
  2019-05-18  8:19 ` [PATCH 2/2] MIPS/LD: Reject tprel_hi and tprel_lo relocations in shared library Faraz Shahbazker
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Faraz Shahbazker @ 2019-05-18  8:19 UTC (permalink / raw)
  To: binutils; +Cc: Faraz Shahbazker, paul.hua.gm

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-21 15:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-18  8:19 [PATCH 0/2] MIPS/LD: Improve error checking for relocations in shared libraries Faraz Shahbazker
2019-05-18  8:19 ` [PATCH 2/2] MIPS/LD: Reject tprel_hi and tprel_lo relocations in shared library Faraz Shahbazker
2019-05-18  8:19 ` [PATCH 1/2] MIPS/LD: Fix memory fault linking non-PIC object in to " Faraz Shahbazker
2019-05-21 15:33 ` [PATCH 0/2] MIPS/LD: Improve error checking for relocations in shared libraries Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).