public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <maskray@google.com>
To: binutils@sourceware.org, Szabolcs Nagy <szabolcs.nagy@arm.com>
Cc: Fangrui Song <maskray@google.com>
Subject: [PATCH] aarch64: Define elf_backend_extern_protected_data to 0 [PR 18705]
Date: Wed,  1 Jun 2022 21:20:59 -0700	[thread overview]
Message-ID: <20220602042059.2898835-1-maskray@google.com> (raw)

If an executable has copy relocations for extern protected data, that
can only work if the library containing the definition is built with
assumptions (a) the compiler emits GOT-generating relocations (b) the
linker produces R_*_GLOB_DAT instead of R_*_RELATIVE.  Otherwise the
library uses its own definition directly and the executable accesses a
stale copy.

Commit 32f573bcb3aaa1c9defcad79dbb5851fcc02ae2d changed ld to produce
R_AARCH64_GLOB_DAT but that defeated the purpose of protected visibility
as an optimization.  Restore the previous behavior (which matches
ld.lld) by defining elf_backend_extern_protected_data to 0.
---
 bfd/elfnn-aarch64.c                      | 2 +-
 ld/testsuite/ld-aarch64/protected-data.d | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 4926bab9cf2..cb316a928ef 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -10090,7 +10090,7 @@ const struct elf_size_info elfNN_aarch64_size_info =
 #define elf_backend_dtrel_excludes_plt 1
 #define elf_backend_got_header_size (GOT_ENTRY_SIZE * 3)
 #define elf_backend_default_execstack  0
-#define elf_backend_extern_protected_data 1
+#define elf_backend_extern_protected_data 0
 #define elf_backend_hash_symbol elf_aarch64_hash_symbol
 
 #undef	elf_backend_obj_attrs_section
diff --git a/ld/testsuite/ld-aarch64/protected-data.d b/ld/testsuite/ld-aarch64/protected-data.d
index 5dabf04748c..ee9b4cfc6b5 100644
--- a/ld/testsuite/ld-aarch64/protected-data.d
+++ b/ld/testsuite/ld-aarch64/protected-data.d
@@ -2,4 +2,4 @@
 #ld: -shared
 #readelf: -r -W
 #...
-.* R_AARCH64_GLOB_DAT .* var.*
+.* R_AARCH64_RELATIVE .*
-- 
2.36.1.255.ge46751e96f-goog


             reply	other threads:[~2022-06-02  4:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02  4:20 Fangrui Song [this message]
2022-06-22 17:58 ` Fangrui Song
2022-06-23  7:58 ` Szabolcs Nagy

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=20220602042059.2898835-1-maskray@google.com \
    --to=maskray@google.com \
    --cc=binutils@sourceware.org \
    --cc=szabolcs.nagy@arm.com \
    /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).