From 0e87343e204b44468ffad0ec5dc8c8d6068f1227 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 23 Jan 2015 11:16:49 -0500 Subject: powerpc: Fix ifuncmain6pie failure with GCC 4.9 This patch fix the elf/ifuncmain6pie failure when building with GCC 4.9+. For some reason, the compiler removes the branch taken code at resolve_ifunc (sysdeps/powerpc/powerpc64/dl-machine.h) as dead-code and thus the testcase fails because the ifunc resolves branches to an invalid memory location. It fixes by explicit adding a dependency of value based on odp variable to avoid compiler optimization. It fixes BZ#17868. --- sysdeps/powerpc/powerpc64/dl-machine.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sysdeps/powerpc/powerpc64') diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h index 944871223f..47bb5a7cb7 100644 --- a/sysdeps/powerpc/powerpc64/dl-machine.h +++ b/sysdeps/powerpc/powerpc64/dl-machine.h @@ -623,7 +623,9 @@ resolve_ifunc (Elf64_Addr value, opd.fd_func = func->fd_func + sym_map->l_addr; opd.fd_toc = func->fd_toc + sym_map->l_addr; opd.fd_aux = func->fd_aux; - value = (Elf64_Addr) &opd; + /* GCC 4.9+ eliminates the branch as dead code, force the odp set + dependency. */ + asm ("" : "=r" (value) : "0" (&opd), "X" (opd)); } #endif #endif -- cgit 1.4.1