Browse Source

+ introduce the TObjSectionOfs type - an unsigned integer, representing an
offset in an obj file section on the current platform; equal to PUInt for now,
but will probably change to LongWord on i8086, in order to support 32-bit
sections (needed for dwarf debug info or when linking with 32-bit object files
in a mixed 16-bit/32-bit application, while using the internal linker)

git-svn-id: trunk@39084 -

nickysn 7 years ago
parent
commit
04129b8c6e
1 changed files with 22 additions and 20 deletions
  1. 22 20
      compiler/ogbase.pas

+ 22 - 20
compiler/ogbase.pas

@@ -196,6 +196,8 @@ interface
        oscs_largest
        oscs_largest
      );
      );
 
 
+     TObjSectionOfs = PUInt;
+
      TObjSectionGroup = class;
      TObjSectionGroup = class;
 
 
      TObjSymbol = class(TFPHashObject)
      TObjSymbol = class(TFPHashObject)
@@ -209,7 +211,7 @@ interface
        symidx     : longint;
        symidx     : longint;
        objsection : TObjSection;
        objsection : TObjSection;
        offset,
        offset,
-       size       : PUInt;
+       size       : TObjSectionOfs;
        { Used for external and common solving during linking }
        { Used for external and common solving during linking }
        exesymbol  : TExeSymbol;
        exesymbol  : TExeSymbol;
 
 
@@ -278,7 +280,7 @@ interface
        SecAlign   : longint;   { alignment of the section }
        SecAlign   : longint;   { alignment of the section }
        { section Data }
        { section Data }
        Size,
        Size,
-       DataPos    : PUInt;
+       DataPos    : TObjSectionOfs;
        MemPos     : qword;
        MemPos     : qword;
        Group      : TObjSectionGroup;
        Group      : TObjSectionGroup;
        AssociativeSection : TObjSection;
        AssociativeSection : TObjSection;
@@ -292,19 +294,19 @@ interface
        VTRefList : TFPObjectList;
        VTRefList : TFPObjectList;
        constructor create(AList:TFPHashObjectList;const Aname:string;Aalign:longint;Aoptions:TObjSectionOptions);virtual;
        constructor create(AList:TFPHashObjectList;const Aname:string;Aalign:longint;Aoptions:TObjSectionOptions);virtual;
        destructor  destroy;override;
        destructor  destroy;override;
-       function  write(const d;l:PUInt):PUInt;
+       function  write(const d;l:TObjSectionOfs):TObjSectionOfs;
        { writes string plus zero byte }
        { writes string plus zero byte }
-       function  writestr(const s:string):PUInt;
-       function  WriteZeros(l:longword):PUInt;
+       function  writestr(const s:string):TObjSectionOfs;
+       function  WriteZeros(l:longword):TObjSectionOfs;
        { writes content of s without null termination }
        { writes content of s without null termination }
-       function  WriteBytes(const s:string):PUInt;
+       function  WriteBytes(const s:string):TObjSectionOfs;
        procedure writeReloc_internal(aTarget:TObjSection;offset:aword;len:byte;reltype:TObjRelocationType);virtual;
        procedure writeReloc_internal(aTarget:TObjSection;offset:aword;len:byte;reltype:TObjRelocationType);virtual;
        function  setmempos(mpos:qword):qword;
        function  setmempos(mpos:qword):qword;
-       procedure setDatapos(var dpos:PUInt);
-       procedure alloc(l:PUInt);
-       procedure addsymReloc(ofs:PUInt;p:TObjSymbol;Reloctype:TObjRelocationType);
-       procedure addsectionReloc(ofs:PUInt;aobjsec:TObjSection;Reloctype:TObjRelocationType);
-       procedure addrawReloc(ofs:PUInt;p:TObjSymbol;RawReloctype:byte);
+       procedure setDatapos(var dpos:TObjSectionOfs);
+       procedure alloc(l:TObjSectionOfs);
+       procedure addsymReloc(ofs:TObjSectionOfs;p:TObjSymbol;Reloctype:TObjRelocationType);
+       procedure addsectionReloc(ofs:TObjSectionOfs;aobjsec:TObjSection;Reloctype:TObjRelocationType);
+       procedure addrawReloc(ofs:TObjSectionOfs;p:TObjSymbol;RawReloctype:byte);
        procedure ReleaseData;
        procedure ReleaseData;
        function  FullName:string;
        function  FullName:string;
        { string representation for the linker map file }
        { string representation for the linker map file }
