Skip to content

Commit

Permalink
Build with -mno-red-zone on x86_64
Browse files Browse the repository at this point in the history
Otherwise, an interrupt may overwrite part of the stack if we're in
checksum_stubs.c at the time. Should help with mirage#80.

Also added -fno-stack-protector in case that's on by default somewhere.
  • Loading branch information
talex5 committed Nov 18, 2014
1 parent 3f1286e commit 13758ea
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
trunk
* Build with -mno-red-zone on x86_64 to avoid stack corruption on Xen (#80).

2.0.2 (2014-11-17):
* Add IPv4 multicast to MAC address mapping in IPv4 output processing (#81 from Luke Dunstan).

Expand Down
4 changes: 3 additions & 1 deletion _oasis
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Library tcpip
Findlibname: tcpip
Modules: Wire_structs, Tcpip_checksum
CSources: checksum_stubs.c
CCOpt: -O2
CCOpt: -O2 -fno-stack-protector
if architecture(amd64)
CCOpt+: -mno-red-zone
BuildDepends: io-page,mirage-types,ipaddr,cstruct

Library ethif
Expand Down
21 changes: 18 additions & 3 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* OASIS_START *)
(* DO NOT EDIT (digest: 8cf23d699acb50bd658e3bbe11ab0ea1) *)
(* DO NOT EDIT (digest: 83f3486e958502c40c51b5ec3602efa4) *)
module OASISGettext = struct
(* # 22 "src/oasis/OASISGettext.ml" *)

Expand Down Expand Up @@ -630,7 +630,22 @@ let package_default =
flags =
[
(["oasis_library_tcpip_ccopt"; "compile"],
[(OASISExpr.EBool true, S [A "-ccopt"; A "-O2"])])
[
(OASISExpr.EBool true,
S
[A "-ccopt"; A "-O2"; A "-ccopt"; A "-fno-stack-protector"
]);
(OASISExpr.ETest ("architecture", "amd64"),
S
[
A "-ccopt";
A "-O2";
A "-ccopt";
A "-fno-stack-protector";
A "-ccopt";
A "-mno-red-zone"
])
])
];
includes =
[
Expand All @@ -646,6 +661,6 @@ let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}

let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;

# 650 "myocamlbuild.ml"
# 665 "myocamlbuild.ml"
(* OASIS_STOP *)
Ocamlbuild_plugin.dispatch dispatch_default;;
15 changes: 11 additions & 4 deletions setup.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(* setup.ml generated for the first time by OASIS v0.4.4 *)

(* OASIS_START *)
(* DO NOT EDIT (digest: 4af05bc101d701a86cf0b9050bf09c4e) *)
(* DO NOT EDIT (digest: afa7409e50063a7b83afea40454cf72f) *)
(*
Regenerated by OASIS v0.4.5
Visit http://oasis.forge.ocamlcore.org for more information and
Expand Down Expand Up @@ -6747,7 +6747,13 @@ let setup_t =
bs_build_tools = [ExternalTool "ocamlbuild"];
bs_c_sources = ["checksum_stubs.c"];
bs_data_files = [];
bs_ccopt = [(OASISExpr.EBool true, ["-O2"])];
bs_ccopt =
[
(OASISExpr.EBool true,
["-O2"; "-fno-stack-protector"]);
(OASISExpr.ETest ("architecture", "amd64"),
["-O2"; "-fno-stack-protector"; "-mno-red-zone"])
];
bs_cclib = [(OASISExpr.EBool true, [])];
bs_dlllib = [(OASISExpr.EBool true, [])];
bs_dllpath = [(OASISExpr.EBool true, [])];
Expand Down Expand Up @@ -7363,14 +7369,15 @@ let setup_t =
};
oasis_fn = Some "_oasis";
oasis_version = "0.4.5";
oasis_digest = Some "\004\158,\155O¯8g\006®\159\142£Õ";
oasis_digest =
Some "\201\031\1524\165\005\127\177\152F\167\130\223\200\r\143";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
};;

let setup () = BaseSetup.setup setup_t;;

# 7375 "setup.ml"
# 7382 "setup.ml"
(* OASIS_STOP *)
let () = setup ();;

0 comments on commit 13758ea

Please sign in to comment.