[uClinux-dev] "reloc outside program" error

David McCullough david_mccullough at au.securecomputing.com
Sun Jan 7 19:00:40 EST 2007


Jivin Aaron Zhong lays it down ...
> Hi all,
> 
> I have a problem when I run my test program on uclinux for mips. The output is
> # ./test
> BINFMT_FLAT: reloc outside program 0xffbb2563 (0 - 0x4df98/0x3e220)  start_brk !
> calc_reloc fail 3 id  = 0 i=3,rp=81f6a22c
> BINFMT_FLAT: reloc outside program 0xffbb2563 (0 - 0x4df98/0x3e220)  start_brk !
> calc_reloc fail 3 id  = 0 i=3,rp=81f6a22c
> Memory fault


mips support has not been included in the elf2flt sources, so to some
extent you will be working this out for yourself ;-)  It hasn't been
included because no one has posted patches for inclusion.


> I noticed that there is a warning when compile the program:
> ...
> mips-linux-gcc -O2 -msoft-float -DPARANOID_TTYS -DUSE_TERMIO -DKLUDGELINEMODE 
> -D_GNU_SOURCE -D__uClinux__   -c -o logout.o logout.c
> mips-linux-gcc -Wl,-elf2flt="-z -s 8192 -v" -o test telnetd.o state.o termstat.o
> slc.o sys_term.o utility.o global.o authenc.o logwtmp.o logout.o  -L. -lfoo -lpthread
> TEXT -> vma=400000 len=3e250
>         lma=400000 clen=0 oo=3e250 ap=0 fp=0
> DATA -> vma=43e260 len=c140
>         lma=43e260 clen=0 oo=c140 ap=0 fp=0
> WARNING: data=43e260 does not directly follow text=3e250
> BSS  -> vma=44a3a0 len=3c38
>         lma=44a3a0 clen=0 oo=3c38 ap=0 fp=0
> GOT table contains 708 entries (2832 bytes)
> SECTION: .text [96df414]: flags=233 vma=400000
> SECTION: .data [96df4cc]: flags=243 vma=43e260
>  RELOCS: .data [96d75d4]: flags=247 vma=43e260
> WARN: GPREL32
> WARN: GPREL32
> WARN: GPREL32
> ...
> 
> Is the warning cause the problem? Which confused me is that a simple program
> like "hello world" could run correctly. Could anybody help me? And the following
> is flthdr and objdump information, and last is the elf2flt.ld:

That warning is a problem and usually points to missing sections in
elf2flt.ld or something not being done quite right for MIPs.

Also checkout:
	WARN: GPREL32 - is this and unhandled relocation ?

Do you need to do anything with the ".pdr" section ?

Have a look at the newer "-a" elf2flt option,  it can make getting this stuff
right easier with newer toolchains,

Cheers,
Davidm


