Browse Source

* ELF linker: track relocation style (REL or RELA) of each input section and use it instead of global default on MIPS targets. This fixes internal linking of tests/test/units/system/tres*.pp.

git-svn-id: trunk@29070 -
sergei 10 years ago
parent
commit
a4053370fc
3 changed files with 8 additions and 2 deletions
  1. 3 1
      compiler/mips/cpuelf.pas
  2. 3 1
      compiler/ogbase.pas
  3. 2 0
      compiler/ogelf.pas

+ 3 - 1
compiler/mips/cpuelf.pas

@@ -207,6 +207,8 @@ implementation
           result:=R_MIPS_NONE;
           result:=R_MIPS_NONE;
         RELOC_ABSOLUTE:
         RELOC_ABSOLUTE:
           result:=R_MIPS_32;
           result:=R_MIPS_32;
+        RELOC_GOTOFF:               {For case jumptables only }
+          result:=R_MIPS_GPREL32;
       else
       else
         result:=0;
         result:=0;
         InternalError(2012110602);
         InternalError(2012110602);
@@ -809,7 +811,7 @@ implementation
           else
           else
             reltyp:=objreloc.ftype;
             reltyp:=objreloc.ftype;
 
 
-          if ElfTarget.relocs_use_addend then
+          if (oso_rela_relocs in objsec.SecOptions) then
             address:=objreloc.orgsize
             address:=objreloc.orgsize
           else
           else
             begin
             begin

+ 3 - 1
compiler/ogbase.pas

@@ -145,7 +145,9 @@ interface
        { Contains only strings }
        { Contains only strings }
        oso_strings,
        oso_strings,
        { Must be cloned when writing separate debug file }
        { Must be cloned when writing separate debug file }
-       oso_debug_copy
+       oso_debug_copy,
+       { Has relocations with explicit addends (ELF-specific) }
+       oso_rela_relocs
      );
      );
 
 
      TObjSectionOptions = set of TObjSectionOption;
      TObjSectionOptions = set of TObjSectionOption;

+ 2 - 0
compiler/ogelf.pas

@@ -1334,6 +1334,8 @@ implementation
         FReader.Seek(secrec.relocpos);
         FReader.Seek(secrec.relocpos);
         if secrec.sec=nil then
         if secrec.sec=nil then
           InternalError(2012060203);
           InternalError(2012060203);
+        if (secrec.relentsize=3*sizeof(pint)) then
+          with secrec.sec do SecOptions:=SecOptions+[oso_rela_relocs];
         for i:=0 to secrec.relocs-1 do
         for i:=0 to secrec.relocs-1 do
           begin
           begin
             FReader.Read(rel,secrec.relentsize);
             FReader.Read(rel,secrec.relentsize);