Fix gdb stack traces on aarch64 (upstream PR6490). Thanks: Mark Shinwell.

This commit is contained in:
Richard W.M. Jones 2015-05-06 19:30:47 +01:00
parent 4c52516d71
commit c8a94cd7b5
17 changed files with 99 additions and 16 deletions

View File

@ -1,7 +1,7 @@
From 607ae33eed09f9eafccda1276626e9c509dcbed1 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 24 Jun 2014 22:29:38 +0100
Subject: [PATCH 01/15] Don't ignore ./configure, it's a real git file.
Subject: [PATCH 01/16] Don't ignore ./configure, it's a real git file.
---
.gitignore | 1 -

View File

@ -1,7 +1,7 @@
From 89f29afc4aaa324585aa010289a4a58416d53700 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 7 Jun 2012 15:36:16 +0100
Subject: [PATCH 02/15] Ensure empty compilerlibs/ directory is created by git.
Subject: [PATCH 02/16] Ensure empty compilerlibs/ directory is created by git.
This directory exists in the OCaml tarball, but is empty. As a
result, git ignores it unless we put a dummy file in it.

View File

@ -1,7 +1,7 @@
From 10209519de242952ebdef608ab5f2f51a6c9e2b3 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 24 Jun 2014 10:00:15 +0100
Subject: [PATCH 03/15] Don't add rpaths to libraries.
Subject: [PATCH 03/16] Don't add rpaths to libraries.
---
tools/Makefile.shared | 6 +++---

View File

@ -1,7 +1,7 @@
From b360841d9b1eae64201d1ee7a1ff6dc5a5b0fa87 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 29 May 2012 20:40:36 +0100
Subject: [PATCH 04/15] ocamlbyteinfo, ocamlplugininfo: Useful utilities from
Subject: [PATCH 04/16] ocamlbyteinfo, ocamlplugininfo: Useful utilities from
Debian, sent upstream.
See:

View File

@ -1,7 +1,7 @@
From 6193266853d3667f18048989ebaaa0cbcb74afb5 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 29 May 2012 20:44:18 +0100
Subject: [PATCH 05/15] configure: Allow user defined C compiler flags.
Subject: [PATCH 05/16] configure: Allow user defined C compiler flags.
---
configure | 4 ++++

View File

@ -1,7 +1,7 @@
From 5022b33b094d5a88c5c372b0873d81023f0d7bb4 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 29 May 2012 20:47:07 +0100
Subject: [PATCH 06/15] Add support for ppc64.
Subject: [PATCH 06/16] Add support for ppc64.
Note (1): This patch was rejected upstream because they don't have
appropriate hardware for testing.

View File

@ -1,7 +1,7 @@
From 834644b81c536fc81022a0a13f860fb33e3d78d2 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 24 Oct 2014 12:59:23 +0200
Subject: [PATCH 07/15] ppc64: Update for OCaml 4.02.0.
Subject: [PATCH 07/16] ppc64: Update for OCaml 4.02.0.
These are based on the power (ppc32) branch and some guesswork.
In particular, I'm not convinced that my changes to floating

View File

@ -1,7 +1,7 @@
From c89bde7d3563e2c7bb725272334fabf53044bd9c Mon Sep 17 00:00:00 2001
From: Michel Normand <normand@linux.vnet.ibm.com>
Date: Tue, 18 Mar 2014 09:15:47 -0400
Subject: [PATCH 08/15] Add support for ppc64le.
Subject: [PATCH 08/16] Add support for ppc64le.
Signed-off-by: Michel Normand <normand@linux.vnet.ibm.com>
---

View File

@ -1,7 +1,7 @@
From 8d86aba4983a254f36f2f1758079b3099ba5fc07 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 24 Oct 2014 12:59:23 +0200
Subject: [PATCH 09/15] ppc64le: Update for OCaml 4.02.0.
Subject: [PATCH 09/16] ppc64le: Update for OCaml 4.02.0.
These are based on the power (ppc32) branch and some guesswork. In
particular, I'm not convinced that my changes to floating point

