瀏覽代碼

* quick fix for broken relocation in stabs

git-svn-id: trunk@4874 -
peter 19 年之前
父節點
當前提交
b7386124c4
共有 2 個文件被更改,包括 24 次插入12 次删除
  1. 18 11
      compiler/ogcoff.pas
  2. 6 1
      compiler/ogelf.pas

+ 18 - 11
compiler/ogcoff.pas

@@ -1037,11 +1037,6 @@ const pemagic : array[0..3] of byte = (
       begin
       begin
         if not assigned(StabsSec) then
         if not assigned(StabsSec) then
           internalerror(200602256);
           internalerror(200602256);
-        { Win32 does not need an offset if a symbol relocation is used }
-        if win32 and
-           assigned(ps) and
-           (ps.bind<>AB_LOCAL) then
-          offset:=0;
         if assigned(p) and (p[0]<>#0) then
         if assigned(p) and (p[0]<>#0) then
           begin
           begin
             stabstrlen:=strlen(p);
             stabstrlen:=strlen(p);
@@ -1080,12 +1075,24 @@ const pemagic : array[0..3] of byte = (
          begin
          begin
            { current address }
            { current address }
            curraddr:=StabsSec.mempos+StabsSec.Size;
            curraddr:=StabsSec.mempos+StabsSec.Size;
-           if DLLSource and RelocSection then
-            { avoid relocation in the .stab section
-              because it ends up in the .reloc section instead }
-            StabsSec.addsymreloc(curraddr-4,ps,RELOC_RVA)
-           else
-            StabsSec.addsymreloc(curraddr-4,ps,RELOC_ABSOLUTE);
+	   if ps.bind=AB_LOCAL then
+	     begin
+               { avoid relocation in the .stab section
+                 because it ends up in the .reloc section instead }
+               if DLLSource and RelocSection then
+                 StabsSec.addsectionreloc(curraddr-4,ps.ObjSection,RELOC_RVA)
+               else
+                 StabsSec.addsectionreloc(curraddr-4,ps.ObjSection,RELOC_ABSOLUTE);
+	     end
+	   else
+	     begin
+               { avoid relocation in the .stab section
+                 because it ends up in the .reloc section instead }
+               if DLLSource and RelocSection then
+                 StabsSec.addsymreloc(curraddr-4,ps,RELOC_RVA)
+               else
+                 StabsSec.addsymreloc(curraddr-4,ps,RELOC_ABSOLUTE);
+	     end;     
          end;
          end;
       end;
       end;
 
 

+ 6 - 1
compiler/ogelf.pas

@@ -671,7 +671,12 @@ implementation
         stab.nvalue:=offset;
         stab.nvalue:=offset;
         stabssec.write(stab,sizeof(stab));
         stabssec.write(stab,sizeof(stab));
         if assigned(ps) then
         if assigned(ps) then
-          stabssec.addsymreloc(stabssec.Size-4,ps,RELOC_ABSOLUTE);
+	  begin
+	    if ps.bind=AB_LOCAL then
+              stabssec.addsectionreloc(stabssec.Size-4,ps.Objsection,RELOC_ABSOLUTE)
+	    else  
+              stabssec.addsymreloc(stabssec.Size-4,ps,RELOC_ABSOLUTE);
+	  end;      
       end;
       end;