[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[microblaze-uclinux] Using absolute symbols in a bFLT binary
Hi all,
I spent several days on a problem which I expected to be simple, and that
may be some of you know how to solve.
My system is composed of 2 cpus, including a microblaze, with a shared
ram mapped at some place in the address space. I am porting some code
on the microblaze (as a process in user space) that assume to find
a C structure instanciated in the shared ram. Note that the code is not
using a pointer on the structure, but the structure itself:
shared_struct.member = 0x1234;
To tell the linker to instanciate it at the target address, I using a new
section to instanciate it:
struct shared_def shared_struct __attribute__ ((section("shared_ram")));
And I add a map file on the linker command line:
MEMORY {
sharedram_mem : ORIGIN = 0x88000000, LENGTH = 0x2000
}
SECTIONS {
shared_ram 0x88000000 : {
*(shared_ram)
} > sharedram_mem
}
My first problem is that I tried hundreds of different syntaxes, instructions,
whatever; I also tried to merge this declaration is the default gcc linker
script; nothing to do, the linking step always fails:
- it can be elf2flt that crashes because it find a data section oversized
(it assumes the section starts at the normal data symbol located near 0x0,
and ends at the shared_struct symbol near 0x88000000!)
- it can be the linker that output that shared_ram is not mapped in any
memory regions, so is put in 0x0 and overlaps with normal text/data sections.
- (i guess I forgot many other errors I had)
Am I doing something that is not regular? Is gcc for microlazed is limited
or whatever? I am doing some obvious error?
I finally found a quick workaround, I just declare my structure as extern
and I set the symbol directly in the linker script:
shared_struct = 0x88000000;
This is working... except that elf2flt adds the symbol to the relocation
table, and when I download it on my board and execute it, the flat loader
complains that it cannot relocate it! I solved this by patching manually
elf2flt and telling it not to relocate symbol from section "*ABS*".
However this solution is not really clean. I have to know exactly the
size of all my symbols (there is actually several struct in the shared ram)
to know where to position them, and I have to use and distribute an hacked
tool.
I am using the petalinux sdk 0.30, and the linux kernel I used was compiled
from the default .config, without big changes.
Did anybody ever succeded in using absolute symbols with a flat binary?
Regards,
Antoine
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/