[Bug ld/23750] New: Linker does not support R_ARM_GOT_BREL with -fdpic
https://sourceware.org/bugzilla/show_bug.cgi?id=23750 Bug ID: 23750 Summary: Linker does not support R_ARM_GOT_BREL with -fdpic Product: binutils Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: d.rodionov at samsung dot com Target Milestone: --- Hello! What do I need: I have MMU-less ARM CPU with XIP (eXecution In Place). I need ELF file with .text and .plt sections into FLASH. It means that @plt entries must be _NOT_ pc-relative. commit a0c3048e3f397a595a14208e82e21399131f782b Author: Tom Tromey Date: Mon Oct 8 16:39:29 2018 -0600 I have configured binutils as follows (with default target=arm-linux-gnueabi): ./configure --enable-fdpic --enable-lto --enable-plugins --disable-werror CPPFLAGS=-UFORTIFY_SOURCE --disable-gdb --disable-sim --disable-libdecnumber --disable-readline --prefix=/home/rodionov/gnu/install/ --target=arm-none-eabi $make $make install I have test.c file: $ cat test.c extern void external_func(int a); volatile int global = 4; void test(void) { external_func(global); } Obtain object file: $ arm-none-eabi-gcc --version arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907] $ arm-none-eabi-gcc -fpic -c -mno-pic-data-is-text-relative test.c -o test.o Try to link: $ ./arm-none-eabi-ld --version GNU ld (GNU Binutils) 2.31.51.20181008 $ ./arm-none-eabi-ld -fdpic -shared -no-pic-data-is-text-relative test.o -o test.so But resulting @plt is pc-relative and cannot be used with XIP: 81d4 : 81d4: e28fc600add ip, pc, #0, 12 81d8: e28cca10add ip, ip, #16, 20 ; 0x1 81dc: e5bcf0d8ldr pc, [ip, #216]! ; 0xd8 I have found into code (binutils-gdb/bfd/elf32-arm.c) plt that I want: 2288 /* ARM FDPIC PLT entry. */ 2289 /* The last 5 words contain PLT lazy fragment code and data. */ 2290 static const bfd_vma elf32_arm_fdpic_plt_entry [] = 2291 { 2292 0xe59fc008,/* ldr r12, .L1 */ 2293 0xe08cc009,/* add r12, r12, r9 */ 2294 0xe59c9004,/* ldr r9, [r12, #4] */ 2295 0xe59cf000,/* ldr pc, [r12] */ 2296 0x,/* L1. .word foo(GOTOFFFUNCDESC) */ 2297 0x,/* L1. .word foo(funcdesc_value_reloc_offset) */ 2298 0xe51fc00c,/* ldr r12, [pc, #-12] */ 2299 0xe92d1000,/* push{r12} */ 2300 0xe599c004,/* ldr r12, [r9, #4] */ 2301 0xe599f000,/* ldr pc, [r9] */ 2302 }; So, as I can see, I need to reconfigure binutils with --target=arm-linux-uclinuxfdpiceabi to enable -m armelf_linux_fdpiceabi emulation and r9-relative @plt (as above) entry: ~$ ./configure --enable-fdpic --enable-lto --enable-plugins --disable-werror CPPFLAGS=-UFORTIFY_SOURCE --disable-gdb --disable-sim --disable-libdecnumber --disable-readline --prefix=/home/rodionov/gnu/install/ --target=arm-linux-uclinuxfdpiceabi Try to link object file with just built linker: ~$ ./arm-linux-uclinuxfdpiceabi-ld -fdpic -shared -m armelf_linux_fdpiceabi test.o -o test.so ./arm-linux-uclinuxfdpiceabi-ld: test.o: in function `test': test.c:(.text+0x18): dangerous relocation: unsupported relocation $ readelf -a test.o ... Relocation section '.rel.text' at offset 0x200 contains 2 entries: Offset InfoTypeSym.Value Sym. Name 000e 0d0a R_ARM_THM_CALL external_func 0018 0b1a R_ARM_GOT_BREL global ... As I can see, the second relocation causes the error: unsupported relocation. Could anyone help with this situation? Is there a bug into binutils or am I doing something wrong? Thanks. Dmitrii Rodionov -- You are receiving this mail because: You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/23750] Linker does not support R_ARM_GOT_BREL with -fdpic
https://sourceware.org/bugzilla/show_bug.cgi?id=23750 Dmitrii changed: What|Removed |Added CC||d.rodionov at samsung dot com -- You are receiving this mail because: You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/23750] Linker does not support R_ARM_GOT_BREL with -fdpic
https://sourceware.org/bugzilla/show_bug.cgi?id=23750 Christophe Lyon changed: What|Removed |Added CC||clyon at gcc dot gnu.org --- Comment #1 from Christophe Lyon --- I think you need to compile your C code with a compiler that targets arm-linux-uclinuxfdpiceabi too. Unfortunately, this is not available in GCC trunk yet, I am in the process of upstreaming the patches. In the FDPIC model, some of the relocations cannot be used. For more details on the ABI, you may want to read: https://github.com/mickael-guene/fdpic_doc -- You are receiving this mail because: You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/23750] Linker does not support R_ARM_GOT_BREL with -fdpic
https://sourceware.org/bugzilla/show_bug.cgi?id=23750 --- Comment #2 from Dmitrii --- Thanks! Can I get anywhere such unreleased patches/branch? -- You are receiving this mail because: You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
Linker does not support R_ARM_GOT_BREL with -fdpic
Hello! What do I need: I have MMU-less ARM CPU with XIP (eXecution In Place). I need ELF file with .text and .plt sections into FLASH. It means that @plt entries must be _NOT_ pc-relative. commit a0c3048e3f397a595a14208e82e21399131f782b Author: Tom Tromey Date: Mon Oct 8 16:39:29 2018 -0600 I have configured binutils as follows (with default target=arm-linux-gnueabi): ./configure --enable-fdpic --enable-lto --enable-plugins --disable-werror CPPFLAGS=-UFORTIFY_SOURCE --disable-gdb --disable-sim --disable-libdecnumber --disable-readline --prefix=/home/rodionov/gnu/install/ --target=arm-none-eabi $make $make install I have test.c file: $ cat test.c extern void external_func(int a); volatile int global = 4; void test(void) { external_func(global); } Obtain object file: $ arm-none-eabi-gcc --version arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907] $ arm-none-eabi-gcc -fpic -c -mno-pic-data-is-text-relative test.c -o test.o Try to link: $ ./arm-none-eabi-ld --version GNU ld (GNU Binutils) 2.31.51.20181008 $ ./arm-none-eabi-ld -fdpic -shared -no-pic-data-is-text-relative test.o -o test.so But resulting @plt is pc-relative and cannot be used with XIP: 81d4 : 81d4: e28fc600add ip, pc, #0, 12 81d8: e28cca10add ip, ip, #16, 20 ; 0x1 81dc: e5bcf0d8ldr pc, [ip, #216]! ; 0xd8 I have found into code (binutils-gdb/bfd/elf32-arm.c) plt that I want: 2288 /* ARM FDPIC PLT entry. */ 2289 /* The last 5 words contain PLT lazy fragment code and data. */ 2290 static const bfd_vma elf32_arm_fdpic_plt_entry [] = 2291 { 2292 0xe59fc008,/* ldr r12, .L1 */ 2293 0xe08cc009,/* add r12, r12, r9 */ 2294 0xe59c9004,/* ldr r9, [r12, #4] */ 2295 0xe59cf000,/* ldr pc, [r12] */ 2296 0x,/* L1. .word foo(GOTOFFFUNCDESC) */ 2297 0x,/* L1. .word foo(funcdesc_value_reloc_offset) */ 2298 0xe51fc00c,/* ldr r12, [pc, #-12] */ 2299 0xe92d1000,/* push{r12} */ 2300 0xe599c004,/* ldr r12, [r9, #4] */ 2301 0xe599f000,/* ldr pc, [r9] */ 2302 }; So, as I can see, I need to reconfigure binutils with --target=arm-linux-uclinuxfdpiceabi to enable -m armelf_linux_fdpiceabi emulation and r9-relative @plt (as above) entry: ~$ ./configure --enable-fdpic --enable-lto --enable-plugins --disable-werror CPPFLAGS=-UFORTIFY_SOURCE --disable-gdb --disable-sim --disable-libdecnumber --disable-readline --prefix=/home/rodionov/gnu/install/ --target=arm-linux-uclinuxfdpiceabi Try to link object file with just built linker: ~$ ./arm-linux-uclinuxfdpiceabi-ld -fdpic -shared -m armelf_linux_fdpiceabi test.o -o test.so ./arm-linux-uclinuxfdpiceabi-ld: test.o: in function `test': test.c:(.text+0x18): dangerous relocation: unsupported relocation $ readelf -a test.o ... Relocation section '.rel.text' at offset 0x200 contains 2 entries: Offset InfoTypeSym.Value Sym. Name 000e 0d0a R_ARM_THM_CALL external_func 0018 0b1a R_ARM_GOT_BREL global ... As I can see, the second relocation causes the error: unsupported relocation. Could anyone help with this situation? Is there a bug into binutils or am I doing something wrong? Thanks. Dmitrii Rodionov ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/23750] Linker does not support R_ARM_GOT_BREL with -fdpic
https://sourceware.org/bugzilla/show_bug.cgi?id=23750 --- Comment #3 from Christophe Lyon --- The most recent version of the GCC patches I posted are: https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00707.html -- You are receiving this mail because: You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/23043] --push-state / --pop-state should be implemented as a true stack in ld.bfd
https://sourceware.org/bugzilla/show_bug.cgi?id=23043 Alan Modra changed: What|Removed |Added Status|NEW |RESOLVED CC||amodra at gmail dot com Resolution|--- |INVALID --- Comment #1 from Alan Modra --- More than one nested --push-state is supported. It's been like that from the intitial commit supporting --push-state. -- You are receiving this mail because: You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils