public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: binutils@sourceware.org
Subject: [PATCH v2 0/2] Improve -z mark-plt
Date: Sat,  6 Jan 2024 14:09:59 -0800	[thread overview]
Message-ID: <20240106221001.1754844-1-hjl.tools@gmail.com> (raw)

Changes in v2:

1. Fix typos.  It should be --enable-mark-plt, not --enable-make-plt.
2. Remove tests changes for -z mark-plt.

Add --enable-mark-plt linker configure option to mark PLT entries with
DT_X86_64_PLT, DT_X86_64_PLTSZ and DT_X86_64_PLTENT dynamic tags by
default.

When -z mark-plt is used to add DT_X86_64_PLT, DT_X86_64_PLTSZ and
DT_X86_64_PLTENT, the r_addend field of the R_X86_64_JUMP_SLOT relocation
stores the offset of the indirect branch instruction.  However, glibc
versions which don't have this commit in glibc 2.36:

commit f8587a61892cbafd98ce599131bf4f103466f084
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri May 20 19:21:48 2022 -0700

    x86-64: Ignore r_addend for R_X86_64_GLOB_DAT/R_X86_64_JUMP_SLOT

    According to x86-64 psABI, r_addend should be ignored for R_X86_64_GLOB_DAT
    and R_X86_64_JUMP_SLOT.  Since linkers always set their r_addends to 0, we
    can ignore their r_addends.

    Reviewed-by: Fangrui Song <maskray@google.com>

won't ignore the r_addend value in the R_X86_64_JUMP_SLOT relocation.
Although this commit has been backported to glibc 2.33/2.34/2.35 release
branches, it is safer to require glibc 2.36 for such binaries.

Extend the glibc version dependency of GLIBC_ABI_DT_RELR for DT_RELR to
also add GLIBC_2.36 version dependency for -z mark-plt on the the shared C
library if it provides a GLIBC_2.XX symbol version.


H.J. Lu (2):
  elf: Add elf_backend_add_glibc_version_dependency
  ld: Add --enable-mark-plt configure option

 bfd/elf-bfd.h                         |  23 ++++
 bfd/elf64-x86-64.c                    |  27 +++++
 bfd/elflink.c                         | 146 +++++++++++++++-----------
 bfd/elfxx-target.h                    |   5 +
 ld/NEWS                               |   5 +
 ld/config.in                          |   4 +
 ld/configure                          |  26 ++++-
 ld/configure.ac                       |  17 +++
 ld/emulparams/x86-64-plt.sh           |   7 +-
 ld/emultempl/elf-x86.em               |  17 +++
 ld/testsuite/ld-x86-64/mark-plt-1a.rd |   7 ++
 ld/testsuite/ld-x86-64/mark-plt-1b.rd |   7 ++
 ld/testsuite/ld-x86-64/x86-64.exp     |  14 +++
 13 files changed, 240 insertions(+), 65 deletions(-)
 create mode 100644 ld/testsuite/ld-x86-64/mark-plt-1a.rd
 create mode 100644 ld/testsuite/ld-x86-64/mark-plt-1b.rd

-- 
2.43.0


             reply	other threads:[~2024-01-06 22:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-06 22:09 H.J. Lu [this message]
2024-01-06 22:10 ` [PATCH v2 1/2] elf: Add elf_backend_add_glibc_version_dependency H.J. Lu
2024-01-08 15:22   ` H.J. Lu
2024-01-09 13:45     ` H.J. Lu
2024-01-06 22:10 ` [PATCH v2 2/2] ld: Add --enable-mark-plt configure option H.J. Lu
2024-01-08 15:24   ` H.J. Lu
2024-01-09 13:46     ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240106221001.1754844-1-hjl.tools@gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).