Commit c351ab7d authored by John van Groningen's avatar John van Groningen
Browse files

report an error if the linker cannot open or create the

application file, instead of aborting
parent f3d04cae
......@@ -5,5 +5,5 @@ import linker2;
:: *Sections = Sections !*String !*String !Sections | EndSections;
write_output_file :: !Bool .{#Char} .Int !.Int !.Int !.LibraryList !.Int !.Int .Bool !*Sections !.Int !{#.Bool} !{#.Int} !*{#*Xcoff} *Files -> (!Bool,Int,Int,*Files);
write_output_file :: !Bool .{#Char} .Int !.Int !.Int !.LibraryList !.Int !.Int .Bool !*Sections !.Int !{#.Bool} !{#.Int} !*{#*Xcoff} *Files -> (!Bool,!String,Int,Int,*Files);
mark_modules :: !Int !Int !*[*Xcoff] !Int !Int !Int !LibraryList -> (![String],!Int,!{#Bool},!{#Int},!*{#*Xcoff});
......@@ -3,7 +3,7 @@ implementation module linker3;
import StdFile,StdArray,StdClass,StdEnum,StdInt,StdBool,StdChar;
from StdMisc import abort;
from StdList import ++;
from StdString import class %, +++.,instance toString Int;
from StdString import class %, +++.,instance toString Int,instance +++ {#Char};
import linker2,linker_resources;
import xcoff_linker;
......@@ -1094,7 +1094,7 @@ mark_modules main_symbol_n main_file_n xcoff_list1 n_xcoff_files n_libraries n_l
(n_xcoff_symbols,xcoff_list2) = n_symbols_of_xcoff_list 0 xcoff_list1;
}
write_output_file :: !Bool .{#Char} .Int !.Int !.Int !.LibraryList !.Int !.Int .Bool !*Sections !.Int !{#.Bool} !{#.Int} !*{#*Xcoff} *Files -> (!Bool,Int,Int,*Files);
write_output_file :: !Bool .{#Char} .Int !.Int !.Int !.LibraryList !.Int !.Int .Bool !*Sections !.Int !{#.Bool} !{#.Int} !*{#*Xcoff} *Files -> (!Bool,!String,Int,Int,*Files);
write_output_file generate_xcoff application_file_name n_xcoff_files n_libraries n_library_symbols library_list0
main_symbol_n main_file_n one_pass_link sections n_xcoff_symbols marked_bool_a1 marked_offset_a0 xcoff_a1 files2
| not generate_xcoff
......@@ -1106,12 +1106,12 @@ write_output_file generate_xcoff application_file_name n_xcoff_files n_libraries
n_xcoff_symbols marked_bool_a1 marked_offset_a0 xcoff_a1 files2;
*/
write_xcoff_file :: .{#Char} .Int !.Int !.Int !.LibraryList .Int .Int .Bool !*Sections !.Int {#.Bool} {#.Int} !*{#*Xcoff} *Files -> *(!Bool,Int,*Files);
write_xcoff_file :: .{#Char} .Int !.Int !.Int !.LibraryList .Int .Int .Bool !*Sections !.Int {#.Bool} {#.Int} !*{#*Xcoff} *Files -> *(!Bool,!String,Int,*Files);
write_xcoff_file application_file_name n_xcoff_files n_libraries n_library_symbols library_list0
main_symbol_n main_file_n one_pass_link sections
n_xcoff_symbols marked_bool_a1 marked_offset_a0 xcoff_a1
files2
= (ok,/* pef_text_section_size2 + */ pef_bss_section_end1,files5);
= (ok,"",/* pef_text_section_size2 + */ pef_bss_section_end1,files5);
{
(ok,files5)=fclose pef_file7 files4;
pef_file7 = pef_file4
......@@ -1169,13 +1169,16 @@ write_xcoff_file application_file_name n_xcoff_files n_libraries n_library_symbo
xcoff_list3 = xcoff_array_to_list 0 xcoff_a1;
}
//import StdDebug;
write_pef_file :: .{#Char} .Int !.Int !.Int !.LibraryList !.Int !.Int .Bool !*Sections !.Int {#.Bool} !{#.Int} !*{#*Xcoff} *Files -> *(!Bool,Int,Int,*Files);
write_pef_file :: .{#Char} .Int !.Int !.Int !.LibraryList !.Int !.Int .Bool !*Sections !.Int {#.Bool} !{#.Int} !*{#*Xcoff} *Files -> *(!Bool,!String,Int,Int,*Files);
write_pef_file application_file_name n_xcoff_files n_libraries n_library_symbols library_list0 main_symbol_n main_file_n one_pass_link sections
n_xcoff_symbols marked_bool_a1 marked_offset_a0 xcoff_a1 files2
// = abort (toString end_toc_offset);
= /*trace_n (toString end_toc_offset)*/ (ok,pef_bss_section_end1,end_toc_offset,files5);
{
| not open_pef_file_ok
= (False,"Error creating or opening application file "+++application_file_name,0,0,files3);
| not ok
= (False,"Error writing application file",pef_bss_section_end1,end_toc_offset,files5);
= (True,"",pef_bss_section_end1,end_toc_offset,files5);
{}{
(ok,files5)=fclose pef_file7 files4;
pef_file7 = pef_file4
THEN write_data_to_pef_files data_sections1 xcoff_list5 0 end_toc_offset marked_bool_a1 module_offset_a3 marked_offset_a0 symbols_a
......@@ -1197,7 +1200,7 @@ write_pef_file application_file_name n_xcoff_files n_libraries n_library_symbols
= write_code_to_output_files xcoff_list4 0 marked_bool_a1 module_offset_a3 marked_offset_a0 symbols_a one_pass_link sections1 pef_file0 files3;
pef_loader_section_size = 56+24*n_libraries+(n_imported_symbols<<2)+(n_loader_relocations<<1)+12+aligned_string_table_size+4;
(pef_file0,files3)
(open_pef_file_ok,pef_file0,files3)
= create_pef_file application_file_name pef_text_section_size1 pef_bss_section_end1 pef_loader_section_size files2;
(n_loader_relocations,loader_relocations) = count_and_reverse_relocations loader_relocations0;
......@@ -1313,23 +1316,20 @@ write_pef_loader library_list n_libraries n_imported_symbols string_table_file_n
= write_symbol_strings symbols (fwritec '\0' (fwrites symbol_name pef_file0));
}
create_pef_file :: !String Int Int Int !*Files -> *(*File,*Files);
create_pef_file :: !String Int Int Int !*Files -> *(!Bool,*File,*Files);
create_pef_file pef_file_name text_section_size data_section_size loader_section_size files0
| ok
= (file1,files1);
{}{
(ok,file0,files1) = fopen pef_file_name FWriteData files0;
# (ok,file0,files1) = fopen pef_file_name FWriteData files0;
| not ok
= (False,file0,files1);
# aligned_text_section_size=(text_section_size+15) bitand (-16);
aligned_data_section_size=(data_section_size+15) bitand (-16);
file1 = file0
FWS "Joy!peffpwpc" FWI 1 FWI 0 FWI 0 FWI 0 FWI 0 FWI 0x30002 FWI 0
FWI (-1) FWI 0 FWI text_section_size FWI text_section_size FWI text_section_size FWI 128 FWI 0x00010200
FWI (-1) FWI 0 FWI data_section_size FWI data_section_size FWI data_section_size FWI (128+aligned_text_section_size) FWI 0x01010300
FWI (-1) FWI 0 FWI 0 FWI 0 FWI loader_section_size FWI (128+aligned_text_section_size+aligned_data_section_size) FWI 0x04010000
FWI 0;
aligned_text_section_size=(text_section_size+15) bitand (-16);
aligned_data_section_size=(data_section_size+15) bitand (-16);
}
= (True,file1,files1);
write_loader_relocations :: !LoaderRelocations !*File -> *File;
write_loader_relocations EmptyRelocation pef_file0
......
......@@ -325,7 +325,7 @@ link_xcoff_files file_names library_file_names application_file_name font_info h
# (application_existed, files3)
= fexists application_file_name files2;
/* ... RWS */
# (ok,pef_application_size,end_toc_offset,files5)
# (ok,error_string,pef_application_size,end_toc_offset,files5)
= write_output_file generate_xcoff application_file_name
n_xcoff_files n_libraries n_library_symbols library_list0
main_symbol_n main_file_n one_pass_link sections
......@@ -333,7 +333,7 @@ link_xcoff_files file_names library_file_names application_file_name font_info h
| end_toc_offset > 64000 // DvA: initial guess...
= ((False,["Too many TOC-entries: "+++toString end_toc_offset]),files5);
| not ok
= ((False,["Link error"]),files5);
= ((False,["Link error: "+++error_string]),files5);
# (ok2,files6) = create_application_resource application_file_name (if add_carb_resource Carbon Classic) /* RWS ... */ application_existed /* ... RWS */ font_info heap_size heap_size_multiple stack_size flags
(pef_application_size+extra_application_memory) initial_heap_size memory_profile_minimum_heap_size files5;
| not ok2
......
Markdown is supported
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