* allocate .bss entries manual so we can take care of alignment

* disable COMMON symbol code, it might be needed again for ELF package
    support (.comm for ELF supports alignment)

git-svn-id: trunk@10549 -
This commit is contained in:
peter 2008-03-24 11:55:03 +00:00
parent 3e1149f740
commit 52722b2cab
5 changed files with 147 additions and 19 deletions

2
.gitattributes vendored
View File

@ -8108,6 +8108,8 @@ tests/webtbs/tw11006.pp svneol=native#text/plain
tests/webtbs/tw11027.pp svneol=native#text/plain tests/webtbs/tw11027.pp svneol=native#text/plain
tests/webtbs/tw1103.pp svneol=native#text/plain tests/webtbs/tw1103.pp svneol=native#text/plain
tests/webtbs/tw11033.pp svneol=native#text/plain tests/webtbs/tw11033.pp svneol=native#text/plain
tests/webtbs/tw11039a.pp svneol=native#text/plain
tests/webtbs/tw11039b.pp svneol=native#text/plain
tests/webtbs/tw1104.pp svneol=native#text/plain tests/webtbs/tw1104.pp svneol=native#text/plain
tests/webtbs/tw1111.pp svneol=native#text/plain tests/webtbs/tw1111.pp svneol=native#text/plain
tests/webtbs/tw1117.pp svneol=native#text/plain tests/webtbs/tw1117.pp svneol=native#text/plain

View File

@ -563,6 +563,7 @@ implementation
ait_align : ait_align :
begin begin
last_align := tai_align_abstract(hp).aligntype;
if tai_align_abstract(hp).aligntype>1 then if tai_align_abstract(hp).aligntype>1 then
begin begin
if not(target_info.system in systems_darwin) then if not(target_info.system in systems_darwin) then
@ -629,19 +630,23 @@ implementation
asmwrite(','+tostr(tai_datablock(hp).size)); asmwrite(','+tostr(tai_datablock(hp).size));
asmwrite(','+tostr(last_align)); asmwrite(','+tostr(last_align));
asmln; asmln;
end end;
end end
else else
begin begin
{$ifdef USE_COMM_IN_BSS}
if writingpackages then
begin
{ The .comm is required for COMMON symbols. These are used { The .comm is required for COMMON symbols. These are used
in the shared library loading. All the symbols declared in in the shared library loading. All the symbols declared in
the .so file need to resolve to the data allocated in the main the .so file need to resolve to the data allocated in the main
program (PFV) } program (PFV) }
if Tai_datablock(hp).is_global then if tai_datablock(hp).is_global then
begin begin
asmwrite(#9'.comm'#9); asmwrite(#9'.comm'#9);
asmwrite(tai_datablock(hp).sym.name); asmwrite(tai_datablock(hp).sym.name);
asmwrite(','+tostr(tai_datablock(hp).size)); asmwrite(','+tostr(tai_datablock(hp).size));
asmwrite(','+tostr(last_align));
asmln; asmln;
end end
else else
@ -649,7 +654,29 @@ implementation
asmwrite(#9'.lcomm'#9); asmwrite(#9'.lcomm'#9);
asmwrite(tai_datablock(hp).sym.name); asmwrite(tai_datablock(hp).sym.name);
asmwrite(','+tostr(tai_datablock(hp).size)); asmwrite(','+tostr(tai_datablock(hp).size));
asmwrite(','+tostr(last_align));
asmln; asmln;
end
end
else
{$endif USE_COMM_IN_BSS}
begin
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 := '@'
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));
end; end;
end; end;
end; end;

View File

