1 {
2 Copyright (c) 2016 by Jonas Maebe, member of the Free Pascal
3 development team
4
5 Contains asmsymbol functionality that depends on symdef (to avoid creating
6 circular dependencies between symdef and aasmdata via aasmtai)
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 ****************************************************************************
23 }
24 unit aasmdef;
25
26 {$i fpcdefs.inc}
27
28 interface
29
30 uses
31 globtype,
32 aasmbase,aasmdata,
33 symtype;
34
35 type
36 TAsmDataDef = class(TAsmData)
DefineAsmSymbolByClassnull37 function DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol; override;
38 end;
39
40 implementation
41
42 uses
43 globals,cutils,systems,
44 aasmtai,aasmcnst,
45 symdef,
46 fmodule;
47
48
DefineAsmSymbolByClassnull49 function TAsmDataDef.DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef): TAsmSymbol;
50 var
51 symind: tasmsymbol;
52 ptrdef: tdef;
53 tcb: ttai_typedconstbuilder;
54 wasdefined: boolean;
55 begin
56 result:=DefineAsmSymbolByClassBase(symclass,s,_bind,_typ,def,wasdefined);
57 { define the indirect asmsymbol if necessary }
58 if not wasdefined and
59 (_bind in [AB_GLOBAL,AB_COMMON]) and
60 (_typ<>AT_DATA_NOINDIRECT) and
61 (((_typ=AT_DATA) and
62 (tf_supports_packages in target_info.flags) and
63 (target_info.system in systems_indirect_var_imports)
64 ) or
65 (_typ=AT_DATA_FORCEINDIRECT)
66 ) then
67 begin
68 ptrdef:=cpointerdef.getreusable(def);
69 symind:=current_asmdata.DefineAsmSymbol(s,AB_INDIRECT,AT_DATA,ptrdef);
70 tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
71 tcb.emit_tai(Tai_const.Create_sym_offset(result,0),ptrdef);
72 current_asmdata.AsmLists[al_indirectglobals].concatlist(tcb.get_final_asmlist(
73 symind,ptrdef,
74 sec_rodata,
75 lower(symind.name),
76 ptrdef.alignment));
77 tcb.free;
78 if (_typ=AT_DATA_FORCEINDIRECT) and not (target_info.system in systems_indirect_var_imports) then
79 current_module.add_public_asmsym(symind.name,AB_INDIRECT,AT_DATA);
80 end;
81 end;
82
83
84 begin
85 { Do not overwrite if already set, by powerpc specific code for example }
86 if not assigned(casmdata) then
87 casmdata:=TAsmDataDef;
88 end.
89
90