Browse Source

* workaround for issue #30348, FPC allowes now 65535 sections in coff object files, but as the section index is normally signed, this is only a dirty workaround

git-svn-id: trunk@34904 -
florian 8 years ago
parent
commit
3f072b3e29
3 changed files with 21 additions and 4 deletions
  1. 1 0
      .gitattributes
  2. 5 4
      compiler/ogcoff.pas
  3. 15 0
      tests/webtbs/tw30348.pp

+ 1 - 0
.gitattributes

@@ -15230,6 +15230,7 @@ tests/webtbs/tw3028.pp svneol=native#text/plain
 tests/webtbs/tw30299.pp svneol=native#text/plain
 tests/webtbs/tw30310.pp svneol=native#text/plain
 tests/webtbs/tw30329.pp -text svneol=native#text/plain
+tests/webtbs/tw30348.pp svneol=native#text/pascal
 tests/webtbs/tw30357.pp svneol=native#text/pascal
 tests/webtbs/tw3038.pp svneol=native#text/plain
 tests/webtbs/tw3041.pp svneol=native#text/plain

+ 5 - 4
compiler/ogcoff.pas

@@ -168,7 +168,7 @@ interface
          { Convert symidx -> TObjSymbol }
          FSymTbl   : ^TObjSymbolArray;
          { Convert secidx -> TObjSection }
-         FSecCount : smallint;
+         FSecCount : Longint;
          FSecTbl   : ^TObjSectionArray;
          win32     : boolean;
          function  GetSection(secidx:longint):TObjSection;
@@ -1583,6 +1583,7 @@ const pemagic : array[0..3] of byte = (
         result:=nil;
         if (secidx<1) or (secidx>FSecCount) then
           begin
+            writeln(secidx,' ',FSecCount);
             InputError('Failed reading coff file, invalid section index');
             exit;
           end;
@@ -1751,7 +1752,7 @@ const pemagic : array[0..3] of byte = (
                     else
                      begin
                        bind:=AB_GLOBAL;
-                       objsec:=GetSection(sym.section);
+                       objsec:=GetSection(word(sym.section));
                        if sym.value>=objsec.mempos then
                          address:=sym.value-objsec.mempos;
                      end;
@@ -1768,7 +1769,7 @@ const pemagic : array[0..3] of byte = (
                     { do not add constants (section=-1) }
                     if sym.section<>-1 then
                      begin
-                       objsec:=GetSection(sym.section);
+                       objsec:=GetSection(word(sym.section));
                        if sym.value>=objsec.mempos then
                          address:=sym.value-objsec.mempos;
                        objsym:=CreateSymbol(strname);
@@ -1782,7 +1783,7 @@ const pemagic : array[0..3] of byte = (
                 COFF_SYM_SECTION :
                   begin
                     { GetSection checks that index is in range }
-                    objsec:=GetSection(sym.section);
+                    objsec:=GetSection(word(sym.section));
                     if assigned(objsec) then
                       begin
                         if sym.value>=objsec.mempos then

+ 15 - 0
tests/webtbs/tw30348.pp

@@ -0,0 +1,15 @@
+{ %os=win32,win64 }
+program project1;
+
+{$mode objfpc}{$H+}
+
+uses
+  {$IFDEF UNIX}{$IFDEF UseCThreads}
+  cthreads,
+  {$ENDIF}{$ENDIF}
+  Classes, JwaWindows
+  { you can add units after this };
+
+begin
+end.
+