Bug 5203 - glibc 2.7 build failure: "undefined reference to fstatat64"
Summary: glibc 2.7 build failure: "undefined reference to fstatat64"
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 critical
Target Milestone: ---
Assignee: Ulrich Drepper
Depends on:
Reported: 2007-10-21 15:53 UTC by Felix von Leitner
Modified: 2014-07-04 07:14 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Last reconfirmed:
fweimer: security-


Note You need to log in before you can comment on or make changes to this bug.
Description Felix von Leitner 2007-10-21 15:53:00 UTC
I'm using gcc 4.2.2, binutils 2.18, and configure like this:

$ cd build && CFLAGS="-pipe -Os" ../configure --prefix=/usr --disable-profile
--enable-add-ons --without-cvs --with-tls --enable-stackguard-randomization

These are the last build lines:

make[2]: Leaving directory `/tmp/glibc-2.7/elf'
cd /tmp/glibc-2.7/build && ar cruv libc.a `cat csu/stamp.o iconv/stamp.o
iconvdata/stamp.o locale/stamp.o localedata/stamp.o assert/stamp.o ctype/stamp.o
intl/stamp.o catgets/stamp.o math/stamp.o setjmp/stamp.o signal/stamp.o
stdlib/stamp.o stdio-common/stamp.o libio/stamp.o dlfcn/stamp.o malloc/stamp.o
string/stamp.o wcsmbs/stamp.o timezone/stamp.o time/stamp.o dirent/stamp.o
grp/stamp.o pwd/stamp.o posix/stamp.o io/stamp.o termios/stamp.o
resource/stamp.o misc/stamp.o socket/stamp.o sysvipc/stamp.o gmon/stamp.o
gnulib/stamp.o wctype/stamp.o manual/stamp.o shadow/stamp.o po/stamp.o
argp/stamp.o crypt/stamp.o nptl/stamp.o resolv/stamp.o nss/stamp.o rt/stamp.o
conform/stamp.o debug/stamp.o libidn/stamp.o nptl_db/stamp.o inet/stamp.o
hesiod/stamp.o sunrpc/stamp.o nis/stamp.o nscd/stamp.o streams/stamp.o
login/stamp.o elf/stamp.o stamp.o`
r - locale/C-ctype.o
r - misc/lseek.o
: /tmp/glibc-2.7/build/libc.a
/opt/gcc/bin/gcc   -nostdlib -nostartfiles -r -o /tmp/glibc-2.7/build/libc_pic.os \
         -Wl,-d -Wl,--whole-archive /tmp/glibc-2.7/build/libc_pic.a
/opt/gcc/bin/gcc   -shared -static-libgcc -Wl,-O1  -Wl,-z,defs
-Wl,-dynamic-linker=/lib64/ld-linux-x86-64.so.2  -B/tmp/glibc-2.7/build/csu/ 
-Wl,--version-script=/tmp/glibc-2.7/build/libc.map -Wl,-soname=libc.so.6
-Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -nostdlib -nostartfiles -e
__libc_main -L/tmp/glibc-2.7/build -L/tmp/glibc-2.7/build/math
-L/tmp/glibc-2.7/build/elf -L/tmp/glibc-2.7/build/dlfcn
-L/tmp/glibc-2.7/build/nss -L/tmp/glibc-2.7/build/nis -L/tmp/glibc-2.7/build/rt
-L/tmp/glibc-2.7/build/resolv -L/tmp/glibc-2.7/build/crypt
-o /tmp/glibc-2.7/build/libc.so -T /tmp/glibc-2.7/build/shlib.lds
/tmp/glibc-2.7/build/csu/abi-note.o /tmp/glibc-2.7/build/elf/soinit.os
/tmp/glibc-2.7/build/libc_pic.os /tmp/glibc-2.7/build/elf/sofini.os
/tmp/glibc-2.7/build/elf/interp.os /tmp/glibc-2.7/build/elf/ld.so -lgcc
/tmp/glibc-2.7/build/libc_pic.os: In function `faccessat':
(.text+0x82aea): undefined reference to `fstatat64'
collect2: ld returned 1 exit status
make[1]: *** [/tmp/glibc-2.7/build/libc.so] Error 1
make[1]: Leaving directory `/tmp/glibc-2.7'
make: *** [all] Error 2

$ grep -lr fstatat64 .
$ grep -lr fstatat64 io | xargs -n1 nm
nm: io/fstatat64.o.d: File format not recognized
nm: io/fstatat64.oS.d: File format not recognized
nm: io/stamp.oS: File format not recognized
                 U _GLOBAL_OFFSET_TABLE_
                 U __fxstatat64
0000000000000000 T fstatat64
                 U _GLOBAL_OFFSET_TABLE_
                 U __atfct_seterrno
                 U __getegid
                 U __geteuid
                 U __getgid
                 U __getuid
                 U __group_member
                 U __have_atfcts
                 U __libc_enable_secure
                 U __libc_errno
                 U __snprintf
0000000000000000 T faccessat
                 U fstatat64
0000000000000000 r procfd.7014
nm: io/stamp.o: File format not recognized
                 U _GLOBAL_OFFSET_TABLE_
                 U __atfct_seterrno
                 U __getegid
                 U __geteuid
                 U __getgid
                 U __getuid
                 U __group_member
                 U __have_atfcts
                 U __libc_enable_secure
                 U __libc_errno
                 U __snprintf
0000000000000000 T faccessat
                 U fstatat64
0000000000000000 r procfd.6816
                 U __fxstatat64
0000000000000000 T fstatat64
Comment 1 Andreas Jaeger 2007-10-21 17:17:54 UTC
This is a bad interaction between compiler and library.  -Os does not inline all
cases and we need those inlined.  I advise to use the default compile flags.
Comment 2 Felix von Leitner 2007-10-21 18:49:22 UTC
OK, will try -O2 then.  Thanks for the help!
Comment 3 Dimitry Andric 2008-12-23 15:30:20 UTC
I know this is marked as WONTFIX, but just for reference, this can be fixed so
it does compile with -Os, simply by unapplying this commit: