diff options
author | Clemens Lang <clemens.lang@bmw-carit.de> | 2016-03-30 15:22:49 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-31 13:18:06 +0100 |
commit | 3ece01215a7b038dbd5cde313754c42d134a887f (patch) | |
tree | 9bb2401973d9e1cb7d313114f7ddc85a585b6843 /meta/recipes-core | |
parent | d492aec2c2afc35eb36e7b7555c514205ab3474c (diff) | |
download | poky-3ece01215a7b038dbd5cde313754c42d134a887f.tar.gz |
ldconfig-native: Fix ELF flags on 64-bit binaries
Yocto's ldconfig-native was exported from an old version of glibc and
generates an ld.so.cache that is partially ignored by current versions
of glibc when loading libraries. This occurs for 64-bit binaries, where
glibc expects FLAG_ELF_LIBC6, but ldconfig-native only generates the
standard ELF flag. Fix this with an additional patch on top of the patch
for now.
You can verify this by applying the patch below to your target copy of
glibc and running
LD_DEBUG=libs /lib64/ld-linux-x86-64.so.2 --list $anybinary
--- ./elf/dl-cache.c.orig 2016-01-07 11:05:36.823447171 +0100
+++ ./elf/dl-cache.c 2016-01-07 11:19:53.925878628 +0100
@@ -106,6 +106,8 @@
if (_dl_cache_check_flags (flags) \
&& _dl_cache_verify_ptr (lib->value)) \
{ \
+ if (__glibc_unlikely (GLRO_dl_debug_mask & DL_DEBUG_LIBS))\
+ _dl_debug_printf (" considering file %s\n", cache_data + lib->value); \
if (best == NULL || flags == GLRO(dl_correct_cache_id)) \
{ \
HWCAP_CHECK; \
@@ -117,6 +119,9 @@
searching. */ \
break; \
} \
+ } else { \
+ if (__glibc_unlikely (GLRO_dl_debug_mask & DL_DEBUG_LIBS)) \
+ _dl_debug_printf (" ignoring file %s due to flags %x, expected %x\n", cache_data + lib->value, lib->flags, GLRO(dl_correct_cache_id)); \
} \
} \
while (++middle <= right); \
@@ -265,14 +270,23 @@
/* Only accept hwcap if it's for the right platform. */
#define HWCAP_CHECK \
- if (lib->hwcap & hwcap_exclude) \
+ if (lib->hwcap & hwcap_exclude) { \
+ if (__glibc_unlikely (GLRO_dl_debug_mask & DL_DEBUG_LIBS)) \
+ _dl_debug_printf (" hwcap mismatch %x vs. %x\n", lib->hwcap, hwcap_exclude); \
continue; \
- if (GLRO(dl_osversion) && lib->osversion > GLRO(dl_osversion)) \
+ } \
+ if (GLRO(dl_osversion) && lib->osversion > GLRO(dl_osversion)) { \
+ if (__glibc_unlikely (GLRO_dl_debug_mask & DL_DEBUG_LIBS)) \
+ _dl_debug_printf (" os version mismatch %x vs. %x\n", lib->osversion, GLRO(dl_osversion)); \
continue; \
+ } \
if (_DL_PLATFORMS_COUNT \
&& (lib->hwcap & _DL_HWCAP_PLATFORM) != 0 \
- && (lib->hwcap & _DL_HWCAP_PLATFORM) != platform) \
- continue
+ && (lib->hwcap & _DL_HWCAP_PLATFORM) != platform) { \
+ if (__glibc_unlikely (GLRO_dl_debug_mask & DL_DEBUG_LIBS)) \
+ _dl_debug_printf (" platform mismatch %x vs. %x\n", lib->hwcap & _DL_HWCAP_PLATFORM, platform); \
+ continue; \
+ }
SEARCH_CACHE (cache_new);
}
else
This version of ldconfig-native should really be replaced with a version
matching the glibc source in use on the target platform.
(From OE-Core rev: bf9c1e6fa1c8eb86670383bad9b7c2e54bfe17f4)
Signed-off-by: Clemens Lang <clemens.lang@bmw-carit.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core')
-rw-r--r-- | meta/recipes-core/glibc/ldconfig-native-2.12.1/add-64-bit-flag-for-ELF64-entries.patch | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/meta/recipes-core/glibc/ldconfig-native-2.12.1/add-64-bit-flag-for-ELF64-entries.patch b/meta/recipes-core/glibc/ldconfig-native-2.12.1/add-64-bit-flag-for-ELF64-entries.patch index a9af110623..f4e38d4256 100644 --- a/meta/recipes-core/glibc/ldconfig-native-2.12.1/add-64-bit-flag-for-ELF64-entries.patch +++ b/meta/recipes-core/glibc/ldconfig-native-2.12.1/add-64-bit-flag-for-ELF64-entries.patch | |||
@@ -64,7 +64,7 @@ index 0bf0de3..6e87afc 100644 | |||
64 | #undef check_ptr | 64 | #undef check_ptr |
65 | #define check_ptr(ptr) \ | 65 | #define check_ptr(ptr) \ |
66 | do \ | 66 | do \ |
67 | @@ -290,6 +295,35 @@ process_elf_file64 (const char *file_name, const char *lib, int *flag, | 67 | @@ -290,6 +295,48 @@ process_elf_file64 (const char *file_name, const char *lib, int *flag, |
68 | libc5/libc6. */ | 68 | libc5/libc6. */ |
69 | *flag = FLAG_ELF; | 69 | *flag = FLAG_ELF; |
70 | 70 | ||
@@ -73,23 +73,36 @@ index 0bf0de3..6e87afc 100644 | |||
73 | + switch (elf_header->e_machine) | 73 | + switch (elf_header->e_machine) |
74 | + { | 74 | + { |
75 | + case EM_IA_64: | 75 | + case EM_IA_64: |
76 | + *flag |= FLAG_IA64_LIB64; | 76 | + /* Intel 64bit libraries are always libc.so.6+. */ |
77 | + /* see sysdeps/unix/sysv/linux/ia64/readelflib.c */ | ||
78 | + *flag |= FLAG_IA64_LIB64|FLAG_ELF_LIBC6; | ||
77 | + break; | 79 | + break; |
78 | + case EM_X86_64: | 80 | + case EM_X86_64: |
79 | + *flag |= FLAG_X8664_LIB64; | 81 | + /* X86-64 64bit libraries are always libc.so.6+. */ |
82 | + /* see sysdeps/unix/sysv/linux/i386/readelflib.c */ | ||
83 | + *flag |= FLAG_X8664_LIB64|FLAG_ELF_LIBC6; | ||
80 | + break; | 84 | + break; |
81 | + case EM_S390: | 85 | + case EM_S390: |
82 | + *flag |= FLAG_S390_LIB64; | 86 | + /* S/390 64bit libraries are always libc.so.6+. */ |
87 | + /* see sysdeps/unix/sysv/linux/s390/readelflib.c */ | ||
88 | + *flag |= FLAG_S390_LIB64|FLAG_ELF_LIBC6; | ||
83 | + break; | 89 | + break; |
84 | + case EM_PPC64: | 90 | + case EM_PPC64: |
85 | + *flag |= FLAG_POWERPC_LIB64; | 91 | + /* PowerPC 64bit libraries are always libc.so.6+. */ |
92 | + /* see sysdeps/unix/sysv/linux/powerpc/readelflib.c */ | ||
93 | + *flag |= FLAG_POWERPC_LIB64|FLAG_ELF_LIBC6; | ||
86 | + break; | 94 | + break; |
87 | + case EM_MIPS: | 95 | + case EM_MIPS: |
88 | + case EM_MIPS_RS3_LE: | 96 | + case EM_MIPS_RS3_LE: |
89 | + *flag |= FLAG_MIPS64_LIBN64; | 97 | + /* n64 libraries are always libc.so.6+. */ |
98 | + /* NOTE: This does not correctly distinguish NAN2008 binaries and is possibly broken */ | ||
99 | + /* see sysdeps/unix/sysv/linux/mips/readelflib.c */ | ||
100 | + *flag |= FLAG_MIPS64_LIBN64|FLAG_ELF_LIBC6; | ||
90 | + break; | 101 | + break; |
91 | + case EM_AARCH64: | 102 | + case EM_AARCH64: |
92 | + *flag |= FLAG_AARCH64_LIB64; | 103 | + /* AArch64 libraries are always libc.so.6+. */ |
104 | + /* see sysdeps/unix/sysv/linux/arm/readelflib.c */ | ||
105 | + *flag |= FLAG_AARCH64_LIB64|FLAG_ELF_LIBC6; | ||
93 | + break; | 106 | + break; |
94 | + default: | 107 | + default: |
95 | + error(0, 0, "%s is a 64-bit ELF for unknown machine %lx\n", | 108 | + error(0, 0, "%s is a 64-bit ELF for unknown machine %lx\n", |