From: Fangrui Song <maskray@google.com>
To: libc-alpha@sourceware.org,
Adhemerval Zanella <adhemerval.zanella@linaro.org>,
Szabolcs Nagy <szabolcs.nagy@arm.com>
Subject: [PATCH 2/3] Revert "[AArch64][BZ #17711] Fix extern protected data handling"
Date: Sat, 30 Apr 2022 23:06:14 -0700 [thread overview]
Message-ID: <20220501060615.1694317-3-maskray@google.com> (raw)
In-Reply-To: <20220501060615.1694317-1-maskray@google.com>
This reverts commit 0910702c4d2cf9e8302b35c9519548726e1ac489.
Say both a.so and b.so define protected var and the executable copy
relocates var. ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA has strange
semantics: a.so accesses the copy in the executable while b.so accesses
its own. This behavior requires that (a) the compiler emits
GOT-generating relocations (b) the linker produces GLOB_DAT instead of
RELATIVE.
Without the ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA code, b.so's GLOB_DAT
will bind to the executable (normal behavior).
For aarch64 it makes sense to restore the original behavior and don't
pay the ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA cost. The behavior is very
unlikely used by anyone.
* Clang code generation treats STV_PROTECTED the same way as STV_HIDDEN:
no GOT-generating relocation in the first place.
* gold and lld reject copy relocation on a STV_PROTECTED symbol.
* Nowadays -fpie/-fpic modes are popular. GCC/Clang's codegen uses
GOT-generating relocation when accessing an default visibility
external symbol which avoids copy relocation.
---
sysdeps/aarch64/dl-machine.h | 13 ++++++-------
sysdeps/aarch64/dl-sysdep.h | 2 --
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index b40050a981..530952a736 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -182,13 +182,12 @@ _dl_start_user: \n\
");
#define elf_machine_type_class(type) \
- ((((type) == AARCH64_R(JUMP_SLOT) \
- || (type) == AARCH64_R(TLS_DTPMOD) \
- || (type) == AARCH64_R(TLS_DTPREL) \
- || (type) == AARCH64_R(TLS_TPREL) \
- || (type) == AARCH64_R(TLSDESC)) * ELF_RTYPE_CLASS_PLT) \
- | (((type) == AARCH64_R(COPY)) * ELF_RTYPE_CLASS_COPY) \
- | (((type) == AARCH64_R(GLOB_DAT)) * ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA))
+ ((((type) == R_AARCH64_JUMP_SLOT || \
+ (type) == R_AARCH64_TLS_DTPMOD || \
+ (type) == R_AARCH64_TLS_DTPREL || \
+ (type) == R_AARCH64_TLS_TPREL || \
+ (type) == R_AARCH64_TLSDESC) * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_AARCH64_COPY) * ELF_RTYPE_CLASS_COPY))
#define ELF_MACHINE_JMP_SLOT AARCH64_R(JUMP_SLOT)
diff --git a/sysdeps/aarch64/dl-sysdep.h b/sysdeps/aarch64/dl-sysdep.h
index 667786671c..ac69f414f3 100644
--- a/sysdeps/aarch64/dl-sysdep.h
+++ b/sysdeps/aarch64/dl-sysdep.h
@@ -21,5 +21,3 @@
/* _dl_argv cannot be attribute_relro, because _dl_start_user
might write into it after _dl_start returns. */
#define DL_ARGV_NOT_RELRO 1
-
-#define DL_EXTERN_PROTECTED_DATA
--
2.36.0.464.gb9c8b46e94-goog
next prev parent reply other threads:[~2022-05-01 6:07 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-01 6:06 [PATCH 0/3] Simplify ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA and revert aarch64/arm's extern protected data handling Fangrui Song
2022-05-01 6:06 ` [PATCH 1/3] elf: Remove ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA check for non-DL_EXTERN_PROTECTED_DATA ports Fangrui Song
2022-05-01 6:06 ` Fangrui Song [this message]
2022-05-23 20:10 ` [PATCH 2/3] Revert "[AArch64][BZ #17711] Fix extern protected data handling" Szabolcs Nagy
2022-05-23 20:17 ` Fangrui Song
2022-05-24 5:13 ` Fangrui Song
2022-05-01 6:06 ` [PATCH 3/3] Revert "[ARM][BZ " Fangrui Song
2022-05-23 20:11 ` Szabolcs Nagy
2022-05-23 20:45 ` Fangrui Song
2022-05-09 21:26 ` [PATCH 0/3] Simplify ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA and revert aarch64/arm's extern protected data handling H.J. Lu
2022-05-10 7:42 ` Fangrui Song
2022-05-10 15:02 ` H.J. Lu
2022-05-12 4:56 ` Fangrui Song
2022-05-13 22:18 ` H.J. Lu
2022-05-13 23:09 ` Fangrui Song
2022-05-24 13:46 [PATCH 2/3] Revert "[AArch64][BZ #17711] Fix extern protected data handling" Wilco Dijkstra
2022-05-24 17:28 ` maskray
2022-05-24 21:58 ` H.J. Lu
2022-05-25 17:13 ` Wilco Dijkstra
2022-05-25 18:21 ` Florian Weimer
2022-05-25 20:44 ` H.J. Lu
2022-05-26 19:17 ` Wilco Dijkstra
2022-05-26 19:25 ` Florian Weimer
2022-05-26 20:03 ` Wilco Dijkstra
2022-05-26 21:27 ` H.J. Lu
2022-05-27 12:43 ` Florian Weimer
2022-05-31 2:03 ` H.J. Lu
2022-05-31 7:49 ` Fangrui Song
2022-05-31 9:42 ` Wilco Dijkstra
2022-05-31 13:47 ` H.J. Lu
2022-05-31 7:42 ` Fangrui Song
2022-05-25 20:10 ` maskray
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=20220501060615.1694317-3-maskray@google.com \
--to=maskray@google.com \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@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).