From patchwork Tue Jan 14 10:02:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 104742 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 928203857000 for ; Tue, 14 Jan 2025 10:03:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 928203857000 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=QjbboBSy X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id 451D63857003 for ; Tue, 14 Jan 2025 10:02:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 451D63857003 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 451D63857003 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736848967; cv=none; b=vpqbKjBQIvwSNV2pDf0F7TeFzbyyEh3UqeMRa4CK7ZiB1+D9lSQXOfUordaqt5bHXmxu4vGWLvCIRahl3Ifw6NhlXhKvWNc8opUPa6psL3clLLEBBHJEDXSN4zwS61DA1NrgI0XCHrWsqYJZeCndToV+i75uGXfo1bb4fLGl7Sw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736848967; c=relaxed/simple; bh=qk6U0D079vBayc67ycA6SaQqKrJmBG/ws0X5sFX5HBg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lnEIAiZO0Dez02nspRVN4KNRP7Q3ftXsvwuW9HLypQd0w5LIyT5dbiyrK8JIgp3l2IhjruOaALLSRZgtLLxNgkQJB4bghiDYhq3XayGo5wcv21nHJZj0aMox5Uhrk4In66rPTeh/CPcb+Fhp1IgymTzB5qPuBuBpXKeymj9z42s= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 451D63857003 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-43618283d48so37554265e9.1 for ; Tue, 14 Jan 2025 02:02:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1736848966; x=1737453766; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=CeccCvyei1+dKKlmXCKtGaizpz1z1FG5WGgkBRadkaI=; b=QjbboBSyytT7s0KdTNmNwLGvr6//JOVLiwOFg49kATZl/17vfgmNSqt+BZ5BZM82Yj 25B+AHkGVBahioiC+XV6GaTt7cIiPcb9y+eZewFEHi/aZHaQn2DjKGek01n/Y25m8j8A sshtk6jX4GapJJs18Ys0k6eVJx6FcIipbh5V/E63Ucln/qcFohwEc0Te3aiFfyF3ZuP2 swBYwrRirPFX10acy/43pmhVpAYVRfHKP7aoLErKyAs0sOBIO2ZcyP1UdkrptLqxlYx4 QU0AyzFFoiVvUS5qX29/pF7PJTEJy9lqkii/fmGfDV/pfi1cV48pN7sgB9twiGA/97NS rc6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736848966; x=1737453766; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CeccCvyei1+dKKlmXCKtGaizpz1z1FG5WGgkBRadkaI=; b=CyWvTMq+iF006avXliBYFlX0TsMph9Kzdl2u9iBpBsKf9KxvMJNZCW74p4JtzHJjs/ QOuu/8rSjUBIjUUEHdxzbOHWZrTeE+ivZyaaN+aNq2e87W2p+BSmeXfJK1acR8aMgdT4 ZZHOEjHxtRDhGwe+1G9nKkCblHWpg2Ojsk7VzaFg0BA3ve0ESfkoL5CDsj5YuhSfbwF7 iAHALZkCX9OBJeqlrkXZlvobfH93AYPDPWvJ/OKHJFbVig7HZoAKNCGIyDhdk2xqhsJM BhkaAtVOguaTF9RCLQaDZiWpcaeqDo2XLSg7HqH10wXhGTHqy+YDdKkN4g6hDdERiMCm oH5w== X-Gm-Message-State: AOJu0Yypne2CiYzBXbqbpB5N7GGIfJKGUdDg5VMw7N2r0Zd11XpkY0aU x/Hh9zEpm0dBc+IhH4Ndsl0Yaln4K+GeqTj7WE3CuBG3TJbTFbnVyz6rs8937ICK6+oLd1YnG08 = X-Gm-Gg: ASbGncs5++N9ZELEwfEYTWdGJsCt2cbx3fkePP5Ls9p7QDe69u4SzzPJKzPmiOsPmQm BOZ28uK0NjYXTo04vy858F/prFjXoQbP3RlV60NFhIhv8goks6ovcvmaD/lOIck2aZ5h3YYdak4 TrXgIJlm8bl3QAAvaE1oDXlRlA9wd2c07p/TkhacmcVvD8fZb7aHUS70q+56BBp9a4v8qh1O1rk xRas+6nH26imoCw2NqZIt92il2z6bOIgmjZleGF1WBArGbwqyXqHIwN1rGD9g55VUILng== X-Google-Smtp-Source: AGHT+IGSMkCgmWyPIQxhna5NjA0Ui8wV5tl5n6+/cifOEFqqd4znd8CQwYlg6fFAiWpI6ujNRLU/zw== X-Received: by 2002:a05:600c:1384:b0:434:f2bf:1708 with SMTP id 5b1f17b1804b1-436e267822amr227298305e9.7.1736848965854; Tue, 14 Jan 2025 02:02:45 -0800 (PST) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2da6271sm203450885e9.9.2025.01.14.02.02.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 02:02:45 -0800 (PST) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix PR ada/118459 Date: Tue, 14 Jan 2025 11:02:44 +0100 Message-ID: <26725295.1r3eYUQgxm@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org This adds the missing support for the S/390 and RISC-V architectures to the object file reader present in the run-time library, fixing the regression. Tested on x86-64/Linux, applied on the mainline. 2025-01-13 Eric Botcazou 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 --git a/gcc/ada/libgnat/s-objrea.adb b/gcc/ada/libgnat/s-objrea.adb index ab0e70116d1..25ab1a2cc9d 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 6159564e78a..a606b6d2bc4 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 -- ------------------