]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libiberty, Darwin : Fix simple-object LTO table for cross-endian case.
authorIain Sandoe <iain@sandoe.co.uk>
Fri, 9 Apr 2021 12:40:11 +0000 (13:40 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Wed, 18 Aug 2021 18:33:49 +0000 (19:33 +0100)
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 <iain@sandoe.co.uk>
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

index aa5e0952fafb6749dc0c8d214d406d56d8c0f241..72b69d19c21627aa29347bc3798aa8f407965fc7 100644 (file)
@@ -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.