from file position 0x1000
means what it says. You have it in the dump:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
...
[ 1] .text PROGBITS c5000000 001000 5ac13e 00 AX 0 0 4096
It's where the .text
section starts in the file, at offset 0x1000
.
But one thing we can see here .text section is greater than DRAM end address
Nope, it's not greater (not in the sense of bigger, at least), it's compiled in the expectation that it'll be loaded at address 0xc5000000
in the memory.
so image should not be loded properly though we are not getting any error after loading first section it keeps on loading other sections
The image can be loaded anywhere, it's just data for the purpose of loading.
OTOH, if loading section to address 0xc5000000
means what it says, the file gets loaded into nowhere since your RAM ends at 0x7fffffff
.
but after this message it hangs.
And that's expected. Machine code is rarely position-independent and so if you load it at a location different from where it's supposed to be loaded, it'll not work. Or if it doesn't even get loaded, then what are you going to execute? Garbage.
Is there any way to set these section addresses before compilation??
Depending on the system you may have one of the two below options or both:
- set up page translation in such a way that virtual addresses from
0xc5000000
and up map to physical addresses from0x5000000
and up for the entire program - find the linker script that your compiler is using and change the initial section address from
0xc5000000
to0x5000000
, google this up, see compiler/linker documentation
Also, it's a bit odd that the entry point is at 0x5000000
. Not that this is necessarily wrong, it's just that it's rarely the case. I'd make sure that the start
label (or _start
or whatever it is) indeed receives the same address as the beginning of the .text
section. If, for some reason, it's not the case, there's something wrong either with the linker script or the compiler/linker command-line options or with the loader.