Shop OBEX P1 Docs P2 Docs Learn Events
Just another image base address — Parallax Forums

Just another image base address

d2rkd2rk Posts: 31
edited 2012-02-17 11:14 in Propeller 1
Hi,

How can I change image base address which is by default is 0? I do not want to relocate all the segments, but to have something like PIC (position-independent code) does. The purpose of this to place the image anywhere on Hub RAM.

Comments

  • ersmithersmith Posts: 6,099
    edited 2012-02-15 13:42
    d2rk wrote: »
    Hi,

    How can I change image base address which is by default is 0? I do not want to relocate all the segments, but to have something like PIC does. The purpose of this to place the image anywhere on Hub RAM.

    I think you would have to write a custom linker script to change the base address. All subroutine addresses and most jump addresses are assigned by the linker. They cannot be changed at run time.

    Eric
  • d2rkd2rk Posts: 31
    edited 2012-02-16 06:57
    Yes, I know that this can not be changed at run time, thus I would like to have some opportunity to have an option to provide the base address or to have relocatable image.
  • Heater.Heater. Posts: 21,230
    edited 2012-02-17 00:09
    What does the PIC (Position independent code) option do in this compiler?
    PIC is normally used when building dynamic library code that could be loaded to and run from any address.
    Don't think it helps with moving data around, only functions.
  • d2rkd2rk Posts: 31
    edited 2012-02-17 01:28
    propgcc doesn't support PIC on this moment. I thought to use it in order to relocate the image. But I'm open for any other fastest ways to do this.
  • ersmithersmith Posts: 6,099
    edited 2012-02-17 05:28
    Using the GNU linker script option is probably the best idea. You could start with one of the default ones, e.g. the one in propeller-elf/lib/ldscripts/propeller.x, and change the hub address start from 0 (adjusting the size appropriately, of course).

    If you don't want to write a linker script, you could give the command line option -Ttext=0xnnnn instead; that will relocate the text section and all the sections that depend on it to a different address. Unfortunately there are a few additional sections (like the .init section) which will not be relocated this way, and the --section-start directive does not seem to be working.

    Another option would be to create a relocatable output (with -r) and write an elf file relocation program. That would be a lot of work :-(.

    Eric
  • d2rkd2rk Posts: 31
    edited 2012-02-17 11:14
    Thanks for the options. I was right about to finish linker script and took a look on boot section. The part of execution of LMM kernel, which goes first, has also be relocated, however it has been written in bytecode (see spinboot.s) with fixed addresses (see Booting and Cog selection).
Sign In or Register to comment.