From: Iain Sandoe Date: Fri, 9 Apr 2021 12:40:11 +0000 (+0100) Subject: libiberty, Darwin : Fix simple-object LTO table for cross-endian case. X-Git-Tag: releases/gcc-10.4.0~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1618884bc3d0013df18a1e550357e6156e9a5ed;p=thirdparty%2Fgcc.git 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 --git a/libiberty/simple-object-mach-o.c b/libiberty/simple-object-mach-o.c index 14f53428643e..f36b9640ebe1 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.