This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix host endianess issue in lto streamer (PR lto/47274)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Jan Hubicka <jh at suse dot cz>
- Date: Thu, 3 Feb 2011 00:22:00 +0100
- Subject: [PATCH] Fix host endianess issue in lto streamer (PR lto/47274)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Both kind and visibility are enum vars, i.e. 32-bit on practically all
hosts, but lto_output_data_stream (stream, &kind, 1); writes first
byte from it (which is the right thing on little endian hosts, but always
writes 0 on big endian).
I haven't found where this section is actually read (somewhere in lto
plugin, somewhere else?), so I assume the section format is fixed.
2011-02-02 Jakub Jelinek <jakub@redhat.com>
PR lto/47274
* lto-streamer-out.c (write_symbol): When writing kind and visibility,
copy them into a unsigned char variable and pass address of it to
lto_output_data_stream.
--- gcc/lto-streamer-out.c.jj 2011-01-15 11:26:42.402838693 +0100
+++ gcc/lto-streamer-out.c 2011-02-02 17:02:55.311388707 +0100
@@ -2410,6 +2410,7 @@ write_symbol (struct lto_streamer_cache_
int slot_num;
uint64_t size;
const char *comdat;
+ unsigned char c;
/* None of the following kinds of symbols are needed in the
symbol table. */
@@ -2505,8 +2506,10 @@ write_symbol (struct lto_streamer_cache_
lto_output_data_stream (stream, name, strlen (name) + 1);
lto_output_data_stream (stream, comdat, strlen (comdat) + 1);
- lto_output_data_stream (stream, &kind, 1);
- lto_output_data_stream (stream, &visibility, 1);
+ c = (unsigned char) kind;
+ lto_output_data_stream (stream, &c, 1);
+ c = (unsigned char) visibility;
+ lto_output_data_stream (stream, &c, 1);
lto_output_data_stream (stream, &size, 8);
lto_output_data_stream (stream, &slot_num, 4);
}
Jakub