From 13758ea6f84f1c05c92a831060e1c3e217f24620 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Tue, 18 Nov 2014 10:35:16 +0000 Subject: [PATCH] Build with -mno-red-zone on x86_64 Otherwise, an interrupt may overwrite part of the stack if we're in checksum_stubs.c at the time. Should help with #80. Also added -fno-stack-protector in case that's on by default somewhere. --- CHANGES | 3 +++ _oasis | 4 +++- myocamlbuild.ml | 21 ++++++++++++++++++--- setup.ml | 15 +++++++++++---- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 20d63d5bb..3c3562c5c 100644 --- a/CHANGES +++ b/CHANGES @@ -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). diff --git a/_oasis b/_oasis index c90c776f4..14cf73dc9 100644 --- a/_oasis +++ b/_oasis @@ -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 diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 632e49d71..61e906591 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -1,5 +1,5 @@ (* OASIS_START *) -(* DO NOT EDIT (digest: 8cf23d699acb50bd658e3bbe11ab0ea1) *) +(* DO NOT EDIT (digest: 83f3486e958502c40c51b5ec3602efa4) *) module OASISGettext = struct (* # 22 "src/oasis/OASISGettext.ml" *) @@ -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 = [ @@ -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;; diff --git a/setup.ml b/setup.ml index 3c3e17f99..2f90f4125 100644 --- a/setup.ml +++ b/setup.ml @@ -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 @@ -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, [])]; @@ -7363,7 +7369,8 @@ 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 @@ -7371,6 +7378,6 @@ let setup_t = let setup () = BaseSetup.setup setup_t;; -# 7375 "setup.ml" +# 7382 "setup.ml" (* OASIS_STOP *) let () = setup ();;