This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
libc_hidden_proto breaks things for PowerPC64
- From: "Steve Munroe" <sjmunroe at us dot ibm dot com>
- To: libc-alpha at sources dot redhat dot com, Alan Modra <amodra at bigpond dot net dot au>
- Cc: "Peter Bergner" <bergner at us dot ibm dot com>
- Date: Tue, 13 Aug 2002 14:08:31 -0500
- Subject: libc_hidden_proto breaks things for PowerPC64
The use of the libc_hidden_proto macro when combined with the weak_alias
macro results in unresolved references in libc.so. For example.
/work/usr/src/build-23/libc.so.6: undefined reference to `.__sysconf'
/work/usr/src/build-23/libc.so.6: undefined reference to `.__iswpunct_l'
/work/usr/src/build-23/libc.so.6: undefined reference to `.__gmtime_r'
/work/usr/src/build-23/libc.so.6: undefined reference to `.__iswgraph_l'
/work/usr/src/build-23/libc.so.6: undefined reference to `.
____strtoul_l_internal'
...
The problem seems to be the combination of libc_hidden_proto and weak_alias
macros. For example ./sysdeps/posix/sysconf.c is externally defined by:
libc_hidden_proto(__sysconf)
which generates the following:
extern long int __sysconf (int __name);
extern __typeof (__sysconf) __GI___sysconf; extern __typeof (__sysconf)
__sysconf __asm__ ("" "__GI___sysconf") ;
When ./sysdeps/posix/sysconf.c is compiled, this causes the symbol "
__sysconf" to be replaced for symbol "__GI___sysconf" in the function
prolog:
.globl __GI___sysconf
.section ".opd","aw"
.align 3
__GI___sysconf:
.quad .__GI___sysconf,.TOC.@tocbase,0
.previous
.size __GI___sysconf,24
.type .__GI___sysconf,@function
.globl .__GI___sysconf
.__GI___sysconf:
But the weak_alias statement at the end of ./sysdeps/posix/sysconf.c
weak_alias(__sysconf, sysconf)
generates:
extern __typeof (__sysconf) sysconf __attribute__ ((weak, alias ("
__sysconf")));
which generates the following asm:
.weak sysconf
.weak .sysconf
.set .sysconf,.__sysconf
.set sysconf,__sysconf
The result is a reference to the symbol ".__sysconf" which is not defined
(because it was replaced with "__GI___sysconf". This problem is showing up
on PowerPC64 because of the "DOT_SYMBOLS" but there may be a hidden problem
on other architectures. The reference to symbol "__sysconf" does not seem
to cause a problem because the "opd" entry is generated implicitly, but it
can't be resolved.
It is not clear to me how ths should be resolved.
Does the weak_alias macro need to be updated to work with
libc_hidden_proto?
Do we need a libc_hidden_weak_alias macro?
If this function is hidden, should the weak_alias be used at all?
Is there a compiler/binutils issue here?
I am building for PowerPC64
cpu: Power3 (630+)
machine: IBM 7044-170
Kernel: 2.4.19-rc3
GCC: 3.2 20020729 (prerelease)
binutils: 2.13.90
glibc: from cvs pulled 08/08/2002