* fix for DLL relocation problems

* external bss vars had wrong stabs for pecoff
  + -WB11000000 to specify default image base, allows to
    load several DLLs with debugging info included
    (relocatable DLL are stripped because the relocation
     of the .Stab section is misplaced by ldw)
This commit is contained in:
pierre 1999-08-16 15:35:20 +00:00
parent 157bc635ce
commit 96fdcfb1f2
7 changed files with 104 additions and 13 deletions

View File

@ -52,4 +52,7 @@ Changes in the syntax or semantic of FPC:
exceptions and exceptions need the class OOP model exceptions and exceptions need the class OOP model
18/05/99 The compiler will stop directly if there are errors in the 18/05/99 The compiler will stop directly if there are errors in the
commandline parameters commandline parameters
16/08/99 DLL are relocatable by default (need to strip symbols)
-WN make non relocatable DLL (which can retain debug info)
for both type of DLL the prefered image base can be specified
with -WB1100000 for instance to get image base at $11000000.

View File

@ -170,6 +170,7 @@ unit globals;
const const
RelocSection : boolean = true; RelocSection : boolean = true;
DLLsource : boolean = false; DLLsource : boolean = false;
DLLImageBase : pstring = nil;
{ should we allow non static members ? } { should we allow non static members ? }
allow_only_static : boolean = false; allow_only_static : boolean = false;
@ -1168,6 +1169,8 @@ unit globals;
procedure DoneGlobals; procedure DoneGlobals;
begin begin
initdefines.done; initdefines.done;
if assigned(DLLImageBase) then
StringDispose(DLLImageBase);
end; end;
procedure InitGlobals; procedure InitGlobals;
@ -1233,7 +1236,15 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.18 1999-08-11 17:26:32 peter Revision 1.19 1999-08-16 15:35:21 pierre
* fix for DLL relocation problems
* external bss vars had wrong stabs for pecoff
+ -WB11000000 to specify default image base, allows to
load several DLLs with debugging info included
(relocatable DLL are stripped because the relocation
of the .Stab section is misplaced by ldw)
Revision 1.18 1999/08/11 17:26:32 peter
* tlinker object is now inherited for win32 and dos * tlinker object is now inherited for win32 and dos
* postprocessexecutable is now a method of tlinker * postprocessexecutable is now a method of tlinker

View File

