From 62da1e3b00b51383ffa7efc89d8addda0502e107 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 31 Mar 2015 05:15:43 -0700 Subject: Add ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA to x86 With copy relocation, address of protected data defined in the shared library may be external. When there is a relocation against the protected data symbol within the shared library, we need to check if we should skip the definition in the executable copied from the protected data. This patch adds ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA and defines it for x86. If ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA isn't 0, do_lookup_x will skip the data definition in the executable from copy reloc. [BZ #17711] * elf/dl-lookup.c (do_lookup_x): When UNDEF_MAP is NULL, which indicates it is called from do_lookup_x on relocation against protected data, skip the data definion in the executable from copy reloc. (_dl_lookup_symbol_x): Pass ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA, instead of ELF_RTYPE_CLASS_PLT, to do_lookup_x for EXTERN_PROTECTED_DATA relocation against STT_OBJECT symbol. * sysdeps/generic/ldsodefs.h * (ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA): New. Defined to 4 if DL_EXTERN_PROTECTED_DATA is defined, otherwise to 0. * sysdeps/i386/dl-lookupcfg.h (DL_EXTERN_PROTECTED_DATA): New. * sysdeps/i386/dl-machine.h (elf_machine_type_class): Set class to ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA for R_386_GLOB_DAT. * sysdeps/x86_64/dl-lookupcfg.h (DL_EXTERN_PROTECTED_DATA): New. * sysdeps/x86_64/dl-machine.h (elf_machine_type_class): Set class to ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA for R_X86_64_GLOB_DAT. --- sysdeps/i386/dl-lookupcfg.h | 4 ++++ sysdeps/i386/dl-machine.h | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'sysdeps/i386') diff --git a/sysdeps/i386/dl-lookupcfg.h b/sysdeps/i386/dl-lookupcfg.h index 9310296d27..310f261fec 100644 --- a/sysdeps/i386/dl-lookupcfg.h +++ b/sysdeps/i386/dl-lookupcfg.h @@ -20,6 +20,10 @@ #include_next +/* Address of protected data defined in the shared library may be + external due to copy relocation. */ +#define DL_EXTERN_PROTECTED_DATA + struct link_map; extern void internal_function _dl_unmap (struct link_map *map); diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index ce5f50f972..04f9247bfa 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -206,13 +206,17 @@ _dl_start_user:\n\ TLS variable, so undefined references should not be allowed to define the value. ELF_RTYPE_CLASS_COPY iff TYPE should not be allowed to resolve to one - of the main executable's symbols, as for a COPY reloc. */ + of the main executable's symbols, as for a COPY reloc. + ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA iff TYPE describes relocation may + against protected data whose address be external due to copy relocation. + */ # define elf_machine_type_class(type) \ ((((type) == R_386_JMP_SLOT || (type) == R_386_TLS_DTPMOD32 \ || (type) == R_386_TLS_DTPOFF32 || (type) == R_386_TLS_TPOFF32 \ || (type) == R_386_TLS_TPOFF || (type) == R_386_TLS_DESC) \ * ELF_RTYPE_CLASS_PLT) \ - | (((type) == R_386_COPY) * ELF_RTYPE_CLASS_COPY)) + | (((type) == R_386_COPY) * ELF_RTYPE_CLASS_COPY) \ + | (((type) == R_386_GLOB_DAT) * ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA)) /* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ #define ELF_MACHINE_JMP_SLOT R_386_JMP_SLOT -- cgit 1.4.1