-
Notifications
You must be signed in to change notification settings - Fork 4
/
0004-Fix-crash-when-linking-with-libdl-on-arm-with-NEON.patch
49 lines (41 loc) · 1.71 KB
/
0004-Fix-crash-when-linking-with-libdl-on-arm-with-NEON.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= <[email protected]>
Date: Tue, 31 Aug 2021 01:19:23 +0300
Subject: [PATCH] Fix crash when linking with libdl on arm with NEON
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
---
dlfcn/dlfcn.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/dlfcn/dlfcn.c b/dlfcn/dlfcn.c
index b30f42d50dbd3f1d4b70d80ecbf9cd9fdfb8f460..69b82e7dafe8da3db7c42896cd55d34c15b92fdf 100644
--- a/dlfcn/dlfcn.c
+++ b/dlfcn/dlfcn.c
@@ -23,16 +23,9 @@ int __dlfcn_argc attribute_hidden;
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
-};