diff options
author | jdp <jdp@FreeBSD.org> | 1998-09-07 23:32:00 +0000 |
---|---|---|
committer | jdp <jdp@FreeBSD.org> | 1998-09-07 23:32:00 +0000 |
commit | 5b11e2a2f4237604a3b79eae0bd8f58cd296fca5 (patch) | |
tree | 3406d2b2dff7ee0b157826eb5429d6e93491b1a8 /lib/csu | |
parent | 06aec80098f1b2500b86064347079545f0d01eaf (diff) | |
download | FreeBSD-src-5b11e2a2f4237604a3b79eae0bd8f58cd296fca5.zip FreeBSD-src-5b11e2a2f4237604a3b79eae0bd8f58cd296fca5.tar.gz |
Make profiling work for ELF. gprof now autodetects the format of
the executable file, so it will work for both a.out and ELF format
files. I have split the object format specific code into separate
source files. It's cleaner than it was before, but it's still
pretty crufty.
Don't cheat on your make world for this update. A lot of things
have to be rebuilt for it to work, including the compiler and all
of the profiled libraries.
Diffstat (limited to 'lib/csu')
-rw-r--r-- | lib/csu/amd64/Makefile | 6 | ||||
-rw-r--r-- | lib/csu/amd64/crt1.c | 21 | ||||
-rw-r--r-- | lib/csu/i386-elf/Makefile | 6 | ||||
-rw-r--r-- | lib/csu/i386-elf/crt1.c | 21 |
4 files changed, 50 insertions, 4 deletions
diff --git a/lib/csu/amd64/Makefile b/lib/csu/amd64/Makefile index a4c72b3..6432efe 100644 --- a/lib/csu/amd64/Makefile +++ b/lib/csu/amd64/Makefile @@ -1,9 +1,10 @@ # -# $Id: Makefile,v 1.6 1996/04/12 02:24:34 jdp Exp $ +# $Id: Makefile,v 1.1.1.1 1998/03/07 20:27:10 jdp Exp $ # SRCS= crt1.c crtbegin.c crtend.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} +OBJS+= gcrt1.o SOBJS= crtbegin.so crtend.so CFLAGS+= -elf CFLAGS+= -Wall -Wno-unused @@ -15,6 +16,9 @@ INTERNALLIB= true all: ${OBJS} ${SOBJS} +gcrt1.o: crt1.c + ${CC} ${CFLAGS} -DGCRT -c -o gcrt1.o ${.CURDIR}/crt1.c + realinstall: .for file in ${OBJS} ${SOBJS} ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ diff --git a/lib/csu/amd64/crt1.c b/lib/csu/amd64/crt1.c index d89d501..a303997 100644 --- a/lib/csu/amd64/crt1.c +++ b/lib/csu/amd64/crt1.c @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: crt1.c,v 1.4 1996/04/12 02:24:35 jdp Exp $ + * $Id: crt1.c,v 1.1.1.1 1998/03/07 20:27:10 jdp Exp $ */ #ifndef __GNUC__ @@ -37,6 +37,13 @@ extern void _fini(void); extern void _init(void); extern int main(int, char **, char **); +#ifdef GCRT +extern void _mcleanup(void); +extern void monstartup(void *, void *); +extern int eprol; +extern int etext; +#endif + extern int _DYNAMIC; #pragma weak _DYNAMIC @@ -71,7 +78,19 @@ _start(char *arguments, ...) if(&_DYNAMIC != 0) atexit(rtld_cleanup); +#ifdef GCRT + atexit(_mcleanup); +#endif atexit(_fini); +#ifdef GCRT + monstartup(&eprol, &etext); +#endif _init(); exit( main(argc, argv, env) ); } + +#ifdef GCRT +__asm__(".text"); +__asm__("eprol:"); +__asm__(".previous"); +#endif diff --git a/lib/csu/i386-elf/Makefile b/lib/csu/i386-elf/Makefile index a4c72b3..6432efe 100644 --- a/lib/csu/i386-elf/Makefile +++ b/lib/csu/i386-elf/Makefile @@ -1,9 +1,10 @@ # -# $Id: Makefile,v 1.6 1996/04/12 02:24:34 jdp Exp $ +# $Id: Makefile,v 1.1.1.1 1998/03/07 20:27:10 jdp Exp $ # SRCS= crt1.c crtbegin.c crtend.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} +OBJS+= gcrt1.o SOBJS= crtbegin.so crtend.so CFLAGS+= -elf CFLAGS+= -Wall -Wno-unused @@ -15,6 +16,9 @@ INTERNALLIB= true all: ${OBJS} ${SOBJS} +gcrt1.o: crt1.c + ${CC} ${CFLAGS} -DGCRT -c -o gcrt1.o ${.CURDIR}/crt1.c + realinstall: .for file in ${OBJS} ${SOBJS} ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ diff --git a/lib/csu/i386-elf/crt1.c b/lib/csu/i386-elf/crt1.c index d89d501..a303997 100644 --- a/lib/csu/i386-elf/crt1.c +++ b/lib/csu/i386-elf/crt1.c @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: crt1.c,v 1.4 1996/04/12 02:24:35 jdp Exp $ + * $Id: crt1.c,v 1.1.1.1 1998/03/07 20:27:10 jdp Exp $ */ #ifndef __GNUC__ @@ -37,6 +37,13 @@ extern void _fini(void); extern void _init(void); extern int main(int, char **, char **); +#ifdef GCRT +extern void _mcleanup(void); +extern void monstartup(void *, void *); +extern int eprol; +extern int etext; +#endif + extern int _DYNAMIC; #pragma weak _DYNAMIC @@ -71,7 +78,19 @@ _start(char *arguments, ...) if(&_DYNAMIC != 0) atexit(rtld_cleanup); +#ifdef GCRT + atexit(_mcleanup); +#endif atexit(_fini); +#ifdef GCRT + monstartup(&eprol, &etext); +#endif _init(); exit( main(argc, argv, env) ); } + +#ifdef GCRT +__asm__(".text"); +__asm__("eprol:"); +__asm__(".previous"); +#endif |