Constify IDENTIFIER_POINTER; reduce calls to get_identifier

Zack Weinberg zack@wolery.cumb.org
Sun Sep 10 22:24:00 GMT 2000


On Sat, Sep 09, 2000 at 08:00:31PM +0200, Krister Walfridsson wrote:
> The change 
> 
>         * varasm.c (make_function_rtl, make_decl_rtl): Rearrange code
>         for comprehensibility.  Do not call get_identifier if we did
>         not change the DECL_ASSEMBLER_NAME of the decl.  Use alloca to
>         create temporary string constants, not ggc_alloc_string.  No
>         need to copy result of ASM_FORMAT_PRIVATE_NAME.  Use const
>         char * to hold IDENTIFIER_POINTERs.
> 
> fails bootstrap on NetBSD a.out architectures.
> 
> In NetBSD, prototypes of some functions such as setjmp are being
> transformed by some preprocessor magic and finally ends up like
> 
>         int     setjmp  (jmp_buf)   __asm__("___setjmp14"  )  ;
> 
> After your patch to varasm.c, the "___setjmp14" symbolname is prefixed by
> an extra "_", and thus prevent linkage of files containing setjmp.

Hm, that's what that mysterious star prefix was for.  Please try the
appended patch.

zw

	* varasm.c (make_decl_rtl): Restore leading star on
	DECL_ASSEMBLER_NAME set for decls with an asmspec.
	* gcc.dg/asm-names.c: New test.

===================================================================
Index: varasm.c
--- varasm.c	2000/08/30 22:50:51	1.132
+++ varasm.c	2000/09/11 05:10:31
@@ -710,8 +710,14 @@ make_decl_rtl (decl, asmspec, top_level)
 
   reg_number = decode_reg_name (asmspec);
   if (reg_number == -2)
-    /* ASMSPEC is given, and not the name of a register.  */
-    new_name = asmspec;
+    {
+      /* ASMSPEC is given, and not the name of a register.  Mark the
+	 name with a star so assemble_name won't munge it.  */
+      char *starred = alloca (strlen (asmspec) + 2);
+      starred[0] = '*';
+      strcpy (starred + 1, asmspec);
+      new_name = starred;
+    }
 
   if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
     {
===================================================================
Index: testsuite/gcc.dg/asm-names.c
--- testsuite/gcc.dg/asm-names.c	Tue May  5 13:32:27 1998
+++ testsuite/gcc.dg/asm-names.c	Sun Sep 10 22:22:47 2000
@@ -0,0 +1,23 @@
+/* The name specified by an asm("...") suffix on a declaration is not
+   to have an underscore prefixed, even if normal symbols are.
+   Problem reported by Krister Walfridsson <cato@df.lth.se>.  */
+
+/* { dg-do link } */
+/* { dg-options "-fleading-underscore" } */
+
+extern void frobnicate (void) asm ("___frob14");  /* three underscores */
+
+void __frob14 (void) {} /* two underscores */
+
+int
+main (void)
+{
+  frobnicate ();
+  return 0;
+}
+
+/* In case built where the runtime expects no leading underscore on
+   main(). */
+extern int xmain (void) asm ("main");
+
+int xmain (void) { return main(); }


More information about the Gcc-bugs mailing list