diff --git a/src/SM.ml b/src/SM.ml index 8ac1c90a4..b72ad4e5b 100644 --- a/src/SM.ml +++ b/src/SM.ml @@ -1014,7 +1014,7 @@ class env cmd imports = {} method current_function = - match fundefs with Top _ -> "main" | Item (fd, _, _) -> fd.name + match fundefs with Top _ -> "_main" | Item (fd, _, _) -> fd.name method private import_imports = let paths = cmd#get_include_paths in @@ -1649,7 +1649,7 @@ let compile cmd ((imports, _), p) = LABEL topname; BEGIN ( topname, - (if topname = "main" then 2 else 0), + (if topname = "_main" then 2 else 0), env#nlocals, [], [], diff --git a/src/X86.ml b/src/X86.ml index 2dbda911f..6d91575db 100644 --- a/src/X86.ml +++ b/src/X86.ml @@ -742,7 +742,7 @@ let compile cmd env imports code = let env = env#enter f nargs nlocals has_closure in ( env, [ (* Meta (Printf.sprintf "\t.type %s, @function" name) *) ] - @ (if f = "main" then [] + @ (if f = "_main" then [] else [ (* Meta @@ -791,7 +791,7 @@ let compile cmd env imports code = Mov (r13, rsi); Mov (r14, rcx); ] - @ (if f = "main" then + @ (if f = "_main" then [ (* Align stack as main function is the only function that could be called without alignment. TODO *) Mov (L 0xF, rax); @@ -826,7 +826,7 @@ let compile cmd env imports code = Mov (rbp, rsp); Pop rbp; ] - @ (if name = "main" then [ Binop ("^", rax, rax) ] else []) + @ (if name = "_main" then [ Binop ("^", rax, rax) ] else []) @ [ Meta "\t.cfi_restore\t5"; Meta "\t.cfi_def_cfa\t4, 4"; @@ -1260,7 +1260,7 @@ class env prg = method gen_line = let lab = Printf.sprintf ".L%d" nlabels in ( {}, - if fname = "main" then + if fname = "_main" then [ (* Meta (Printf.sprintf "\t.stabn 68,0,%d,%s" line lab); *) Label lab ] else (if first_line then