> # mips-linux-flthdr test
> test
>     Magic:        bFLT
>     Rev:          4
>     Build Date:   Fri Jan  5 11:07:49 2007
>     Entry:        0x400060
>     Data Start:   0x3e2a0
>     Data End:     0x4a3e0
>     BSS End:      0x4e018
>     Stack Size:   0x2000
>     Reloc Start:  0x4a3e0
>     Reloc Count:  0x112
>     Flags:        0x6 ( Has-PIC-GOT Gzip-Compressed )
> 
> # mips-linux-objdump -h test.gdb
> 
> test.gdb:     file format elf32-tradbigmips
> 
> Sections:
> Idx Name          Size      VMA       LMA       File off  Algn
>   0 .text         0003e250  00400000  00400000  00001000  2**4
>                   CONTENTS, ALLOC, LOAD, READONLY, CODE
>   1 .data         0000c140  0043e260  0043e260  0003f260  2**5
>                   CONTENTS, ALLOC, LOAD, DATA
>   2 .bss          00003c38  0044a3a0  0044a3a0  0004b3a0  2**4
>                   ALLOC
>   3 .junk         00000000  00000000  00000000  00001000  2**4
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>   4 .comment      00000402  00000000  00000000  0004b3a0  2**0
>                   CONTENTS, READONLY
>   5 .debug_aranges 00000200  00000000  00000000  0004b7a2  2**0
>                   CONTENTS, READONLY, DEBUGGING
>   6 .debug_pubnames 0000024a  00000000  00000000  0004b9a2  2**0
>                   CONTENTS, READONLY, DEBUGGING
>   7 .debug_info   00007521  00000000  00000000  0004bbec  2**0
>                   CONTENTS, READONLY, DEBUGGING
>   8 .debug_abbrev 0000204d  00000000  00000000  0005310d  2**0
>                   CONTENTS, READONLY, DEBUGGING
>   9 .debug_line   00001148  00000000  00000000  0005515a  2**0
>                   CONTENTS, READONLY, DEBUGGING
>  10 .debug_frame  0000031c  00000000  00000000  000562a4  2**2
>                   CONTENTS, READONLY, DEBUGGING
>  11 .debug_str    0000079d  00000000  00000000  000565c0  2**0
>                   CONTENTS, READONLY, DEBUGGING
>  12 .pdr          00006c80  00000000  00000000  00056d60  2**2
>                   CONTENTS, READONLY
>  13 .mdebug.abi32 00000000  00000000  00000000  0005d9e0  2**0
>                   CONTENTS, READONLY
>  14 .debug_ranges 00000380  00000000  00000000  0005d9e0  2**0
>                   CONTENTS, READONLY, DEBUGGING
> 
> 
> # cat elf2flt.ld
> 
> ENTRY (__start)
> 
> MEMORY {
>         flatmem : ORIGIN = 0x400000, LENGTH = 0xffffff
>         junk    : ORIGIN = 0x0, LENGTH = 0x100000
> }
> 
> SECTIONS {
>         .text 0x400000 : {
>                 . = . + 4;
>                 . = ALIGN(0x4) ;
>                 _stext = . ;
>                 *(.reginfo)
>                 *(.text)
>                 *(.text.*)
>                 *(.gnu.warning)
>                 *(.stub)
>                 *(.gnu.linkonce.t*)
>                 *(.glue_7t)
>                 *(.glue_7)
>                 *(.jcr)
>                 *(.init)
>                 *(.fini)
> 
> W_RODAT         *(.rodata)
> W_RODAT         *(.rodata1)
> W_RODAT         *(.rodata.*)
> 
>                 /* This is special code area at the end of the normal
>                    text section.  It contains a small lookup table at
>                    the start followed by the code pointed to by entries
>                    in the lookup table.  */
>                 . = ALIGN (4) ;
>                 PROVIDE(__ctbp = .);
>                 *(.call_table_data)
>                 *(.call_table_text)
> 
>                 . = ALIGN(0x10) ;
>                 _etext = . ;
>         } > flatmem
>         .data : {
>                 . = ALIGN(0x4) ;
>                 _sdata = . ;
>                 __data_start = . ;
>                 data_start = . ;
>                 _gp = . ;
>                 *(.got.plt)
>                 *(.got)
>                 . = ALIGN(0x10) ;
>                 LONG(-1)
> R_RODAT         *(.rodata)
> R_RODAT         *(.rodata1)
> R_RODAT         *(.rodata.*)
>                 *(.gnu.linkonce.r*)
>                 *(.data)
>                 *(.data1)
>                 *(.data.*)
>                 *(.gnu.linkonce.d*)
>                 *(.data1)
>                 *(.eh_frame)
>                 *(.gcc_except_table)
>                 *(.sdata)
>                 *(.sdata.*)
>                 *(.gnu.linkonce.s.*)
>                 *(__libc_atexit)
>                 *(__libc_subinit)
>                 *(__libc_subfreeres)
>                 *(.note.ABI-tag)
>                 . = ALIGN(4) ;
>                 *(.ctors.*)
>                 *(.ctors)
>                 LONG(0)
>                 *(.dtors.*)
>                 *(.dtors)
>                 LONG(0)
>                 . = ALIGN(0x10) ;
>                 _edata = . ;
>         } > flatmem
>         .bss : {
>                 . = ALIGN(0x4) ;
>                 _sbss = ALIGN(0x4) ;
>                 __bss_start = . ;
>                 *(.dynsbss)
>                 *(.sbss)
>                 *(.sbss.*)
>                 *(.scommon)
>                 *(.dynbss)
>                 *(.bss)
>                 *(.bss.*)
>                 *(COMMON)
>                 . = ALIGN(0x4) ;
>                 _ebss = . ;
>                 _end = . ;
>                 end = . ;
>         } > flatmem
> 
>         .junk : {
>                 *(.rel*)
>                 *(.rela*)
>         } > junk
> }
> 
> 
> _______________________________________________
> uClinux-dev mailing list
> uClinux-dev at uclinux.org
> http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
> This message was resent by uclinux-dev at uclinux.org
> To unsubscribe see:
> http://mailman.uclinux.org/mailman/options/uclinux-dev

-- 
David McCullough,  david_mccullough at securecomputing.com,   Ph:+61 734352815
Secure Computing - SnapGear  http://www.uCdot.org http://www.cyberguard.com


More information about the uClinux-dev mailing list