View File

@ -1,7 +1,7 @@
From 4d08d0e8511e247a96440693b73773c72b04fee2 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 10 May 2014 03:20:35 -0400
Subject: [PATCH 10/15] arm, arm64: Mark stack as non-executable.
Subject: [PATCH 10/16] arm, arm64: Mark stack as non-executable.
The same fix as this one, which was only fully applied to
i686 & x86-64:

View File

@ -1,7 +1,7 @@
From 8ee89eee0500d17ffb91aa2febdeb6792ac53f27 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 1 Apr 2014 11:17:07 +0100
Subject: [PATCH 11/15] arg: Add no_arg and get_arg helper functions.
Subject: [PATCH 11/16] arg: Add no_arg and get_arg helper functions.
The no_arg function in this patch is a no-op. It will do something
useful in the followups.

View File

@ -1,7 +1,7 @@
From 350eab7918f0adf385e01411ae6fed3e0579145f Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 1 Apr 2014 11:21:40 +0100
Subject: [PATCH 12/15] arg: Allow flags such as --flag=arg as well as --flag
Subject: [PATCH 12/16] arg: Allow flags such as --flag=arg as well as --flag
arg.
Allow flags to be followed directly by their argument, separated by an '='

View File

@ -1,7 +1,7 @@
From 4072cbf56bba989f87783f285952d7227ba5898d Mon Sep 17 00:00:00 2001
From: Xavier Leroy <xavier.leroy@inria.fr>
Date: Wed, 27 Aug 2014 09:58:33 +0000
Subject: [PATCH 13/15] PR#6517: use ISO C99 types {,u}int{32,64}_t in
Subject: [PATCH 13/16] PR#6517: use ISO C99 types {,u}int{32,64}_t in
preference to our homegrown types {,u}int{32,64}.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15131 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

View File

@ -1,7 +1,7 @@
From 8e493f90181b8b592185b2f9322575113b5ff7d5 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 11 Sep 2014 14:49:54 +0100
Subject: [PATCH 14/15] ppc, ppc64, ppc64le: Mark stack as non-executable.
Subject: [PATCH 14/16] ppc, ppc64, ppc64le: Mark stack as non-executable.
The same fix as this one, which was only fully applied to
i686 & x86-64:

View File

@ -1,7 +1,7 @@
From df5201a35d02a13ad7ffd6fb38252851910cae43 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 24 Oct 2014 10:10:54 +0100
Subject: [PATCH 15/15] ppc64/ppc64le: proc: Interim definitions for op_is_pure
Subject: [PATCH 15/16] ppc64/ppc64le: proc: Interim definitions for op_is_pure
and regs_are_volatile.
See: https://bugzilla.redhat.com/show_bug.cgi?id=1156300

View File

