diff options
author | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-08-20 07:22:00 +0000 |
---|---|---|
committer | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-08-20 07:22:00 +0000 |
commit | 19a0a17aee02f48c6d9bd7c9d37b6f5595b27f58 (patch) | |
tree | 5c5e41facf57ef4825e7b3b24cf64955e807a594 | |
parent | c2fcb6231f55b2c2e0881dee4faf3d44cf8abcc6 (diff) | |
download | fpc-19a0a17aee02f48c6d9bd7c9d37b6f5595b27f58.tar.gz |
* tprocdef.mangledname now gets an extra boolean parameter indicating
whether the mangled name is for defining a symbol, or for referencing
it later (e.g. for a call or load of its address). The reason is that
on the JVM both cases are different.
+ jvmdef unit to encode types according to the JVM rules
+ tprocdef.jvmmangledname() to encode a procdef's JVM mangled name
(the common part of defining/referencing it; tprocdef.mangledname
afterwards adorns it as required)
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/jvmbackend@18288 3ad0048d-3df7-0310-abae-a5850022a9f2
41 files changed, 511 insertions, 90 deletions
diff --git a/compiler/arm/cgcpu.pas b/compiler/arm/cgcpu.pas index 8623c6a357..8f63194b0e 100644 --- a/compiler/arm/cgcpu.pas +++ b/compiler/arm/cgcpu.pas @@ -2497,7 +2497,7 @@ unit cgcpu; end { case 0 } else - list.concat(taicpu.op_sym(A_B,current_asmdata.RefAsmSymbol(procdef.mangledname))); + list.concat(taicpu.op_sym(A_B,current_asmdata.RefAsmSymbol(procdef.mangledname(false)))); list.concatlist(current_procinfo.aktlocaldata); current_procinfo.Free; diff --git a/compiler/dbgdwarf.pas b/compiler/dbgdwarf.pas index bf95586ddd..7444590748 100644 --- a/compiler/dbgdwarf.pas +++ b/compiler/dbgdwarf.pas @@ -2097,7 +2097,7 @@ implementation ]) else append_entry(DW_TAG_subprogram,true, - [DW_AT_name,DW_FORM_string,def.mangledname+#0 + [DW_AT_name,DW_FORM_string,def.mangledname(false)+#0 { data continues below } { problem: base reg isn't known here DW_AT_frame_base,DW_FORM_block1,1 @@ -2152,9 +2152,9 @@ implementation current_asmdata.asmlists[al_procedures].insertbefore(tai_label.create(procendlabel),def.procendtai); if (target_info.system = system_powerpc64_linux) then - procentry := '.' + def.mangledname + procentry := '.' + def.mangledname(false) else - procentry := def.mangledname; + procentry := def.mangledname(false); append_labelentry(DW_AT_low_pc,current_asmdata.RefAsmSymbol(procentry)); append_labelentry(DW_AT_high_pc,procendlabel); diff --git a/compiler/dbgstabs.pas b/compiler/dbgstabs.pas index 06d8694b90..91f7fb0d50 100644 --- a/compiler/dbgstabs.pas +++ b/compiler/dbgstabs.pas @@ -1058,13 +1058,13 @@ implementation ss:=tostr(N_LBRAC)+',0,0,'; if target_info.cpu=cpu_powerpc64 then ss:=ss+'.'; - ss:=ss+def.mangledname; + ss:=ss+def.mangledname(false); if not(af_stabs_use_function_absolute_addresses in target_asm.flags) then begin ss:=ss+'-'; if target_info.cpu=cpu_powerpc64 then ss:=ss+'.'; - ss:=ss+def.mangledname; + ss:=ss+def.mangledname(false); end; templist.concat(Tai_stab.Create_ansistr(stab_stabn,ss)); // RBRAC @@ -1074,7 +1074,7 @@ implementation ss:=ss+'-'; if target_info.cpu=cpu_powerpc64 then ss:=ss+'.'; - ss:=ss+def.mangledname; + ss:=ss+def.mangledname(false); end; templist.concat(Tai_stab.Create_ansistr(stab_stabn,ss)); @@ -1091,7 +1091,7 @@ implementation { including the LBRAC/RBRAC ones } if (target_info.system in systems_darwin) then templist.concat(Tai_stab.create(stab_stabs, - strpnew('"",'+tostr(N_FUNCTION)+',0,0,'+stabsendlabel.name+'-'+def.mangledname))); + strpnew('"",'+tostr(N_FUNCTION)+',0,0,'+stabsendlabel.name+'-'+def.mangledname(false)))); current_asmdata.asmlists[al_procedures].insertlistafter(def.procendtai,templist); @@ -1123,7 +1123,7 @@ implementation assigned(tprocdef(def.owner.defowner).procsym) then info := ','+GetSymName(def.procsym)+','+GetSymName(tprocdef(def.owner.defowner).procsym); end; - templist.concat(Tai_stab.Create_ansistr(stab_stabs,'"'+ansistring(obj)+':'+RType+def_stab_number(def.returndef)+info+'",'+tostr(n_function)+',0,'+tostr(def.fileinfo.line)+','+ansistring(def.mangledname))); + templist.concat(Tai_stab.Create_ansistr(stab_stabs,'"'+ansistring(obj)+':'+RType+def_stab_number(def.returndef)+info+'",'+tostr(n_function)+',0,'+tostr(def.fileinfo.line)+','+ansistring(def.mangledname(false)))); current_asmdata.asmlists[al_procedures].insertlistbefore(def.procstarttai,templist); diff --git a/compiler/export.pas b/compiler/export.pas index d363d7434a..95499841e8 100644 --- a/compiler/export.pas +++ b/compiler/export.pas @@ -135,13 +135,13 @@ procedure exportname(const s : string; options: word); var item: TCmdStrListItem; begin - exportprocsym(sym,pd.mangledname,0,options); + exportprocsym(sym,pd.mangledname(false),0,options); { walk through all aliases } item:=TCmdStrListItem(pd.aliasnames.first); while assigned(item) do begin { avoid duplicate entries, sometimes aliasnames contains the mangledname } - if item.str<>pd.mangledname then + if item.str<>pd.mangledname(false) then exportprocsym(sym,item.str,0,options); item:=TCmdStrListItem(item.next); end; diff --git a/compiler/expunix.pas b/compiler/expunix.pas index ffc4727714..992832bed5 100644 --- a/compiler/expunix.pas +++ b/compiler/expunix.pas @@ -157,7 +157,7 @@ begin (target_info.system in [system_i386_freebsd,system_x86_64_freebsd,system_x86_64_linux,system_i386_linux,system_x86_64_solaris,system_i386_solaris]) then begin {$ifdef x86} - sym:=current_asmdata.RefAsmSymbol(pd.mangledname); + sym:=current_asmdata.RefAsmSymbol(pd.mangledname(false)); reference_reset_symbol(r,sym,0,sizeof(pint)); if cs_create_pic in current_settings.moduleswitches then r.refaddr:=addr_pic @@ -167,7 +167,7 @@ begin {$endif x86} end else - cg.a_jmp_name(current_asmdata.asmlists[al_procedures],pd.mangledname); + cg.a_jmp_name(current_asmdata.asmlists[al_procedures],pd.mangledname(false)); current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^)); end; exportedsymnames.insert(hp2.name^); diff --git a/compiler/hlcgobj.pas b/compiler/hlcgobj.pas index 0da399e7e7..99ef360c88 100644 --- a/compiler/hlcgobj.pas +++ b/compiler/hlcgobj.pas @@ -1526,7 +1526,7 @@ implementation procedure thlcgobj.gen_proc_symbol_end(list: TAsmList); begin - list.concat(Tai_symbol_end.Createname(current_procinfo.procdef.mangledname)); + list.concat(Tai_symbol_end.Createname(current_procinfo.procdef.mangledname(true))); current_procinfo.procdef.procendtai:=tai(list.last); diff --git a/compiler/i386/cgcpu.pas b/compiler/i386/cgcpu.pas index 863638d3e7..49a0cded8a 100644 --- a/compiler/i386/cgcpu.pas +++ b/compiler/i386/cgcpu.pas @@ -705,11 +705,11 @@ unit cgcpu; begin if (target_info.system <> system_i386_darwin) then begin - lab:=current_asmdata.RefAsmSymbol(procdef.mangledname); + lab:=current_asmdata.RefAsmSymbol(procdef.mangledname(false)); list.concat(taicpu.op_sym(A_JMP,S_NO,lab)) end else - list.concat(taicpu.op_sym(A_JMP,S_NO,get_darwin_call_stub(procdef.mangledname,false))) + list.concat(taicpu.op_sym(A_JMP,S_NO,get_darwin_call_stub(procdef.mangledname(false),false))) end; List.concat(Tai_symbol_end.Createname(labelname)); diff --git a/compiler/jvmdef.pas b/compiler/jvmdef.pas new file mode 100644 index 0000000000..18f15a524f --- /dev/null +++ b/compiler/jvmdef.pas @@ -0,0 +1,222 @@ +{ + Copyright (c) 2010 by Jonas Maebe + + This unit implements some JVM type helper routines (minimal + unit dependencies, usable in symdef). + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + **************************************************************************** +} + +{$i fpcdefs.inc} + +unit jvmdef; + +interface + + uses + node, + symtype; + + { Encode a type into the internal format used by the JVM (descriptor). + Returns false if a type is not representable by the JVM, + and in that case also the failing definition. } + function jvmtryencodetype(def: tdef; out encodedtype: ansistring; out founderror: tdef): boolean; + + { Check whether a type can be used in a JVM methom signature or field + declaration. } + function jvmchecktype(def: tdef; out founderror: tdef): boolean; + + function jvmaddencodedtype(def: tdef; bpacked: boolean; var encodedstr: ansistring; out founderror: tdef): boolean; + +implementation + + uses + globtype, + cutils,cclasses, + verbose,systems, + symtable,symconst,symsym,symdef, + defutil,paramgr; + +{****************************************************************** + Type encoding +*******************************************************************} + + function jvmaddencodedtype(def: tdef; bpacked: boolean; var encodedstr: ansistring; out founderror: tdef): boolean; + var + recname: ansistring; + recdef: trecorddef; + objdef: tobjectdef; + len: aint; + c: char; + addrpara: boolean; + begin + result:=true; + case def.typ of + stringdef : + begin + case tstringdef(def).stringtype of + { translated into Java.Lang.String } + st_widestring: + encodedstr:=encodedstr+'Ljava/lang/String;'; + else + { May be handled via wrapping later } + result:=false; + end; + end; + enumdef, + orddef : + begin + { for procedure "results" } + if is_void(def) then + c:='V' + { only Pascal-style booleans conform to Java's definition of + Boolean } + else if is_pasbool(def) and + (def.size=1) then + c:='Z' + else if is_widechar(def) then + c:='C' + else + begin + case def.size of + 1: + c:='B'; + 2: + c:='S'; + 4: + c:='I'; + 8: + c:='J'; + else + internalerror(2010121905); + end; + end; + encodedstr:=encodedstr+c; + end; + pointerdef : + begin + { some may be handled via wrapping later } + result:=false; + end; + floatdef : + begin + case tfloatdef(def).floattype of + s32real: + c:='F'; + s64real: + c:='D'; + else + result:=false; + end; + encodedstr:=encodedstr+c; + end; + filedef : + result:=false; + recorddef : + begin + { will be hanlded via wrapping later, although wrapping may + happen at higher level } + result:=false; + end; + variantdef : + begin + { will be hanlded via wrapping later, although wrapping may + happen at higher level } + result:=false; + end; + classrefdef : + begin + { may be handled via wrapping later } + result:=false; + end; + setdef : + begin + { will be hanlded via wrapping later, although wrapping may + happen at higher level } + result:=false; + end; + formaldef : + begin + { not supported (may be changed into "java.lang.Object" later) } + result:=false; + end; + arraydef : + begin + if is_array_of_const(def) or + is_open_array(def) or + is_packed_array(def) then + result:=false + else + begin + encodedstr:=encodedstr+'['; + if not jvmaddencodedtype(tarraydef(def).elementdef,false,encodedstr,founderror) then + begin + result:=false; + { report the exact (nested) error defintion } + exit; + end; + end; + end; + procvardef : + begin + { will be hanlded via wrapping later, although wrapping may + happen at higher level } + result:=false; + end; + objectdef : + case tobjectdef(def).objecttype of + odt_javaclass, + odt_interfacejava: + encodedstr:=encodedstr+'L'+tobjectdef(def).objextname^+';'; + else + result:=false; + end; + undefineddef, + errordef : + result:=false; + procdef : + { must be done via jvmencodemethod() } + internalerror(2010121903); + else + internalerror(2010121904); + end; + if not result then + founderror:=def; + end; + + + function jvmtryencodetype(def: tdef; out encodedtype: ansistring; out founderror: tdef): boolean; + begin + result:=jvmaddencodedtype(def,false,encodedtype,founderror); + end; + + +{****************************************************************** + jvm type validity checking +*******************************************************************} + + function jvmchecktype(def: tdef; out founderror: tdef): boolean; + var + encodedtype: ansistring; + begin + { don't duplicate the code like in objcdef, since the resulting strings + are much shorter here so it's not worth it } + result:=jvmtryencodetype(def,encodedtype,founderror); + end; + + +end. diff --git a/compiler/m68k/cgcpu.pas b/compiler/m68k/cgcpu.pas index a98ffce61b..5d812b4303 100644 --- a/compiler/m68k/cgcpu.pas +++ b/compiler/m68k/cgcpu.pas @@ -1613,7 +1613,7 @@ unit cgcpu; end { case 0 } else -// list.concat(taicpu.op_sym(A_B,current_asmdata.RefAsmSymbol(procdef.mangledname))); +// list.concat(taicpu.op_sym(A_B,current_asmdata.RefAsmSymbol(procdef.mangledname(false)))); List.concat(Tai_symbol_end.Createname(labelname)); end; diff --git a/compiler/m68k/ra68kmot.pas b/compiler/m68k/ra68kmot.pas index b61ecbe50b..eb6c3d0f5c 100644 --- a/compiler/m68k/ra68kmot.pas +++ b/compiler/m68k/ra68kmot.pas @@ -699,7 +699,7 @@ const begin if tprocsym(sym).procdeflist.count>1 then Message(asmr_w_calling_overload_func); - hs:=tprocdef(tprocsym(sym).procdeflist[0]).mangledname; + hs:=tprocdef(tprocsym(sym).procdeflist[0]).mangledname(false); end; typesym : begin diff --git a/compiler/mips/cgcpu.pas b/compiler/mips/cgcpu.pas index a145800cab..7b655a64b9 100644 --- a/compiler/mips/cgcpu.pas +++ b/compiler/mips/cgcpu.pas @@ -1686,7 +1686,7 @@ begin op_onr24methodaddr; end else - list.concat(taicpu.op_sym(A_B,current_asmdata.RefAsmSymbol(procdef.mangledname))); + list.concat(taicpu.op_sym(A_B,current_asmdata.RefAsmSymbol(procdef.mangledname(false)))); { Delay slot } list.Concat(TAiCpu.Op_none(A_NOP)); diff --git a/compiler/ncal.pas b/compiler/ncal.pas index c5bb0c5a08..456da83431 100644 --- a/compiler/ncal.pas +++ b/compiler/ncal.pas @@ -1722,7 +1722,7 @@ implementation begin if assigned(current_procinfo) and not(po_inline in current_procinfo.procdef.procoptions) and - not wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname) then + not wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname(true)) then begin {$ifdef debug_deadcode} writeln(' NOT adding creadion of ',def.typename,' because performed in dead stripped proc: ',current_procinfo.procdef.typename); @@ -1918,7 +1918,7 @@ implementation (srsym.typ<>procsym) or (tprocsym(srsym).ProcdefList.count<>1) then Message1(cg_f_unknown_compilerproc,'objc.'+msgsendname); - fobjcforcedprocname:=stringdup(tprocdef(tprocsym(srsym).ProcdefList[0]).mangledname); + fobjcforcedprocname:=stringdup(tprocdef(tprocsym(srsym).ProcdefList[0]).mangledname(false)); { B) Handle self } { 1) in case of sending a message to a superclass, self is a pointer to @@ -3862,7 +3862,7 @@ implementation {$ifdef DEBUGINLINE} writeln; - writeln('**************************',tprocdef(procdefinition).mangledname); + writeln('**************************',tprocdef(procdefinition).mangledname(false)); printnode(output,result); {$endif DEBUGINLINE} end; diff --git a/compiler/ncgcal.pas b/compiler/ncgcal.pas index 817b5e134b..81c848c8d1 100644 --- a/compiler/ncgcal.pas +++ b/compiler/ncgcal.pas @@ -701,7 +701,7 @@ implementation assigned(methodpointer) and (methodpointer.nodetype<>typen) and (not assigned(current_procinfo) or - wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname)) then + wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname(true))) then tobjectdef(tprocdef(procdefinition).struct).register_vmt_call(tprocdef(procdefinition).extnumber); {$ifdef vtentry} if not is_interface(tprocdef(procdefinition)._class) then @@ -748,7 +748,7 @@ implementation vmtoffset:=tobjectdef(tprocdef(procdefinition).struct).vmtmethodoffset(tprocdef(procdefinition).extnumber); { register call for WPO } if (not assigned(current_procinfo) or - wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname)) then + wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname(true))) then tobjectdef(tprocdef(procdefinition).struct).register_vmt_call(tprocdef(procdefinition).extnumber); {$ifndef x86} pvreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_ADDR); @@ -809,7 +809,7 @@ implementation extra_interrupt_code; extra_call_code; if (name_to_call='') then - cg.a_call_name(current_asmdata.CurrAsmList,tprocdef(procdefinition).mangledname,po_weakexternal in procdefinition.procoptions) + cg.a_call_name(current_asmdata.CurrAsmList,tprocdef(procdefinition).mangledname(false),po_weakexternal in procdefinition.procoptions) else cg.a_call_name(current_asmdata.CurrAsmList,name_to_call,po_weakexternal in procdefinition.procoptions); extra_post_call_code; diff --git a/compiler/ncgld.pas b/compiler/ncgld.pas index cac77973d9..324e90d7a0 100644 --- a/compiler/ncgld.pas +++ b/compiler/ncgld.pas @@ -500,7 +500,7 @@ implementation not is_objectpascal_helper(procdef.struct) then begin if (not assigned(current_procinfo) or - wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname)) then + wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname(true))) then tobjectdef(procdef.struct).register_vmt_call(procdef.extnumber); {$ifdef vtentry} if not is_interface(procdef.struct) then @@ -527,7 +527,7 @@ implementation else begin { load address of the function } - reference_reset_symbol(href,current_asmdata.RefAsmSymbol(procdef.mangledname),0,sizeof(pint)); + reference_reset_symbol(href,current_asmdata.RefAsmSymbol(procdef.mangledname(false)),0,sizeof(pint)); hregister:=cg.getaddressregister(current_asmdata.CurrAsmList); cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,href,hregister); cg.a_load_reg_ref(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,hregister,location.reference); @@ -538,14 +538,14 @@ implementation pd:=tprocdef(tprocsym(symtableentry).ProcdefList[0]); if (po_external in pd.procoptions) then location.reference.base := - cg.g_indirect_sym_load(current_asmdata.CurrAsmList,pd.mangledname, + cg.g_indirect_sym_load(current_asmdata.CurrAsmList,pd.mangledname(false), po_weakexternal in pd.procoptions); {!!!!! Be aware, work on virtual methods too } if (location.reference.base = NR_NO) then if not(po_weakexternal in pd.procoptions) then - location.reference.symbol:=current_asmdata.RefAsmSymbol(procdef.mangledname) + location.reference.symbol:=current_asmdata.RefAsmSymbol(procdef.mangledname(false)) else - location.reference.symbol:=current_asmdata.WeakRefAsmSymbol(procdef.mangledname); + location.reference.symbol:=current_asmdata.WeakRefAsmSymbol(procdef.mangledname(false)); end; end; labelsym : diff --git a/compiler/ncgrtti.pas b/compiler/ncgrtti.pas index 9301cbd63e..9277902e53 100644 --- a/compiler/ncgrtti.pas +++ b/compiler/ncgrtti.pas @@ -341,7 +341,7 @@ implementation if not(po_virtualmethod in tprocdef(propaccesslist.procdef).procoptions) or is_objectpascal_helper(tprocdef(propaccesslist.procdef).struct) then begin - current_asmdata.asmlists[al_rtti].concat(Tai_const.createname(tprocdef(propaccesslist.procdef).mangledname,0)); + current_asmdata.asmlists[al_rtti].concat(Tai_const.createname(tprocdef(propaccesslist.procdef).mangledname(false),0)); typvalue:=1; end else diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas index c9b06d5933..6af8dc0522 100644 --- a/compiler/ncgutil.pas +++ b/compiler/ncgutil.pas @@ -85,6 +85,8 @@ interface function has_alias_name(pd:tprocdef;const s:string):boolean; procedure alloc_proc_symbol(pd: tprocdef); + procedure gen_proc_symbol(list:TAsmList); + procedure gen_proc_symbol_end(list:TAsmList); procedure gen_proc_entry_code(list:TAsmList); procedure gen_proc_exit_code(list:TAsmList); procedure gen_stack_check_size_para(list:TAsmList); @@ -2293,6 +2295,71 @@ implementation end; + procedure gen_proc_symbol(list:TAsmList); + var + item, + previtem : TCmdStrListItem; + begin + previtem:=nil; + item := TCmdStrListItem(current_procinfo.procdef.aliasnames.first); + while assigned(item) do + begin +{$ifdef arm} + if current_settings.cputype in cpu_thumb2 then + list.concat(tai_thumb_func.create); +{$endif arm} + { "double link" all procedure entry symbols via .reference } + { directives on darwin, because otherwise the linker } + { sometimes strips the procedure if only on of the symbols } + { is referenced } + if assigned(previtem) and + (target_info.system in systems_darwin) then + list.concat(tai_directive.create(asd_reference,item.str)); + if (cs_profile in current_settings.moduleswitches) or + (po_global in current_procinfo.procdef.procoptions) then + list.concat(Tai_symbol.createname_global(item.str,AT_FUNCTION,0)) + else + list.concat(Tai_symbol.createname(item.str,AT_FUNCTION,0)); + if assigned(previtem) and + (target_info.system in systems_darwin) then + list.concat(tai_directive.create(asd_reference,previtem.str)); + if not(af_stabs_use_function_absolute_addresses in target_asm.flags) then + list.concat(Tai_function_name.create(item.str)); + previtem:=item; + item := TCmdStrListItem(item.next); + end; + current_procinfo.procdef.procstarttai:=tai(list.last); + end; + + + + procedure gen_proc_symbol_end(list:TAsmList); + begin + list.concat(Tai_symbol_end.Createname(current_procinfo.procdef.mangledname(true))); + + current_procinfo.procdef.procendtai:=tai(list.last); + + if (current_module.islibrary) then + if (current_procinfo.procdef.proctypeoption = potype_proginit) then + { setinitname may generate a new section -> don't add to the + current list, because we assume this remains a text section } + exportlib.setinitname(current_asmdata.AsmLists[al_exports],current_procinfo.procdef.mangledname); + + if (current_procinfo.procdef.proctypeoption=potype_proginit) then + begin + if (target_info.system in (systems_darwin+[system_powerpc_macos])) and + not(current_module.islibrary) then + begin + new_section(list,sec_code,'',4); + list.concat(tai_symbol.createname_global( + target_info.cprefix+mainaliasname,AT_FUNCTION,0)); + { keep argc, argv and envp properly on the stack } + cg.a_jmp_name(list,target_info.cprefix+'FPC_SYSTEMMAIN'); + end; + end; + end; + + procedure gen_proc_entry_code(list:TAsmList); var hitemp, diff --git a/compiler/nld.pas b/compiler/nld.pas index 98565a5050..cd3a24c059 100644 --- a/compiler/nld.pas +++ b/compiler/nld.pas @@ -427,7 +427,7 @@ implementation inherited printnodedata(t); write(t,printnodeindention,'symbol = ',symtableentry.name); if symtableentry.typ=procsym then - write(t,printnodeindention,'procdef = ',fprocdef.mangledname); + write(t,printnodeindention,'procdef = ',fprocdef.mangledname(false)); writeln(t,''); end; diff --git a/compiler/nmem.pas b/compiler/nmem.pas index 45825ee74a..f181735bd7 100644 --- a/compiler/nmem.pas +++ b/compiler/nmem.pas @@ -244,7 +244,7 @@ implementation if not(nf_ignore_for_wpo in flags) and (not assigned(current_procinfo) or (po_inline in current_procinfo.procdef.procoptions) or - wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname)) then + wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname(true))) then begin { keep track of which classes might be instantiated via a classrefdef } if (left.resultdef.typ=classrefdef) then diff --git a/compiler/nobj.pas b/compiler/nobj.pas index 7ce974f2f7..0b9c58e87a 100644 --- a/compiler/nobj.pas +++ b/compiler/nobj.pas @@ -969,7 +969,7 @@ implementation current_asmdata.asmlists[al_globals].concat(cai_align.create(const_align(sizeof(pint)))); current_asmdata.asmlists[al_globals].concat(Tai_const.Create_sym(p^.nl)); current_asmdata.asmlists[al_globals].concat(cai_align.create(const_align(sizeof(pint)))); - current_asmdata.asmlists[al_globals].concat(Tai_const.Createname(p^.data.mangledname,0)); + current_asmdata.asmlists[al_globals].concat(Tai_const.Createname(p^.data.mangledname(false),0)); if assigned(p^.r) then writestrentry(p^.r); @@ -1013,7 +1013,7 @@ implementation current_asmdata.asmlists[al_globals].concat(cai_align.create(const_align(sizeof(longint)))); current_asmdata.asmlists[al_globals].concat(Tai_const.Create_32bit(p^.data.messageinf.i)); current_asmdata.asmlists[al_globals].concat(cai_align.create(const_align(sizeof(pint)))); - current_asmdata.asmlists[al_globals].concat(Tai_const.Createname(p^.data.mangledname,0)); + current_asmdata.asmlists[al_globals].concat(Tai_const.Createname(p^.data.mangledname(false),0)); if assigned(p^.r) then writeintentry(p^.r); @@ -1091,7 +1091,7 @@ implementation begin if assigned(p^.l) then writedmtaddressentry(p^.l); - al_globals.concat(Tai_const_symbol.Createname(p^.data.mangledname,0)); + al_globals.concat(Tai_const_symbol.Createname(p^.data.mangledname(false),0)); if assigned(p^.r) then writedmtaddressentry(p^.r); end; @@ -1175,7 +1175,7 @@ implementation if po_abstractmethod in pd.procoptions then current_asmdata.asmlists[al_globals].concat(Tai_const.Create_sym(nil)) else - current_asmdata.asmlists[al_globals].concat(Tai_const.Createname(pd.mangledname,0)); + current_asmdata.asmlists[al_globals].concat(Tai_const.Createname(pd.mangledname(false),0)); end; end; end; @@ -1300,7 +1300,7 @@ implementation begin pd:=tprocdef(AImplIntf.procdefs[i]); hs:=make_mangledname('WRPR',_class.owner,_class.objname^+'_$_'+AImplIntf.IntfDef.objname^+'_$_'+ - tostr(i)+'_$_'+pd.mangledname); + tostr(i)+'_$_'+pd.mangledname(false)); { create reference } rawdata.concat(Tai_const.Createname(hs,0)); end; @@ -1347,7 +1347,7 @@ implementation current_asmdata.asmlists[al_globals].concat(Tai_const.Create_pint(AImplIntf.VtblImplIntf.IOffset)); etStaticMethodResult, etStaticMethodClass: current_asmdata.asmlists[al_globals].concat(Tai_const.Createname( - tprocdef(tpropertysym(AImplIntf.ImplementsGetter).propaccesslist[palt_read].procdef).mangledname, + tprocdef(tpropertysym(AImplIntf.ImplementsGetter).propaccesslist[palt_read].procdef).mangledname(false), 0 )); etVirtualMethodResult, etVirtualMethodClass: @@ -1457,7 +1457,7 @@ implementation if (po_abstractmethod in vmtpd.procoptions) then procname:='FPC_ABSTRACTERROR' else if not wpoinfomanager.optimized_name_for_vmt(_class,vmtpd,procname) then - procname:=vmtpd.mangledname; + procname:=vmtpd.mangledname(false); List.concat(Tai_const.createname(procname,0)); {$ifdef vtentry} hs:='VTENTRY'+'_'+_class.vmt_mangledname+'$$'+tostr(_class.vmtmethodoffset(i) div sizeof(pint)); diff --git a/compiler/objcgutl.pas b/compiler/objcgutl.pas index 96d6d545d3..70504d285b 100644 --- a/compiler/objcgutl.pas +++ b/compiler/objcgutl.pas @@ -322,7 +322,7 @@ procedure tobjcrttiwriter.gen_objc_methods(list: tasmlist; objccls: tobjectdef; { reference to the obj-c encoded function parameters (signature) } list.Concat(tai_const.Create_sym(defs[i].encsym)); { mangled name of the method } - sym:=current_asmdata.GetAsmSymbol(defs[i].def.mangledname); + sym:=current_asmdata.GetAsmSymbol(defs[i].def.mangledname(false)); if not assigned(sym) then internalerror(2009091601); list.Concat(tai_const.Create_sym(sym)); diff --git a/compiler/opttail.pas b/compiler/opttail.pas index c6659c39a5..5429c8bb36 100644 --- a/compiler/opttail.pas +++ b/compiler/opttail.pas @@ -104,7 +104,7 @@ unit opttail; begin { found one! } { - writeln('tail recursion optimization for ',p.mangledname); + writeln('tail recursion optimization for ',p.mangledname(false)); printnode(output,n); } { create assignments for all parameters } diff --git a/compiler/optvirt.pas b/compiler/optvirt.pas index 9646c1b172..20e71233cb 100644 --- a/compiler/optvirt.pas +++ b/compiler/optvirt.pas @@ -708,7 +708,7 @@ unit optvirt; vmcs_yes: begin { add info about devirtualised vmt entry } - classdevirtinfo.addstaticmethod(i,pvmtentry(node.def.vmtentries[i])^.procdef.mangledname); + classdevirtinfo.addstaticmethod(i,pvmtentry(node.def.vmtentries[i])^.procdef.mangledname(false)); end; vmcs_unreachable: begin diff --git a/compiler/pexports.pas b/compiler/pexports.pas index 4b6d45eb33..66229d95b3 100644 --- a/compiler/pexports.pas +++ b/compiler/pexports.pas @@ -107,7 +107,7 @@ implementation not(po_exports in pd.procoptions)) then Message(parser_e_illegal_symbol_exported) else - InternalProcName:=pd.mangledname; + InternalProcName:=pd.mangledname(false); end; typesym : begin diff --git a/compiler/pmodules.pas b/compiler/pmodules.pas index 6afffede95..6ec14c3dd3 100644 --- a/compiler/pmodules.pas +++ b/compiler/pmodules.pas @@ -404,12 +404,12 @@ implementation begin pd := tabstractrecorddef(structlist[i]).find_procdef_bytype(potype_class_constructor); if assigned(pd) then - unitinits.concat(Tai_const.Createname(pd.mangledname,0)) + unitinits.concat(Tai_const.Createname(pd.mangledname(false),0)) else unitinits.concat(Tai_const.Create_pint(0)); pd := tabstractrecorddef(structlist[i]).find_procdef_bytype(potype_class_destructor); if assigned(pd) then - unitinits.concat(Tai_const.Createname(pd.mangledname,0)) + unitinits.concat(Tai_const.Createname(pd.mangledname(false),0)) else unitinits.concat(Tai_const.Create_pint(0)); inc(count); @@ -908,7 +908,7 @@ implementation include(pd.procoptions,po_hascallingconvention); pd.forwarddef:=false; pd.setmangledname(target_info.cprefix+name); - pd.aliasnames.insert(pd.mangledname); + pd.aliasnames.insert(pd.mangledname(true)); handle_calling_convention(pd); { We don't need is a local symtable. Change it into the static symtable } @@ -1522,13 +1522,13 @@ implementation ((tsymtable(arg).symtabletype=staticsymtable) and (po_public in tprocdef(tprocsym(sym).ProcdefList[i]).procoptions)) ) then begin - procexport(tprocdef(tprocsym(sym).ProcdefList[i]).mangledname); + procexport(tprocdef(tprocsym(sym).ProcdefList[i]).mangledname(false)); { walk through all aliases } item:=TCmdStrListItem(tprocdef(tprocsym(sym).ProcdefList[i]).aliasnames.first); while assigned(item) do begin { avoid duplicate entries, sometimes aliasnames contains the mangledname } - if item.str<>tprocdef(tprocsym(sym).ProcdefList[i]).mangledname then + if item.str<>tprocdef(tprocsym(sym).ProcdefList[i]).mangledname(false) then procexport(item.str); item:=TCmdStrListItem(item.next); end; diff --git a/compiler/ppcgen/cgppc.pas b/compiler/ppcgen/cgppc.pas index f08d7b4deb..29c072c60a 100644 --- a/compiler/ppcgen/cgppc.pas +++ b/compiler/ppcgen/cgppc.pas @@ -730,12 +730,12 @@ unit cgppc; case target_info.system of system_powerpc_darwin, system_powerpc64_darwin: - list.concat(taicpu.op_sym(A_B,get_darwin_call_stub(procdef.mangledname,false))); + list.concat(taicpu.op_sym(A_B,get_darwin_call_stub(procdef.mangledname(false),false))); system_powerpc64_linux: {$note ts:todo add GOT change?? - think not needed :) } - list.concat(taicpu.op_sym(A_B,current_asmdata.RefAsmSymbol('.' + procdef.mangledname))); + list.concat(taicpu.op_sym(A_B,current_asmdata.RefAsmSymbol('.' + procdef.mangledname(false)))); else - list.concat(taicpu.op_sym(A_B,current_asmdata.RefAsmSymbol(procdef.mangledname))) + list.concat(taicpu.op_sym(A_B,current_asmdata.RefAsmSymbol(procdef.mangledname(false)))) end; List.concat(Tai_symbol_end.Createname(labelname)); end; diff --git a/compiler/psub.pas b/compiler/psub.pas index b479841f30..1b0a4d8cb3 100644 --- a/compiler/psub.pas +++ b/compiler/psub.pas @@ -1246,7 +1246,7 @@ implementation { add the procedure to the al_procedures } maybe_new_object_file(current_asmdata.asmlists[al_procedures]); - new_section(current_asmdata.asmlists[al_procedures],sec_code,lower(procdef.mangledname),getprocalign); + new_section(current_asmdata.asmlists[al_procedures],sec_code,lower(procdef.mangledname(true)),getprocalign); current_asmdata.asmlists[al_procedures].concatlist(aktproccode); { save local data (casetable) also in the same file } if assigned(aktlocaldata) and @@ -1569,7 +1569,7 @@ implementation isnestedproc:=(current_procinfo.procdef.parast.symtablelevel>normal_function_level); { Insert mangledname } - pd.aliasnames.insert(pd.mangledname); + pd.aliasnames.insert(pd.mangledname(true)); { Handle Export of this procedure } if (po_exports in pd.procoptions) and @@ -1577,7 +1577,7 @@ implementation begin pd.aliasnames.insert(pd.procsym.realname); if cs_link_deffile in current_settings.globalswitches then - deffile.AddExport(pd.mangledname); + deffile.AddExport(pd.mangledname(false)); end; { Insert result variables in the localst } @@ -1804,9 +1804,9 @@ implementation begin if (po_global in pd.procoptions) or (cs_profile in current_settings.moduleswitches) then - current_asmdata.DefineAsmSymbol(pd.mangledname,AB_GLOBAL,AT_FUNCTION) + current_asmdata.DefineAsmSymbol(pd.mangledname(false),AB_GLOBAL,AT_FUNCTION) else - current_asmdata.DefineAsmSymbol(pd.mangledname,AB_LOCAL,AT_FUNCTION); + current_asmdata.DefineAsmSymbol(pd.mangledname(false),AB_LOCAL,AT_FUNCTION); end; current_structdef:=old_current_structdef; diff --git a/compiler/ptconst.pas b/compiler/ptconst.pas index ea55148e7e..fdf2a7c371 100644 --- a/compiler/ptconst.pas +++ b/compiler/ptconst.pas @@ -346,7 +346,7 @@ implementation { update wpo info } if not assigned(current_procinfo) or (po_inline in current_procinfo.procdef.procoptions) or - wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname) then + wpoinfomanager.symbol_live(current_procinfo.procdef.mangledname(true)) then tobjectdef(tclassrefdef(n.resultdef).pointeddef).register_maybe_created_object_type; end; niln: @@ -547,7 +547,7 @@ implementation if po_abstractmethod in pd.procoptions then Message(type_e_cant_take_address_of_abstract_method) else - list.concat(Tai_const.Createname(pd.mangledname,offset)); + list.concat(Tai_const.Createname(pd.mangledname(false),offset)); end; staticvarsym : list.concat(Tai_const.Createname(tstaticvarsym(srsym).mangledname,offset)); @@ -1014,7 +1014,7 @@ implementation (tloadnode(n).symtableentry.typ=procsym) then begin pd:=tloadnode(n).procdef; - list.concat(Tai_const.createname(pd.mangledname,0)); + list.concat(Tai_const.createname(pd.mangledname(false),0)); { nested procvar typed consts can only be initialised with nil (checked above) or with a global procedure (checked here), because in other cases we need a valid frame pointer } diff --git a/compiler/raatt.pas b/compiler/raatt.pas index ed80e8c375..85544cf03e 100644 --- a/compiler/raatt.pas +++ b/compiler/raatt.pas @@ -987,28 +987,28 @@ unit raatt; AS_DATA: Begin - new_section(curList,sec_data,lower(current_procinfo.procdef.mangledname),0); + new_section(curList,sec_data,lower(current_procinfo.procdef.mangledname(true)),0); lasTSec:=sec_data; Consume(AS_DATA); end; AS_TEXT: Begin - new_section(curList,sec_code,lower(current_procinfo.procdef.mangledname),0); + new_section(curList,sec_code,lower(current_procinfo.procdef.mangledname(true)),0); lasTSec:=sec_code; Consume(AS_TEXT); end; AS_INIT: Begin - new_section(curList,sec_init,lower(current_procinfo.procdef.mangledname),0); + new_section(curList,sec_init,lower(current_procinfo.procdef.mangledname(true)),0); lasTSec:=sec_init; Consume(AS_INIT); end; AS_FINI: Begin - new_section(curList,sec_fini,lower(current_procinfo.procdef.mangledname),0); + new_section(curList,sec_fini,lower(current_procinfo.procdef.mangledname(true)),0); lasTSec:=sec_fini; Consume(AS_FINI); end; @@ -1178,7 +1178,7 @@ unit raatt; if lasTSec<>sec_code then begin Message(asmr_w_assembler_code_not_returned_to_text); - new_section(curList,sec_code,lower(current_procinfo.procdef.mangledname),0); + new_section(curList,sec_code,lower(current_procinfo.procdef.mangledname(true)),0); end; { Return the list in an asmnode } assemble:=curlist; @@ -1450,7 +1450,7 @@ unit raatt; begin if Tprocsym(sym).ProcdefList.Count>1 then Message(asmr_w_calling_overload_func); - hs:=tprocdef(tprocsym(sym).ProcdefList[0]).mangledname; + hs:=tprocdef(tprocsym(sym).ProcdefList[0]).mangledname(false); hssymtyp:=AT_FUNCTION; end; typesym : diff --git a/compiler/rautils.pas b/compiler/rautils.pas index c567dd7f79..d6bbe9251c 100644 --- a/compiler/rautils.pas +++ b/compiler/rautils.pas @@ -906,7 +906,7 @@ Begin Message(asmr_w_calling_overload_func); l:=opr.ref.offset; opr.typ:=OPR_SYMBOL; - opr.symbol:=current_asmdata.RefAsmSymbol(tprocdef(tprocsym(sym).ProcdefList[0]).mangledname); + opr.symbol:=current_asmdata.RefAsmSymbol(tprocdef(tprocsym(sym).ProcdefList[0]).mangledname(false)); opr.symofs:=l; hasvar:=true; SetupVar:=TRUE; @@ -1400,7 +1400,7 @@ Begin procdef:=tprocdef(tprocsym(sym).ProcdefList[0]); if (not needvmtofs) then begin - mangledname:=procdef.mangledname; + mangledname:=procdef.mangledname(false); end else begin diff --git a/compiler/sparc/cgcpu.pas b/compiler/sparc/cgcpu.pas index 634c912317..f5b240d871 100644 --- a/compiler/sparc/cgcpu.pas +++ b/compiler/sparc/cgcpu.pas @@ -1393,7 +1393,7 @@ implementation end else begin - reference_reset_symbol(href,current_asmdata.RefAsmSymbol(procdef.mangledname),0,sizeof(pint)); + reference_reset_symbol(href,current_asmdata.RefAsmSymbol(procdef.mangledname(false)),0,sizeof(pint)); href.refaddr := addr_high; list.concat(taicpu.op_ref_reg(A_SETHI,href,NR_G1)); g1_used:=true; diff --git a/compiler/sparc/ncpuset.pas b/compiler/sparc/ncpuset.pas index ef562c62c1..c1dc015ac3 100644 --- a/compiler/sparc/ncpuset.pas +++ b/compiler/sparc/ncpuset.pas @@ -113,7 +113,7 @@ unit ncpuset; { Delay slot } current_asmdata.CurrAsmList.concat(taicpu.op_none(A_NOP)); { generate jump table } - new_section(current_procinfo.aktlocaldata,sec_data,current_procinfo.procdef.mangledname,sizeof(pint)); + new_section(current_procinfo.aktlocaldata,sec_data,current_procinfo.procdef.mangledname(true),sizeof(pint)); current_procinfo.aktlocaldata.concat(Tai_label.Create(table)); last:=min_; genitem(current_procinfo.aktlocaldata,hp); diff --git a/compiler/symdef.pas b/compiler/symdef.pas index 82f3ac779f..b34838cfc8 100644 --- a/compiler/symdef.pas +++ b/compiler/symdef.pas @@ -566,11 +566,15 @@ interface procedure derefimpl;override; function GetSymtable(t:tGetSymtable):TSymtable;override; function GetTypeName : string;override; - function mangledname : string; + { on some targets the mangled name for defining a procedure is + different from the mangled name used for calling it later } + function mangledname(fordefinition: boolean) : string; procedure setmangledname(const s : string); function fullprocname(showhidden:boolean):string; function cplusplusmangledname : string; function objcmangledname : string; + function jvmmangledname: string; + procedure adornmangledname(var name: string; fordefinition: boolean);{$ifndef jvm}inline;{$endif} function is_methodpointer:boolean;override; function is_addressonly:boolean;override; procedure make_external; @@ -832,7 +836,7 @@ implementation { target } systems,aasmcpu,paramgr, { symtable } - symsym,symtable,symutil,defutil,objcdef, + symsym,symtable,symutil,defutil,objcdef,jvmdef, { module } fmodule, { other } @@ -3593,7 +3597,7 @@ implementation if (cs_link_deffile in current_settings.globalswitches) and (tf_need_export in target_info.flags) and (po_exports in procoptions) then - deffile.AddExport(mangledname); + deffile.AddExport(mangledname(false)); forwarddef:=false; interfacedef:=false; hasforward:=false; @@ -3928,7 +3932,7 @@ implementation end; - function tprocdef.mangledname : string; + function tprocdef.mangledname(fordefinition: boolean) : string; var hp : TParavarsym; hs : string; @@ -3944,6 +3948,7 @@ implementation {$else} mangledname:=_mangledname^; {$endif} + adornmangledname(mangledname,fordefinition); exit; end; { we need to use the symtable where the procsym is inserted, @@ -3985,6 +3990,7 @@ implementation {$else} _mangledname:=stringdup(mangledname); {$endif} + adornmangledname(mangledname,fordefinition); end; @@ -4164,6 +4170,132 @@ implementation end; + procedure tprocdef.adornmangledname(var name: string; fordefinition: boolean); + var + tmpresult:string; + begin +{$ifdef jvm} + { see tprocdef.jvmmangledname for description of the format } + if fordefinition then + begin + { definition: visibility/static } + case visibility of + vis_private, + vis_strictprivate: + tmpresult:='private '; + vis_protected, + vis_strictprotected: + tmpresult:='protected '; + vis_public: + tmpresult:='public '; + else + internalerror(2010122609); + end; + if (procsym.owner.symtabletype in [globalsymtable,staticsymtable,localsymtable]) or + (po_staticmethod in procoptions) then + tmpresult:=tmpresult+'static '; + end + else + begin + { invocation: package/class name } + case procsym.owner.symtabletype of + globalsymtable, + staticsymtable, + localsymtable: + begin + owningunit:=procsym.owner; + while (owningunit.symtabletype in [localsymtable,objectsymtable,recordsymtable]) do + owningunit:=owner.defowner.owner; + { TODO: add package name !!! } + tmpresult:=owningunit.realname^; + end; + objectsymtable: + case tobjectdef(procsym.owner.defowner).objecttype of + odt_javaclass, + odt_interfacejava: + tmpresult:=tobjectdef(procsym.owner.defowner).objextname^; + else + internalerror(2010122606); + end + else + internalerror(2010122605); + end; + if po_has_importname in procoptions then + begin + { import_dll comes from "external 'import_dll_name' name 'external_name'" } + if assigned(import_dll) then + tmpresult:=result+import_dll^+'/' + else + internalerror(2010122607); + end; + end; + name:=name+tmpresult; +{$endif} + end; + + + function tprocdef.jvmmangledname: string; + var + owningunit: tsymtable; + parasize, + vs: tparavarsym; + i: longint; + founderror: tdef; + tmpresult: ansistring; + begin + { format: + * method definition: + (private|protected|public) [static] method(parametertypes)returntype + * method invocation + package/class/method(parametertypes)returntype + -> store common part: method(parametertypes)returntype and + adorn as required when using it. + } + { method name } + if po_has_importname in procoptions then + begin + if assigned(import_name) then + tmpresult:=result+import_name^ + else + internalerror(2010122608); + end + else + begin + { package name must be set for all external routines } + if po_external in procoptions then + internalerror(2010122607); + { TODO: add current package name! } + tmpresult:=result+procsym.realname; + end; + { parameter types } + tmpresult:=tmpresult+'('; + init_paraloc_info(callerside); + for i:=0 to paras.count-1 do + begin + vs:=tparavarsym(paras[i]); + { function result and self pointer are not part of the mangled + name } + if ([vo_is_funcret,vo_is_self] * vs.varoptions <> []) then + continue; + { reference parameters are not yet supported } + if (vs.varspez in [vs_var,vs_out,vs_constref]) then + internalerror(2010122603); + { Add the parameter type. } + if not jvmaddencodedtype(vs.vardef,false,tmpresult,founderror) then + { should be checked earlier on } + internalerror(2010122604); + end; + tmpresult:=tmpresult+')'; + { And the type of the function result (void in case of a procedure and + constructor). } + if (proctypeoption=potype_constructor) then + jvmaddencodedtype(voidtype,false,tmpresult,founderror) + else if not jvmaddencodedtype(returndef,false,tmpresult,founderror) then + internalerror(2010122610); + result:=tmpresult; + end; + + procedure tprocdef.setmangledname(const s : string); begin { This is not allowed anymore, the forward declaration @@ -5363,12 +5495,12 @@ implementation begin { copied from psub.read_proc } if assigned(tobjectdef(pd.struct).import_lib) then - current_module.AddExternalImport(tobjectdef(pd.struct).import_lib^,pd.mangledname,pd.mangledname,0,false,false) + current_module.AddExternalImport(tobjectdef(pd.struct).import_lib^,pd.mangledname(false),pd.mangledname(false),0,false,false) else begin { add import name to external list for DLL scanning } if tf_has_dllscanner in target_info.flags then - current_module.dllscannerinputlist.Add(pd.mangledname,pd); + current_module.dllscannerinputlist.Add(pd.mangledname(false),pd); end; end; diff --git a/compiler/systems/t_beos.pas b/compiler/systems/t_beos.pas index 2a80274f52..07bba63eb2 100644 --- a/compiler/systems/t_beos.pas +++ b/compiler/systems/t_beos.pas @@ -146,13 +146,13 @@ begin { the manglednames can already be the same when the procedure is declared with cdecl } pd:=tprocdef(tprocsym(hp2.sym).ProcdefList[0]); - if pd.mangledname<>hp2.name^ then + if pd.mangledname(false)<>hp2.name^ then begin {$ifdef i386} { place jump in al_procedures } current_asmdata.asmlists[al_procedures].concat(Tai_align.Create_op(4,$90)); current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0)); - current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname))); + current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname(false)))); current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^)); {$endif i386} end; diff --git a/compiler/systems/t_haiku.pas b/compiler/systems/t_haiku.pas index ef59652bbe..16bcfc2a43 100644 --- a/compiler/systems/t_haiku.pas +++ b/compiler/systems/t_haiku.pas @@ -147,13 +147,13 @@ begin { the manglednames can already be the same when the procedure is declared with cdecl } pd:=tprocdef(tprocsym(hp2.sym).ProcdefList[0]); - if pd.mangledname<>hp2.name^ then + if pd.mangledname(false)<>hp2.name^ then begin {$ifdef i386} { place jump in al_procedures } current_asmdata.asmlists[al_procedures].concat(Tai_align.Create_op(4,$90)); current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0)); - current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname))); + current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname(false)))); current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^)); {$endif i386} end; diff --git a/compiler/systems/t_nwl.pas b/compiler/systems/t_nwl.pas index 0cc59bf5ac..fe26049040 100644 --- a/compiler/systems/t_nwl.pas +++ b/compiler/systems/t_nwl.pas @@ -224,13 +224,13 @@ begin { the manglednames can already be the same when the procedure is declared with cdecl } pd:=tprocdef(tprocsym(hp2.sym).ProcdefList[0]); - if pd.mangledname<>hp2.name^ then + if pd.mangledname(false)<>hp2.name^ then begin {$ifdef i386} { place jump in al_procedures } current_asmdata.asmlists[al_procedures].concat(Tai_align.Create_op(4,$90)); current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0)); - current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname))); + current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname(false)))); current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^)); {$endif i386} end; diff --git a/compiler/systems/t_nwm.pas b/compiler/systems/t_nwm.pas index e8fdbf62bc..88ff25b78a 100644 --- a/compiler/systems/t_nwm.pas +++ b/compiler/systems/t_nwm.pas @@ -226,13 +226,13 @@ begin { the manglednames can already be the same when the procedure is declared with cdecl } pd:=tprocdef(tprocsym(hp2.sym).ProcdefList[0]); - if pd.mangledname<>hp2.name^ then + if pd.mangledname(false)<>hp2.name^ then begin {$ifdef i386} { place jump in al_procedures } current_asmdata.asmlists[al_procedures].concat(Tai_align.Create_op(4,$90)); current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0)); - current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname))); + current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname(false)))); current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^)); {$endif i386} end; diff --git a/compiler/systems/t_win.pas b/compiler/systems/t_win.pas index fd8288bc47..b8bbc15f04 100644 --- a/compiler/systems/t_win.pas +++ b/compiler/systems/t_win.pas @@ -866,7 +866,7 @@ implementation staticvarsym : asmsym:=current_asmdata.RefAsmSymbol(tstaticvarsym(hp.sym).mangledname); procsym : - asmsym:=current_asmdata.RefAsmSymbol(tprocdef(tprocsym(hp.sym).ProcdefList[0]).mangledname) + asmsym:=current_asmdata.RefAsmSymbol(tprocdef(tprocsym(hp.sym).ProcdefList[0]).mangledname(false)) else internalerror(200709272); end diff --git a/compiler/x86/cgx86.pas b/compiler/x86/cgx86.pas index c5bed32bde..453bca8a49 100644 --- a/compiler/x86/cgx86.pas +++ b/compiler/x86/cgx86.pas @@ -2017,10 +2017,10 @@ unit cgx86; mcountPrefix:=''; end; current_asmdata.getaddrlabel(pl); - new_section(list,sec_data,lower(current_procinfo.procdef.mangledname),sizeof(pint)); + new_section(list,sec_data,lower(current_procinfo.procdef.mangledname(true)),sizeof(pint)); list.concat(Tai_label.Create(pl)); list.concat(Tai_const.Create_32bit(0)); - new_section(list,sec_code,lower(current_procinfo.procdef.mangledname),0); + new_section(list,sec_code,lower(current_procinfo.procdef.mangledname(true)),0); list.concat(Taicpu.Op_reg(A_PUSH,S_L,NR_EDX)); list.concat(Taicpu.Op_sym_ofs_reg(A_MOV,S_L,pl,0,NR_EDX)); a_call_name(list,target_info.Cprefix+mcountprefix+'mcount',false); diff --git a/compiler/x86/nx86set.pas b/compiler/x86/nx86set.pas index d16151a1df..e725d38700 100644 --- a/compiler/x86/nx86set.pas +++ b/compiler/x86/nx86set.pas @@ -145,7 +145,7 @@ implementation jtlist:=current_procinfo.aktlocaldata; sectype:=sec_data; end; - new_section(jtlist,sectype,current_procinfo.procdef.mangledname,sizeof(aint)); + new_section(jtlist,sectype,current_procinfo.procdef.mangledname(true),sizeof(aint)); jtlist.concat(Tai_label.Create(table)); genitem(jtlist,hp); end; diff --git a/compiler/x86/rax86int.pas b/compiler/x86/rax86int.pas index 6419c8df2b..78b9fca1b5 100644 --- a/compiler/x86/rax86int.pas +++ b/compiler/x86/rax86int.pas @@ -996,7 +996,7 @@ Unit Rax86int; begin if Tprocsym(sym).ProcdefList.Count>1 then Message(asmr_w_calling_overload_func); - hs:=tprocdef(tprocsym(sym).ProcdefList[0]).mangledname; + hs:=tprocdef(tprocsym(sym).ProcdefList[0]).mangledname(false); hssymtyp:=AT_FUNCTION; end; typesym : diff --git a/compiler/x86_64/cgcpu.pas b/compiler/x86_64/cgcpu.pas index c7406afea5..f6e33c0e50 100644 --- a/compiler/x86_64/cgcpu.pas +++ b/compiler/x86_64/cgcpu.pas @@ -192,7 +192,7 @@ unit cgcpu; end else begin - sym:=current_asmdata.RefAsmSymbol(procdef.mangledname); + sym:=current_asmdata.RefAsmSymbol(procdef.mangledname(false)); reference_reset_symbol(r,sym,0,sizeof(pint)); if (cs_create_pic in current_settings.moduleswitches) and { darwin/x86_64's assembler doesn't want @PLT after call symbols } |