-mno-pic-data-is-text-relative does not create correct plt code

Asked by Marco

I try to set up a customized dynamic linker on an embedded system on an cortex-m4.
-mno-pic-data-is-text-relative -msingle-pic-base -mpic-register=r9
result in code using r9 located .got as expected.
However the generated plt code still uses pc relative addressing to the .got This can not work since data and text are not relative.

000002d0 <exfunc@plt>:
 2d0: f240 1c3c movw ip, #316 ; 0x13c
 2d4: f2c0 0c01 movt ip, #1
 2d8: 44fc add ip, pc
 2da: f8dc f000 ldr.w pc, [ip]
 2de: bf00 nop

When calling my sample function it jumps to the exfunc plt code above.
extern int exfunc(void);

there the offset 0x1013C is loaded to the ip and added to the pc to reference to the .got entry for exfunc() that is found at
 (0x1013C + 4 + 0x2d8) = 0x10418 , wich is the got entry for exfunc that is listed as expected for relocation

Relocation section '.rel.plt' at offset 0x2b8 contains 1 entries:
 Offset Info Type Sym.Value Sym. Name
00010418 00000616 R_ARM_JUMP_SLOT 00000000 exfunc

I did not find any option to change this behaviour, so I concluded that this is a bug or why is the plt code not using the r9 for locating the GOT? Or did I miss something else?
Currently I see only the possibility to creat a workaround that exchanges the generated plt code.

Similar this applies to the PLT common first call code that uses a value at 0x2cc to locate the GOT.
000002c0 <exfunc@plt-0x10>:
 2c0: b500 push {lr}
 2c2: f8df e008 ldr.w lr, [pc, #8] ; 2cc <exfunc@plt-0x4>
 2c6: 44fe add lr, pc
 2c8: f85e ff08 ldr.w pc, [lr, #8]!
 2cc: 00010140 .word 0x00010140

Question information

English Edit question
GNU Arm Embedded Toolchain Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :

This question was expired because it remained in the 'Open' state without activity for the last 15 days.