aboutsummaryrefslogtreecommitdiffstats
path: root/src/ortho/mcode/binary_file.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-04-04 06:41:21 +0200
committerTristan Gingold <tgingold@free.fr>2022-04-04 06:41:21 +0200
commitf599ef1897cc77f7c4f2249be43bd45bc1243e29 (patch)
treea986be3798d579938c64277773e37ca40a8a6195 /src/ortho/mcode/binary_file.adb
parentecc10af3a4ce267165aff5481598d0f73b399176 (diff)
downloadghdl-f599ef1897cc77f7c4f2249be43bd45bc1243e29.tar.gz
ghdl-f599ef1897cc77f7c4f2249be43bd45bc1243e29.tar.bz2
ghdl-f599ef1897cc77f7c4f2249be43bd45bc1243e29.zip
ortho/mcode: handle image relative relocation (for Win64)
Diffstat (limited to 'src/ortho/mcode/binary_file.adb')
-rw-r--r--src/ortho/mcode/binary_file.adb17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/ortho/mcode/binary_file.adb b/src/ortho/mcode/binary_file.adb
index d061b4f2a..1a8291c64 100644
--- a/src/ortho/mcode/binary_file.adb
+++ b/src/ortho/mcode/binary_file.adb
@@ -132,7 +132,8 @@ package body Binary_File is
Nbr_Relocs => 0,
Number => 0,
Seg => Memsegs.Create,
- Vaddr => 0);
+ Vaddr => 0,
+ Img_Off => 0);
if (Flags and Section_Zero) = 0 then
-- Allocate memory for the segment, unless BSS.
Resize (Sect, 8192);
@@ -792,6 +793,15 @@ package body Binary_File is
Gen_32 (Conv (Offset));
end Gen_X86_32;
+ procedure Gen_X86_Img_32 (Sym : Symbol; Offset : Unsigned_32) is
+ begin
+ pragma Assert (Arch = Arch_X86_64 or Arch = Arch_X86);
+ if Sym /= Null_Symbol then
+ Add_Reloc (Sym, Reloc_Img_32);
+ end if;
+ Gen_32 (Offset);
+ end Gen_X86_Img_32;
+
procedure Gen_Sparc_32 (Sym : Symbol; Offset : Integer_32) is
begin
if Sym /= Null_Symbol then
@@ -886,6 +896,11 @@ package body Binary_File is
To_Unsigned_32 (Get_Symbol_Vaddr (Sym)
- (Sect.Vaddr + Addr)
- Reloc.Neg_Addend));
+ when Reloc_Img_32 =>
+ Add_32 (Sect, Addr,
+ To_Unsigned_32 (Get_Symbol_Value (Sym)
+ + Get_Section (Sym).Img_Off));
+
when Reloc_Disp22 =>
Set_Wdisp (Sect, Addr, Sym, 22);
when Reloc_Disp30 =>