* [PATCH] arm: Define elf_backend_extern_protected_data to 0
@ 2022-06-02 4:27 Fangrui Song
2022-06-23 3:38 ` Fangrui Song
2022-06-23 8:21 ` Szabolcs Nagy
0 siblings, 2 replies; 3+ messages in thread
From: Fangrui Song @ 2022-06-02 4:27 UTC (permalink / raw)
To: binutils, Szabolcs Nagy
From: Fangrui Song <i@maskray.me>
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 b68a20d6675f1360ea4db50a9835c073675b9889 changed ld to produce
R_ARM_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/elf32-arm.c | 2 +-
ld/testsuite/ld-arm/protected-data.d | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 5b8f5e5a0e6..36f09cb3427 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -20315,7 +20315,7 @@ elf32_arm_backend_symbol_processing (bfd *abfd, asymbol *sym)
#define elf_backend_dtrel_excludes_plt 1
#define elf_backend_got_header_size 12
-#define elf_backend_extern_protected_data 1
+#define elf_backend_extern_protected_data 0
#undef elf_backend_obj_attrs_vendor
#define elf_backend_obj_attrs_vendor "aeabi"
diff --git a/ld/testsuite/ld-arm/protected-data.d b/ld/testsuite/ld-arm/protected-data.d
index 3f266dea1b4..7dffe9ab958 100644
--- a/ld/testsuite/ld-arm/protected-data.d
+++ b/ld/testsuite/ld-arm/protected-data.d
@@ -2,4 +2,4 @@
#ld: -shared
#readelf: -r -W
#...
-.* R_ARM_GLOB_DAT .* var.*
+.* R_ARM_RELATIVE .*
--
2.36.1.255.ge46751e96f-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] arm: Define elf_backend_extern_protected_data to 0
2022-06-02 4:27 [PATCH] arm: Define elf_backend_extern_protected_data to 0 Fangrui Song
@ 2022-06-23 3:38 ` Fangrui Song
2022-06-23 8:21 ` Szabolcs Nagy
1 sibling, 0 replies; 3+ messages in thread
From: Fangrui Song @ 2022-06-23 3:38 UTC (permalink / raw)
To: binutils, Szabolcs Nagy
On Wed, Jun 1, 2022 at 9:27 PM Fangrui Song <maskray@google.com> wrote:
>
> From: Fangrui Song <i@maskray.me>
>
> 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 b68a20d6675f1360ea4db50a9835c073675b9889 changed ld to produce
> R_ARM_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/elf32-arm.c | 2 +-
> ld/testsuite/ld-arm/protected-data.d | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
> index 5b8f5e5a0e6..36f09cb3427 100644
> --- a/bfd/elf32-arm.c
> +++ b/bfd/elf32-arm.c
> @@ -20315,7 +20315,7 @@ elf32_arm_backend_symbol_processing (bfd *abfd, asymbol *sym)
> #define elf_backend_dtrel_excludes_plt 1
>
> #define elf_backend_got_header_size 12
> -#define elf_backend_extern_protected_data 1
> +#define elf_backend_extern_protected_data 0
>
> #undef elf_backend_obj_attrs_vendor
> #define elf_backend_obj_attrs_vendor "aeabi"
> diff --git a/ld/testsuite/ld-arm/protected-data.d b/ld/testsuite/ld-arm/protected-data.d
> index 3f266dea1b4..7dffe9ab958 100644
> --- a/ld/testsuite/ld-arm/protected-data.d
> +++ b/ld/testsuite/ld-arm/protected-data.d
> @@ -2,4 +2,4 @@
> #ld: -shared
> #readelf: -r -W
> #...
> -.* R_ARM_GLOB_DAT .* var.*
> +.* R_ARM_RELATIVE .*
> --
> 2.36.1.255.ge46751e96f-goog
>
Ping:)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] arm: Define elf_backend_extern_protected_data to 0
2022-06-02 4:27 [PATCH] arm: Define elf_backend_extern_protected_data to 0 Fangrui Song
2022-06-23 3:38 ` Fangrui Song
@ 2022-06-23 8:21 ` Szabolcs Nagy
1 sibling, 0 replies; 3+ messages in thread
From: Szabolcs Nagy @ 2022-06-23 8:21 UTC (permalink / raw)
To: Fangrui Song; +Cc: binutils, Fangrui Song
The 06/01/2022 21:27, Fangrui Song wrote:
> From: Fangrui Song <i@maskray.me>
>
> 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 b68a20d6675f1360ea4db50a9835c073675b9889 changed ld to produce
> R_ARM_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.
This patch looks good to me.
Thanks.
> ---
> bfd/elf32-arm.c | 2 +-
> ld/testsuite/ld-arm/protected-data.d | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
> index 5b8f5e5a0e6..36f09cb3427 100644
> --- a/bfd/elf32-arm.c
> +++ b/bfd/elf32-arm.c
> @@ -20315,7 +20315,7 @@ elf32_arm_backend_symbol_processing (bfd *abfd, asymbol *sym)
> #define elf_backend_dtrel_excludes_plt 1
>
> #define elf_backend_got_header_size 12
> -#define elf_backend_extern_protected_data 1
> +#define elf_backend_extern_protected_data 0
>
> #undef elf_backend_obj_attrs_vendor
> #define elf_backend_obj_attrs_vendor "aeabi"
> diff --git a/ld/testsuite/ld-arm/protected-data.d b/ld/testsuite/ld-arm/protected-data.d
> index 3f266dea1b4..7dffe9ab958 100644
> --- a/ld/testsuite/ld-arm/protected-data.d
> +++ b/ld/testsuite/ld-arm/protected-data.d
> @@ -2,4 +2,4 @@
> #ld: -shared
> #readelf: -r -W
> #...
> -.* R_ARM_GLOB_DAT .* var.*
> +.* R_ARM_RELATIVE .*
> --
> 2.36.1.255.ge46751e96f-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-23 8:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02 4:27 [PATCH] arm: Define elf_backend_extern_protected_data to 0 Fangrui Song
2022-06-23 3:38 ` Fangrui Song
2022-06-23 8:21 ` Szabolcs Nagy
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).