mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 23:09:09 +02:00
* fix Mantis #8760: do not put actually empty sections in executable by internal linker.
* .bss section no longer required by internal linker. git-svn-id: trunk@7316 -
This commit is contained in:
parent
fa232dd4ac
commit
821c91c230
@ -949,6 +949,7 @@ Implementation
|
|||||||
myexit;
|
myexit;
|
||||||
var
|
var
|
||||||
bsssize : aint;
|
bsssize : aint;
|
||||||
|
bsssec : TExeSection;
|
||||||
begin
|
begin
|
||||||
result:=false;
|
result:=false;
|
||||||
|
|
||||||
@ -996,7 +997,11 @@ Implementation
|
|||||||
{$warning TODO fixed section names}
|
{$warning TODO fixed section names}
|
||||||
status.codesize:=exeoutput.findexesection('.text').size;
|
status.codesize:=exeoutput.findexesection('.text').size;
|
||||||
status.datasize:=exeoutput.findexesection('.data').size;
|
status.datasize:=exeoutput.findexesection('.data').size;
|
||||||
bsssize:=exeoutput.findexesection('.bss').size;
|
bsssec:=exeoutput.findexesection('.bss');
|
||||||
|
if assigned(bsssec) then
|
||||||
|
bsssize:=bsssec.size
|
||||||
|
else
|
||||||
|
bsssize:=0;
|
||||||
|
|
||||||
{ Executable info }
|
{ Executable info }
|
||||||
Message1(execinfo_x_codesize,tostr(status.codesize));
|
Message1(execinfo_x_codesize,tostr(status.codesize));
|
||||||
|
@ -2317,8 +2317,9 @@ implementation
|
|||||||
|
|
||||||
procedure TExeOutput.RemoveEmptySections;
|
procedure TExeOutput.RemoveEmptySections;
|
||||||
var
|
var
|
||||||
i : longint;
|
i, j : aint;
|
||||||
exesec : TExeSection;
|
exesec : TExeSection;
|
||||||
|
doremove : boolean;
|
||||||
begin
|
begin
|
||||||
for i:=0 to ExeSectionList.Count-1 do
|
for i:=0 to ExeSectionList.Count-1 do
|
||||||
begin
|
begin
|
||||||
@ -2335,14 +2336,26 @@ implementation
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if not(oso_keep in exesec.SecOptions) and
|
doremove:=not(oso_keep in exesec.SecOptions) and
|
||||||
(
|
(
|
||||||
(exesec.ObjSectionlist.count=0) or
|
(exesec.ObjSectionlist.count=0) or
|
||||||
(
|
(
|
||||||
(cs_link_strip in current_settings.globalswitches) and
|
(cs_link_strip in current_settings.globalswitches) and
|
||||||
(oso_debug in exesec.SecOptions)
|
(oso_debug in exesec.SecOptions)
|
||||||
)
|
)
|
||||||
) then
|
);
|
||||||
|
if not doremove then
|
||||||
|
begin
|
||||||
|
{ Check if section has no actual data }
|
||||||
|
doremove:=true;
|
||||||
|
for j:=0 to exesec.ObjSectionList.Count-1 do
|
||||||
|
if TObjSection(exesec.ObjSectionList[j]).Size<>0 then
|
||||||
|
begin
|
||||||
|
doremove:=false;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if doremove then
|
||||||
begin
|
begin
|
||||||
Comment(V_Debug,'Deleting empty section '+exesec.name);
|
Comment(V_Debug,'Deleting empty section '+exesec.name);
|
||||||
ExeSectionList[i]:=nil;
|
ExeSectionList[i]:=nil;
|
||||||
|
@ -2113,8 +2113,7 @@ const pemagic : array[0..3] of byte = (
|
|||||||
dataExeSec:=FindExeSection('.data');
|
dataExeSec:=FindExeSection('.data');
|
||||||
bssExeSec:=FindExeSection('.bss');
|
bssExeSec:=FindExeSection('.bss');
|
||||||
if not assigned(TextExeSec) or
|
if not assigned(TextExeSec) or
|
||||||
not assigned(DataExeSec) or
|
not assigned(DataExeSec) then
|
||||||
not assigned(BSSExeSec) then
|
|
||||||
internalerror(200602231);
|
internalerror(200602231);
|
||||||
{ Stub }
|
{ Stub }
|
||||||
if win32 then
|
if win32 then
|
||||||
@ -2162,7 +2161,8 @@ const pemagic : array[0..3] of byte = (
|
|||||||
peoptheader.MinorLinkerVersion:=(ord(release_nr)-ord('0'))*10 + (ord(patch_nr)-ord('0'));
|
peoptheader.MinorLinkerVersion:=(ord(release_nr)-ord('0'))*10 + (ord(patch_nr)-ord('0'));
|
||||||
peoptheader.tsize:=TextExeSec.Size;
|
peoptheader.tsize:=TextExeSec.Size;
|
||||||
peoptheader.dsize:=DataExeSec.Size;
|
peoptheader.dsize:=DataExeSec.Size;
|
||||||
peoptheader.bsize:=BSSExeSec.Size;
|
if assigned(BSSExeSec) then
|
||||||
|
peoptheader.bsize:=BSSExeSec.Size;
|
||||||
peoptheader.text_start:=TextExeSec.mempos;
|
peoptheader.text_start:=TextExeSec.mempos;
|
||||||
{$ifndef x86_64}
|
{$ifndef x86_64}
|
||||||
peoptheader.data_start:=DataExeSec.mempos;
|
peoptheader.data_start:=DataExeSec.mempos;
|
||||||
@ -2211,7 +2211,8 @@ const pemagic : array[0..3] of byte = (
|
|||||||
djoptheader.magic:=COFF_OPT_MAGIC;
|
djoptheader.magic:=COFF_OPT_MAGIC;
|
||||||
djoptheader.tsize:=TextExeSec.Size;
|
djoptheader.tsize:=TextExeSec.Size;
|
||||||
djoptheader.dsize:=DataExeSec.Size;
|
djoptheader.dsize:=DataExeSec.Size;
|
||||||
djoptheader.bsize:=BSSExeSec.Size;
|
if assigned(BSSExeSec) then
|
||||||
|
djoptheader.bsize:=BSSExeSec.Size;
|
||||||
djoptheader.text_start:=TextExeSec.mempos;
|
djoptheader.text_start:=TextExeSec.mempos;
|
||||||
djoptheader.data_start:=DataExeSec.mempos;
|
djoptheader.data_start:=DataExeSec.mempos;
|
||||||
djoptheader.entry:=EntrySym.offset;
|
djoptheader.entry:=EntrySym.offset;
|
||||||
|
Loading…
Reference in New Issue
Block a user