This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] Add ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA to x86


On Thu, Mar 5, 2015 at 4:19 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> 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.
>
> I only defined DL_EXTERN_PROTECTED_DATA for x86.  Other targets can
> define DL_EXTERN_PROTECTED_DATA and update elf_machine_type_class to
> support copy relocation on protected data.
>
> I will submit a testcase in a separate email.
>
> Tested on x86-32 and x86-64.  OK for master?
>
> Thanks.
>
> H.J.
> ---
>         [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.

FWIW, If a target doesn't define DL_NO_COPY_RELOCS, its elf_machine_type_class
should properly handle ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA.  Fix it
should be very much straight forward by adding

| (((type) == R_XXX_GLOB_DAT) * ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA))

to elf_machine_type_class.  Target maintainer should give it a try.


-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]