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. I originally posted this message on
the microblaze mailing list, but nobody there seem to have experienced this
kind of problem.
My system is composed of 2 cpus, including a microblaze and an arm, with a
shared ram mapped at a fixed range 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, e.g.:
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? On the other hand, the similiar
code on the ARM is succesfully compiled with RVDS or Gnuarm.
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 in a flat binary?
Regards,
Antoine
_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev