[PATCH] Fixes for i686-pc-linux-newlib
Jeff Johnston
jjohnstn@redhat.com
Tue Jan 10 20:58:00 GMT 2006
Paolo,
A number of issues with this patch. First of all, I usually build
x86-linux apps with -nostdlib and manually specify newlib's crt0.o.
This basic test fails with the patch below because _init and _fini
aren't defined in newlib (we don't supply crt[1/n/o] .o files at
present). Hacking past that initial problem, I ran into a problem
building a hello world program with -fprofile-arcs and -ftest-coverage.
These options drag in libgcov.a which was built with glibc headers and
it expects some magic symbols that aren't in newlib (e.g. stderr,
__errno_location, and __fxstat). I hacked past the link problem by
adding newlib symbols and linking in /usr/lib/crti.o but I eventually
ended up with a SIGSEGV.
Could you elaborate on how you built your application to get profile
data output? Can you verify that you actually have a newlib application
as opposed to one that is using glibc?
-- Jeff J.
Paolo Bonzini wrote:
> The first hunk is a work around for the (in)famous INSTALL = ../ bug.
> We can just pass down INSTALL as we detect it correctly in the toplevel
> configure and in newlib's configure.
>
> The second hunk is needed to invoke initialization and finalization
> functions. I tested it by running a program compiled with gcc and with
> profiling enabled. It creates the .gcda file correctly.
>
> Can you apply them? I have no copyright on file, but these are small
> enough to not require it.
>
> 2005-06-03 Paolo Bonzini <bonzini@gnu.org>
>
> * Makefile.am (AM_MAKEFLAGS): Pass down INSTALL.
> * libc/sys/linux/machine/i386/crt0.c (_start): Invoke _init and
> _fini.
>
> Paolo
>
>
> ------------------------------------------------------------------------
>
> Index: Makefile.am
> ===================================================================
> RCS file: /cvs/src/src/newlib/Makefile.am,v
> retrieving revision 1.35
> diff -u -p -r1.35 Makefile.am
> --- Makefile.am 8 Sep 2005 22:45:49 -0000 1.35
> +++ Makefile.am 3 Jan 2006 19:01:02 -0000
> @@ -50,6 +50,7 @@ AM_MAKEFLAGS = \
> "LD=$(LD)" \
> "LIBCFLAGS=$(LIBCFLAGS)" \
> "NM=$(NM)" \
> + "INSTALL=$(INSTALL)" \
> "PICFLAG=$(PICFLAG)" \
> "RANLIB=$(RANLIB)" \
> "DESTDIR=$(DESTDIR)"
> Index: libc/sys/linux/machine/i386/crt0.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/sys/linux/machine/i386/crt0.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 crt0.c
> --- libc/sys/linux/machine/i386/crt0.c 10 Sep 2002 00:46:45 -0000 1.5
> +++ libc/sys/linux/machine/i386/crt0.c 3 Jan 2006 19:01:04 -0000
> @@ -16,6 +16,9 @@ extern char **environ;
>
> extern int main(int argc,char **argv,char **envp);
>
> +extern void _init (void);
> +extern void _fini (void);
> +
> extern char _end;
> extern char __bss_start;
>
> @@ -41,5 +44,8 @@ void _start(int args)
> * by this time by Linux. */
>
> tzset(); /* initialize timezone info */
> +
> + atexit (_fini);
> + _init ();
> exit(main(argc,argv,environ));
> }
More information about the Newlib
mailing list