Browse Source

* Fixed a bug introduced in r23077: relative_reloc_count must be increased only once per GOT entry, not every time a relocation to that entry is seen.

git-svn-id: trunk@23126 -
sergei 12 years ago
parent
commit
a771d68685
2 changed files with 7 additions and 5 deletions
  1. 4 2
      compiler/ogelf.pas
  2. 3 3
      compiler/x86_64/cpuelf.pas

+ 4 - 2
compiler/ogelf.pas

@@ -244,7 +244,7 @@ interface
          dynreloclist: TFPObjectList;
          tlsseg: TElfSegment;
          relative_reloc_count: longint;
-         procedure AllocGOTSlot(objsym: TObjSymbol);
+         function AllocGOTSlot(objsym: TObjSymbol):boolean;
          procedure WriteDynRelocEntry(dataofs:aword;typ:byte;symidx:aword;addend:aword);
          procedure WriteFirstPLTEntry;virtual;abstract;
          procedure WritePLTEntry(exesym:TExeSymbol);virtual;
@@ -1994,10 +1994,11 @@ implementation
       end;
 
 
-    procedure TElfExeOutput.AllocGOTSlot(objsym:TObjSymbol);
+    function TElfExeOutput.AllocGOTSlot(objsym:TObjSymbol):boolean;
       var
         exesym: TExeSymbol;
       begin
+        result:=false;
         exesym:=objsym.exesymbol;
 
         { Although local symbols should not be accessed through GOT,
@@ -2019,6 +2020,7 @@ implementation
           only the latter applies. }
         if IsSharedLibrary or (exesym.dynindex>0) then
           dynrelocsec.alloc(dynrelocsec.shentsize);
+        result:=true;
       end;
 
 

+ 3 - 3
compiler/x86_64/cpuelf.pas

@@ -241,9 +241,9 @@ implementation
         R_X86_64_GOTPCREL,
         R_X86_64_GOTPCREL64:
           begin
-            AllocGOTSlot(objreloc.symbol);
-            if IsSharedLibrary and (objreloc.symbol.exesymbol.dynindex=0) then
-              Inc(relative_reloc_count);
+            if AllocGOTSlot(objreloc.symbol) then
+              if IsSharedLibrary and (objreloc.symbol.exesymbol.dynindex=0) then
+                Inc(relative_reloc_count);
           end;
 
         //R_X86_64_TLSGD,