* [pushed] libiberty, Darwin : Fix simple-object LTO table for cross-endian case.
@ 2021-08-18 18:37 Iain Sandoe
2021-08-23 8:07 ` Martin Liška
0 siblings, 1 reply; 3+ messages in thread
From: Iain Sandoe @ 2021-08-18 18:37 UTC (permalink / raw)
To: GCC Patches; +Cc: Ian Lance Taylor
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.
tested on a cross from x86_64-darwin to powerpc-darwin,
pushed to master, thanks
Iain
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 | 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.
--
2.24.3 (Apple Git-128)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pushed] libiberty, Darwin : Fix simple-object LTO table for cross-endian case.
2021-08-18 18:37 [pushed] libiberty, Darwin : Fix simple-object LTO table for cross-endian case Iain Sandoe
@ 2021-08-23 8:07 ` Martin Liška
2021-08-23 16:40 ` Iain Sandoe
0 siblings, 1 reply; 3+ messages in thread
From: Martin Liška @ 2021-08-23 8:07 UTC (permalink / raw)
To: Iain Sandoe, GCC Patches; +Cc: Ian Lance Taylor
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 <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 | 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.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pushed] libiberty, Darwin : Fix simple-object LTO table for cross-endian case.
2021-08-23 8:07 ` Martin Liška
@ 2021-08-23 16:40 ` Iain Sandoe
0 siblings, 0 replies; 3+ messages in thread
From: Iain Sandoe @ 2021-08-23 16:40 UTC (permalink / raw)
To: Martin Liska; +Cc: GCC Patches, Ian Lance Taylor
Hi,
> On 23 Aug 2021, at 09:07, Martin Liška <mliska@suse.cz> wrote:
>
> On 8/18/21 20:37, Iain Sandoe wrote:
>> 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.
> 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]
thanks for catching that, fixed as below
tested on x86_64-darwin X powerpc-darwin (with clang and GCC).
pushed to master, thanks
Iain
diff --git a/libiberty/simple-object-mach-o.c b/libiberty/simple-object-mach-o.c
index 72b69d19c21..a8869e7c639 100644
--- a/libiberty/simple-object-mach-o.c
+++ b/libiberty/simple-object-mach-o.c
@@ -1228,7 +1228,7 @@ simple_object_mach_o_write_segment (simple_object_write *sobj, int descriptor,
/* Swap the indices, if required. */
for (i = 0; i < (nsects_in * 4); ++i)
- set_32 (&index[i], index[i]);
+ set_32 ((unsigned char *) &index[i], index[i]);
sechdr_offset += sechdrsize;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-23 16:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 18:37 [pushed] libiberty, Darwin : Fix simple-object LTO table for cross-endian case Iain Sandoe
2021-08-23 8:07 ` Martin Liška
2021-08-23 16:40 ` Iain Sandoe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).