From a4053370fc3e77d4cbcf2f2baaf5b38c40826230 Mon Sep 17 00:00:00 2001 From: sergei Date: Thu, 13 Nov 2014 22:10:53 +0000 Subject: [PATCH] * 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 - --- compiler/mips/cpuelf.pas | 4 +++- compiler/ogbase.pas | 4 +++- compiler/ogelf.pas | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/mips/cpuelf.pas b/compiler/mips/cpuelf.pas index 720bc0aea6..1c2de17e0c 100644 --- a/compiler/mips/cpuelf.pas +++ b/compiler/mips/cpuelf.pas @@ -207,6 +207,8 @@ implementation result:=R_MIPS_NONE; RELOC_ABSOLUTE: result:=R_MIPS_32; + RELOC_GOTOFF: {For case jumptables only } + result:=R_MIPS_GPREL32; else result:=0; InternalError(2012110602); @@ -809,7 +811,7 @@ implementation else reltyp:=objreloc.ftype; - if ElfTarget.relocs_use_addend then + if (oso_rela_relocs in objsec.SecOptions) then address:=objreloc.orgsize else begin diff --git a/compiler/ogbase.pas b/compiler/ogbase.pas index 700b550592..4b1c54da77 100644 --- a/compiler/ogbase.pas +++ b/compiler/ogbase.pas @@ -145,7 +145,9 @@ interface { Contains only strings } oso_strings, { 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; diff --git a/compiler/ogelf.pas b/compiler/ogelf.pas index 8aa5526c39..802d9eba66 100644 --- a/compiler/ogelf.pas +++ b/compiler/ogelf.pas @@ -1334,6 +1334,8 @@ implementation FReader.Seek(secrec.relocpos); if secrec.sec=nil then 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 begin FReader.Read(rel,secrec.relentsize);