[ECOS] Code coverage using synthetic eCos.

Andrew Lunn andrew@lunn.ch
Tue Mar 1 14:00:00 GMT 2005

On Tue, Mar 01, 2005 at 05:16:26PM +0530, Santoshkumar Zalake wrote:
> Hi all,
> I want to do code coverage of C code using synthetic eCos-2.0 on Linux. I
> used gcov.
> I enable the flag of gcov "-fprofile-arcs -ftest-coverage" at time of
> complication.
> But at the time of linking I got following error.
> gcc -nostdlib -Tos/ecos/lib/target.ld -Los/ecos//lib/ -L/usr/lib -o a.out
> .test.o .test_1.o
> /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/libgcc.a(_bb.oS)(.text+0x439): In
> function `__bb_exit_func':
> : undefined reference to `getpid'
> /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/libgcc.a(_bb.oS)(.text+0x44c): In
> function `__bb_exit_func':
> : undefined reference to `fileno'
> /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/libgcc.a(_bb.oS)(.text+0x454): In
> function `__bb_exit_func':
> : undefined reference to `fcntl'
> /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/libgcc.a(_bb.oS)(.text+0x460): In
> function `__bb_exit_func':
> : undefined reference to `__errno_location'
> collect2: ld returned 1 exit status
> make: *** [test/systest/ap.out] Error 1

It looks like gcov assumes it has access to glibc. This is not true
for eCos, it uses its own libc. Hence the linker errors. What you need
to do is take a look at the source for libgcc.a and see what it is
trying to do with these system calls. You will probably need to add
dummy/real implementations of these functions to make it work.

One other things to think about. The compiler will be adding calls to
write the profile data to a filesystem. These calls are made within
eCos and so will try to write to an eCos filesystem, not the native
filesystem of the Linux box. You will need to think about supplying an
eCos filesystem it can use and how you want to get the resulting files
out of the eCos filesystem and onto the native filesystem so that you
can run gcov on the files.


Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list