From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 2FF173829BD4; Sun, 29 May 2022 19:06:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2FF173829BD4 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 r10-10784] 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/releases/gcc-10 X-Git-Oldrev: 1265bfa73a4334879170bb10854abcff5c17e501 X-Git-Newrev: d1618884bc3d0013df18a1e550357e6156e9a5ed Message-Id: <20220529190659.2FF173829BD4@sourceware.org> Date: Sun, 29 May 2022 19:06:59 +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: Sun, 29 May 2022 19:06:59 -0000 https://gcc.gnu.org/g:d1618884bc3d0013df18a1e550357e6156e9a5ed commit r10-10784-gd1618884bc3d0013df18a1e550357e6156e9a5ed 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. (cherry picked from commit 220c410162ebece4fffa2912ed79e348d3731d77) 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 14f53428643..f36b9640ebe 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 ((unsigned char *) &index[i], index[i]); + sechdr_offset += sechdrsize; /* Write out the section names.