Compiling with RTEMS

Angel angel.gonzalez at orbital-aerospace.com
Thu Jan 30 16:49:32 UTC 2014


Hi, I am trying to compile a hello world example from the RTEMS examples 
for a leon2 sparc.

First of all I have compiled the toolchain and RTEMS. I am trying to 
compile the "RTEMS Improvement" version which is based in the RTEMS 
4.8.0 so I compiled with the versions from the 4.8 they are:

- binutils 2.18 + RTEMS patch 20071104
- gcc 4.2.1 + RTEMS patch 20071129
- gdb 6.8
- newlib 1.15 + RTEMS patch 20071221

I have to compile this version of RTEMS so I can't try with a newer version.

After some tweak I have managed to compile the toolchain and I can build 
the RTEMS without any error.
I have all the sparc-rtems4.8-* binaries, and I can debug the ticker 
executables. However now I want to compile the hello world example.

In the first try I had some errors with the '_start' symbol, and other 
problems with the Makefile ( -llibc instead of -lc) after looking over 
the error I had to modify the source of the hello world in order to compile.

********** Code ***********

#define RTEMS_USES_NEWLIB   //Solve wint_t error
#include <bsp.h>

#include <stdlib.h>
#include <stdio.h>

// Solve unresolved '_exit'
#include <unistd.h>
extern void _exit(int status)
{
     while(1){
       asm volatile("nop");
     };
}


rtems_task Init(
   rtems_task_argument ignored
)
{
   printf( "\n\n*** HELLO WORLD TEST ***\n" );
   printf( "Hello World\n" );
   printf( "*** END OF HELLO WORLD TEST ***\n" );
   exit( 0 );
}

/* configuration information */
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
**********************************

With this code and the changes in the Makefile I can compile it with:

sparc-rtems4.8-gcc --pipe -B/<RTEMS_DIR>/sparc-rtems4.8/sis/lib/ -specs 
bsp_specs -qrtems   -g -Wall  -g -g  -mcpu=cypress -msoft-float 
-nodefaultlibs  -o o-optimize/hello.exe  o-optimize/test.o -lrtemscpu 
-levent -lext -lio -lmsg -lrtmon -lsem -ltimer -lrtemsbsp -lrtemscpu -lc 
-lrtemscpu -Wl,--script=linkcmds -Wl,-Map,o-optimize/hello.map 
~/rtems_all/rtems-4.8/sparc-rtems4.8/lib/crt0.o

But when I try to run the 'hello.exe' in the sparc-rtems4.8-sis I got:

sis> go
resuming at 0x02000000
IU in error mode (257)
        16  02000000  00000000  Address 0x0000000002000000 is out of bounds.

How can the entry point of the elf file be out of bounds?

The ELF-Information of the file is:
ELF Header:
   Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00
   Class: ELF32
   Data:                              2's complement, big endian
   Version:                           1 (current)
   OS/ABI:                            UNIX - System V
   ABI Version: 0
   Type:                              EXEC (Executable file)
   Machine: Sparc
   Version: 0x1
   Entry point address: 0x2000000
   Start of program headers:          52 (bytes into file)
   Start of section headers:          454364 (bytes into file)
   Flags: 0x0
   Size of this header:               52 (bytes)
   Size of program headers:           32 (bytes)
   Number of program headers: 1
   Size of section headers:           40 (bytes)
   Number of section headers: 18
   Section header string table index: 15

Section Headers:
   [Nr] Name              Type            Addr     Off    Size   ES Flg 
Lk Inf Al
   [ 0]                   NULL            00000000 000000 000000 00      
0   0  0
   [ 1] .text             PROGBITS        02000000 000060 006650 00 WAX  
0   0  8
   [ 2] .data             PROGBITS        02006650 0066b0 0004f0 00 WA  
0   0  8
   [ 3] .jcr              PROGBITS        02006b40 006ba0 000004 00 WA  
0   0  4
   [ 4] .bss              NOBITS          02006b50 006ba4 000654 00 WA  
0   0 16
   [ 5] .debug_line       PROGBITS        00000000 006ba4 00af1d 00      
0   0  1
   [ 6] .debug_info       PROGBITS        00000000 011ac1 0460a2 00      
0   0  1
   [ 7] .debug_abbrev     PROGBITS        00000000 057b63 009aaa 00      
0   0  1
   [ 8] .debug_aranges    PROGBITS        00000000 061610 000bc0 00      
0   0  8
   [ 9] .comment          PROGBITS        00000000 0621d0 00068a 00      
0   0  1
   [10] .debug_frame      PROGBITS        00000000 06285c 001310 00      
0   0  4
   [11] .debug_loc        PROGBITS        00000000 063b6c 002c07 00      
0   0  1
   [12] .debug_pubnames   PROGBITS        00000000 066773 001cee 00      
0   0  1
   [13] .debug_str        PROGBITS        00000000 068461 006100 00      
0   0  1
   [14] .debug_ranges     PROGBITS        00000000 06e561 0008c8 00      
0   0  1
   [15] .shstrtab         STRTAB          00000000 06ee29 0000b0 00      
0   0  1
   [16] .symtab           SYMTAB          00000000 06f1ac 001ff0 10     
17 202  4
   [17] .strtab           STRTAB          00000000 07119c 001e17 00      
0   0  1
Key to Flags:
   W (write), A (alloc), X (execute), M (merge), S (strings)
   I (info), L (link order), G (group), x (unknown)
   O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
   LOAD           0x000060 0x02000000 0x02000000 0x06b44 0x071a4 RWE 0x10

  Section to Segment mapping:
   Segment Sections...
    00     .text .data .jcr .bss


I have compare it with other executables from the RTEMS ftp (which I run 
correctly) and the hello.exe doesn't have so many differences.


Does someone know what is happening?

Thanks in advance,
Angel





More information about the users mailing list