aboutsummaryrefslogtreecommitdiffstats
path: root/src/ortho/mcode/binary_file.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2018-11-19 20:47:30 +0100
committerTristan Gingold <tgingold@free.fr>2018-11-19 20:47:30 +0100
commitfef22520072c40329a5e61559a723666748c7a0e (patch)
tree3e61bfbe69b8d77707fda2a712eedc7e0fe2afb8 /src/ortho/mcode/binary_file.adb
parent59a7cdd7433954e651b94576c3573317f695b4f5 (diff)
downloadghdl-fef22520072c40329a5e61559a723666748c7a0e.tar.gz
ghdl-fef22520072c40329a5e61559a723666748c7a0e.tar.bz2
ghdl-fef22520072c40329a5e61559a723666748c7a0e.zip
ortho/mcode: pack all sections for huge programs on x86-64.
For #698
Diffstat (limited to 'src/ortho/mcode/binary_file.adb')
-rw-r--r--src/ortho/mcode/binary_file.adb15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/ortho/mcode/binary_file.adb b/src/ortho/mcode/binary_file.adb
index 7d8b9348a..d666a6626 100644
--- a/src/ortho/mcode/binary_file.adb
+++ b/src/ortho/mcode/binary_file.adb
@@ -18,7 +18,6 @@
with System.Storage_Elements;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Latin_1;
-with Ada.Unchecked_Conversion;
with Hex_Images; use Hex_Images;
with Disassemble;
@@ -27,9 +26,6 @@ package body Binary_File is
HT : Character renames Ada.Characters.Latin_1.HT;
- function To_Byte_Array_Acc is new Ada.Unchecked_Conversion
- (Source => System.Address, Target => Byte_Array_Acc);
-
-- Resize a section to SIZE bytes.
procedure Resize (Sect : Section_Acc; Size : Pc_Type) is
begin
@@ -182,7 +178,9 @@ package body Binary_File is
Rel := Src.First_Reloc;
if Rel /= null then
- -- Move relocs.
+ -- Move internal relocs.
+ -- Note: external relocs are not modified, so they can still refer
+ -- to this SRC section.
if Dest.Last_Reloc = null then
Dest.First_Reloc := Rel;
Dest.Last_Reloc := Rel;
@@ -192,7 +190,6 @@ package body Binary_File is
end if;
Dest.Nbr_Relocs := Dest.Nbr_Relocs + Src.Nbr_Relocs;
-
-- Reloc reloc, since the pc has changed.
while Rel /= null loop
Rel.Addr := Rel.Addr + Dest.Pc;
@@ -201,6 +198,7 @@ package body Binary_File is
end if;
if Src.Pc > 0 then
+ -- Alignment is assumed to be compatible...
Sect_Prealloc (Dest, Src.Pc);
Dest.Data (Dest.Pc .. Dest.Pc + Src.Pc - 1) :=
Src.Data (0 .. Src.Pc - 1);
@@ -618,10 +616,9 @@ package body Binary_File is
function Pow_Align (V : Pc_Type; Align : Natural) return Pc_Type
is
- Tmp : Pc_Type;
+ Mask : constant Pc_Type := (2 ** Align) - 1;
begin
- Tmp := V + 2 ** Align - 1;
- return Tmp - (Tmp mod Pc_Type (2 ** Align));
+ return (V + Mask) and not Mask;
end Pow_Align;
procedure Gen_Pow_Align (Align : Natural) is