Explorar o código

* Fixed stabs generation for DLLs by internal assembler (use RELOC_ABSOLUTE in all cases).
* Do not generate relocs by internal linker for sections which are not loaded in memory.

git-svn-id: trunk@7829 -

yury %!s(int64=18) %!d(string=hai) anos
pai
achega
04147151e4
Modificáronse 2 ficheiros con 7 adicións e 10 borrados
  1. 1 8
      compiler/assemble.pas
  2. 6 2
      compiler/ogcoff.pas

+ 1 - 8
compiler/assemble.pas

@@ -796,7 +796,6 @@ Implementation
         pcurr,
         pendquote : pchar;
         oldsec    : TObjSection;
-        reltype   : TObjRelocationType;
       begin
         pcurr:=nil;
         pstr:=nil;
@@ -885,13 +884,7 @@ Implementation
             oldsec:=ObjData.CurrObjSec;
             ObjData.SetSection(ObjData.StabsSec);
             ObjData.Writebytes(stab,sizeof(TObjStabEntry)-4);
-            if assigned(relocsym) and
-               (target_info.system in system_windows+system_wince) and
-               (DLLSource and RelocSection) then
-              reltype:=RELOC_RVA
-            else
-              reltype:=RELOC_ABSOLUTE;
-            ObjData.Writereloc(stab.nvalue,4,relocsym,reltype);
+            ObjData.Writereloc(stab.nvalue,4,relocsym,RELOC_ABSOLUTE);
             ObjData.setsection(oldsec);
           end;
         if assigned(pendquote) then

+ 6 - 2
compiler/ogcoff.pas

@@ -1501,7 +1501,6 @@ const pemagic : array[0..3] of byte = (
         rel_type  : TObjRelocationType;
         i         : longint;
         p         : TObjSymbol;
-        extradist : longint;
       begin
         for i:=1 to s.coffrelocs do
          begin
@@ -2532,12 +2531,17 @@ const pemagic : array[0..3] of byte = (
             for j:=0 to exesec.ObjSectionList.count-1 do
               begin
                 objsec:=TObjSection(exesec.ObjSectionList[j]);
+                { create relocs only for sections which are loaded in memory }
+                if not (oso_load in objsec.SecOptions) then
+                  continue;
                 for k:=0 to objsec.ObjRelocations.Count-1 do
                   begin
                     objreloc:=TObjRelocation(objsec.ObjRelocations[k]);
                     if not (objreloc.typ in [{$ifdef x86_64}RELOC_ABSOLUTE32,{$endif x86_64}RELOC_ABSOLUTE]) then
                       continue;
                     offset:=objsec.MemPos+objreloc.dataoffset;
+                    if offset<pgaddr then
+                      Internalerror(2007062701);
                     if (offset-pgaddr>=4096) or (pgaddr=-1) then
                       begin
                         FinishBlock;
@@ -2566,7 +2570,7 @@ const pemagic : array[0..3] of byte = (
         exesec:=FindExeSection('.reloc');
         if exesec=nil then
           exit;
-        exesec.SecOptions:=exesec.SecOptions + [oso_Data,oso_keep];
+        exesec.SecOptions:=exesec.SecOptions + [oso_Data,oso_keep,oso_load];
       end;