summaryrefslogtreecommitdiff
path: root/compiler/hlcgobj.pas
diff options
context:
space:
mode:
authorjonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2>2019-05-18 18:41:38 +0000
committerjonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2>2019-05-18 18:41:38 +0000
commitee6cf3731897481ba954345b82b17de5007165dc (patch)
tree390a4813f5c3fec4300ef2d2b0c440113843810f /compiler/hlcgobj.pas
parent65affd81051a52ec2c012d686af545e9e454164e (diff)
downloadfpc-ee6cf3731897481ba954345b82b17de5007165dc.tar.gz
* don't double-define function aliases for Darwin defined via ".set" directive
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@42095 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/hlcgobj.pas')
-rw-r--r--compiler/hlcgobj.pas43
1 files changed, 31 insertions, 12 deletions
diff --git a/compiler/hlcgobj.pas b/compiler/hlcgobj.pas
index 077e51026a..0a1b7f5704 100644
--- a/compiler/hlcgobj.pas
+++ b/compiler/hlcgobj.pas
@@ -4479,9 +4479,18 @@ implementation
var
firstitem,
item: TCmdStrListItem;
+ global: boolean;
begin
item:=TCmdStrListItem(current_procinfo.procdef.aliasnames.first);
firstitem:=item;
+ global:=
+ (cs_profile in current_settings.moduleswitches) or
+ { smart linking using a library requires to promote
+ all non-nested procedures to AB_GLOBAL
+ otherwise you get undefined symbol error at linking
+ for msdos target with -CX option for instance }
+ (create_smartlink_library and not is_nested_pd(current_procinfo.procdef)) or
+ (po_global in current_procinfo.procdef.procoptions);
while assigned(item) do
begin
{$ifdef arm}
@@ -4493,19 +4502,29 @@ implementation
subsections and be reordered }
if (item<>firstitem) and
(target_info.system in systems_darwin) then
- list.concat(tai_symbolpair.create(spk_set,item.str,firstitem.str));
- if (cs_profile in current_settings.moduleswitches) or
- { smart linking using a library requires to promote
- all non-nested procedures to AB_GLOBAL
- otherwise you get undefined symbol error at linking
- for msdos target with -CX option for instance }
- (create_smartlink_library and not is_nested_pd(current_procinfo.procdef)) or
- (po_global in current_procinfo.procdef.procoptions) then
- list.concat(Tai_symbol.createname_global(item.str,AT_FUNCTION,0,current_procinfo.procdef))
+ begin
+ { the .set already defines the symbol, so can't emit a tai_symbol as that will redefine it }
+ if global then
+ begin
+ list.concat(tai_symbolpair.create(spk_set_global,item.str,firstitem.str));
+ { needed for generating the tai_symbol_end }
+ current_asmdata.DefineAsmSymbol(item.str,AB_GLOBAL,AT_FUNCTION,current_procinfo.procdef);
+ end
+ else
+ begin
+ list.concat(tai_symbolpair.create(spk_set,item.str,firstitem.str));
+ current_asmdata.DefineAsmSymbol(item.str,AB_LOCAL,AT_FUNCTION,current_procinfo.procdef);
+ end;
+ end
else
- list.concat(Tai_symbol.createname(item.str,AT_FUNCTION,0,current_procinfo.procdef));
- if not(af_stabs_use_function_absolute_addresses in target_asm.flags) then
- list.concat(Tai_function_name.create(item.str));
+ begin
+ if global then
+ list.concat(Tai_symbol.createname_global(item.str,AT_FUNCTION,0,current_procinfo.procdef))
+ else
+ list.concat(Tai_symbol.createname(item.str,AT_FUNCTION,0,current_procinfo.procdef));
+ if not(af_stabs_use_function_absolute_addresses in target_asm.flags) then
+ list.concat(Tai_function_name.create(item.str));
+ end;
item:=TCmdStrListItem(item.next);
end;
current_procinfo.procdef.procstarttai:=tai(list.last);