@@ -948,7 +950,7 @@ implementation
       end;
       end;
 
 
 
 
-    function TObjSection.write(const d;l:PUInt):PUInt;
+    function TObjSection.write(const d;l:TObjSectionOfs):TObjSectionOfs;
       begin
       begin
         result:=size;
         result:=size;
         if assigned(Data) then
         if assigned(Data) then
@@ -967,7 +969,7 @@ implementation
       end;
       end;
 
 
 
 
-    function TObjSection.writestr(const s:string):PUInt;
+    function TObjSection.writestr(const s:string):TObjSectionOfs;
       var
       var
         b: byte;
         b: byte;
       begin
       begin
@@ -977,13 +979,13 @@ implementation
       end;
       end;
 
 
 
 
-    function TObjSection.WriteBytes(const s:string):PUInt;
+    function TObjSection.WriteBytes(const s:string):TObjSectionOfs;
       begin
       begin
         result:=Write(s[1],length(s));
         result:=Write(s[1],length(s));
       end;
       end;
 
 
 
 
-    function TObjSection.WriteZeros(l:longword):PUInt;
+    function TObjSection.WriteZeros(l:longword):TObjSectionOfs;
       var
       var
         empty : array[0..1023] of byte;
         empty : array[0..1023] of byte;
       begin
       begin
@@ -1015,7 +1017,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure TObjSection.setDatapos(var dpos:PUInt);
+    procedure TObjSection.setDatapos(var dpos:TObjSectionOfs);
       begin
       begin
         if oso_Data in secoptions then
         if oso_Data in secoptions then
           begin
           begin
@@ -1038,7 +1040,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure TObjSection.alloc(l:PUInt);
+    procedure TObjSection.alloc(l:TObjSectionOfs);
       begin
       begin
 {$ifndef cpu64bitalu}
 {$ifndef cpu64bitalu}
         if (qword(size)+l)>high(size) then
         if (qword(size)+l)>high(size) then
@@ -1051,19 +1053,19 @@ implementation
       end;
       end;
 
 
 
 
-    procedure TObjSection.addsymReloc(ofs:PUInt;p:TObjSymbol;Reloctype:TObjRelocationType);
+    procedure TObjSection.addsymReloc(ofs:TObjSectionOfs;p:TObjSymbol;Reloctype:TObjRelocationType);
       begin
       begin
         ObjRelocations.Add(TObjRelocation.CreateSymbol(ofs,p,reloctype));
         ObjRelocations.Add(TObjRelocation.CreateSymbol(ofs,p,reloctype));
       end;
       end;
 
 
 
 
-    procedure TObjSection.addsectionReloc(ofs:PUInt;aobjsec:TObjSection;Reloctype:TObjRelocationType);
+    procedure TObjSection.addsectionReloc(ofs:TObjSectionOfs;aobjsec:TObjSection;Reloctype:TObjRelocationType);
       begin
       begin
         ObjRelocations.Add(TObjRelocation.CreateSection(ofs,aobjsec,reloctype));
         ObjRelocations.Add(TObjRelocation.CreateSection(ofs,aobjsec,reloctype));
       end;
       end;
 
 
 
 
-    procedure TObjSection.addrawReloc(ofs:PUInt;p:TObjSymbol;RawReloctype:byte);
+    procedure TObjSection.addrawReloc(ofs:TObjSectionOfs;p:TObjSymbol;RawReloctype:byte);
       begin
       begin
         ObjRelocations.Add(TObjRelocation.CreateRaw(ofs,p,RawReloctype));
         ObjRelocations.Add(TObjRelocation.CreateRaw(ofs,p,RawReloctype));
       end;
       end;