From 110a5642c04582d9e89a04eceab6b49b91649769 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Thu, 7 Jan 2016 22:05:38 +0000 Subject: [PATCH] - removed ait_weak/tai_weak, and replaced it with the previously existing asd_weak_reference/asd_weak_definition directives git-svn-id: trunk@32879 - --- compiler/aasmtai.pas | 39 ++------------------------------------ compiler/aggas.pas | 31 +++++++++++++++++------------- compiler/assemble.pas | 17 ++++++++++++++--- compiler/avr/aasmcpu.pas | 1 - compiler/llvm/aasmllvm.pas | 3 ++- compiler/llvm/agllvm.pas | 6 ------ compiler/psystem.pas | 1 - compiler/raatt.pas | 6 +++++- 8 files changed, 41 insertions(+), 63 deletions(-) diff --git a/compiler/aasmtai.pas b/compiler/aasmtai.pas index b2cf957016..43b5c4c9bb 100644 --- a/compiler/aasmtai.pas +++ b/compiler/aasmtai.pas @@ -73,7 +73,6 @@ interface ait_labeled_instruction, {$endif m68k} ait_symbolpair, - ait_weak, { used to split into tiny assembler files } ait_cutobject, ait_regalloc, @@ -204,7 +203,6 @@ interface 'labeled_instr', {$endif m68k} 'symbolpair', - 'weak', 'cut', 'regalloc', 'tempalloc', @@ -298,7 +296,7 @@ interface ait_stab,ait_function_name, ait_cutobject,ait_marker,ait_varloc,ait_align,ait_section,ait_comment, ait_const,ait_directive, - ait_symbolpair,ait_weak, + ait_symbolpair, ait_realconst, ait_symbol, {$ifdef JVM} @@ -375,7 +373,7 @@ interface directivestr : array[TAsmDirective] of string[23]=( 'indirect_symbol', 'extern','nasm_import', 'tc', 'reference', - 'no_dead_strip','weak_reference','lazy_reference','weak_definition', + 'no_dead_strip','weak','lazy_reference','weak', { for Jasmin } 'class','interface','super','field','limit','line', { .ent/.end for MIPS } @@ -899,14 +897,6 @@ interface procedure ppuwrite(ppufile:tcompilerppufile);override; end; - tai_weak = class(tai) - sym: pshortstring; - constructor create(const asym: string); - destructor destroy;override; - constructor ppuload(t:taitype;ppufile:tcompilerppufile);override; - procedure ppuwrite(ppufile:tcompilerppufile);override; - end; - var { array with all class types for tais } aiclass : taiclassarray; @@ -1019,31 +1009,6 @@ implementation end; - constructor tai_weak.create(const asym: string); - begin - inherited create; - typ:=ait_weak; - sym:=stringdup(asym); - end; - - destructor tai_weak.destroy; - begin - stringdispose(sym); - inherited destroy; - end; - - constructor tai_weak.ppuload(t: taitype; ppufile: tcompilerppufile); - begin - inherited ppuload(t,ppufile); - sym:=stringdup(ppufile.getstring); - end; - - procedure tai_weak.ppuwrite(ppufile: tcompilerppufile); - begin - inherited ppuwrite(ppufile); - ppufile.putstring(sym^); - end; - constructor tai_symbolpair.create(akind: TSymbolPairKind; const asym, avalue: string); begin inherited create; diff --git a/compiler/aggas.pas b/compiler/aggas.pas index 6efc21bef1..3bf3785361 100644 --- a/compiler/aggas.pas +++ b/compiler/aggas.pas @@ -52,7 +52,7 @@ interface procedure WriteExtraHeader;virtual; procedure WriteExtraFooter;virtual; procedure WriteInstruction(hp: tai); - procedure WriteWeakSymbolDef(s: tasmsymbol); virtual; + procedure WriteWeakSymbolRef(s: tasmsymbol); virtual; procedure WriteAixStringConst(hp: tai_string); procedure WriteAixIntConst(hp: tai_const); procedure WriteUnalignedIntConst(hp: tai_const); @@ -91,8 +91,8 @@ interface TAppleGNUAssembler=class(TGNUAssembler) protected function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override; - procedure WriteWeakSymbolDef(s: tasmsymbol); override; - + procedure WriteWeakSymbolRef(s: tasmsymbol); override; + procedure WriteDirectiveName(dir: TAsmDirective); override; end; @@ -1206,13 +1206,6 @@ implementation writer.AsmWriteLn(tai_symbolpair(hp).value^); end; end; - ait_weak: - begin - if replaceforbidden then - writer.AsmWriteLn(#9'.weak '+ReplaceForbiddenAsmSymbolChars(tai_weak(hp).sym^)) - else - writer.AsmWriteLn(#9'.weak '+tai_weak(hp).sym^); - end; ait_symbol_end : begin if tf_needs_symbol_size in target_info.flags then @@ -1378,7 +1371,7 @@ implementation end; - procedure TGNUAssembler.WriteWeakSymbolDef(s: tasmsymbol); + procedure TGNUAssembler.WriteWeakSymbolRef(s: tasmsymbol); begin writer.AsmWriteLn(#9'.weak '+s.name); end; @@ -1572,7 +1565,7 @@ implementation { add weak symbol markers } for i:=0 to current_asmdata.asmsymboldict.count-1 do if (tasmsymbol(current_asmdata.asmsymboldict[i]).bind=AB_WEAK_EXTERNAL) then - writeweaksymboldef(tasmsymbol(current_asmdata.asmsymboldict[i])); + WriteWeakSymbolRef(tasmsymbol(current_asmdata.asmsymboldict[i])); if create_smartlink_sections and (target_info.system in systems_darwin) then @@ -1806,11 +1799,23 @@ implementation end; - procedure TAppleGNUAssembler.WriteWeakSymbolDef(s: tasmsymbol); + procedure TAppleGNUAssembler.WriteWeakSymbolRef(s: tasmsymbol); begin writer.AsmWriteLn(#9'.weak_reference '+s.name); end; + procedure TAppleGNUAssembler.WriteDirectiveName(dir: TAsmDirective); + begin + case dir of + asd_weak_reference: + writer.AsmWrite('.weak_reference '); + asd_weak_definition: + writer.AsmWrite('.weak_definition '); + else + inherited; + end; + end; + {****************************************************************************} { a.out/GNU Assembler writer } diff --git a/compiler/assemble.pas b/compiler/assemble.pas index 1d498abd26..ac872aef34 100644 --- a/compiler/assemble.pas +++ b/compiler/assemble.pas @@ -1922,10 +1922,21 @@ Implementation ait_cutobject : if SmartAsm then break; - ait_weak: + ait_directive : begin - objsym:=ObjData.symbolref(tai_weak(hp).sym^); - objsym.bind:=AB_WEAK_EXTERNAL; + case tai_directive(hp).directive of + asd_weak_definition, + asd_weak_reference: + begin + objsym:=ObjData.symbolref(tai_directive(hp).name); + if objsym.bind in [AB_EXTERNAL,AB_WEAK_EXTERNAL] then + objsym.bind:=AB_WEAK_EXTERNAL + else + { TODO: should become a weak definition; for now, do + the same as what was done for ait_weak } + objsym.bind:=AB_WEAK_EXTERNAL; + end + end end; ait_symbolpair: begin diff --git a/compiler/avr/aasmcpu.pas b/compiler/avr/aasmcpu.pas index 800bd23c6c..675570bb74 100644 --- a/compiler/avr/aasmcpu.pas +++ b/compiler/avr/aasmcpu.pas @@ -422,7 +422,6 @@ implementation end; ait_align: inc(CurrOffset,tai_align(curtai).aligntype); - ait_weak, ait_symbolpair, ait_marker: ; diff --git a/compiler/llvm/aasmllvm.pas b/compiler/llvm/aasmllvm.pas index 314cb0b4ad..430754e101 100644 --- a/compiler/llvm/aasmllvm.pas +++ b/compiler/llvm/aasmllvm.pas @@ -154,7 +154,8 @@ interface ldf_definition, { definition as opposed to (an external) declaration } ldf_tls, { tls definition } ldf_unnamed_addr, { address doesn't matter, only content } - ldf_vectorized { vectorized, dead-strippable data } + ldf_vectorized, { vectorized, dead-strippable data } + ldf_weak { weak definition } ); taillvmdeclflags = set of taillvmdeclflag; diff --git a/compiler/llvm/agllvm.pas b/compiler/llvm/agllvm.pas index 2c7c7f1065..5c02c42e06 100644 --- a/compiler/llvm/agllvm.pas +++ b/compiler/llvm/agllvm.pas @@ -1047,12 +1047,6 @@ implementation internalerror(2013010708); end; - ait_weak: - begin - { should be emitted as part of the symbol def } - internalerror(2013010709); - end; - ait_symbol_end : begin if tai_symbol_end(hp).sym.typ=AT_FUNCTION then diff --git a/compiler/psystem.pas b/compiler/psystem.pas index 6d9314bb12..56b4c8fef7 100644 --- a/compiler/psystem.pas +++ b/compiler/psystem.pas @@ -751,7 +751,6 @@ implementation // aiclass[ait_labeled_instruction]:=tai_labeled_instruction; {$endif SPARC} aiclass[ait_symbolpair]:=tai_symbolpair; - aiclass[ait_weak]:=tai_weak; aiclass[ait_cutobject]:=tai_cutobject; aiclass[ait_regalloc]:=tai_regalloc; aiclass[ait_tempalloc]:=tai_tempalloc; diff --git a/compiler/raatt.pas b/compiler/raatt.pas index d346a18565..d9c2ba2d07 100644 --- a/compiler/raatt.pas +++ b/compiler/raatt.pas @@ -1275,7 +1275,11 @@ unit raatt; begin Consume(AS_WEAK); BuildConstSymbolExpression(true,false,false, l1,symname,symtyp); - curList.concat(tai_weak.create(symname)); + { ideally, we should look up the symbol here (or later) and + depending on whether it's external or net, generate + asd_weak_reference or asd_weak_definition -- this is different + on some targets) } + curList.concat(tai_directive.create(asd_weak_definition,symname)); end; AS_SECTION: