This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR42531: lto generates invalid assembler ".section" directives.
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 31 Dec 2009 08:02:51 -0800
- Subject: Re: [PATCH] Fix PR42531: lto generates invalid assembler ".section" directives.
- References: <4B3B8789.7060107@gmail.com>
On Wed, Dec 30, 2009 at 9:02 AM, Dave Korn
<dave.korn.cygwin@googlemail.com> wrote:
> [ ref: http://gcc.gnu.org/ml/gcc/2009-12/threads.html#00292 ]
>
>
> ? ?Hi,
>
> ?This simple patch fixes the problem I reported in the above thread. ?Some
> DECL_ASSEMBLER_NAMEs begin with an asterisk; when lto wants to use one of
> these to generate a section name, it should skip the leading asterisk, and
> does so in most places, but there are a couple of sites where it omits to do
> so; this patch fixes them in line with what is done elsewhere.
>
> gcc/ChangeLog:
>
> ? ? ? ?* lto-streamer-out.c (produce_asm): Skip any leading asterisk when
> ? ? ? ?using DECL_ASSEMBLER_NAME to generate a section name.
> ? ? ? ?(copy_function): Likewise.
>
>
> ?Bootstrapped and tested on i686-pc-cygwin; no new FAILs and resolves four
> FAILs arising from gcc.c-torture/compile/20011119-1.c. ?Ok?
>
> ? ?cheers,
> ? ? ?DaveK
>
The patch doesn't look right:
@@ -2005,12 +2007,17 @@ copy_function (struct cgraph_node *node)
const char *data;
size_t len;
const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (function));
- char *section_name =
- lto_get_section_name (LTO_section_function_body, name);
+ char *section_name;
size_t i, j;
struct lto_in_decl_state *in_state;
- struct lto_out_decl_state *out_state = lto_get_out_decl_state ();
+ struct lto_out_decl_state *out_state;
+ if (name[0] == '*')
+ name++;
+ section_name =
+ lto_get_section_name (LTO_section_function_body, name);
+ out_state = lto_get_out_decl_state ();
+
lto_begin_section (section_name, !flag_wpa);
free (section_name);
It doesn't handle name == NULL.
--
H.J.