This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to make section position independent?

Hello,
i work with uVision 3 V3.72, linker V3.1.0.942. i check in linker options make ro section postion independent and also use memory layout from the Target dialog.And duing linking shows warnign L6914W: option ropi ignored when using --scatter. My question is why? Why this warning has appeared?
Is there any other why to make section position independent?
thanks in advance

  • Position-independant code requires the memory addresses to be relative.

    A scatter file allows multiple memory areas to be specified.

    Position-independant code would not manage that you move one memory area but keeps the other fixed since that would change the relative distance.

    In the end, you will really have to think twice about your memory layout and use of global variables or pointers with hard-coded destination when working with position-independant code.

    Moving the code to a 4kB higher address may not mean that you want all variable references to also move to a 4kB higher address...

  • I believe this answer gives some information but i want to know how to make my position independent. i just want my program to work independently to any adress.i want the same program to work if i will load it to any area without making any changes to linker.

  • But you still did not give any information about whatyou consider "position independent". If the code moves to a 1kB higher address - what about global variables? Should they also move or stay fixed?

  • After a compilation appears a bin file. i want this bin file using a bootloader to put at any address. It must work properly if bootloader will put it at addres 0x100000 or at addres 0x110000.So the code must be position independent.

  • You wrote >>
    And duing linking shows warnign L6914W: option ropi ignored when using --scatter. My question is why? Why this warning has appeared?
    <<

    This warning indicates that you are passing both '--ropi' and '--scatter' to the linker. If you are passing --scatter (and a scatter file) then the --ropi option is not going to have any effect, which is why the linker is giving a warning.

    This is covered in the manual, which you might want to read: <http://www.keil.com/support/man/docs/armlinkref/armlinkref_chdechji.htm>

  • Well the problem is that i DO NOT pass both '--ropi' and '--scatter' to the linker. As i wrote above i checked: use memory layout from the Target dialog so i don't use any scatter file but in linker control string appears --scatter and there is no checkbox or something else which can let me to turn off scatter file. That is why i believe there is a mistake in uVision version which i use.
    Have you got any idea how turn off scatter file in my uVision version.

  • You must not activate "Use Memory Layout from Target Dialog", also the field "Scatter File" must be empty. As soon as you use one of them the --scatter control string will be addet because also the "Use Memory Layout from Target Dialog" is generating a scatter file with the values you entered on the target tab.