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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
https://git.savannah.gnu.org/cgit/libffcall.git/commit/?id=580f0bb144c0d63560c61229291e172e55971437
From 580f0bb144c0d63560c61229291e172e55971437 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sat, 26 Jun 2021 18:19:21 +0200
Subject: [PATCH] x86_64: Create a read-only .eh_frame section on all
platforms.
Reported by Thomas Klausner <tk@giga.or.at> at
<https://savannah.gnu.org/bugs/?60815>.
* common/asm-x86_64.h (EH_FRAME_SECTION): Use flags "a" (instead of
"aw") on all platforms.
diff --git a/ChangeLog b/ChangeLog
index 1e87b99..d2bde2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-06-26 Bruno Haible <bruno@clisp.org>
+
+ x86_64: Create a read-only .eh_frame section on all platforms.
+ Reported by Thomas Klausner <tk@giga.or.at> at
+ <https://savannah.gnu.org/bugs/?60815>.
+ * common/asm-x86_64.h (EH_FRAME_SECTION): Use flags "a" (instead of
+ "aw") on all platforms.
+
2021-06-13 Bruno Haible <bruno@clisp.org>
maint: Don't require an internet connection for running autogen.sh.
diff --git a/common/asm-x86_64.h b/common/asm-x86_64.h
index b4713d7..edb1ea5 100644
--- a/common/asm-x86_64.h
+++ b/common/asm-x86_64.h
@@ -279,11 +279,24 @@
// Solaris/ELF
#define EH_FRAME_SECTION .eh_frame,"aL",link=.text,@unwind
#else
-#if defined __FreeBSD__
-// FreeBSD/ELF
+// The eh_frame section was usually writable (flags "aw") in older OS versions,
+// but can be made read-only (flags "a") under specific conditions, depending
+// on the assembler's behaviour (look for EH_TABLES_CAN_BE_READ_ONLY in
+// gcc-11.1.0/gcc/defaults.h).
+// To determine whether the eh_frame section is writable or read-only by
+// default, compile a simple program:
+// gcc -S -fno-dwarf2-cfi-asm hello.c (GCC >= 4.4)
+// or
+// gcc -S hello.c (GCC < 4.4)
+// The result is that all modern systems (at least Ubuntu >= 16.04,
+// Red Hat Enterprise Linux >= 5, Fedora >= 13, Alpine Linux >= 3.7,
+// FreeBSD >= 11, DragonFly BSD >= 6, NetBSD >= 7, OpenBSD >= 6)
+// use a read-only eh_frame section.
+#if 1
+// all modern systems
#define EH_FRAME_SECTION .eh_frame,"a",@progbits
#else
-// Linux/ELF
+// only very old systems
#define EH_FRAME_SECTION .eh_frame,"aw",@progbits
#endif
#endif
--
2.45.2
|