aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>2005-10-07 22:13:17 +0000
committerBruce Evans <bde@FreeBSD.org>2005-10-07 22:13:17 +0000
commitd31f7e49912209dceef45659c6400e0ecf2a9499 (patch)
tree031c66171514bc1340a1e8cc029bf422a2cc9b81 /lib
parent57bbb41ebdf505e6edd6855114b07451c429ab47 (diff)
downloadsrc-d31f7e49912209dceef45659c6400e0ecf2a9499.tar.gz
src-d31f7e49912209dceef45659c6400e0ecf2a9499.zip
Fixed profiling of main() for amd64 and i386. This started rotting
in 1993 in rev.1.5 of the i386 a.out version (csu/i386/crt0.c). Profiling uses a magic label "eprol" to delimit the start of the part of the text section covered by profiling. This label must be placed before the call to main() to get main() properly profiled. It was placed there in rev.1.1 of crt0.c. Rev.1.5 imported the initial implementation of shared libraries in FreeBSD and misplaced the label. Fortunately, the misplaced label was misspelled and the old label wasn't removed, so the new label had no effect. Unfortunately, when profiling was implemented for the ELF in 1998 in rev.1.2 of csu/i386-elf/crt1.c, only the incorrectly placed label was copied (after fixing its name). The bug was then copied to all other arches. The label seems to be still misplaced in NetBSD for most arches. It is in common.c for most arches so it is even further from being inside the function that calls main(). I think "eprol" is short for "end of prologue", but it must be placed before the end of the prologue so that it covers main(). crt0.c has it before the calls atexit(_mcleanup) and monstartup(...), but it cannot affect these calls so I moved it after the call to monstartup(). It now also covers the call to _init() but not the newer call to _init_tls(). Profiling of _init() seems to be harmless, and the call to _init_tls() seems to be misplaced. Reviewed by: jdp (long ago, for a slightly different i386 version)
Notes
Notes: svn path=/head/; revision=151072
Diffstat (limited to 'lib')
-rw-r--r--lib/csu/amd64/crt1.c7
-rw-r--r--lib/csu/i386-elf/crt1.c7
2 files changed, 2 insertions, 12 deletions
diff --git a/lib/csu/amd64/crt1.c b/lib/csu/amd64/crt1.c
index f1f0f7b0b0c2..943b07b31a94 100644
--- a/lib/csu/amd64/crt1.c
+++ b/lib/csu/amd64/crt1.c
@@ -86,15 +86,10 @@ _start(char **ap, void (*cleanup)(void))
atexit(_fini);
#ifdef GCRT
monstartup(&eprol, &etext);
+__asm__("eprol:");
#endif
_init();
exit( main(argc, argv, env) );
}
-#ifdef GCRT
-__asm__(".text");
-__asm__("eprol:");
-__asm__(".previous");
-#endif
-
__asm__(".ident\t\"$FreeBSD$\"");
diff --git a/lib/csu/i386-elf/crt1.c b/lib/csu/i386-elf/crt1.c
index c6774b0f394f..093433330e35 100644
--- a/lib/csu/i386-elf/crt1.c
+++ b/lib/csu/i386-elf/crt1.c
@@ -104,15 +104,10 @@ _start(char *ap, ...)
atexit(_fini);
#ifdef GCRT
monstartup(&eprol, &etext);
+__asm__("eprol:");
#endif
_init();
exit( main(argc, argv, env) );
}
-#ifdef GCRT
-__asm__(".text");
-__asm__("eprol:");
-__asm__(".previous");
-#endif
-
__asm__(".ident\t\"$FreeBSD$\"");