undefined reference to `c_rtems_main' with rtems-ss-20011025 and posix bsp
Joel Sherrill
joel.sherrill at OARcorp.com
Thu Nov 22 01:13:06 UTC 2001
Matthew J Fletcher wrote:
>
> Hi,.
>
> just to let you know that under rtems-ss-20011025 and the posix bsp you cant
> link properly against 'c_rtems_main', (from main.c), librtemsall.a does
> contain main.o,... so it built ok,.
>
> (there is a load of information bellow, but i will cut to the chase now)
>
> i checked that c_rtems_main, (in main.c) is transformed to main() correctly
> and it was,.. (see objdump bellow)
>
> i dont know quite how the link process got muddled so that bootcard.c
> was looking for c_rtems_main() instead of main(), but a quick hack
> to call main() instead of c_rtems_main and everything works just fine.
This is a side-effect of moving main() into user space. On the POSIX
BSP,
we really do still need to have the special main in the BSP AFAIK.
Here is the patch to posix/unix/startup/Makefile.am.
===================================================================
RCS file:
/usr1/CVS/rtems/c/src/lib/libbsp/unix/posix/startup/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- rtems/c/src/lib/libbsp/unix/posix/startup/Makefile.am
2000/09/05 15:55:02 1.3
+++ rtems/c/src/lib/libbsp/unix/posix/startup/Makefile.am
2001/11/07 23:21:22 1.4
@@ -1,5 +1,5 @@
##
-## $Id: Makefile.am,v 1.3 2000/09/05 15:55:02 joel Exp $
+## $Id: Makefile.am,v 1.4 2001/11/07 23:21:22 joel Exp $
##
AUTOMAKE_OPTIONS = foreign 1.4
@@ -11,7 +11,7 @@
if HAS_CXX
C_MAIN_C_FILES =
else
-C_MAIN_C_FILES = main.c bootcard.c
+C_MAIN_C_FILES = main.c
endif
# C sources
> in case it helps this all worked just fine with rtems-ss-20010126.
>
> #
> a fairly usless error message,..
> #
>
> gmake[5]: Entering directory `/xfs/rtems-build/c/posix/tests/samples/hello'
> mkdir o-optimize
> gcc --pipe -B../../../../../ -B../../../../../posix/lib/ -specs bsp_specs
> -qrtems -ansi -fasm -D_BSD_SOURCE -O2 -g -Wall -o o-optimize/init.o
> -c ../../../../../../rtems-ss-20011025/c/src/tests/samples/hello/init.c
> ../../../../../../rtems-ss-20011025/c/src/tests/samples/hello/init.c: In
> function `Init':
> ../../../../../../rtems-ss-20011025/c/src/tests/samples/hello/init.c:33:
> warning: implicit declaration of function `exit'
> gcc --pipe -B../../../../../ -B../../../../../posix/lib/ -specs bsp_specs
> -qrtems -g -Wall -ansi -fasm -D_BSD_SOURCE -L ../../../../../posix/lib
> -O2 -o o-optimize/hello.exe o-optimize/init.o
> ../../../../../posix/lib/no-dpmem.rel ../../../../../posix/lib/no-event.rel
> ../../../../../posix/lib/no-msg.rel ../../../../../posix/lib/no-mp.rel
> ../../../../../posix/lib/no-part.rel ../../../../../posix/lib/no-signal.rel
> ../../../../../posix/lib/no-timer.rel ../../../../../posix/lib/no-rtmon.rel
> ../../../../../posix/lib/librtemsall.a(bootcard.o): In function `boot_card':
> /xfs/rtems-build/c/posix/lib/libbsp/unix/posix/startup/../../../../../../../../rtems-ss-20011025/c/src/lib/libbsp/shared/bootcard.c:127:
> undefined reference to `c_rtems_main'
> collect2: ld returned 1 exit status
>
> #
> #
> just to get some more information i tired,...
>
> objdump -atxS librtemsall.a > outfile
>
> and c_rtems_main() seems to have turned into
> main(),.. correctly so no problem there,.
> #
> #
>
> main.o: file format elf32-i386
> r--r--r-- 504/535 50740 Nov 21 21:29 2001 main.o
> architecture: i386, flags 0x00000011:
> HAS_RELOC, HAS_SYMS
> start address 0x00000000
>
> SYMBOL TABLE:
> 00000000 l df *ABS* 00000000 main.c
> 00000000 l d .text 00000000
> 00000000 l d .data 00000000
> 00000000 l d .bss 00000000
> 00000000 l d .rodata.str1.1 00000000
> 00000000 l .rodata.str1.1 00000000 .LC0
> 00000000 l d .stab 00000000
> 00000000 l d .stabstr 00000000
> 00000000 l d .comment 00000000
> 00000000 g F .text 00000074 main
> 00000000 *UND* 00000000 rtems_argc
> 00000000 *UND* 00000000 rtems_argv
> 00000000 *UND* 00000000 bsp_start
> 00000004 O *COM* 00000004 rtems_progname
> 00000000 *UND* 00000000 bsp_isr_level
> 00000000 *UND* 00000000 rtems_initialize_executive_late
> 00000000 *UND* 00000000 stdout
> 00000000 *UND* 00000000 fflush
> 00000000 *UND* 00000000 stderr
> 00000000 *UND* 00000000 bsp_cleanup
>
> Disassembly of section .text:
>
> 00000000 <main>:
> int main(
> int argc,
> char **argv
> )
> {
> 0: 55 push %ebp
> 1: 89 e5 mov %esp,%ebp
> 3: 56 push %esi
> 4: 53 push %ebx
> 5: 8b 75 0c mov 0xc(%ebp),%esi
> 8: 8b 5d 08 mov 0x8(%ebp),%ebx
> b: 83 e4 f0 and $0xfffffff0,%esp
> rtems_argc = argc;
> e: 89 1d 00 00 00 00 mov %ebx,0x0
> 10: R_386_32 rtems_argc
> rtems_argv = argv;
> 14: 89 35 00 00 00 00 mov %esi,0x0
> 16: R_386_32 rtems_argv
>
> bsp_start();
> 1a: e8 fc ff ff ff call 1b <main+0x1b>
> 1b: R_386_PC32 bsp_start
>
> if ((argc > 0) && argv && argv[0])
> 1f: 85 db test %ebx,%ebx
> 21: 7e 45 jle 68 <main+0x68>
> 23: 85 f6 test %esi,%esi
> 25: 74 41 je 68 <main+0x68>
> 27: 8b 06 mov (%esi),%eax
> 29: 85 c0 test %eax,%eax
> 2b: 74 3b je 68 <main+0x68>
> rtems_progname = argv[0];
> 2d: a3 00 00 00 00 mov %eax,0x0
> 2e: R_386_32 rtems_progname
> else
> rtems_progname = "RTEMS";
>
> /*
> * Start multitasking
> */
>
> rtems_initialize_executive_late( bsp_isr_level );
> 32: 83 ec 0c sub $0xc,%esp
> 35: 8b 35 00 00 00 00 mov 0x0,%esi
> 37: R_386_32 bsp_isr_level
> 3b: 56 push %esi
> 3c: e8 fc ff ff ff call 3d <main+0x3d>
> 3d: R_386_PC32 rtems_initialize_executive_late
>
> /*
> * Returns when multitasking is stopped
> * This allows our destructors to get run normally
> */
>
> fflush( stdout );
> 41: 5b pop %ebx
> 42: 8b 0d 00 00 00 00 mov 0x0,%ecx
> 44: R_386_32 stdout
> 48: 51 push %ecx
> 49: e8 fc ff ff ff call 4a <main+0x4a>
> 4a: R_386_PC32 fflush
> fflush( stderr );
> 4e: 5a pop %edx
> 4f: a1 00 00 00 00 mov 0x0,%eax
> 50: R_386_32 stderr
> 54: 50 push %eax
> 55: e8 fc ff ff ff call 56 <main+0x56>
> 56: R_386_PC32 fflush
>
> bsp_cleanup();
> 5a: e8 fc ff ff ff call 5b <main+0x5b>
> 5b: R_386_PC32 bsp_cleanup
>
> return 0;
> }
> 5f: 8d 65 f8 lea 0xfffffff8(%ebp),%esp
> 62: 5b pop %ebx
> 63: 31 c0 xor %eax,%eax
> 65: 5e pop %esi
> 66: 5d pop %ebp
> 67: c3 ret
> 68: c7 05 00 00 00 00 00 movl $0x0,0x0
> 6f: 00 00 00
> 6a: R_386_32 rtems_progname
> 6e: R_386_32 .LC0
> 72: eb be jmp 32 <main+0x32>
> 74: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
> 7a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
>
> mallocfreespace.o: file format elf32-i386
> r--r--r-- 504/535 52668 Nov 21 21:29 2001 mallocfreespace.o
> architecture: i386, flags 0x00000011:
> HAS_RELOC, HAS_SYMS
> start address 0x00000000
>
> Sections:
> Idx Name Size VMA LMA File off Algn
> 0 .text 00000030 00000000 00000000 00000040 2**4
> CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
> 1 .data 00000000 00000000 00000000 00000070 2**2
> CONTENTS, ALLOC, LOAD, DATA
> 2 .bss 00000000 00000000 00000000 00000070 2**2
> ALLOC
> 3 .stab 00002bec 00000000 00000000 00000070 2**2
> CONTENTS, RELOC, READONLY, DEBUGGING
> 4 .stabstr 00009de2 00000000 00000000 00002c5c 2**0
> CONTENTS, READONLY, DEBUGGING
> 5 .comment 00000012 00000000 00000000 0000ca3e 2**0
> CONTENTS, READONLY
> SYMBOL TABLE:
> 00000000 l df *ABS* 00000000 mallocfreespace.c
> 00000000 l d .text 00000000
> 00000000 l d .data 00000000
> 00000000 l d .bss 00000000
> 00000000 l d .stab 00000000
> 00000000 l d .stabstr 00000000
> 00000000 l d .comment 00000000
> 00000000 g F .text 00000028 malloc_free_space
> 00000000 *UND* 00000000 RTEMS_Malloc_Heap
> 00000000 *UND* 00000000 rtems_region_get_information
>
> regards
>
> ---
> Matthew J Fletcher amimjf at connectfree.co.uk
> Software Engineering Matthew.Fletcher at student.shu.ac.uk
> www.amimjf.org ICQ amimjf 44193496
>
> Since when did ignorance become a point of view ??
> ---
--
Joel Sherrill, Ph.D. Director of Research & Development
joel at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the users
mailing list