diff options
| author | Mark Hatle <mark.hatle@windriver.com> | 2015-10-30 09:48:27 -0500 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-01-12 08:42:31 +0000 |
| commit | a29ec8108eb4cb64bbef3faa139e95c6d82e1c98 (patch) | |
| tree | 804dd6859a676cf515f58bff278e9feeab861d72 | |
| parent | b1e980f33bfa259f886c1ae6eaa28ab40120d0a1 (diff) | |
| download | poky-a29ec8108eb4cb64bbef3faa139e95c6d82e1c98.tar.gz | |
glibc: Fix ld.so / prelink interface for ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA
A bug in glibc 2.22's ld.so interface for the prelink support causes
the displayed values to be incorrect. The included path fixes this
issue.
Clear ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA for prelink
prelink runs ld.so with the environment variable LD_TRACE_PRELINKING
set to dump the relocation type class from _dl_debug_bindings. prelink
has the following relocation type classes:
where ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA has a conflict with
RTYPE_CLASS_TLS.
Since prelink doesn't use ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA, we
should clear the ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA bit when the
DL_DEBUG_PRELINK bit is set.
(From OE-Core master rev: 12c86bdcc60c54e587a896b0dceb8bb6cc9ff7e3)
(From OE-Core rev: 73919830f88f2d28da973e72fbdfaab591a5af69)
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-core/glibc/glibc/0028-Clear-ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA-for-prel.patch | 84 | ||||
| -rw-r--r-- | meta/recipes-core/glibc/glibc_2.22.bb | 1 |
2 files changed, 85 insertions, 0 deletions
diff --git a/meta/recipes-core/glibc/glibc/0028-Clear-ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA-for-prel.patch b/meta/recipes-core/glibc/glibc/0028-Clear-ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA-for-prel.patch new file mode 100644 index 0000000000..3455df1cff --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0028-Clear-ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA-for-prel.patch | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | From cadaf1336332ca7bcdfe4a400776e5782a20e26d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: "H.J. Lu" <hjl.tools@gmail.com> | ||
| 3 | Date: Wed, 28 Oct 2015 07:49:44 -0700 | ||
| 4 | Subject: [PATCH] Keep only ELF_RTYPE_CLASS_{PLT|COPY} bits for prelink | ||
| 5 | |||
| 6 | prelink runs ld.so with the environment variable LD_TRACE_PRELINKING | ||
| 7 | set to dump the relocation type class from _dl_debug_bindings. prelink | ||
| 8 | has the following relocation type classes: | ||
| 9 | |||
| 10 | #define RTYPE_CLASS_VALID 8 | ||
| 11 | #define RTYPE_CLASS_PLT (8|1) | ||
| 12 | #define RTYPE_CLASS_COPY (8|2) | ||
| 13 | #define RTYPE_CLASS_TLS (8|4) | ||
| 14 | |||
| 15 | where ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA has a conflict with | ||
| 16 | RTYPE_CLASS_TLS. | ||
| 17 | |||
| 18 | Since prelink only uses ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY | ||
| 19 | bits, we should clear the other bits when the DL_DEBUG_PRELINK bit is | ||
| 20 | set. | ||
| 21 | |||
| 22 | [BZ #19178] | ||
| 23 | * elf/dl-lookup.c (RTYPE_CLASS_VALID): New. | ||
| 24 | (RTYPE_CLASS_PLT): Likewise. | ||
| 25 | (RTYPE_CLASS_COPY): Likewise. | ||
| 26 | (RTYPE_CLASS_TLS): Likewise. | ||
| 27 | (_dl_debug_bindings): Use RTYPE_CLASS_TLS and RTYPE_CLASS_VALID | ||
| 28 | to set relocation type class for DL_DEBUG_PRELINK. Keep only | ||
| 29 | ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY bits for | ||
| 30 | DL_DEBUG_PRELINK. | ||
| 31 | |||
| 32 | Upstream-Status: submitted (https://sourceware.org/bugzilla/show_bug.cgi?id=19178) | ||
| 33 | |||
| 34 | Signed-off-by: Mark Hatle <mark.hatle@windriver.com> | ||
| 35 | --- | ||
| 36 | elf/dl-lookup.c | 21 +++++++++++++++++++-- | ||
| 37 | 1 file changed, 19 insertions(+), 2 deletions(-) | ||
| 38 | |||
| 39 | diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c | ||
| 40 | index 581fb20..6ae6cc3 100644 | ||
| 41 | --- a/elf/dl-lookup.c | ||
| 42 | +++ b/elf/dl-lookup.c | ||
| 43 | @@ -1016,6 +1016,18 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map, | ||
| 44 | #ifdef SHARED | ||
| 45 | if (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK) | ||
| 46 | { | ||
| 47 | +/* ELF_RTYPE_CLASS_XXX must match RTYPE_CLASS_XXX used by prelink with | ||
| 48 | + LD_TRACE_PRELINKING. */ | ||
| 49 | +#define RTYPE_CLASS_VALID 8 | ||
| 50 | +#define RTYPE_CLASS_PLT (8|1) | ||
| 51 | +#define RTYPE_CLASS_COPY (8|2) | ||
| 52 | +#define RTYPE_CLASS_TLS (8|4) | ||
| 53 | +#if ELF_RTYPE_CLASS_PLT != 0 && ELF_RTYPE_CLASS_PLT != 1 | ||
| 54 | +# error ELF_RTYPE_CLASS_PLT must be 0 or 1! | ||
| 55 | +#endif | ||
| 56 | +#if ELF_RTYPE_CLASS_COPY != 0 && ELF_RTYPE_CLASS_COPY != 2 | ||
| 57 | +# error ELF_RTYPE_CLASS_COPY must be 0 or 2! | ||
| 58 | +#endif | ||
| 59 | int conflict = 0; | ||
| 60 | struct sym_val val = { NULL, NULL }; | ||
| 61 | |||
| 62 | @@ -1071,12 +1083,17 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map, | ||
| 63 | |||
| 64 | if (value->s) | ||
| 65 | { | ||
| 66 | + /* Keep only ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY | ||
| 67 | + bits since since prelink only uses them. */ | ||
| 68 | + type_class &= ELF_RTYPE_CLASS_PLT | ELF_RTYPE_CLASS_COPY; | ||
| 69 | if (__glibc_unlikely (ELFW(ST_TYPE) (value->s->st_info) | ||
| 70 | == STT_TLS)) | ||
| 71 | - type_class = 4; | ||
| 72 | + /* Clear the RTYPE_CLASS_VALID bit in RTYPE_CLASS_TLS. */ | ||
| 73 | + type_class = RTYPE_CLASS_TLS & ~RTYPE_CLASS_VALID; | ||
| 74 | else if (__glibc_unlikely (ELFW(ST_TYPE) (value->s->st_info) | ||
| 75 | == STT_GNU_IFUNC)) | ||
| 76 | - type_class |= 8; | ||
| 77 | + /* Set the RTYPE_CLASS_VALID bit. */ | ||
| 78 | + type_class |= RTYPE_CLASS_VALID; | ||
| 79 | } | ||
| 80 | |||
| 81 | if (conflict | ||
| 82 | -- | ||
| 83 | 1.9.3 | ||
| 84 | |||
diff --git a/meta/recipes-core/glibc/glibc_2.22.bb b/meta/recipes-core/glibc/glibc_2.22.bb index 71ff8249f7..c1f6b4eb71 100644 --- a/meta/recipes-core/glibc/glibc_2.22.bb +++ b/meta/recipes-core/glibc/glibc_2.22.bb | |||
| @@ -40,6 +40,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ | |||
| 40 | file://0027-eglibc-use-option-groups-Conditionally-exclude-c-tes.patch \ | 40 | file://0027-eglibc-use-option-groups-Conditionally-exclude-c-tes.patch \ |
| 41 | file://nscd-no-bash.patch \ | 41 | file://nscd-no-bash.patch \ |
| 42 | file://strcoll-Remove-incorrect-STRDIFF-based-optimization-.patch \ | 42 | file://strcoll-Remove-incorrect-STRDIFF-based-optimization-.patch \ |
| 43 | file://0028-Clear-ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA-for-prel.patch \ | ||
| 43 | " | 44 | " |
| 44 | 45 | ||
| 45 | SRC_URI += "\ | 46 | SRC_URI += "\ |
