From 0aa72047075b96a0aafe3f1ae49075a405e902d2 Mon Sep 17 00:00:00 2001 From: sergei Date: Sun, 16 Dec 2012 09:36:34 +0000 Subject: [PATCH] + Added codes of dynamic relocations to TElfTarget; since most targets use similar dynamic relocation model differing only in code values, this will allow to do majority of handling in the base class. git-svn-id: trunk@23154 - --- compiler/i386/cpuelf.pas | 7 +++++++ compiler/ogelf.pas | 9 ++++++++- compiler/sparc/cpuelf.pas | 7 +++++++ compiler/x86_64/cpuelf.pas | 8 ++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/compiler/i386/cpuelf.pas b/compiler/i386/cpuelf.pas index 3f6e278195..2bae07f763 100644 --- a/compiler/i386/cpuelf.pas +++ b/compiler/i386/cpuelf.pas @@ -469,6 +469,13 @@ implementation exe_image_base: $8048000; machine_code: EM_386; relocs_use_addend: false; + dyn_reloc_codes: ( + R_386_RELATIVE, + R_386_GLOB_DAT, + R_386_JUMP_SLOT, + R_386_COPY, + R_386_IRELATIVE + ); relocname: @elf_i386_relocName; encodereloc: @elf_i386_encodeReloc; loadreloc: @elf_i386_loadReloc; diff --git a/compiler/ogelf.pas b/compiler/ogelf.pas index a0227362c8..64c9534ddf 100644 --- a/compiler/ogelf.pas +++ b/compiler/ogelf.pas @@ -150,12 +150,20 @@ interface TEncodeRelocProc=function(objrel:TObjRelocation):byte; TLoadRelocProc=procedure(objrel:TObjRelocation); TLoadSectionProc=function(objinput:TElfObjInput;objdata:TObjData;const shdr:TElfsechdr;shindex:longint):boolean; + TDynamicReloc=( + dr_relative, + dr_glob_dat, + dr_jump_slot, + dr_copy, + dr_irelative + ); TElfTarget=record max_page_size: longword; exe_image_base: longword; machine_code: word; relocs_use_addend: boolean; + dyn_reloc_codes: array[TDynamicReloc] of byte; relocname: TRelocNameProc; encodereloc: TEncodeRelocProc; loadreloc: TLoadRelocProc; @@ -2805,7 +2813,6 @@ implementation procedure TElfExeOutput.GenerateLibraryImports(ImportLibraryList:TFPHashObjectList); var - i:longint; exportlist: TCmdStrList; sym: TExeSymbol; begin diff --git a/compiler/sparc/cpuelf.pas b/compiler/sparc/cpuelf.pas index 1b313e55b1..027e7dce8e 100644 --- a/compiler/sparc/cpuelf.pas +++ b/compiler/sparc/cpuelf.pas @@ -103,6 +103,13 @@ implementation exe_image_base: $8000; // fixme machine_code: EM_SPARC; relocs_use_addend: false; + dyn_reloc_codes: ( + R_SPARC_RELATIVE, + R_SPARC_GLOB_DAT, + R_SPARC_JUMP_SLOT, + R_SPARC_COPY, + 0 // IRELATIVE is absent(?) + ); relocname: @elf_sparc_relocName; encodereloc: @elf_sparc_encodeReloc; loadreloc: @elf_sparc_loadReloc; diff --git a/compiler/x86_64/cpuelf.pas b/compiler/x86_64/cpuelf.pas index 7d075b7d08..f85f153db3 100644 --- a/compiler/x86_64/cpuelf.pas +++ b/compiler/x86_64/cpuelf.pas @@ -393,6 +393,7 @@ implementation R_X86_64_PC32, R_X86_64_PC64: begin + // TODO: ld rejects PC32 relocations to dynamic symbols, they must use @PLT address:=address+relocval-PC; end; @@ -577,6 +578,13 @@ implementation exe_image_base: $400000; machine_code: EM_X86_64; relocs_use_addend: true; + dyn_reloc_codes: ( + R_X86_64_RELATIVE, + R_X86_64_GLOB_DAT, + R_X86_64_JUMP_SLOT, + R_X86_64_COPY, + R_X86_64_IRELATIVE + ); relocname: @elf_x86_64_relocName; encodereloc: @elf_x86_64_encodeReloc; loadreloc: @elf_x86_64_loadReloc;