ocaml/0012-Mark-certain-symbols-as-.hidden-in-arm64-codegen-pos.patch
Richard W.M. Jones 5f905fc187 - New upstream version 4.05.0.
- Disable parallel builds for now.
- *.mli files are now included in ocaml-compiler-libs.
- Add possible fix for aarch64 with new binutils.
2017-08-05 16:33:41 +01:00

68 lines
2.6 KiB
Diff

From 2cc11dbf4e046610e85e66139f0d1ffc9e1cff65 Mon Sep 17 00:00:00 2001
From: Jiong Wang <jiong.wang@foss.arm.com>
Date: Fri, 28 Jul 2017 19:00:00 +0200
Subject: [PATCH 12/12] Mark certain symbols as .hidden in arm64 codegen,
possibly fixes MPR#7585
binutils 2.29 arm64 linker is more strict about when to perform pc-relative
relocations for global symbols. Specifically, they must be marked as .hidden.
ocaml arm64 codegen does not do this, so tests/lib-dynlink-native/ fails as
some symbols were not relocated. This patch fixes that by marking (hopefully)
the appropriate symbols as .hidden.
---
asmcomp/arm64/emit.mlp | 4 ++++
asmcomp/compilenv.ml | 1 -
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp
index f75646e12..ee72c114f 100644
--- a/asmcomp/arm64/emit.mlp
+++ b/asmcomp/arm64/emit.mlp
@@ -324,6 +324,7 @@ let emit_literals() =
let emit_load_symbol_addr dst s =
if (not !Clflags.dlcode) || Compilenv.symbol_in_current_unit s then begin
+ ` .hidden {emit_symbol s}\n`;
` adrp {emit_reg dst}, {emit_symbol s}\n`;
` add {emit_reg dst}, {emit_reg dst}, #:lo12:{emit_symbol s}\n`
end else begin
@@ -575,6 +576,7 @@ let emit_instr i =
` fmov {emit_reg i.res.(0)}, #{emit_printf "0x%Lx" f}\n`
else begin
let lbl = float_literal f in
+ ` .hidden {emit_label lbl}\n`;
` adrp {emit_reg reg_tmp1}, {emit_label lbl}\n`;
` ldr {emit_reg i.res.(0)}, [{emit_reg reg_tmp1}, #:lo12:{emit_label lbl}]\n`
end
@@ -609,6 +611,7 @@ let emit_instr i =
match addr with
| Iindexed _ -> i.arg.(0)
| Ibased(s, ofs) ->
+ ` .hidden {emit_symbol s}\n`;
` adrp {emit_reg reg_tmp1}, {emit_symbol_offset s ofs}\n`;
reg_tmp1 in
begin match size with
@@ -636,6 +639,7 @@ let emit_instr i =
match addr with
| Iindexed _ -> i.arg.(1)
| Ibased(s, ofs) ->
+ ` .hidden {emit_symbol s}\n`;
` adrp {emit_reg reg_tmp1}, {emit_symbol_offset s ofs}\n`;
reg_tmp1 in
begin match size with
diff --git a/asmcomp/compilenv.ml b/asmcomp/compilenv.ml
index a50c57f45..32f8bf1da 100644
--- a/asmcomp/compilenv.ml
+++ b/asmcomp/compilenv.ml
@@ -161,7 +161,6 @@ let make_symbol ?(unitname = current_unit.ui_symbol) idopt =
let symbol_in_current_unit name =
let prefix = "caml" ^ current_unit.ui_symbol in
- name = prefix ||
(let lp = String.length prefix in
String.length name >= 2 + lp
&& String.sub name 0 lp = prefix
--
2.13.1