https://gcc.gnu.org/g:744a59f3f55bfc890f755c57c72919566e1bcad5
commit r15-6889-g744a59f3f55bfc890f755c57c72919566e1bcad5 Author: Eric Botcazou <ebotca...@adacore.com> Date: Tue Jan 14 11:00:24 2025 +0100 Ada: add missing support for the S/390 and RISC-V architectures ...to the object file reader present in the run-time library. gcc/ada/ PR ada/118459 * libgnat/s-objrea.ads (Object_Arch): Add S390 and RISCV. * libgnat/s-objrea.adb (EM_S390): New named number. (EM_RISCV): Likewise. (ELF_Ops.Initialize): Deal with EM_S390 and EM_RISCV. (Read_Address): Deal with S390 and RISCV. Diff: --- gcc/ada/libgnat/s-objrea.adb | 30 ++++++++++++++++++++++++++---- gcc/ada/libgnat/s-objrea.ads | 8 +++++++- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/gcc/ada/libgnat/s-objrea.adb b/gcc/ada/libgnat/s-objrea.adb index ab0e70116d1f..25ab1a2cc9d5 100644 --- a/gcc/ada/libgnat/s-objrea.adb +++ b/gcc/ada/libgnat/s-objrea.adb @@ -75,11 +75,13 @@ package body System.Object_Reader is EM_SPARC32PLUS : constant := 18; -- Sun SPARC 32+ EM_PPC : constant := 20; -- PowerPC EM_PPC64 : constant := 21; -- PowerPC 64-bit + EM_S390 : constant := 22; -- IBM S/390 EM_ARM : constant := 40; -- ARM EM_SPARCV9 : constant := 43; -- SPARC v9 64-bit EM_IA_64 : constant := 50; -- Intel Merced EM_X86_64 : constant := 62; -- AMD x86-64 architecture EM_AARCH64 : constant := 183; -- Aarch64 + EM_RISCV : constant := 243; -- RISC-V EN_NIDENT : constant := 16; @@ -620,8 +622,8 @@ package body System.Object_Reader is => Res.Arch := SPARC; - when EM_386 => - Res.Arch := i386; + when EM_SPARCV9 => + Res.Arch := SPARC64; when EM_MIPS | EM_MIPS_RS3_LE @@ -634,8 +636,11 @@ package body System.Object_Reader is when EM_PPC64 => Res.Arch := PPC64; - when EM_SPARCV9 => - Res.Arch := SPARC64; + when EM_S390 => + Res.Arch := S390; + + when EM_386 => + Res.Arch := i386; when EM_IA_64 => Res.Arch := IA64; @@ -649,6 +654,9 @@ package body System.Object_Reader is when EM_AARCH64 => Res.Arch := AARCH64; + when EM_RISCV => + Res.Arch := RISCV; + when others => raise Format_Error with "unrecognized architecture"; end case; @@ -2073,6 +2081,20 @@ package body System.Object_Reader is Address_64 := Read (S); return Address_64; + when RISCV | S390 => + case Obj.Format is + when ELF32 => + Address_32 := Read (S); + return uint64 (Address_32); + + when ELF64 => + Address_64 := Read (S); + return Address_64; + + when others => + raise Format_Error with "unrecognized object format"; + end case; + when Unknown => raise Format_Error with "unrecognized machine architecture"; end case; diff --git a/gcc/ada/libgnat/s-objrea.ads b/gcc/ada/libgnat/s-objrea.ads index 6159564e78ab..a606b6d2bc4d 100644 --- a/gcc/ada/libgnat/s-objrea.ads +++ b/gcc/ada/libgnat/s-objrea.ads @@ -120,12 +120,18 @@ package System.Object_Reader is PPC64, -- 64-bit PowerPC + S390, + -- IBM S/390 + ARM, -- 32-bit ARM - AARCH64); + AARCH64, -- 64-bit ARM + RISCV); + -- RISC-V + ------------------ -- Target types -- ------------------