Created attachment 8849 [details] test case [forwarded from https://bugs.debian.org/807974] When the glibc is build with binutils from the 2.26 branch 20151209 on arm-linux-gnueabi*, all the IFUNC tests end up in a segmentation fault. test case from glibc attached.
On 16/12/15 13:31, doko at debian dot org wrote: > https://sourceware.org/bugzilla/show_bug.cgi?id=19368 > > Matthias Klose <doko at debian dot org> changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |ramana at sourceware dot org > Jiong, can you please look into this ?
(In reply to ramana.radhakrishnan from comment #1) > On 16/12/15 13:31, doko at debian dot org wrote: > > https://sourceware.org/bugzilla/show_bug.cgi?id=19368 > > > > Matthias Klose <doko at debian dot org> changed: > > > > What |Removed |Added > > ---------------------------------------------------------------------------- > > CC| |ramana at sourceware dot org > > > > Jiong, can you please look into this ? OK, let me check.
This is caused by the following commit which turn on elf_backend_extern_protected_data. commit b68a20d6675f1360ea4db50a9835c073675b9889 Author: Szabolcs Nagy <szabolcs.nagy@arm.com> Date: Mon Jul 27 11:45:27 2015 +0100 [ARM] Fix extern protected data handling after this change we are turning on PC relocative relocation to absolute relocation, and thus the following relocation entries change: --- dump.a.right 2015-12-16 16:13:01.797125100 +0000 +++ dump.a.wrong 2015-12-16 16:10:06.045693098 +0000 Relocation section '.rel.dyn' at offset 0x4e4 contains 16 entries: Offset Info Type Sym. Value Symbol's Name ... -00011030 00000017 R_ARM_RELATIVE 0001104c 00000017 R_ARM_RELATIVE 00011018 000000a0 R_ARM_IRELATIVE 0001101c 000000a0 R_ARM_IRELATIVE @@ -115,6 +114,7 @@ 00011024 00000415 R_ARM_GLOB_DAT 00000000 __cxa_finalize 00011028 00000515 R_ARM_GLOB_DAT 00000000 _ITM_registerTMCloneTable 0001102c 00000615 R_ARM_GLOB_DAT 00000000 ret_foo +00011030 00001315 R_ARM_GLOB_DAT 00011050 global ... These runtime relocation types change looks ok to me, but their runtime resolve order will cause problem for ifunc resolver. You can see "global" is turned from RELATIVE which is resolved before IRELATIVE, into GLOBA_DAT which will be resolved after the IRELATIVE, while "global" is referenced in the ifunc function, so that ifunc function will get uninitialized address zero, then trigger segment fault. I think ARM backend need the similar fix from: https://sourceware.org/bugzilla/show_bug.cgi?id=13302 we need to make sure IRELATIVE relocation happen last.
mark as duplicate of 13302 *** This bug has been marked as a duplicate of bug 13302 ***
Looks to me ARM target has two issues on IFUNC support. 1 Sometimes STT_GNU_IFUNC symbols haven't gone through PLT. We force STT_GNU_IFUNC to go through PLT to workaround the relocation order issue by utilizing lazy relocation. This is the issue caused the segment fault in this PR. 2 IRELATIVE should be put in the last in .rel.plt. This is a further improvement we should done after issue 1 addressed. Simliar improvement has been done on x86 by PR13302. To fix this PR, we need to fix issue 1 first. So this PR is not purely a duplicate of PR13302 which only caused by issue 2.
Fix proposed at https://sourceware.org/ml/binutils/2016-01/msg00009.html It turns out that ARM IFUNC implementaion is following PowerPC approach and we are missing the relocation type class for ARM_IRELATIVE. After add the mapping, the generic code should sort IRELATIVE to the last of .rel.dyn, and I can confirm the failure gone aways after the fix.
The master branch has been updated by Jiong Wang <jiwang@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=109575d7ebac21a0eb67980001ecd4173d696f88 commit 109575d7ebac21a0eb67980001ecd4173d696f88 Author: Jiong Wang <jiong.wang@arm.com> Date: Fri Jan 8 09:47:24 2016 +0000 [ARM] PR ld/19368: Add missing relocation type class for R_ARM_IRELATIVE 2016-01-08 Richard Sandiford <richard.sandiford@arm.com> Jiong Wang <jiong.wang@arm.com> PR ld/19368 bfd/ * elf32-arm.c (elf32_arm_reloc_type_class): Map R_ARM_IRELATIVE to reloc_class_ifunc. ld/ * testsuite/ld-arm/ifunc-3.rd: Update expected result. * testsuite/ld-arm/ifunc-4.rd: Likewise. * testsuite/ld-arm/ifunc-9.rd: Likewise. * testsuite/ld-arm/ifunc-10.rd: Likewise. * testsuite/ld-arm/ifunc-12.rd: Likewise. * testsuite/ld-arm/ifunc-13.rd: Likewise.
fixed on master.
The binutils-2_26-branch branch has been updated by Jiong Wang <jiwang@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e48a6a3c4a4ae7a343dd54348d37bf9e0f246735 commit e48a6a3c4a4ae7a343dd54348d37bf9e0f246735 Author: Jiong Wang <jiong.wang@arm.com> Date: Mon Jan 11 10:49:57 2016 +0000 [BACKPORT][ARM] PR ld/19368: Add missing relocation type class for R_ARM_IRELATIVE Apply from master 2016-01-08 Richard Sandiford <richard.sandiford@arm.com> Jiong Wang <jiong.wang@arm.com> bfd/ PR ld/19368 * elf32-arm.c (elf32_arm_reloc_type_class): Map R_ARM_IRELATIVE to reloc_class_ifunc. ld/testsuite/ * testsuite/ld-arm/ifunc-3.rd: Update expected result. * testsuite/ld-arm/ifunc-4.rd: Likewise. * testsuite/ld-arm/ifunc-9.rd: Likewise. * testsuite/ld-arm/ifunc-10.rd: Likewise. * testsuite/ld-arm/ifunc-12.rd: Likewise. * testsuite/ld-arm/ifunc-13.rd: Likewise.