i'm working on the C library, and to make debuggin easy i've copied
/usr/src/lib/libc to another directory and only build libc.a.

i've also copied /usr/src/lib/csu/i386-elf to another directory and 
have enabled debug symbols on both csu and libc.

to try things out i create a static binary and coerce it to use my
C library instead of the system's one.

this is how i compile my program:

cc -g -DYP -DFreeBSD -Wall -pedantic -ansi -c -I../../libc/include nss-test.c 
cc -g -nostdlib -static -L../../libc -o nss-test nss-test.o \
        ../../csu/i386-elf/crt1.o ../../csu/i386-elf/crti.o -lc

now, the program runs fine, but at the very end gives me a bus error
and core dumps... i've tracked the bug to the following call in line 90
csu/i386-elf/crt1.c in function _start()

    atexit(_fini);

at this point, in gdb

(gdb) print _fini
$1 = {<text variable, no debug info>} 0x80528e4
(gdb) step
atexit (fn=0x80528e4)
    at /usr/home/obonilla/freebsd/nss/libc/../libc/stdlib/atexit.c:59
1: __progname = 0xbfbffa86 "nss-test"
(gdb) print fn
$2 = (void (*)()) 0

fn is the argument to atexit()

later, in fuction exit() it will try to dereference a null pointer due
to the above...

i'm puzzled by this behavior... am i missing something?
how is it possible that the value i'm seeing before the call to atexit()
(0x80528e4) gets to be null once inside atexit()?

thanks and regards,

-oscar

-- 
pgp public key: finger [EMAIL PROTECTED]
pgp fingerprint: 6D 18 8C 90 4C DF F0 4B  DF 35 1F 69 A1 33 C7 BC


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to