On 8/18/21 20:37, Iain Sandoe wrote:
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.

Hello.

I noticed the change produced the following Clang warning:

build/libiberty/simple-object-mach-o.c:1231:10: warning: incompatible pointer 
types passing 'unsigned int *' to parameter of type 'unsigned char *' 
[-Wincompatible-pointer-types]

Can you please take a look?
Thanks,
Martin


tested on a cross from x86_64-darwin to powerpc-darwin,
pushed to master, thanks
Iain

Signed-off-by: Iain Sandoe <i...@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 | 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.


Reply via email to