Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Mar 2000 15:03:27 -0600
From:      Oscar Bonilla <obonilla@fisicc-ufm.edu>
To:        freebsd-hackers@freebsd.org
Subject:   inner workings of the C compiler
Message-ID:  <20000308150327.A77039@fisicc-ufm.edu>

next in thread | raw e-mail | index | archive | help
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 obonilla@fisicc-ufm.edu
pgp fingerprint: 6D 18 8C 90 4C DF F0 4B  DF 35 1F 69 A1 33 C7 BC


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000308150327.A77039>