Nick Clifton - RFC/RFA: Preventing name mangling of . in anchor expressions (original) (raw)
This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
- From: Nick Clifton
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 14 Feb 2007 17:14:10 +0000
- Subject: RFC/RFA: Preventing name mangling of . in anchor expressions
Hi Guys,
I ran across a problem with the PowerPC port today which I think has a simple fix, but I would like to check with the collective wisdom of this list. The problem is that the special assembler symbol "." can become mangled when gcc is generating anchor expressions.
In order to reproduce this problem proceed as follows:
* Configure a powerpc-elf toolchain. (Other powerpc-* targets may
experience this problem as well, I have not checked). Make sure
that multilibs are enabled.
% ../src/configure --quiet --target=powerpc-elf
--enable-languages=c
* Build libgcc.
% make all-target-libgcc
* Look at the relocs for the .got2 section in the crtbegin.o file
for the -fleading-underscore multilib. You will find some
relocs against a symbol called "_.":
% binutils/objdump -r powerpc-elf/und/crtbegin.o
...
RELOCATION RECORDS FOR [.got2]:
OFFSET TYPE VALUE
00000000 R_PPC_ADDR32 _.
00000004 R_PPC_ADDR32 _.
00000008 R_PPC_ADDR32 ___deregister_frame_info
0000000c R_PPC_ADDR32 _.
00000010 R_PPC_ADDR32 ___register_frame_info
00000014 R_PPC_ADDR32 _.
00000018 R_PPC_ADDR32 __Jv_RegisterClasses
...
What has happened is that the assembler has been given an
expression of the form ". + <symbol>" except that the "."
has had an underscore prefixed to it, changing it into an
unrecognized symbol, and so forcing a relocation to be
generated.
Alternatively just build the powerpc-elf toolchain and run the gcc testsuite for the -fleading-underscore multilib. There will be lots of failures because of an undefined symbol called "_."
The answer it seems to me is the patch below which amends the default_asm_output_anchor() function to change "." into "*.". This prevents varasm's assemble_name() function from prefixing "." with an underscore when -fleading-underscore is active.
My concern, and the reason for not just applying this patch as obvious, is that the asterisk will prevent all target name mangling, not just the prepending of an underscore. This might be a bad thing, although I can think of no reason why a target would ever want to mangle ".".
Also the powerpc-beos and rs6000-aix targets uses their own anchor generating function which refers to a special symbol called "$". I would guess that this function would need similar alteration although I have no way to verify this.
So what do people think ? Should I apply this patch or is there some other way to resolve this problem ?
Cheers Nick
gcc/ChangeLog 2007-02-14 Nick Clifton nickc@redhat.com
* varasm.c (default_asm_output_anchor): Prepend * to . symbol in
order to prevent it from being munged by the target.
Index: gcc/varasm.c
--- gcc/varasm.c (revision 121945) +++ gcc/varasm.c (working copy) @@ -6098,7 +6098,7 @@ default_asm_output_anchor (rtx symbol) { char buffer[100];
- sprintf (buffer, ". + " HOST_WIDE_INT_PRINT_DEC,
- sprintf (buffer, "*. + " HOST_WIDE_INT_PRINT_DEC, SYMBOL_REF_BLOCK_OFFSET (symbol)); ASM_OUTPUT_DEF (asm_out_file, XSTR (symbol, 0), buffer); }
- Follow-Ups:
- Re: RFC/RFA: Preventing name mangling of . in anchor expressions
* From: Ian Lance Taylor
- Re: RFC/RFA: Preventing name mangling of . in anchor expressions
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |