From 3f072b3e29a1ef440c86c5d8c3257ea2dc265ef2 Mon Sep 17 00:00:00 2001 From: florian Date: Tue, 15 Nov 2016 22:06:00 +0000 Subject: [PATCH] * 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 - --- .gitattributes | 1 + compiler/ogcoff.pas | 9 +++++---- tests/webtbs/tw30348.pp | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/webtbs/tw30348.pp diff --git a/.gitattributes b/.gitattributes index c759f73659..b8f666a8b8 100644 --- a/.gitattributes +++ b/.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 diff --git a/compiler/ogcoff.pas b/compiler/ogcoff.pas index df2aa3fccb..05a225838d 100644 --- a/compiler/ogcoff.pas +++ b/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 diff --git a/tests/webtbs/tw30348.pp b/tests/webtbs/tw30348.pp new file mode 100644 index 0000000000..515348eba7 --- /dev/null +++ b/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. +