Fix ifunc on x86_64 x32
PATCH 1/1 Fix ifunc on x86_64 x32
Hi Mark,
The ifunc1, ifunc2, and ifunc3 tests currently fail on x86_64 x32 ABI because the testcase crashes at runtime. The testcases run fine when not prelinked.
In the case of ifunc1, the test tries to call the "lib2t2" function directly, instead of using it as an indirect call, which leads to the testcase aborting. In real code this would not cause an immediate crash, but presumably would lead to undefined behaviour.
The attached patch fixes the problem by converting R_X86_64_32 conflict relocations to R_X86_64_IRELATIVE (in the same way as R_X86_64_64 relocations are).
I've tested this with the cross_prelink branch and a suitably configured cross-toolchain. I expect it would be fine on the master branch also, but I can't test that.
Andrew Stubbs
Mentor Graphics/CodeSourcery
2016-12-09 Andrew Stubbs <[email protected]>
* src/arch-x86_64.c (x86_64_prelink_conflict_rela): Also convert R_X86_64_32 conflicts to R_X86_64_IRELATIVE for ifuncs. --- src/arch-x86_64.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
src/arch-x86_64.c +1 -4
@@ -332,16 +332,13 @@ x86_64_prelink_conflict_rela (DSO *dso, struct prelink_info *info, ret->r_info =GELF_R_INFO (0 , (gelf_getclass (dso->elf) ==ELFCLASS32 ?R_X86_64_32 :R_X86_64_64 ));/* FALLTHROUGH */ case R_X86_64_JUMP_SLOT : +case R_X86_64_32 :case R_X86_64_64 :case R_X86_64_IRELATIVE : ret->r_addend = value + rela->r_addend;if (conflict !=NULL && conflict->ifunc) ret->r_info =GELF_R_INFO (0 ,R_X86_64_IRELATIVE );break ; -case R_X86_64_32 : - value += rela->r_addend; - ret->r_addend = value; -break ;case R_X86_64_PC32 : ret->r_addend = value + rela->r_addend - rela->r_offset; ret->r_info =GELF_R_INFO (0 ,R_X86_64_32 );
Signature · 1 line
2.8.1
Thanks. I try to get this merged soon.
--Mark
Quoted 22 lines · Andrew Stubbs
Hi Mark,
The ifunc1, ifunc2, and ifunc3 tests currently fail on
x86_64x32 ABI because the testcase crashes at runtime. The testcases run fine when not prelinked.In the case of ifunc1, the test tries to call the "lib2t2" function directly, instead of using it as an indirect call, which leads to the testcase aborting. In real code this would not cause an immediate crash, but presumably would lead to undefined behaviour.
The attached patch fixes the problem by converting
R_X86_64_32conflict relocations toR_X86_64_IRELATIVE(in the same way asR_X86_64_64relocations are).I've tested this with the
cross_prelinkbranch and a suitably configured cross-toolchain. I expect it would be fine on the master branch also, but I can't test that.Andrew Stubbs
Mentor Graphics/CodeSourcery