Commit cc594428 authored by Richard Braakman's avatar Richard Braakman

Fix crash when linking with libdl on arm with NEON

With -mfpu=neon, libdl got a badly aligned .init_array section which
caused the dynamic linker to segfault when initializing any program that
links to libdl.

Added eglibc-2.15-fix-neon-libdl.patch to fix it.
Signed-off-by: default avatarRichard Braakman <>
parent 9a5f0eca
When compiled for arm with -mfpu=neon, the .init_array section declared
here becomes 64-bit aligned. Since the dynamic linker expects an array of
32-bit function pointers with no gaps, this causes an immediate SIGSEGV
for any application linked with libdl.
I suspect the default array alignment becomes 64 bits because the neon
has 64-bit registers, but I'm not sure. The explicit aligned attribute
does not help because it can only increase the alignment.
Fortunately, the whole declaration can be replaced with a constructor
attribute on the init function, which also adds it to the init_array
table and does the right thing with alignment.
(Why wasn't it this way already? I don't know, but maybe the constructor
attribute wasn't available yet when this code was written.)
Richard Braakman
--- eglibc-2.15/dlfcn/dlfcn.c 2006-08-17 04:18:26.000000000 +0300
+++ glibc-fixed/dlfcn/dlfcn.c 2013-06-10 13:20:34.846885906 +0300
@@ -24,16 +24,9 @@
char **__dlfcn_argv attribute_hidden;
-static void
+static void __attribute ((constructor))
init (int argc, char *argv[])
__dlfcn_argc = argc;
__dlfcn_argv = argv;
-static void (*const init_array []) (int argc, char *argv[])
- __attribute__ ((section (".init_array"), aligned (sizeof (void *))))
- __attribute_used__ =
- init
* Wed Jun 26 2013 Richard Braakman <> - 2.15
- Fix crash when linking with libdl on arm with NEON
* Wed Apr 24 2013 David Greaves <> - 2.15
- must use absolute paths when being called using -r
This happens when using scratchbox2 with x86 targets.
......@@ -36,6 +36,7 @@ Patch10: eglibc-2.15-mips-no-n32-n64.patch
Patch11: glibc-2.14-locarchive-fedora.patch
Patch12: eglibc-2.15-disable-multilib.patch
Patch13: eglibc-2.15-use-usrbin-localedef.patch
Patch14: eglibc-2.15-neon-fix.patch
Provides: ldconfig
# The dynamic linker supports DT_GNU_HASH
......@@ -198,6 +199,7 @@ If unsure if you need this, don't install this package.
%patch12 -p1
%if 0%{?qemu_user_space_build}
%patch13 -p1
%patch14 -p1
# Not well formatted locales --cvm
......@@ -242,10 +244,10 @@ AddOns=`echo */configure | sed -e 's!/configure!!g;s!\(linuxthreads\|nptl\|rtkai
%ifarch armv7tnhl
#%ifarch armv7tnhl
# workaround for a potential compiler bug using -mfpu=neon (gcc 4.6 2013.01)
BuildFlags="$BuildFlags -mfpu=vfpv3-d16"
#BuildFlags="$BuildFlags -mfpu=vfpv3-d16"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment