public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] Revert "[AArch64][BZ #17711] Fix extern protected data handling"
@ 2022-05-23 20:37 Fangrui Song
  0 siblings, 0 replies; only message in thread
From: Fangrui Song @ 2022-05-23 20:37 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e555954e026df1b85b8ef6c101d05f97b1520d7e

commit e555954e026df1b85b8ef6c101d05f97b1520d7e
Author: Fangrui Song <maskray@google.com>
Date:   Mon May 23 13:37:05 2022 -0700

    Revert "[AArch64][BZ #17711] Fix extern protected data handling"
    
    This reverts commit 0910702c4d2cf9e8302b35c9519548726e1ac489.
    
    Say both a.so and b.so define protected data symbol `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 generator 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.
    
    Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>

Diff:
---
 sysdeps/aarch64/dl-machine.h | 13 ++++++-------
 sysdeps/aarch64/dl-sysdep.h  | 21 ---------------------
 2 files changed, 6 insertions(+), 28 deletions(-)

diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index fe120bb507..292abe5152 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -109,13 +109,12 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[],
 #define RTLD_START asm (".globl _dl_start");
 
 #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
deleted file mode 100644
index 1516dd7d3f..0000000000
--- a/sysdeps/aarch64/dl-sysdep.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright (C) 2002-2022 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include_next <dl-sysdep.h>
-
-#define DL_EXTERN_PROTECTED_DATA


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-23 20:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23 20:37 [glibc] Revert "[AArch64][BZ #17711] Fix extern protected data handling" Fangrui Song

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).