Blame sysdeps/powerpc/ifunc-sel.h
|
Packit Service |
82fcde |
/* Used by the elf ifunc tests. */
|
|
Packit Service |
82fcde |
#ifndef ELF_IFUNC_SEL_H
|
|
Packit Service |
82fcde |
#define ELF_IFUNC_SEL_H 1
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
extern int global;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static inline __attribute__ ((always_inline)) void *
|
|
Packit Service |
82fcde |
inhibit_stack_protector
|
|
Packit Service |
82fcde |
ifunc_sel (int (*f1) (void), int (*f2) (void), int (*f3) (void))
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
register void *ret __asm__ ("r3");
|
|
Packit Service |
82fcde |
__asm__ ("mflr 12\n\t"
|
|
Packit Service |
82fcde |
"bcl 20,31,1f\n"
|
|
Packit Service |
82fcde |
"1:\tmflr 11\n\t"
|
|
Packit Service |
82fcde |
"mtlr 12\n\t"
|
|
Packit Service |
82fcde |
"addis 12,11,global-1b@ha\n\t"
|
|
Packit Service |
82fcde |
"lwz 12,global-1b@l(12)\n\t"
|
|
Packit Service |
82fcde |
"addis %0,11,%2-1b@ha\n\t"
|
|
Packit Service |
82fcde |
"addi %0,%0,%2-1b@l\n\t"
|
|
Packit Service |
82fcde |
"cmpwi 12,1\n\t"
|
|
Packit Service |
82fcde |
"beq 2f\n\t"
|
|
Packit Service |
82fcde |
"addis %0,11,%3-1b@ha\n\t"
|
|
Packit Service |
82fcde |
"addi %0,%0,%3-1b@l\n\t"
|
|
Packit Service |
82fcde |
"cmpwi 12,-1\n\t"
|
|
Packit Service |
82fcde |
"beq 2f\n\t"
|
|
Packit Service |
82fcde |
"addis %0,11,%4-1b@ha\n\t"
|
|
Packit Service |
82fcde |
"addi %0,%0,%4-1b@l\n\t"
|
|
Packit Service |
82fcde |
"2:"
|
|
Packit Service |
82fcde |
: "=r" (ret)
|
|
Packit Service |
82fcde |
: "i" (&global), "i" (f1), "i" (f2), "i" (f3)
|
|
Packit Service |
82fcde |
: "11", "12", "cr0");
|
|
Packit Service |
82fcde |
return ret;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static inline __attribute__ ((always_inline)) void *
|
|
Packit Service |
82fcde |
inhibit_stack_protector
|
|
Packit Service |
82fcde |
ifunc_one (int (*f1) (void))
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
register void *ret __asm__ ("r3");
|
|
Packit Service |
82fcde |
__asm__ ("mflr 12\n\t"
|
|
Packit Service |
82fcde |
"bcl 20,31,1f\n"
|
|
Packit Service |
82fcde |
"1:\tmflr %0\n\t"
|
|
Packit Service |
82fcde |
"mtlr 12\n\t"
|
|
Packit Service |
82fcde |
"addis %0,%0,%1-1b@ha\n\t"
|
|
Packit Service |
82fcde |
"addi %0,%0,%1-1b@l"
|
|
Packit Service |
82fcde |
: "=r" (ret)
|
|
Packit Service |
82fcde |
: "i" (f1)
|
|
Packit Service |
82fcde |
: "12");
|
|
Packit Service |
82fcde |
return ret;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
#endif
|