* 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

@ -250,7 +250,7 @@ implementation
{ vtable for a class called Window: } { vtable for a class called Window: }
{ .section .data.rel.ro._ZTV6Window,"awG",@progbits,_ZTV6Window,comdat } { .section .data.rel.ro._ZTV6Window,"awG",@progbits,_ZTV6Window,comdat }
{$warning TODO .data.ro not yet working} {$warning TODO .data.ro not yet working}
{$if defined(arm) or defined(powerpc)} {$if defined(arm) or defined(powerpc)}
'.rodata', '.rodata',
{$else arm} {$else arm}
'.data', '.data',
@ -258,7 +258,7 @@ implementation
{$if defined(m68k)} { Amiga/m68k GNU AS doesn't seem to like .rodata (KB) } {$if defined(m68k)} { Amiga/m68k GNU AS doesn't seem to like .rodata (KB) }
'.data', '.data',
{$else} {$else}
'.rodata', '.rodata',
{$endif} {$endif}
'.bss', '.bss',
'.threadvar', '.threadvar',
@ -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,27 +630,53 @@ 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
{ The .comm is required for COMMON symbols. These are used {$ifdef USE_COMM_IN_BSS}
in the shared library loading. All the symbols declared in if writingpackages then
the .so file need to resolve to the data allocated in the main
program (PFV) }
if Tai_datablock(hp).is_global then
begin begin
asmwrite(#9'.comm'#9); { The .comm is required for COMMON symbols. These are used
asmwrite(tai_datablock(hp).sym.name); in the shared library loading. All the symbols declared in
asmwrite(','+tostr(tai_datablock(hp).size)); the .so file need to resolve to the data allocated in the main
asmln; program (PFV) }
if tai_datablock(hp).is_global then
begin
asmwrite(#9'.comm'#9);
asmwrite(tai_datablock(hp).sym.name);
asmwrite(','+tostr(tai_datablock(hp).size));
asmwrite(','+tostr(last_align));
asmln;
end
else
begin
asmwrite(#9'.lcomm'#9);
asmwrite(tai_datablock(hp).sym.name);
asmwrite(','+tostr(tai_datablock(hp).size));
asmwrite(','+tostr(last_align));
asmln;
end
end end
else else
{$endif USE_COMM_IN_BSS}
begin begin
asmwrite(#9'.lcomm'#9); if Tai_datablock(hp).is_global then
asmwrite(tai_datablock(hp).sym.name); begin
asmwrite(','+tostr(tai_datablock(hp).size)); asmwrite(#9'.globl ');
asmln; 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.