@ -587,6 +587,9 @@ var
success : boolean; success : boolean;
ii : longint; ii : longint;
begin begin
{ can be changed after InitLinker
for DLLs due to relocation problems PM }
Strip:=(cs_link_strip in aktglobalswitches);
{$ifdef linux} {$ifdef linux}
if LinkToC then if LinkToC then
begin begin
@ -632,8 +635,9 @@ begin
same memory pool. The heap grows upwards, the stack grows downwards.} same memory pool. The heap grows upwards, the stack grows downwards.}
Replace(s,'$DOSHEAPKB',tostr((stacksize+maxheapsize+1023) shr 10)); Replace(s,'$DOSHEAPKB',tostr((stacksize+maxheapsize+1023) shr 10));
if Strip and Target_Link.StripBind then if Strip and Target_Link.StripBind then
Replace (S, '$STRIP', Target_Link.StripOpt) else Replace (S, '$STRIP', Target_Link.StripOpt)
Replace (S, '$STRIP', ''); else
Replace (S, '$STRIP', '');
if utilsdirectory<>'' then if utilsdirectory<>'' then
begin begin
bindbin:=Search(target_link.bindbin[ii]+source_os.exeext, bindbin:=Search(target_link.bindbin[ii]+source_os.exeext,
@ -767,7 +771,15 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.66 1999-08-11 17:26:34 peter Revision 1.67 1999-08-16 15:35:23 pierre
* fix for DLL relocation problems
* external bss vars had wrong stabs for pecoff
+ -WB11000000 to specify default image base, allows to
load several DLLs with debugging info included
(relocatable DLL are stripped because the relocation
of the .Stab section is misplaced by ldw)
Revision 1.66 1999/08/11 17:26:34 peter
* tlinker object is now inherited for win32 and dos * tlinker object is now inherited for win32 and dos
* postprocessexecutable is now a method of tlinker * postprocessexecutable is now a method of tlinker

View File

@ -614,6 +614,10 @@ unit og386cff;
s:=currsec s:=currsec
else } else }
s:=section; s:=section;
{ do not use the size stored in offset field
this is DJGPP specific ! PM }
if win32 then
offset:=0;
{ local var can be at offset -1 !! PM } { local var can be at offset -1 !! PM }
if reloc then if reloc then
begin begin
@ -960,7 +964,15 @@ unit og386cff;
end. end.
{ {
$Log$ $Log$
Revision 1.11 1999-08-11 17:17:38 peter Revision 1.12 1999-08-16 15:35:25 pierre
* fix for DLL relocation problems
* external bss vars had wrong stabs for pecoff
+ -WB11000000 to specify default image base, allows to
load several DLLs with debugging info included
(relocatable DLL are stripped because the relocation
of the .Stab section is misplaced by ldw)
Revision 1.11 1999/08/11 17:17:38 peter
* fixed rva writting for section relocs * fixed rva writting for section relocs
* fixed section flags for edata and idata * fixed section flags for edata and idata

View File

@ -663,12 +663,28 @@ begin
IllegalPara(opt); IllegalPara(opt);
'W' : begin 'W' : begin
for j:=1 to length(More) do for j:=1 to length(More) do
case More[j]of case More[j] of
'B': {bind_win32_dll:=true} 'B': {bind_win32_dll:=true}
RelocSection:=true; begin
{ -WB200000 means set prefered base address
to $200000, but does not change relocsection boolean
this way we can create both relocatble and
non relocatable DLL at a specific base address PM }
if (length(More)>j) then
begin
if DLLImageBase=nil then
DLLImageBase:=StringDup(Copy(More,j+1,255));
end
else
RelocSection:=true;
break;
end;
'C': apptype:=at_cui; 'C': apptype:=at_cui;
'G': apptype:=at_gui; 'G': apptype:=at_gui;
'N': RelocSection:=false; 'N': begin
RelocSection:=false;
end;
'R': RelocSection:=true; 'R': RelocSection:=true;
else else
IllegalPara(opt); IllegalPara(opt);
@ -1163,7 +1179,15 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.13 1999-08-11 17:26:35 peter Revision 1.14 1999-08-16 15:35:26 pierre
* fix for DLL relocation problems
* external bss vars had wrong stabs for pecoff
+ -WB11000000 to specify default image base, allows to
load several DLLs with debugging info included
(relocatable DLL are stripped because the relocation
of the .Stab section is misplaced by ldw)
Revision 1.13 1999/08/11 17:26:35 peter
* tlinker object is now inherited for win32 and dos * tlinker object is now inherited for win32 and dos
* postprocessexecutable is now a method of tlinker * postprocessexecutable is now a method of tlinker

View File

@ -233,12 +233,19 @@ unit pmodules;
target_link.linkcmd:=target_link.linkcmd+' --base-file base.$$$'; target_link.linkcmd:=target_link.linkcmd+' --base-file base.$$$';
target_link.bindcmd[1]:=target_link.bindcmd[1]+' --base-file base.$$$'; target_link.bindcmd[1]:=target_link.bindcmd[1]+' --base-file base.$$$';
end; end;
if assigned(DLLImageBase) then
begin
target_link.linkcmd:=target_link.linkcmd+' --image-base=0x'+DLLImageBase^;
target_link.bindcmd[2]:=target_link.bindcmd[2]+' --image-base=0x'+DLLImageBase^;
end;
end; end;
if apptype=at_gui then if apptype=at_gui then
begin begin
target_link.linkcmd:='--subsystem windows '+target_link.linkcmd; target_link.linkcmd:='--subsystem windows '+target_link.linkcmd;
target_link.bindcmd[2]:='--subsystem windows '+target_link.bindcmd[2]; target_link.bindcmd[2]:='--subsystem windows '+target_link.bindcmd[2];
end; end;
if (cs_link_strip in aktglobalswitches) then
target_link.bindcmd[2]:='-s '+target_link.bindcmd[2];
end; end;
{$endif i386} {$endif i386}
{$ifdef m68k} {$ifdef m68k}
@ -1189,6 +1196,12 @@ unit pmodules;
if islibrary then if islibrary then
begin begin
consume(_LIBRARY); consume(_LIBRARY);
{ relocation works only without stabs !! PM }
if RelocSection then
begin
aktglobalswitches:=aktglobalswitches+[cs_link_strip];
aktmoduleswitches:=aktmoduleswitches-[cs_debuginfo];
end;
stringdispose(current_module^.modulename); stringdispose(current_module^.modulename);
current_module^.modulename:=stringdup(pattern); current_module^.modulename:=stringdup(pattern);
current_module^.islibrary:=true; current_module^.islibrary:=true;
@ -1356,7 +1369,15 @@ unit pmodules;
end. end.
{ {
$Log$ $Log$
Revision 1.141 1999-08-11 17:26:36 peter Revision 1.142 1999-08-16 15:35:27 pierre
* fix for DLL relocation problems
* external bss vars had wrong stabs for pecoff
+ -WB11000000 to specify default image base, allows to
load several DLLs with debugging info included
(relocatable DLL are stripped because the relocation
of the .Stab section is misplaced by ldw)
Revision 1.141 1999/08/11 17:26:36 peter
* tlinker object is now inherited for win32 and dos * tlinker object is now inherited for win32 and dos
* postprocessexecutable is now a method of tlinker * postprocessexecutable is now a method of tlinker

View File

@ -895,7 +895,7 @@ implementation
binders : 0; binders : 0;
bindbin : ('dlltool','ldw'); bindbin : ('dlltool','ldw');
bindcmd : ('--as asw.exe --dllname $EXE --output-exp exp.$$$', bindcmd : ('--as asw.exe --dllname $EXE --output-exp exp.$$$',
'-s $OPT -o $EXE $RES exp.$$$'); '$OPT -o $EXE $RES exp.$$$');
stripopt : '-s'; stripopt : '-s';
stripbind : false; stripbind : false;
libpathprefix : 'SEARCH_DIR('; libpathprefix : 'SEARCH_DIR(';
@ -1734,7 +1734,15 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.90 1999-08-04 13:03:11 jonas Revision 1.91 1999-08-16 15:35:29 pierre
* fix for DLL relocation problems
* external bss vars had wrong stabs for pecoff
+ -WB11000000 to specify default image base, allows to
load several DLLs with debugging info included
(relocatable DLL are stripped because the relocation
of the .Stab section is misplaced by ldw)
Revision 1.90 1999/08/04 13:03:11 jonas
* all tokens now start with an underscore * all tokens now start with an underscore
* PowerPC compiles!! * PowerPC compiles!!