Skip to content

Commit a899ced

Browse files
committed
ELF targets: avoid putting jump tables in .text section
Some systems (e.g. OpenBSD) can make the text section not readable. Use .rodata section instead of .text. Fixes: #508
1 parent 1670ae7 commit a899ced

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

powerpc/TargetPrinter.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ module Linux_System : SYSTEM =
130130
elf_mergeable_string_section sz ".section .rodata"
131131
| Section_literal sz ->
132132
elf_mergeable_literal_section sz ".section .rodata"
133-
| Section_jumptable -> ".text"
133+
| Section_jumptable -> ".section .rodata"
134134
| Section_user(s, wr, ex) ->
135135
sprintf ".section \"%s\",\"a%s%s\",@progbits"
136136
s (if wr then "w" else "") (if ex then "x" else "")

x86/TargetPrinter.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ module ELF_System : SYSTEM =
152152
elf_mergeable_string_section sz ".section .rodata"
153153
| Section_literal sz ->
154154
elf_mergeable_literal_section sz ".section .rodata"
155-
| Section_jumptable -> ".text"
155+
| Section_jumptable -> ".section .rodata"
156156
| Section_user(s, wr, ex) ->
157157
sprintf ".section \"%s\",\"a%s%s\",@progbits"
158158
s (if wr then "w" else "") (if ex then "x" else "")

0 commit comments

Comments
 (0)