Re: darwin vs linux linkage visibility issues
Re: darwin vs linux linkage visibility issues
- Subject: Re: darwin vs linux linkage visibility issues
- From: Peter O'Gorman <email@hidden>
- Date: Mon, 10 May 2010 21:05:29 -0500
On 05/09/2010 10:57 AM, Jack Howarth wrote:
> In the new Link Time Optimization support for darwin
> in current FSF gcc trunk, we have run into one lto testcase
> that passes under linux with binutils but fails for darwin's
> linker. The reduced testcase is...
>
> [MacPro:~/lto_bug] howarth% cat 20081222_0.h
> int x();
>
> [MacPro:~/lto_bug] howarth% cat 20081222_1.c
> #include "20081222_0.h"
Part of the "problem" is that Mac OS X prepends an underscore to C
symbols, whereas many linux systems don't (this is not consistent across
all architectures with linux).
>
> /* Actually, call "x" "INT_X", and make it hidden. */
> extern __typeof (x) x
> __asm__ ("INT_x")
Need to change this to __asm__ ("_INT_x")
> __attribute__ (( __visibility__ ("hidden")));
>
> int x ()
> {
> return 7;
> }
>
> /* Make an externally-visible symbol "X" that's an alias for INT_x. */
> extern __typeof (x) EXT_x
> __asm__ ("x")
and this to __asm__ ("_x")
> __attribute__ (( __alias__ ("INT_x")));
>
> [MacPro:~/lto_bug] howarth% gcc -O0 -c -o c_lto_20081222_1.o 20081222_1.c
> 20081222_1.c:16: error: ‘EXT_x’ aliased to undefined symbol ‘INT_x’
Then the message becomes for the __weak__ case becomes:
20081222_1.c:16: warning: alias definitions not supported in Mach-O; ignored
Which is odd because as you have pointed out clang does it fine by
simply adding:
.globl _x
_x = _INT_x
for the non-weak case, and, for the __weak__ case:
.weak_reference _x
_x = _INT_x
to the assembly.
It may be that this works by accident with clang, for this minor test
case, though, I don't know.
Peter
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden