From 8a46d76bf9359b5cc505b3f2f9c81eb624c631fa Mon Sep 17 00:00:00 2001 From: jacobly0 Date: Sun, 18 Oct 2020 07:57:53 -0400 Subject: [PATCH] Fix mergeable section flags and use .rodata.cst16 where appropriate (#9981) On x86-64 ELF, the `.rodata.cst8` section was incorrectly used. --- Changes | 4 ++++ asmcomp/amd64/emit.mlp | 5 +++-- runtime/amd64.S | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 4ae790e5c..8207dbca3 100644 --- a/Changes +++ b/Changes @@ -182,6 +182,10 @@ Working version that is rejected by the assembler. (Xavier Leroy, review by Stephen Dolan) +- #9969, #9981: Added mergeable flag to ELF sections containing mergeable + constants. Fixes compatibility with the integrated assembler in clang 11.0.0. + (Jacob Young, review by Nicolás Ojeda Bär) + ### Standard library: - #9865: add Format.pp_print_seq diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp index 255f3a45c..06988c670 100644 --- a/asmcomp/amd64/emit.mlp +++ b/asmcomp/amd64/emit.mlp @@ -956,7 +956,7 @@ let begin_assembly() = | S_macosx -> D.section ["__TEXT";"__literal16"] None ["16byte_literals"] | S_mingw64 | S_cygwin -> D.section [".rdata"] (Some "dr") [] | S_win64 -> D.data () - | _ -> D.section [".rodata.cst8"] (Some "a") ["@progbits"] + | _ -> D.section [".rodata.cst16"] (Some "aM") ["@progbits";"16"] end; D.align 16; _label (emit_symbol "caml_negf_mask"); @@ -982,8 +982,9 @@ let end_assembly() = | S_macosx -> D.section ["__TEXT";"__literal8"] None ["8byte_literals"] | S_mingw64 | S_cygwin -> D.section [".rdata"] (Some "dr") [] | S_win64 -> D.data () - | _ -> D.section [".rodata.cst8"] (Some "a") ["@progbits"] + | _ -> D.section [".rodata.cst8"] (Some "aM") ["@progbits";"8"] end; + D.align 8; List.iter (fun (cst,lbl) -> emit_float_constant cst lbl) !float_constants end; diff --git a/runtime/amd64.S b/runtime/amd64.S index a542a62a7..7cf702a37 100644 --- a/runtime/amd64.S +++ b/runtime/amd64.S @@ -679,7 +679,7 @@ G(caml_system__frametable): #elif defined(SYS_mingw64) || defined(SYS_cygwin) .section .rdata,"dr" #else - .section .rodata.cst8,"a",@progbits + .section .rodata.cst16,"aM",@progbits,16 #endif .globl G(caml_negf_mask) .align SIXTEEN_ALIGN