This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

atexit in a glibc function


I have been writing a custom variant of glibc Version 2.14 that differs primarily in malloc/malloc.c .  My malloc.c has a function called "init_globals" that initializes some global data structures, which opens some files and pipes in the process.  In order to make sure that these pipes and files get closed when the process terminates, I have a "clean_up" function to close them, and, at the end of "init_globals," I have

atexit(&clean_up);

But, when I try to build this variant glibc, the linker reports "undefined reference to 'atexit'":

gcc   -shared -static-libgcc -Wl,-O1  -Wl,-z,defs -Wl,-dynamic-linker=/home/afa9/GLIBC/glibc_install/lib/ld-linux-x86-64.so.2  -B/home/afa9/GLIBC/glibc_obj/csu/  -Wl,--version-script=/home/afa9/GLIBC/glibc_obj/libc.map -Wl,-soname=libc.so.6 -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -nostdlib -nostartfiles -e __libc_main -L/home/afa9/GLIBC/glibc_obj -L/home/afa9/GLIBC/glibc_obj/math -L/home/afa9/GLIBC/glibc_obj/elf -L/home/afa9/GLIBC/glibc_obj/dlfcn -L/home/afa9/GLIBC/glibc_obj/nss -L/home/afa9/GLIBC/glibc_obj/nis -L/home/afa9/GLIBC/glibc_obj/rt -L/home/afa9/GLIBC/glibc_obj/resolv -L/home/afa9/GLIBC/glibc_obj/crypt -L/home/afa9/GLIBC/glibc_obj/nptl -Wl,-rpath-link=/home/afa9/GLIBC/glibc_obj:/home/afa9/GLIBC/glibc_obj/math:/home/afa9/GLIBC/glibc_obj/elf:/home/afa9/GLIBC/glibc_obj/dlfcn:/home/afa9/GLIBC/glibc_obj/nss:/home/afa9/GLIBC/glibc_obj/nis:/home/afa9/GLIBC/glibc_obj/rt:/home/afa9/GLIBC/glibc_obj/resolv:/home/afa9/GLIBC/glibc_obj/crypt:/home/afa9/GLIBC/glibc_obj/nptl -o /home/afa9/GLIBC/glibc_obj/libc.so -T /home/afa9/GLIBC/glibc_obj/shlib.lds /home/afa9/GLIBC/glibc_obj/csu/abi-note.o /home/afa9/GLIBC/glibc_obj/elf/soinit.os /home/afa9/GLIBC/glibc_obj/libc_pic.os /home/afa9/GLIBC/glibc_obj/elf/sofini.os /home/afa9/GLIBC/glibc_obj/elf/interp.os /home/afa9/GLIBC/glibc_obj/elf/ld.so -lgcc
/home/afa9/GLIBC/glibc_obj/libc_pic.os: In function `init_globals':
/home/afa9/GLIBC/glibc/malloc/malloc.c:5186: undefined reference to `atexit'
collect2: ld returned 1 exit status

My malloc.c definitely #includes <stdlib.h>.  Why doesn't the linker recognize "atexit"?  Thanks!

Amittai

Amittai Aviram
PhD Student in Computer Science
Yale University
646 483 2639
amittai.aviram@yale.edu
http://www.amittai.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]