@ -0,0 +1,79 @@
From d3ca0ccc0eccfecd4aa922decf99ca7d67d40fa7 Mon Sep 17 00:00:00 2001
From: Mark Shinwell <mshinwell@janestreet.com>
Date: Wed, 6 May 2015 17:37:43 +0000
Subject: [PATCH 16/16] Fix PR#6490: incorrect backtraces in gdb on AArch64.
(Also fixes the same problem for 32-bit ARM.)
git-svn-id: http://caml.inria.fr/svn/ocaml/version/4.02@16091 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
---
asmcomp/arm/emit.mlp | 4 +++-
asmcomp/arm64/emit.mlp | 6 ++++--
asmcomp/emitaux.ml | 9 +++++++++
asmcomp/emitaux.mli | 1 +
4 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/asmcomp/arm/emit.mlp b/asmcomp/arm/emit.mlp
index 61035b8..4948fb2 100644
--- a/asmcomp/arm/emit.mlp
+++ b/asmcomp/arm/emit.mlp
@@ -852,8 +852,10 @@ let fundecl fundecl =
let n = frame_size() in
if n > 0 then begin
ignore(emit_stack_adjustment (-n));
- if !contains_calls then
+ if !contains_calls then begin
+ cfi_offset ~reg:14 (* lr *) ~offset:(-4);
` str lr, [sp, #{emit_int(n - 4)}]\n`
+ end
end;
`{emit_label !tailrec_entry_point}:\n`;
emit_all 0 fundecl.fun_body;
diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp
index 734bd23..c5c30d4 100644
--- a/asmcomp/arm64/emit.mlp
+++ b/asmcomp/arm64/emit.mlp
@@ -654,8 +654,10 @@ let fundecl fundecl =
let n = frame_size() in
if n > 0 then
emit_stack_adjustment (-n);
- if !contains_calls then
- ` str x30, [sp, #{emit_int (n-8)}]\n`;
+ if !contains_calls then begin
+ cfi_offset ~reg:30 (* return address *) ~offset:(-8);
+ ` str x30, [sp, #{emit_int (n-8)}]\n`
+ end;
`{emit_label !tailrec_entry_point}:\n`;
emit_all fundecl.fun_body;
List.iter emit_call_gc !call_gc_sites;
diff --git a/asmcomp/emitaux.ml b/asmcomp/emitaux.ml
index 24a621b..ec2e8f0 100644
--- a/asmcomp/emitaux.ml
+++ b/asmcomp/emitaux.ml
@@ -195,6 +195,15 @@ let cfi_adjust_cfa_offset n =
emit_string "\t.cfi_adjust_cfa_offset\t"; emit_int n; emit_string "\n";
end
+let cfi_offset ~reg ~offset =
+ if is_cfi_enabled () then begin
+ emit_string "\t.cfi_offset ";
+ emit_int reg;
+ emit_string ", ";
+ emit_int offset;
+ emit_string "\n"
+ end
+
(* Emit debug information *)
(* This assoc list is expected to be very short *)
diff --git a/asmcomp/emitaux.mli b/asmcomp/emitaux.mli
index 486a583..e943da3 100644
--- a/asmcomp/emitaux.mli
+++ b/asmcomp/emitaux.mli
@@ -56,3 +56,4 @@ val is_generic_function: string -> bool
val cfi_startproc : unit -> unit
val cfi_endproc : unit -> unit
val cfi_adjust_cfa_offset : int -> unit
+val cfi_offset : reg:int -> offset:int -> unit
--
2.3.1

View File

@ -17,7 +17,7 @@
Name: ocaml
Version: 4.02.1
Release: 3%{?dist}
Release: 4%{?dist}
Summary: OCaml compiler and programming environment
@ -60,6 +60,7 @@ Patch0012: 0012-arg-Allow-flags-such-as-flag-arg-as-well-as-flag-arg.patch
Patch0013: 0013-PR-6517-use-ISO-C99-types-u-int-32-64-_t-in-preferen.patch
Patch0014: 0014-ppc-ppc64-ppc64le-Mark-stack-as-non-executable.patch
Patch0015: 0015-ppc64-ppc64le-proc-Interim-definitions-for-op_is_pur.patch
Patch0016: 0016-Fix-PR-6490-incorrect-backtraces-in-gdb-on-AArch64.-.patch
# Add BFD support so that ocamlobjinfo supports *.cmxs format (RHBZ#1113735).
BuildRequires: binutils-devel
@ -421,6 +422,9 @@ fi
%changelog
* Wed May 6 2015 Richard W.M. Jones <rjones@redhat.com> - 4.02.1-4
- Fix gdb stack traces on aarch64 (upstream PR6490). Thanks: Mark Shinwell.
* Thu Apr 23 2015 Richard W.M. Jones <rjones@redhat.com> - 4.02.1-3
- ppc, ppc64, ppc64le: Properly mark stack as non-executable.
The upstream fix was not applied completely.