From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 955143854812; Wed, 18 Aug 2021 18:34:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 955143854812 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3005] libiberty, Darwin : Fix simple-object LTO table for cross-endian case. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/master X-Git-Oldrev: 15bdae016654f63a36e49a37c9d26282bebb1da9 X-Git-Newrev: 220c410162ebece4fffa2912ed79e348d3731d77 Message-Id: <20210818183452.955143854812@sourceware.org> Date: Wed, 18 Aug 2021 18:34:52 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Aug 2021 18:34:52 -0000 https://gcc.gnu.org/g:220c410162ebece4fffa2912ed79e348d3731d77 commit r12-3005-g220c410162ebece4fffa2912ed79e348d3731d77 Author: Iain Sandoe Date: Fri Apr 9 13:40:11 2021 +0100 libiberty, Darwin : Fix simple-object LTO table for cross-endian case. We encapsulate streamed IR 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. 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. Diff: --- 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.