@ -943,9 +943,12 @@ Implementation
end; end;
ait_datablock : ait_datablock :
begin begin
if Tai_datablock(hp).is_global then {$ifdef USE_COMM_IN_BSS}
if writingpackages and
Tai_datablock(hp).is_global then
ObjData.SymbolDefine(Tai_datablock(hp).sym) ObjData.SymbolDefine(Tai_datablock(hp).sym)
else else
{$endif USE_COMM_IN_BSS}
begin begin
ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign)); ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign));
ObjData.SymbolDefine(Tai_datablock(hp).sym); ObjData.SymbolDefine(Tai_datablock(hp).sym);
@ -1026,13 +1029,17 @@ Implementation
begin begin
if (oso_data in ObjData.CurrObjSec.secoptions) then if (oso_data in ObjData.CurrObjSec.secoptions) then
Message(asmw_e_alloc_data_only_in_bss); Message(asmw_e_alloc_data_only_in_bss);
if Tai_datablock(hp).is_global then {$ifdef USE_COMM_IN_BSS}
if writingpackages and
Tai_datablock(hp).is_global then
begin begin
objsym:=ObjData.SymbolDefine(Tai_datablock(hp).sym); objsym:=ObjData.SymbolDefine(Tai_datablock(hp).sym);
objsym.size:=Tai_datablock(hp).size; objsym.size:=Tai_datablock(hp).size;
objsym.bind:=AB_COMMON; objsym.bind:=AB_COMMON;
objsym.alignment:=needtowritealignmentalsoforELF;
end end
else else
{$endif USE_COMM_IN_BSS}
begin begin
ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign)); ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign));
objsym:=ObjData.SymbolDefine(Tai_datablock(hp).sym); objsym:=ObjData.SymbolDefine(Tai_datablock(hp).sym);
@ -1127,7 +1134,10 @@ Implementation
ait_datablock : ait_datablock :
begin begin
ObjOutput.exportsymbol(ObjData.SymbolRef(Tai_datablock(hp).sym)); ObjOutput.exportsymbol(ObjData.SymbolRef(Tai_datablock(hp).sym));
if not Tai_datablock(hp).is_global then {$ifdef USE_COMM_IN_BSS}
if not(writingpackages and
Tai_datablock(hp).is_global) then
{$endif USE_COMM_IN_BSS}
begin begin
ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign)); ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign));
ObjData.alloc(Tai_datablock(hp).size); ObjData.alloc(Tai_datablock(hp).size);

45
tests/webtbs/tw11039a.pp Normal file
View File

@ -0,0 +1,45 @@
{ %opt=-Xe }
{ %target=win32,win64 }
{$packrecords 16}
{$codealign varmin=16}
{$codealign localmin=16}
type
rec=record
v:array[0..511] of byte;
end;
var
a,b:longword;
x:rec;
y: longword;
begin
a:=b;
y:=1;
writeln(hexstr(@a));
if ptruint(@a) and $f<>0 then
begin
writeln('ERROR in alignment of a');
halt(1);
end;
writeln(hexstr(@b));
if ptruint(@b) and $f<>0 then
begin
writeln('ERROR in alignment of b');
halt(1);
end;
writeln(hexstr(@x));
if ptruint(@x) and $f<>0 then
begin
writeln('ERROR in alignment of x');
halt(1);
end;
writeln(hexstr(@y));
if ptruint(@y) and $f<>0 then
begin
writeln('ERROR in alignment of y');
halt(1);
end;
end.

44
tests/webtbs/tw11039b.pp Normal file
View File

@ -0,0 +1,44 @@
{ %opt=-Xe }
{$packrecords 16}
{$codealign varmin=16}
{$codealign localmin=16}
type
rec=record
v:array[0..511] of byte;
end;
var
a,b:longword;
x:rec;
y: longword;
begin
a:=b;
y:=1;
writeln(hexstr(@a));
if ptruint(@a) and $f<>0 then
begin
writeln('ERROR in alignment of a');
halt(1);
end;
writeln(hexstr(@b));
if ptruint(@b) and $f<>0 then
begin
writeln('ERROR in alignment of b');
halt(1);
end;
writeln(hexstr(@x));
if ptruint(@x) and $f<>0 then
begin
writeln('ERROR in alignment of x');
halt(1);
end;
writeln(hexstr(@y));
if ptruint(@y) and $f<>0 then
begin
writeln('ERROR in alignment of y');
halt(1);
end;
end.