mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 12:49:33 +02:00
* emit a weak symbol for the exception tag, since that's what the LLVM linker
wants to treat them as shared between .o files
This commit is contained in:
parent
f701d2f294
commit
cdf1ceca76
@ -47,7 +47,8 @@ interface
|
||||
AB_TEMP,
|
||||
{ a global symbol that points to another global symbol and is only used
|
||||
to allow indirect loading in case of packages and indirect imports }
|
||||
AB_INDIRECT,AB_EXTERNAL_INDIRECT);
|
||||
AB_INDIRECT,AB_EXTERNAL_INDIRECT,
|
||||
AB_WEAK);
|
||||
|
||||
TAsmsymtype=(
|
||||
AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,
|
||||
@ -89,7 +90,7 @@ interface
|
||||
asmlabeltypeprefix : array[TAsmLabeltype] of string[2] = ('j','a','d','l','f','t','c','eb','ee');
|
||||
asmsymbindname : array[TAsmsymbind] of string[23] = ('none', 'external','common',
|
||||
'local','global','weak external','private external','lazy','import','internal temp',
|
||||
'indirect','external indirect');
|
||||
'indirect','external indirect','weak');
|
||||
asmsymbindindirect = [AB_INDIRECT,AB_EXTERNAL_INDIRECT];
|
||||
|
||||
type
|
||||
|
@ -607,6 +607,7 @@ interface
|
||||
has_value : boolean;
|
||||
constructor Create(_sym:tasmsymbol;siz:longint);
|
||||
constructor Create_Global(_sym:tasmsymbol;siz:longint);
|
||||
constructor Create_Weak(_sym:tasmsymbol;siz:longint);
|
||||
constructor Createname(const _name : string;_symtyp:Tasmsymtype;siz:longint;def:tdef);
|
||||
constructor Createname_global(const _name : string;_symtyp:Tasmsymtype;siz:longint;def:tdef);
|
||||
constructor Createname_hidden(const _name : string;_symtyp:Tasmsymtype;siz:longint;def:tdef);
|
||||
@ -1449,6 +1450,19 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
constructor tai_symbol.Create_Weak(_sym:tasmsymbol;siz:longint);
|
||||
begin
|
||||
inherited Create;
|
||||
typ:=ait_symbol;
|
||||
sym:=_sym;
|
||||
size:=siz;
|
||||
if not(sym.bind in [AB_NONE,AB_WEAK_EXTERNAL]) then
|
||||
internalerror(2021092801);
|
||||
sym.bind:=AB_WEAK;
|
||||
is_global:=false;
|
||||
end;
|
||||
|
||||
|
||||
constructor tai_symbol.Createname(const _name : string;_symtyp:Tasmsymtype;siz:longint;def:tdef);
|
||||
begin
|
||||
inherited Create;
|
||||
|
@ -842,7 +842,7 @@ implementation
|
||||
|
||||
procedure TObjSymbol.SetAddress(apass:byte;aobjsec:TObjSection;abind:TAsmsymbind;atyp:Tasmsymtype);
|
||||
begin
|
||||
if not(abind in [AB_GLOBAL,AB_PRIVATE_EXTERN,AB_LOCAL,AB_COMMON,AB_IMPORT]) then
|
||||
if not(abind in [AB_GLOBAL,AB_PRIVATE_EXTERN,AB_LOCAL,AB_COMMON,AB_IMPORT,AB_WEAK]) then
|
||||
internalerror(200603016);
|
||||
if not assigned(aobjsec) then
|
||||
internalerror(200603017);
|
||||
|
@ -1497,6 +1497,8 @@ implementation
|
||||
WriteUleb(FWasmSymbolTable,WASM_SYM_BINDING_LOCAL)
|
||||
else if objsym.bind=AB_EXTERNAL then
|
||||
WriteUleb(FWasmSymbolTable,WASM_SYM_UNDEFINED)
|
||||
else if objsym.bind=AB_WEAK then
|
||||
WriteUleb(FWasmSymbolTable,WASM_SYM_BINDING_WEAK)
|
||||
else
|
||||
internalerror(2021092715);
|
||||
WriteUleb(FWasmSymbolTable,objsym.TagIndex);
|
||||
|
@ -691,7 +691,7 @@ implementation
|
||||
hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,0,excepttemps.reasonbuf);
|
||||
current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,4)); // jump to the 'finally' section
|
||||
|
||||
current_asmdata.CurrAsmList.concat(taicpu.op_sym(a_catch,current_asmdata.RefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
|
||||
current_asmdata.CurrAsmList.concat(taicpu.op_sym(a_catch,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
|
||||
thlcgwasm(hlcg).decblock;
|
||||
{ exceptionreason:=1 (exception) }
|
||||
hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,1,excepttemps.reasonbuf);
|
||||
|
@ -159,7 +159,7 @@ implementation
|
||||
procedure twasminlinenode.second_throw_fpcexception;
|
||||
begin
|
||||
location_reset(location,LOC_VOID,OS_NO);
|
||||
current_asmdata.CurrAsmList.Concat(taicpu.op_sym(a_throw,current_asmdata.RefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
|
||||
current_asmdata.CurrAsmList.Concat(taicpu.op_sym(a_throw,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
|
||||
end;
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ implementation
|
||||
if ts_wasm_native_exceptions in current_settings.targetswitches then
|
||||
begin
|
||||
list.Concat(tai_tagtype.create(FPC_EXCEPTION_TAG_SYM, []));
|
||||
list.Concat(tai_symbol.Create(current_asmdata.DefineAsmSymbol(FPC_EXCEPTION_TAG_SYM,AB_LOCAL,AT_WASM_EXCEPTION_TAG,nil),0));
|
||||
list.Concat(tai_symbol.Create_Weak(current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG),0));
|
||||
end;
|
||||
|
||||
for i:=0 to current_module.deflist.Count-1 do
|
||||
|
Loading…
Reference in New Issue
Block a user