Skip to content

Commit af024c0

Browse files
committed
x86 ELF: avoid putting constants in .text section
Some systems (e.g. OpenBSD) can make the text section not readable. Use .rodata section instead of .text.
1 parent 1373cbd commit af024c0

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

runtime/x86_64/i64_dtou.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ FUNCTION(__compcert_i64_dtou)
4848
addq .LC2(%rip), INT_RES
4949
ret
5050

51+
ENDFUNCTION(__compcert_i64_dtou)
52+
53+
RODATA
5154
.p2align 3
5255
.LC1: .quad 0x43e0000000000000 // 2^63 in double precision
5356
.LC2: .quad 0x8000000000000000 // 2^63 as an integer
54-
55-
ENDFUNCTION(__compcert_i64_dtou)
56-

runtime/x86_64/sysdeps.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#define ENDFUNCTION(f) \
4949
.type f, @function; .size f, . - f
5050

51+
#define RODATA .section .rodata
52+
5153
#endif
5254

5355
#if defined(SYS_macos)
@@ -61,6 +63,8 @@ _##f:
6163

6264
#define ENDFUNCTION(f)
6365

66+
#define RODATA .text
67+
6468
#endif
6569

6670
#if defined(SYS_cygwin)
@@ -74,6 +78,8 @@ _##f:
7478

7579
#define ENDFUNCTION(f)
7680

81+
#define RODATA .text
82+
7783
#endif
7884

7985
// Names for argument and result registers

0 commit comments

Comments
 (0)