Commit 234f7a03 authored by Diederik van Arkel's avatar Diederik van Arkel
Browse files

improved macho linker communication;

parent 3cbf7de4
......@@ -552,14 +552,19 @@ Link linker` winfun path
+++ "'"
// +++ " -g" // for debugging syms
+++ if (ss > standard_mosx_stack) (" -stack-size " +++ stack_size) ""
);
)(to_unix_path linkerrspath/*startupdir +++ "/linker_out"*/);
| r1==r1
# application_existed = False;
# (resources_ok,ps) = accFiles (create_application_resource path MachO application_existed (fs,fn) hs heap_size_multiple ss flags
0 initial_heap_size minheap) ps
= (ps,True)
= (winfun ["Linker error: "+++toString r1] ps,False)
| r1==(-1)
= (winfun ["Linker error: Could not start the linker (/usr/bin/cc)."] ps,False)
| r2<>0
# ((errtext_not_empty,errtext),ps) = accFiles (ReadLinkInfo linkerrspath) ps;
= (winfun ["Linker error: Linker returned with error code." : StrictListToList errtext] ps, False)
// otherwise
# application_existed = False;
# (resources_ok,ps) = accFiles (create_application_resource path MachO application_existed (fs,fn) hs heap_size_multiple ss flags
0 initial_heap_size minheap) ps
# ((errtext_not_empty,errtext),ps) = accFiles (ReadLinkInfo linkerrspath) ps;
= (winfun (StrictListToList errtext) ps, True)
# ((link_ok,link_errors),ps)
= accFiles (link_xcoff_files objectFileNames libraryFileNames path
(fs,fn) hs heap_size_multiple ss flags em initial_heap_size minheap False (if (ProcessorSuffix processor == ".xo") True False)/*add_carb_resource*/) ps
......@@ -601,6 +606,38 @@ hex_int i
= hex ((i bitand 0xff000000) >> 24);
= /*"0x" +++ */ b3 +++ b2 +++ b1 +++ b0;
ReadLinkInfo :: !Pathname !*Files -> ((!Bool, !List String), !*Files)
ReadLinkInfo path env
# (opened,file,env) = fopen path FReadData env
| not opened
= ((False,Nil),env)
# (errlist,errors,file`) = ReadLinkMsg file
(_,env) = fclose file` env
= ((errors,errlist),env)
ReadLinkMsg :: !*File -> (!List String,!Bool,!*File)
ReadLinkMsg file
# (string,file) = freadline file
(eof,file) = fend file
| eof && IsLinkerErrorMsg string
= (Strip string :! Nil,True,file)
| eof
= (Nil,False,file)
# (errmsg,_,file) = ReadLinkMsg file
= (Strip string :! errmsg,True,file)
// IsLinkerErrorMsg :: !String -> Bool;
IsLinkerErrorMsg str :== not (LayOut 0 (size str) str);
where
LayOut :: !Int !Int !String -> Bool
LayOut pos len str
| pos >= len = True
| layout = LayOut (inc pos) len str
= False
where
layout = curchar == ' ' || curchar == '\t'
curchar = str.[pos]
//
isMachOObject object = equal_suffix ".o" object
......@@ -634,20 +671,20 @@ where
= to_unix_path (inc i) (p % (0,i-1)+++"/"+++p % (i+1,size p-1));
= to_unix_path (inc i) p;
*/
fork_execv_waitpid :: !String -> Int;
fork_execv_waitpid s = code (s=CD0)(r=D0){
call .fork_execv_waitpid
};
send_command_to_application :: !Bool !String !String -> (!Int,!Int);
send_command_to_application _ _ s
# r=fork_execv_waitpid (s+++"\0");
| r == 0
= (0,0);
= (0,r);
// | r==(-1)
// = (-1,-1);
// = (0,0);
fork_execv_waitpid :: !String !String -> (!Int,!Int);
fork_execv_waitpid s stdout_file_name
= code {
ccall fork_execv_waitpid "ss:II"
};
send_command_to_application :: !Bool !String !String !String -> (!Int,!Int);
send_command_to_application _ _ s stdout_file_name
# (r,status)=fork_execv_waitpid (s+++"\0") (stdout_file_name+++"\0");
| r==(-1)
= (-1,-1);
| status bitand 0177<>0
= (-1,status);
= (0,status>>8);
/*
Link_ppc winfun path u_system_file_name paths defs
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment