bFLT relocations incomplete... I think.

Richard Garcia rick.2g at gmail.com
Tue Oct 17 16:39:51 UTC 2006


    I'm running into a problem installing a flat binary busybox image on a
custom embedded linux.  What I've observed is that after linux boots and
starts up busybox, the bFLT will start attempting to use some pretty low
addresses for it's internal variables; I've managed to observe this in a few
specific instances where it's trying to use an area of ROM flash as memory
for some enviromental variables.  It can't write to those locations, but it
can read from it.  Once it requires one of these symbols, it's downhill from
there; it ends up trying to execute at some random or bogus memory location
depending on whatever text was in the ROM area it was using.

    My guess is that during the bFLT conversion, not all the symbols are
being properly relocated.  Here's the output from the build where it starts
relocation :

TEXT -> vma=0x0 len=0x2f4e0
DATA -> vma=0x2f4e0 len=0x6c50
BSS  -> vma=0x36130 len=0x162b0
GOT table contains 768 entries (3072 bytes)
SECTION: .text [0x7aa750]: flags=0x11b vma=0x0
SECTION: .data [0x7aa7f8]: flags=0x123 vma=0x2f4e0
 RELOCS: .data [0x7a28f8]: flags=0x127 vma=0x2f4e0
  RELOC[0]: offset=0x4cb6 symbol=.data+0x4053 section=.data size=4
fixup=0x33533 (reloc=0x34196)
reloc[0] = 0x34196
... and so on for a few hundred relocations.

The problem here is that it ends up generating 300-something relocations.
Here's the output when I run ./flthdr on the binary

busybox
    Magic:        bFLT
    Rev:          4
    Build Date:   Thu Oct 12 15:41:48 2006
    Entry:        0x2e208
    Data Start:   0x2f520
    Data End:     0x36170
    BSS End:      0x4c420
    Stack Size:   0x1000
    Reloc Start:  0x36170
    Reloc Count:  0x142
    Flags:        0x12 ( Has-PIC-GOT Kernel-Traced-Load )

   This shows 0x142 relocations done, which translates to 322 valid
symbols.  This matches what I see in execution - there are 322 relocations
done on file loading, it terminates on 0xffffffff, so that much seems to be
working.
  The proble is that I've definitely got some symbols which are not being
relocated - I don't know how many.  The GOT table above is showing 768
symbols, but I don't know solidly what else that includes.  All
functions/text addresses seem to be resolving properly, but quite a bit of
the .bss obviously isn't.
    I'm kinda new to bFLT, so if I'm completely off base on something, call
me out here...

    - Rick Garcia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/busybox/attachments/20061017/b925043a/attachment-0002.htm 


More information about the busybox mailing list