This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: New target powerpc64 symbol collision
- From: Chung-Ju Wu <jasonwucj at gmail dot com>
- To: Dan Schatzberg <schatzberg dot dan at gmail dot com>
- Cc: gcc <gcc-help at gcc dot gnu dot org>
- Date: Fri, 3 May 2013 12:41:24 +0800
- Subject: Re: New target powerpc64 symbol collision
- References: <CAAx7rQd93S3g-Yb0ZRb6t+mDY0bQWbKRmYmA_1yEJnMvn35sfg at mail dot gmail dot com>
2013/5/3 Dan Schatzberg <schatzberg.dan@gmail.com>:
> I am trying to add a new OS target to gcc 4.7.1. In particular I am
> focused on the powerpc64 architecture. I've modified the gcc 4.7.1
> source to add my target. I've managed to build a cross compiler for my
> target but I had a problem:
>
> sample code test.c:
> void foo() {}
>
> output of gcc test.c -S:
>
> .file "test.c"
> .section ".text"
> .align 2
> .globl foo
> .section ".opd","aw"
> .align 3
> foo:
> .quad foo,.TOC.@tocbase,0
> .previous
> .size foo,24
> .type .foo,@function
> .globl .foo
> foo:
> stdu 1,-32(1)
> std 31,24(1)
> mr 31,1
> addi 11,31,32
> ld 31,-8(11)
> mr 1,11
> blr
> .size foo, .-foo
> .ident "GCC: (GNU) 4.7.1"
>
> GCC introduces the same symbol twice which fails to assemble. I would
> expect the second "foo" symbol (and corresponding references) to just
> be a local symbol like ".L.foo". What do I need to change to see the
> correct behavior? Thanks
>
> ---
> Dan Schatzberg
Generally, a function body will be produced with following pattern:
.text
.globl foo
.type foo, @function
foo:
XXX
YYY
ZZZ
.size foo, .-foo
I guess you explicitly output following assembly code somewhere else:
.section ".opd","aw"
.align 3
foo:
.quad foo,.TOC.@tocbase,0
.previous
.size foo,24
Are you trying to save function address in a paricular section
so that you can access it for some purposes?
I would suggest not producing those in the middle of function body.
You can use a structure to preserve essential information
and then output them at the end of asm file.
Also, try to use the symbol like "_entry_to_foo_" so that
you won't get conflict with the symbol in a normal function body.
Best regards,
jasonwucj