diff --git a/compiler/aggas.pas b/compiler/aggas.pas index ccec72eea6..6387aafd60 100644 --- a/compiler/aggas.pas +++ b/compiler/aggas.pas @@ -615,22 +615,26 @@ implementation end else begin + { The .comm is required for COMMON symbols. These are used + in the shared library loading. All the symbols declared in + the .so file need to resolve to the data allocated in the main + program (PFV) } if Tai_datablock(hp).is_global then begin - asmwrite(#9'.globl '); - asmwriteln(Tai_datablock(hp).sym.name); - end; - if (target_info.system <> system_arm_linux) then - sepChar := '@' + asmwrite(#9'.comm'#9); + asmwrite(tai_datablock(hp).sym.name); + asmwrite(','+tostr(tai_datablock(hp).size)); + asmwrite(','+tostr(last_align)); + asmwriteln(''); + end else - sepChar := '%'; - if (tf_needs_symbol_type in target_info.flags) then - asmwriteln(#9'.type '+Tai_datablock(hp).sym.name+','+sepChar+'object'); - if (tf_needs_symbol_size in target_info.flags) and (tai_datablock(hp).size > 0) then - asmwriteln(#9'.size '+Tai_datablock(hp).sym.name+','+tostr(Tai_datablock(hp).size)); - asmwrite(Tai_datablock(hp).sym.name); - asmwriteln(':'); - asmwriteln(#9'.zero '+tostr(Tai_datablock(hp).size)); + begin + asmwrite(#9'.lcomm'#9); + asmwrite(tai_datablock(hp).sym.name); + asmwrite(','+tostr(tai_datablock(hp).size)); + asmwrite(','+tostr(last_align)); + asmwriteln(''); + end; end; end; diff --git a/compiler/assemble.pas b/compiler/assemble.pas index 352d023163..28e3b09bd9 100644 --- a/compiler/assemble.pas +++ b/compiler/assemble.pas @@ -276,7 +276,6 @@ Implementation end; var - dir : TSearchRec; hs : string; begin if PathExists(s,false) then @@ -713,6 +712,8 @@ Implementation end; hs[0]:=chr(len); val(hs,exprvalue,code); + if code<>0 then + internalerror(200702251); end; '.','_', 'A'..'Z', @@ -918,9 +919,14 @@ Implementation end; ait_datablock : begin - ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign)); - ObjData.SymbolDefine(Tai_datablock(hp).sym); - ObjData.alloc(Tai_datablock(hp).size); + if Tai_datablock(hp).is_global then + ObjData.SymbolDefine(Tai_datablock(hp).sym) + else + begin + ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign)); + ObjData.SymbolDefine(Tai_datablock(hp).sym); + ObjData.alloc(Tai_datablock(hp).size); + end; end; ait_real_80bit : ObjData.alloc(10); @@ -979,10 +985,19 @@ Implementation begin if (oso_data in ObjData.CurrObjSec.secoptions) then Message(asmw_e_alloc_data_only_in_bss); - ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign)); - objsym:=ObjData.SymbolDefine(Tai_datablock(hp).sym); - objsym.size:=Tai_datablock(hp).size; - ObjData.alloc(Tai_datablock(hp).size); + if Tai_datablock(hp).is_global then + begin + objsym:=ObjData.SymbolDefine(Tai_datablock(hp).sym); + objsym.size:=Tai_datablock(hp).size; + objsym.bind:=AB_COMMON; + end + else + begin + ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign)); + objsym:=ObjData.SymbolDefine(Tai_datablock(hp).sym); + objsym.size:=Tai_datablock(hp).size; + ObjData.alloc(Tai_datablock(hp).size); + end; end; ait_real_80bit : ObjData.alloc(10); @@ -1074,9 +1089,12 @@ Implementation end; ait_datablock : begin - ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign)); ObjOutput.exportsymbol(ObjData.SymbolRef(Tai_datablock(hp).sym)); - ObjData.alloc(Tai_datablock(hp).size); + if not Tai_datablock(hp).is_global then + begin + ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign)); + ObjData.alloc(Tai_datablock(hp).size); + end; end; ait_real_80bit : ObjData.writebytes(Tai_real_80bit(hp).value,10);