diff options
author | Fangrui Song <maskray@google.com> | 2022-06-15 11:29:55 -0700 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2022-06-15 11:29:55 -0700 |
commit | de38b2a343e6d64b95c50004943d6107a9e380d0 (patch) | |
tree | 7024de16def267741d9bcf6ff5f29d27dcdceeba /sysdeps/generic/ldsodefs.h | |
parent | ff439c47173565fbff4f0f78d07b0f14e4a7db05 (diff) | |
download | glibc-de38b2a343e6d64b95c50004943d6107a9e380d0.tar.gz glibc-de38b2a343e6d64b95c50004943d6107a9e380d0.tar.xz glibc-de38b2a343e6d64b95c50004943d6107a9e380d0.zip |
elf: Remove ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA
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. Note: the GOT relocations defeat the purpose of protected visibility as an optimization, but allow rtld to make the executable and library use the same copy when copy relocations are present, but it turns out this never worked perfectly. ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA has strange semantics when both a.so and b.so define protected var and the executable copy relocates var: b.so accesses its own copy even with GLOB_DAT. The behavior change is from commit 62da1e3b00b51383ffa7efc89d8addda0502e107 (x86) and then copied to nios2 (ae5eae7cfc9c4a8297ff82ec6b794faca1976ecc) and arc (0e7d930c4c11de896fe807f67fa1eb756c9c1e05). Without ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA, b.so accesses the copy relocated data like a.so. There is now a warning for copy relocation on protected symbol since commit 7374c02b683b7110b853a32496a619410364d70b. It's extremely unlikely anyone relies on the ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA behavior, so let's remove it: this removes a check in the symbol lookup code.
Diffstat (limited to 'sysdeps/generic/ldsodefs.h')
-rw-r--r-- | sysdeps/generic/ldsodefs.h | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 446d12a68c..050a3032de 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -149,23 +149,13 @@ dl_symbol_visibility_binds_local_p (const ElfW(Sym) *sym) satisfied by any symbol in the executable. Some architectures do not support copy relocations. In this case we define the macro to zero so that the code for handling them gets automatically optimized - out. ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA means address of protected - data defined in the shared library may be external, i.e., due to copy - relocation. */ + out. */ #define ELF_RTYPE_CLASS_PLT 1 #ifndef DL_NO_COPY_RELOCS # define ELF_RTYPE_CLASS_COPY 2 #else # define ELF_RTYPE_CLASS_COPY 0 #endif -/* If DL_EXTERN_PROTECTED_DATA is defined, address of protected data - defined in the shared library may be external, i.e., due to copy - relocation. */ -#ifdef DL_EXTERN_PROTECTED_DATA -# define ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA 4 -#else -# define ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA 0 -#endif /* ELF uses the PF_x macros to specify the segment permissions, mmap uses PROT_xxx. In most cases the three macros have the values 1, 2, |