Bug 35483 - GCC on AIX doesn't support dollar in symbols name.
Summary: GCC on AIX doesn't support dollar in symbols name.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-06 15:08 UTC by Laurent Vivier
Modified: 2008-10-15 16:55 UTC (History)
3 users (show)

See Also:
Host:
Target: powerpc-ibm-aix6.1.0.0
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-07-11 21:54:53


Attachments
This patch learns to gcc how to use IBM as with symbols with dollar inside. (1.85 KB, patch)
2008-03-06 15:14 UTC, Laurent Vivier
Details | Diff
new version of previous patch (aix-asm.patch) (1.81 KB, patch)
2008-03-11 15:28 UTC, Laurent Vivier
Details | Diff
patch to convert dollar signs to underscores (1.81 KB, patch)
2008-10-14 17:06 UTC, David Edelsohn
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Vivier 2008-03-06 15:08:59 UTC
When compiling libjava on AIX 6.1, gcc generates to the assembler symbols with dollar inside.
But IBM "as" is not able to manage dollar in symbol names, so the compilation fails.
Comment 1 Laurent Vivier 2008-03-06 15:14:42 UTC
Created attachment 15273 [details]
This patch learns to gcc how to use IBM as with symbols with dollar inside.

This patch removes '$' from symbol names and replace them by "_".
It emits ".rename" pseudo-op to keep the good symbol name in the symbol table.

See http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.aixassem/doc/alangref/rename.htm
Comment 2 Laurent Vivier 2008-03-11 15:28:18 UTC
Created attachment 15298 [details]
new version of previous patch (aix-asm.patch)

correctly export symbols
Add compatibility with libtool processing
correctly import them
remove asm part specific to libjava
Comment 3 Andrew Pinski 2008-05-05 05:54:24 UTC
I don't think this is a real bug.  Also patches should be off of the trunk and submitted to gcc-patches@gcc.gnu.org.
Comment 4 David Edelsohn 2008-07-11 21:54:53 UTC
Yes, this will substitute "_" for "$", but most programs do not use dollar signs in symbol names, except Java.  GNU Java is not supported on AIX, so building libjava does not accomplish much.

This is a large patch and requires an assignment.  With an assignment, I can consider it.
Comment 5 David Edelsohn 2008-10-02 20:47:05 UTC
This patch causes G++ to crash building some applications on AIX.  Apparently a version of G++ including this patch is being distributed and users are reporting problems.
Comment 6 David Edelsohn 2008-10-02 21:30:24 UTC
+  strip = (char *)ggc_alloc_string (name, len);
+
+  for (len = 0; name[len]; len++)
+    if (name[len] == '$')
+      strip[len] = '_';
+    else
+      strip[len] = name[len];
+  strip[len] = 0;
+
+  return strip;

It is not safe to edit a ggc_alloc_string-allocated string in place.  This should be

+  strip = (char *)alloca (name, len);
...
+  return ggc_alloc_string  (strip, len);

Also, using fixed-size 256 byte buffers is not safe because they can overflow.
Comment 7 David Edelsohn 2008-10-14 17:06:38 UTC
Created attachment 16493 [details]
patch to convert dollar signs to underscores

New patch.  This patch intercepts the dollar signs at a lower level and correctly handles garbage collection allocations of strings.
Comment 8 David Edelsohn 2008-10-15 12:25:19 UTC
Subject: Bug 35483

Author: dje
Date: Wed Oct 15 12:23:55 2008
New Revision: 141134

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141134
Log:
        PR target/35483
        Based on patches by Laurent Vivier.
        * xcoffout.h (DBX_FINISH_STABS): Translate dollar sign to underscore.
        * config/rs6000/rs6000-protos.h (rs6000_xcoff_strip_dollar): Declare.
        * config/rs6000/xcoff.h (ASM_DECLARE_FUNCTION_NAME): Translate
        dollar sign to underscore.
        (ASM_OUTPUT_EXTERNAL): Same.
        (ASM_OUTPUT_LABELREF): New.
        * config/rs6000/rs6000.c (rs6000_xcoff_strip_dollar): New.

        * config/rs6000/aix51.h (TARGET_USE_JCR_SECTION): Define.
        * config/rs6000/aix52.h (TARGET_USE_JCR_SECTION): Define.
        * config/rs6000/aix53.h (TARGET_USE_JCR_SECTION): Define.
        * config/rs6000/aix61.h (TARGET_USE_JCR_SECTION): Define.

Modified:
    trunk/gcc/config/rs6000/aix51.h
    trunk/gcc/config/rs6000/aix52.h
    trunk/gcc/config/rs6000/aix53.h
    trunk/gcc/config/rs6000/aix61.h
    trunk/gcc/config/rs6000/rs6000-protos.h
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/config/rs6000/xcoff.h
    trunk/gcc/xcoffout.h

Comment 9 David Edelsohn 2008-10-15 16:55:00 UTC
Patch committed.
Comment 10 David Edelsohn 2008-10-16 11:58:40 UTC
Subject: Bug 35483

Author: dje
Date: Thu Oct 16 11:57:26 2008
New Revision: 141170

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141170
Log:
gcc/
        PR target/35483
        * Makefile.in (coverage.o): Depend on $(TM_P_H).
        * coverage.c: Include tm_p.h.
        * config/rs6000/x-aix (jc1): Override LDFLAGS.
        * config/rs6000/xcoff.h (ASM_GENERATE_INTERNAL_LABEL): Strip
        dollar signs from PREFIX.
        * config/rs6000/rs6000.c (output_toc): Use RS6000_OUTPUT_BASENAME
        instead of manual strip_name_encoding.

java/
        PR target/35483
        * Make-lang.in (class.o): Depend on $(TM_P_H).
        (expr.o): Same.
        * class.c: Include tm_p.h.
        * expr.c: Include tm_p.h.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/config/rs6000/x-aix
    trunk/gcc/config/rs6000/xcoff.h
    trunk/gcc/coverage.c
    trunk/gcc/java/ChangeLog
    trunk/gcc/java/Make-lang.in
    trunk/gcc/java/class.c
    trunk/gcc/java/expr.c