UPDATE
I have made some progress and can copy and jump to the new bootloader in the app space, but found the encountered the following problem:
Before the programm enters the new main function, in the new system startup code, this happens
256c(656c): 1fffcbb0 .word 0x1fffcbb0 is in a register at some point, and then
the PC value is added, then the program branches to the resulting adressvalue.
The problem is probably, that normally, 0x1fffcbb0+ 0x2b47 is an ok adress, but 0x1fffcbb0+ 0x6b47 is > 0x20000000, which is not an ok adress in this context anymore.
When the program uses the PC value to calculate jump adresses, it's fine if it happens only in the flash adress context, but it can result in problems, if this method is also used to create jump adresses in the SRAM adress space. Because in flash space, everything moves, but the SRAM adresses stay the same, yet the program uses the modified PC (which is 0x4000) bigger than expected.
EDIT: More exactly: ldr r2, [r3, r2] causes the problem, because r3+r2 is no valid adress anymore, so the program complains if I want to dereference this.
Can I somehow let the program compile in a way, that the code is position independent for flash space and not independent (not using the pc) for other spaces (SRAM, Peripherals, etc.)?
Thanks for any pointers,
Michael