How to map text and data section to same address in the linker script for targets based on Harvard architectures

Ian Lance Taylor iant@google.com
Tue Jun 2 19:08:00 GMT 2009


Sarajyo Puli <psarajyo@yahoo.com> writes:

>   For targets based on Harvard architectures, it is possible that the program memory and data memory are
> two different memory systems, hence both of them could start/map at the same start address.
> But, if I set the start address of text and data segment in the linker script, linker errors out saying
> that both text and data section overlaps (while creating the final executable).
> Does anyone have an idea how to do this in the linker script for a cross linker?
> Or is it the job of the loader to do the right mapping?

The trick I've used in the past is to set high bits in the address in
the executable.  For example, if you have 16-bit addresses, put the text
segment from 0 to 0xffff and put the data segment from 0x10000 to
0x1ffff.  Change the relocation routines to do the right thing with such
addresses--give errors for invalid references and/or strip the high bit.
Write your loader to ignore the high bit, or if appropriate to use it to
decide where to load the segments.

Ian



More information about the Binutils mailing list