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

always export _catch_exception_raise, _catch_exception_raise_state and...

always export _catch_exception_raise, _catch_exception_raise_state and _catch_exception_raise_state_identity
for mach exception handler
parent 7e4600b7
......@@ -104,9 +104,11 @@ create_xcoff_boolean_array n_xcoff_files n_xcoff_symbols list0
:: OffsetArray :== {#Int};
mark_used_modules :: !Int !Int !*{#Bool} !OffsetArray !*{#*Xcoff} Files -> (!*{#Bool},!*{#*Xcoff},!Files);
mark_used_modules main_symbol_n main_file_n marked_bool_a0 marked_offset_a xcoff_a files
= mark_used_module main_file_n main_symbol_n marked_offset_a xcoff_a marked_bool_a0 files;
mark_used_modules :: !Int !Int [(String,Int,Int)] !*{#Bool} !OffsetArray !*{#*Xcoff} Files -> (!*{#Bool},!*{#*Xcoff},!Files);
mark_used_modules main_symbol_n main_file_n exception_symbols marked_bool_a0 marked_offset_a xcoff_a files
# (marked_bool_a,xcoff_a,files) = mark_used_module main_file_n main_symbol_n marked_offset_a xcoff_a marked_bool_a0 files;
# (marked_bool_a,xcoff_a,files) = mark_used_exception_modules exception_symbols marked_offset_a xcoff_a marked_bool_a files;
= (marked_bool_a,xcoff_a,files);
{
mark_used_module :: Int Int OffsetArray *{#*Xcoff} *{#Bool} Files -> (!*{#Bool},!*{#*Xcoff},!Files);
mark_used_module file_n symbol_n marked_offset_a xcoff_a marked_bool_a0 files
......@@ -295,6 +297,12 @@ mark_used_modules main_symbol_n main_file_n marked_bool_a0 marked_offset_a xcoff
= mark_relocations_module relocation_n n_relocations relocation_string marked_bool_a xcoff_a1 files;
}
}
mark_used_exception_modules [(_,file_n,symbol_n):exception_symbols] marked_offset_a xcoff_a marked_bool_a files
# (marked_bool_a,xcoff_a,files) = mark_used_module file_n symbol_n marked_offset_a xcoff_a marked_bool_a files;
= mark_used_exception_modules exception_symbols marked_offset_a xcoff_a marked_bool_a files;
mark_used_exception_modules [] marked_offset_a xcoff_a marked_bool_a files
= (marked_bool_a,xcoff_a,files);
}
read_text_section_and_make_PPC_RELOC_BR14_and_24_relocations_scattered xcoff_a file_n symbol_n files
......@@ -707,14 +715,14 @@ compute_indirect_symbol_information indirect_symbols exported_indirect_symbol_n
}
}
write_indirect_symbol_table [] n_exported_indirect_symbols output_object_file
write_indirect_symbol_table [] n_exception_symbols first_undefined_symbol_n output_object_file
= output_object_file;
write_indirect_symbol_table [label_n:indirect_symbols] n_exported_indirect_symbols output_object_file
write_indirect_symbol_table [label_n:indirect_symbols] n_exception_symbols first_undefined_symbol_n output_object_file
| label_n>=0
# output_object_file = output_object_file FWI (label_n+1+n_exported_indirect_symbols);
= write_indirect_symbol_table indirect_symbols n_exported_indirect_symbols output_object_file;
# output_object_file = output_object_file FWI (~label_n);
= write_indirect_symbol_table indirect_symbols n_exported_indirect_symbols output_object_file;
# output_object_file = output_object_file FWI (label_n+first_undefined_symbol_n);
= write_indirect_symbol_table indirect_symbols n_exception_symbols first_undefined_symbol_n output_object_file;
# output_object_file = output_object_file FWI (n_exception_symbols-label_n);
= write_indirect_symbol_table indirect_symbols n_exception_symbols first_undefined_symbol_n output_object_file;
//split_data_symbol_lists_of_files2 :: !{#Int} !{#Bool} ![*SXcoff] -> [*SXcoff];
split_data_symbol_lists_of_files2 :: !{#Int} !{#Bool} ![*SXcoff] -> [SXcoff];
......@@ -1379,13 +1387,26 @@ write_nop_bytes_to_file n pe_file0
find_main_symbol :: NamesTable -> (!Bool,!Int,!Int);
find_main_symbol names_table0
# (main_names_table_element,_)=find_symbol_in_symbol_table "_main" names_table0;
= case (main_names_table_element) of {
= case main_names_table_element of {
(NamesTableElement _ symbol_n file_n _)
-> (True,symbol_n,file_n);
_
-> (False,0,0);
};
find_exception_symbols :: [String] NamesTable -> (![(String,Int,Int)],!NamesTable);
find_exception_symbols [] names_table
= ([],names_table);
find_exception_symbols [exception_symbol_name:exception_symbol_names] names_table
# (main_names_table_element,names_table)=find_symbol_in_symbol_table exception_symbol_name names_table;
= case main_names_table_element of {
(NamesTableElement _ symbol_n file_n _)
# (exception_symbols,names_table) = find_exception_symbols exception_symbol_names names_table;
-> ([(exception_symbol_name,file_n,symbol_n) : exception_symbols],names_table);
_
-> find_exception_symbols exception_symbol_names names_table;
};
link_mach_o_files :: ![String] !String !Files -> (!Bool,![String],!Files);
link_mach_o_files file_names application_file_name files
#! one_pass_link = True;
......@@ -1398,12 +1419,13 @@ link_mach_o_files file_names application_file_name files
| not_nil undefined_symbols
= (False,["Undefined symbols:" : undefined_symbols],files1);
*/
#! (main_symbol_error,main_symbol_n,main_file_n) = find_main_symbol names_table2;
# (exception_symbols,names_table3)=find_exception_symbols ["_catch_exception_raise","_catch_exception_raise_state","_catch_exception_raise_state_identity"] names_table2;
#! (main_symbol_error,main_symbol_n,main_file_n) = find_main_symbol names_table3;
| not main_symbol_error
= (False,["Symbol \"main\" not defined"],files1);
# undefined_symbols = reverse undefined_symbols;
#! (ok,files5)
= write_mach_o_file application_file_name n_xcoff_files xcoff_list1 undefined_symbols n_undefined_symbols main_symbol_n main_file_n one_pass_link sections files1;
= write_mach_o_file application_file_name n_xcoff_files xcoff_list1 exception_symbols undefined_symbols n_undefined_symbols main_symbol_n main_file_n one_pass_link sections files1;
| not ok
= (False,["Link error: Cannot write the application file '"+++application_file_name+++"'"],files5);
= (True,[],files5);
......@@ -1437,6 +1459,11 @@ compute_size_undefined_symbol_strings [undefined_symbol:undefined_symbols] size_
compute_size_undefined_symbol_strings [] size_undefined_symbol_strings
= size_undefined_symbol_strings;
count_exception_symbols_and_compute_size_strings [(exception_symbol_name,_,_):exception_symbols] size_exception_symbol_strings n_exception_symbols
= count_exception_symbols_and_compute_size_strings exception_symbols (size_exception_symbol_strings+size exception_symbol_name+1) (n_exception_symbols+1);
count_exception_symbols_and_compute_size_strings [] size_exception_symbol_strings n_exception_symbols
= (n_exception_symbols,size_exception_symbol_strings);
write_indirect_symbols_symbol_table [] first_indirect_symbol_string_offset output_object_file
= output_object_file;
write_indirect_symbols_symbol_table [(section_n,module_offset,string_offset):indirect_symbols] first_indirect_symbol_string_offset output_object_file
......@@ -1453,22 +1480,44 @@ write_undefined_symbols [undefined_symbol:undefined_symbols] string_offset pe_fi
write_undefined_symbols [] string_offset pe_file
= pe_file;
write_symbol_strings [symbol_name:symbol_names] pe_file
# pe_file=fwrites symbol_name pe_file;
# pe_file=fwritec '\000' pe_file;
= write_symbol_strings symbol_names pe_file;
write_symbol_strings [] pe_file
= pe_file;
write_exception_symbol_strings [(exception_symbol_name,_,_):exception_symbols] exec_file
# exec_file=fwrites exception_symbol_name exec_file;
# exec_file=fwritec '\000' exec_file;
= write_exception_symbol_strings exception_symbols exec_file;
write_exception_symbol_strings [] exec_file
= exec_file;
write_symbol_strings [symbol_name:symbol_names] exec_file
# exec_file=fwrites symbol_name exec_file;
# exec_file=fwritec '\000' exec_file;
= write_symbol_strings symbol_names exec_file;
write_symbol_strings [] exec_file
= exec_file;
write_function_symbol symbol_file_n symbol_n string_offset xcoff_a module_offset_a offset_a exe_file
# offset = case xcoff_a.[symbol_file_n].symbol_table.symbols.[symbol_n] of {
Module _ _ _ _ _ _ _
= module_offset_a.[offset_a.[symbol_file_n]+symbol_n];
Label _ label_offset section_symbol_n
= module_offset_a.[offset_a.[symbol_file_n]+section_symbol_n]+label_offset;
};
= exe_file FWI string_offset FWI (((N_SECT bitor N_EXT)<<24) bitor (1<<16)) FWI offset;
write_mach_o_file :: .{#Char} Int *[*SXcoff] [String] Int Int Int Bool *Sections *Files -> (!Bool,*Files);
write_mach_o_file application_file_name n_xcoff_files xcoff_list1 undefined_symbols n_undefined_symbols
write_exception_function_symbols [(exception_symbol_name,file_n,symbol_n):exception_symbols] string_offset xcoff_a2 module_offset_a2 offset_a exe_file
# exe_file = write_function_symbol file_n symbol_n string_offset xcoff_a2 module_offset_a2 offset_a exe_file;
= write_exception_function_symbols exception_symbols (string_offset+size exception_symbol_name+1) xcoff_a2 module_offset_a2 offset_a exe_file;
write_exception_function_symbols [] string_offset xcoff_a2 module_offset_a2 offset_a exe_file
= exe_file;
write_mach_o_file :: .{#Char} Int *[*SXcoff] [(String,Int,Int)] [String] Int Int Int Bool *Sections *Files -> (!Bool,*Files);
write_mach_o_file application_file_name n_xcoff_files xcoff_list1 exception_symbols undefined_symbols n_undefined_symbols
main_symbol_n main_file_n one_pass_link sections files
# (n_xcoff_symbols,xcoff_list2) = n_symbols_of_xcoff_list 0 xcoff_list1;
(marked_bool_a0,offset_a,xcoff_a0)
= create_xcoff_boolean_array n_xcoff_files n_xcoff_symbols xcoff_list2;
(marked_bool_a1,xcoff_a1,files) = mark_used_modules main_symbol_n main_file_n marked_bool_a0 offset_a xcoff_a0 files;
(marked_bool_a1,xcoff_a1,files) = mark_used_modules main_symbol_n main_file_n exception_symbols marked_bool_a0 offset_a xcoff_a0 files;
# (create_ok,pe_file,files) = fopen application_file_name FWriteData files;
| not create_ok
= (False,files);
......@@ -1503,22 +1552,16 @@ write_mach_o_file application_file_name n_xcoff_files xcoff_list1 undefined_symb
(indirect_symbol_table,indirect_symbols_symbol_table,indirect_symbol_strings,n_exported_indirect_symbols,indirect_symbol_strings_size)
= compute_indirect_symbol_information indirect_symbols 0 0 xcoff_a2 offset_a module_offset_a2 section_addresses;
main_offset=case xcoff_a2.[main_file_n].symbol_table.symbols.[main_symbol_n] of {
Module _ _ _ _ _ _ _
= module_offset_a2.[offset_a.[main_file_n]+main_symbol_n];
Label _ label_offset section_symbol_n
= module_offset_a2.[offset_a.[main_file_n]+section_symbol_n]+label_offset;
};
size_undefined_symbol_strings = compute_size_undefined_symbol_strings undefined_symbols 0;
(n_exception_symbols,size_exception_symbol_strings) = count_exception_symbols_and_compute_size_strings exception_symbols 0 0;
first_undefined_symbol_n = 1+n_exported_indirect_symbols;
first_undefined_symbol_n = 1+n_exception_symbols+n_exported_indirect_symbols;
pe_file
= write_mach_o_headers text_section_size_align_4 data_section_size_align_4 bss_section_size_align_4 stubs_section_size_align_4 lazy_pointers_section_size_align_4 non_lazy_pointers_section_size_align_4
n_code_relocations n_data_relocations n_stub_relocations n_lazy_pointers_relocations n_non_lazy_pointers_relocations
first_lazy_pointer_symbol_n first_non_lazy_pointer_symbol_n n_indirect_symbols
first_undefined_symbol_n n_undefined_symbols (7+indirect_symbol_strings_size+size_undefined_symbol_strings) pe_file;
first_undefined_symbol_n n_undefined_symbols (7+size_exception_symbol_strings+indirect_symbol_strings_size+size_undefined_symbol_strings) pe_file;
relocations = [];
(data_sections,stub_sections,lazy_pointer_sections,non_lazy_pointer_sections,relocations,pe_file,files4)
......@@ -1536,15 +1579,17 @@ write_mach_o_file application_file_name n_xcoff_files xcoff_list1 undefined_symb
THEN write_relocation_strings (reverse relocations);
pe_file=pe_file
THEN write_indirect_symbol_table indirect_symbol_table n_exported_indirect_symbols;
THEN write_indirect_symbol_table indirect_symbol_table n_exception_symbols first_undefined_symbol_n;
pe_file=pe_file
FWI 1 FWI (((N_SECT bitor N_EXT)<<24) bitor (1<<16)) FWI main_offset
THEN write_indirect_symbols_symbol_table indirect_symbols_symbol_table 7
THEN write_undefined_symbols undefined_symbols (7+indirect_symbol_strings_size);
THEN write_function_symbol main_file_n main_symbol_n 1 xcoff_a2 module_offset_a2 offset_a
THEN write_exception_function_symbols exception_symbols 7 xcoff_a2 module_offset_a2 offset_a
THEN write_indirect_symbols_symbol_table indirect_symbols_symbol_table (7+size_exception_symbol_strings)
THEN write_undefined_symbols undefined_symbols (7+size_exception_symbol_strings+indirect_symbol_strings_size);
pe_file=pe_file
FWS "\000_main\000"
THEN write_exception_symbol_strings exception_symbols
THEN write_symbol_strings indirect_symbol_strings
THEN write_symbol_strings undefined_symbols;
......
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