From patchwork Wed Aug 18 18:37:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1518102 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gqc9n4bMSz9sX1 for ; Thu, 19 Aug 2021 04:38:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 34B783890011 for ; Wed, 18 Aug 2021 18:38:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp002.apm-internet.net (smtp002.apm-internet.net [85.119.248.221]) by sourceware.org (Postfix) with ESMTPS id 601A538515EE for ; Wed, 18 Aug 2021 18:37:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 601A538515EE Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=sandoe.co.uk Received: (qmail 24549 invoked from network); 18 Aug 2021 18:37:58 -0000 X-APM-Out-ID: 16293118772454 X-APM-Authkey: 257869/1(257869/1) 3 Received: from unknown (HELO ?192.168.1.214?) (81.138.1.83) by smtp002.apm-internet.net with SMTP; 18 Aug 2021 18:37:58 -0000 From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: [pushed] libiberty, Darwin : Fix simple-object LTO table for cross-endian case. Message-Id: <8465E34A-78A0-4216-B13B-C56A554BC8EE@sandoe.co.uk> Date: Wed, 18 Aug 2021 19:37:57 +0100 To: GCC Patches X-Mailer: Apple Mail (2.3445.104.21) X-Spam-Status: No, score=-15.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ian Lance Taylor Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, For mach-o, we encapsulate streamed IR for LTO in three special sections with a table that describes their entries. The table is expected to be written with native endianness for the target, but for cross-endian cross-compilation the swapping was omitted. Fixed thus. tested on a cross from x86_64-darwin to powerpc-darwin, pushed to master, thanks Iain Signed-off-by: Iain Sandoe libiberty/ChangeLog: * simple-object-mach-o.c (simple_object_mach_o_write_segment): Arrange to swap the LTO index tables where needed. --- libiberty/simple-object-mach-o.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libiberty/simple-object-mach-o.c b/libiberty/simple-object-mach-o.c index aa5e0952faf..72b69d19c21 100644 --- a/libiberty/simple-object-mach-o.c +++ b/libiberty/simple-object-mach-o.c @@ -1225,6 +1225,11 @@ simple_object_mach_o_write_segment (simple_object_write *sobj, int descriptor, index[4 * i] -= index[0]; index[0] = 0; + /* Swap the indices, if required. */ + + for (i = 0; i < (nsects_in * 4); ++i) + set_32 (&index[i], index[i]); + sechdr_offset += sechdrsize; /* Write out the section names.