Re: [uClinux-dev] elf2flt: ARM and PIC

From: Adrian von Bidder (avbidder@acter.ch)
Date: Wed Dec 05 2001 - 04:06:25 EST


Adrian von Bidder wrote:
> [avbidder@atlas hello]$ arm-uclinux-gcc -fpic -msingle-pic-base
> -mcpu=arm7tdmi -O3 -c hello.c 
> [avbidder@atlas hello]$ arm-uclinux-ld -r -d -o hello.elftmp -L
> ../uclibc/lib ../uclibc/lib/crt0.o hello.o -lc   
> [avbidder@atlas hello]$ arm-uclinux-ld -T ../../../gcc-3/lib/elf2flt.ld
> -Ur -o hello.elf hello.elftmp 
> [avbidder@atlas hello]$ arm-uclinux-ld -T ../../../gcc-3/lib/elf2flt.ld
> -o hello.gdb hello.elftmp 
> [avbidder@atlas hello]$ elf2flt -v -p hello.gdb hello.elf
> Architecture and machine:  arm
> TEXT -> vma=1 len=160
>         lma=0 clen=0 oo=160 ap=0 fp=0
> DATA -> vma=1 len=50
>         lma=160 clen=160 oo=50 ap=0 fp=0
> ERROR: text=160 overlaps data=1 ?
> 
> Why is the lma, but not the vma set? In the ld script if only one
> address is specified, shouldn't it be the vma? Dave?

Some more info on this:
from readelf hello.gdb:
===
Section Headers:
  [Nr] Name    Type           Addr     Off    Size   ES Flg Lk Inf Al  
  [ 1] .text  PROGBITS        00000000 008000 000160 00  AX  0   0 4
  [ 2] .data  PROGBITS        00000160 008160 000050 04 WA   0   0 4
  [ 3] .bss   NOBITS          000001b0 0081b0 000000 00 WA   0   0 1
[...]

Program Header:
  Type        Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD        0x008000 0x00000000 0x00000000 0x001b0 0x001b0 RWE 0x8000

 Section to Segment mapping:
  Segment Sections...
   00     .text .data 
===
Why is there an offset and align of 0x8000 (And what is it for?)

readelf hello.elf says:
===
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        00000000 000034 000160 00  AX  0   0 4
[ 2] .rel.text REL            00000000 0003d8 000088 08      8   1 4
[ 3] .data    PROGBITS        00000160 000194 000040 00 WA   0   0 4
[ 4] .rel.data REL            00000000 000460 000010 08      8   3 4
[ 5] .bss     NOBITS          000001a0 0001d4 000000 00 WA   0   0 1
[...]

Relocation section '.rel.text' at offset 0x3d8 contains 17 entries:
  Offset    Info  Type            Symbol's Value  Symbol's Name
  00000018  01f01 R_ARM_PC24            00000060 
__uClibc_main            
  0000001c  02b02 R_ARM_ABS32           00000000 
__data_start             
  00000034  01a01 R_ARM_PC24            00000110 
write                    
  00000050  01a01 R_ARM_PC24            00000110 
write                    
  00000054  00d1a R_ARM_GOT32           0000000c 
.LC1                     
  00000058  00c1a R_ARM_GOT32           00000028 
p                        
[...]
===
I assume that the linker knows that How does the linker decide whether a
reloc points to the data or the text segment? Ok, I assume it's ok - but
the output is not too helpful for me.

Dump of the .data section shows that both hello.elf and hello.gdb seem
to contain some .got entries at the beginning of the data section. Or
this could be because the ld script puts .rel[a].got into the got.
 
greets from Zürich
-- vbi
This message resent by the uclinux-dev@uclinux.org list server http://www.uClinux.org/


This archive was generated by hypermail 2.1.4 : Thu Sep 19 2002 - 13:20:34 EDT