alias of hidden function

Jack Howarth howarth@bromo.med.uc.edu
Mon May 10 15:19:00 GMT 2010


On Mon, May 10, 2010 at 04:17:26PM +0100, Dave Korn wrote:
> On 10/05/2010 14:30, Jack Howarth wrote:
> 
> > Are there any standards in effect which would dictate that
> > the alias of a hidden function is valid? 
> 
>   Visiblity doesn't apply to functions, it applies to symbols.  Symbols are
> textual names with a linked value that exist in object files.  The compiler
> emits assembler source that directs the assembler to output an object file
> containing the code for the function x, and for two symbols that both have the
> value of the address of x (but neither of which is actually called "x").  The
> visibility of one of these symbols is set to hidden; the visibility of the
> other is not.  It is not the function that is hidden, only (one of the two)
> symbols pointing at that function.
> 
>   (Also, it's not hidden from the compiler, or indeed the static linker, but
> only from the runtime loader, in any case.)
> 
>     cheers,
>       DaveK

Dave,
   The darwin linker maintainer suggested that the alias attribute might
not be supported in their gcc. Their on-line documentation seems to be
silent on the issue. However I do notice the following on powerpc-apple-darwin9...

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'
20081222_1.c:16: warning: alias definitions not supported in Mach-O; ignored

gcc-4.2 -O0 -c -o c_lto_20081222_1.o 20081222_1.c
20081222_1.c:16: error: 'EXT_x' aliased to undefined symbol 'INT_x'

So it appears that may be the case for the older gcc 4.0.1 compiler in
darwin but they would have appeared to have added support in the newer
Apple gcc 4.2.1 compiler.
    Interestingly, with the alias marked as weak, I get...

 gcc-4.2 -O0 -v -c -o c_lto_20081222_1.o 20081222_1.c
Using built-in specs.
Target: powerpc-apple-darwin9
Configured with: /var/tmp/gcc_42/gcc_42-5574~1/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/usr/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-gxx-include-dir=/usr/include/c++/4.0.0 --program-prefix= --host=powerpc-apple-darwin9 --target=powerpc-apple-darwin9
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5574)
 /usr/libexec/gcc/powerpc-apple-darwin9/4.2.1/cc1 -quiet -v -D__DYNAMIC__ 20081222_1.c -fPIC -quiet -dumpbase 20081222_1.c -mmacosx-version-min=10.5.8 -auxbase-strip c_lto_20081222_1.o -O0 -version -o /var/tmp//ccfwMpMN.s
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/powerpc-apple-darwin9/4.2.1/../../../../powerpc-apple-darwin9/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
GNU C version 4.2.1 (Apple Inc. build 5574) (powerpc-apple-darwin9)
        compiled by GNU C version 4.2.1 (Apple Inc. build 5574).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: c54eb6db87684e4d5a5bb9ad02c2b2c4
20081222_1.c:16: error: 'EXT_x' aliased to undefined symbol 'INT_x'

which I assume means this error message is coming from the compiler and not
the linker. So it still unclear to me if this is a bug in the alias attribute
support in gcc for darwin or in darwin's assembler or linker.
           Jack



More information about the Binutils mailing list