* changed last parameter of g_indirect_sym_load() to a set and also

pass on whether the symbol refers to code or data (important for
    AIX weak symbols; note that AIX does not support undefined weak
    external symbols, and FPC does not yet support weakly defining
    non-external symbols, so this functionality isn't really used yet)

git-svn-id: trunk@20802 -
This commit is contained in:
Jonas Maebe 2012-04-11 18:02:03 +00:00
parent ac43eb9b70
commit 260958eb45
2 changed files with 18 additions and 6 deletions

View File

@ -45,6 +45,8 @@ unit cgobj;
type
talignment = (AM_NATURAL,AM_NONE,AM_2BYTE,AM_4BYTE,AM_8BYTE);
tsubsetloadopt = (SL_REG,SL_REGNOSRCMASK,SL_SETZERO,SL_SETMAX);
tindsymflag = (is_data,is_weak);
tindsymflags = set of tindsymflag;
{# @abstract(Abstract code generator)
This class implements an abstract instruction generator. Some of
@ -513,7 +515,7 @@ unit cgobj;
procedure g_intf_wrapper(list: TAsmList; procdef: tprocdef; const labelname: string; ioffset: longint);virtual;abstract;
procedure g_adjust_self_value(list:TAsmList;procdef: tprocdef;ioffset: tcgint);virtual;
function g_indirect_sym_load(list:TAsmList;const symname: string; weak: boolean): tregister;virtual;
function g_indirect_sym_load(list:TAsmList;const symname: string; const flags: tindsymflags): tregister;virtual;
{ generate a stub which only purpose is to pass control the given external method,
setting up any additional environment before doing so (if required).
@ -626,6 +628,8 @@ unit cgobj;
cg64 : tcg64;
{$endif cpu64bitalu}
function asmsym2indsymflags(sym: TAsmSymbol): tindsymflags;
procedure destroy_codegen;
implementation
@ -4174,7 +4178,7 @@ implementation
end;
function tcg.g_indirect_sym_load(list:TAsmList;const symname: string; weak: boolean): tregister;
function tcg.g_indirect_sym_load(list:TAsmList;const symname: string; const flags: tindsymflags): tregister;
var
l: tasmsymbol;
ref: treference;
@ -4195,7 +4199,7 @@ implementation
new_section(current_asmdata.asmlists[al_picdata],sec_data_nonlazy,'',sizeof(pint));
l:=current_asmdata.DefineAsmSymbol(nlsymname,AB_LOCAL,AT_DATA);
current_asmdata.asmlists[al_picdata].concat(tai_symbol.create(l,0));
if not(weak) then
if not(is_weak in flags) then
current_asmdata.asmlists[al_picdata].concat(tai_directive.Create(asd_indirect_symbol,current_asmdata.RefAsmSymbol(symname).Name))
else
current_asmdata.asmlists[al_picdata].concat(tai_directive.Create(asd_indirect_symbol,current_asmdata.WeakRefAsmSymbol(symname).Name));
@ -4210,8 +4214,8 @@ implementation
{ a_load_ref_reg will turn this into a pic-load if needed }
a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,result);
end;
end;
end;
end;
procedure tcg.g_maybe_got_init(list: TAsmList);
@ -4390,6 +4394,14 @@ implementation
end;
{$endif cpu64bitalu}
function asmsym2indsymflags(sym: TAsmSymbol): tindsymflags;
begin
result:=[];
if sym.typ<>AT_FUNCTION then
include(result,is_data);
if sym.bind=AB_WEAK_EXTERNAL then
include(result,is_weak);
end;
procedure destroy_codegen;
begin

View File

@ -506,7 +506,7 @@ unit cgx86;
((cs_create_pic in current_settings.moduleswitches) and
(ref.symbol.bind in [AB_COMMON,AB_GLOBAL,AB_PRIVATE_EXTERN])) then
begin
hreg:=g_indirect_sym_load(list,ref.symbol.name,ref.symbol.bind=AB_WEAK_EXTERNAL);
hreg:=g_indirect_sym_load(list,ref.symbol.name,asmsym2indsymflags(ref.symbol));
ref.symbol:=nil;
end
else
@ -919,7 +919,7 @@ unit cgx86;
(ref.symbol.bind in [AB_COMMON,AB_GLOBAL,AB_PRIVATE_EXTERN])) then
begin
reference_reset_base(tmpref,
g_indirect_sym_load(list,ref.symbol.name,ref.symbol.bind=AB_WEAK_EXTERNAL),
g_indirect_sym_load(list,ref.symbol.name,asmsym2indsymflags(ref.symbol)),
offset,sizeof(pint));
a_loadaddr_ref_reg(list,tmpref,r);
end