5 void *func[8], **pfunc;
7 typedef struct xxx xxx_t;
20 #define EXPORT_FUNC(x) \
22 " .globl mon_" #x "\n" \
25 " movl pfunc, %%ecx\n" \
26 " jmp *(%%ecx,%%eax)\n" \
27 : : "i"(XF_ ## x * sizeof(void *)) : "eax", "ecx");
28 #elif defined(__powerpc__)
29 #define EXPORT_FUNC(x) \
31 " .globl mon_" #x "\n" \
33 " lwz %%r11, %0(%%r2)\n" \
34 " lwz %%r11, %1(%%r11)\n" \
37 : : "i"(offsetof(xxx_t, pfunc)), "i"(XF_ ## x * sizeof(void *)) : "r11", "r2");
38 #elif defined(__arm__)
39 #define EXPORT_FUNC(x) \
41 " .globl mon_" #x "\n" \
43 " ldr ip, [r8, %0]\n" \
44 " ldr pc, [ip, %1]\n" \
45 : : "i"(offsetof(xxx_t, pfunc)), "i"(XF_ ## x * sizeof(void *)) : "ip");
46 #elif defined(__mips__)
47 #define EXPORT_FUNC(x) \
49 " .globl mon_" #x "\n" \
51 " lw $25, %0($26)\n" \
52 " lw $25, %1($25)\n" \
54 : : "i"(offsetof(xxx_t, pfunc)), "i"(XF_ ## x * sizeof(void *)) : "t9");
55 #elif defined(__nds32__)
56 #define EXPORT_FUNC(x) \
58 " .globl mon_" #x "\n" \
60 " lwi $r16, [$gp + (%0)]\n" \
61 " lwi $r16, [$r16 + (%1)]\n" \
63 : : "i"(offsetof(xxx_t, pfunc)), \
64 "i"(XF_ ## x * sizeof(void *)) : "$r16");
67 #error [No stub code for this arch]
80 #elif defined(__powerpc__)
81 register volatile xxx_t *pq asm("r2");
82 #elif defined(__arm__)
83 register volatile xxx_t *pq asm("r8");
84 #elif defined(__mips__)
85 register volatile xxx_t *pq asm("k0");
86 #elif defined(__nds32__)
87 register volatile xxx_t *pq asm("$r16");
91 func[XF_strcpy] = strcpy;
92 func[XF_printf] = printf;
94 pq->pfunc = pfunc = func;
96 mon_strcpy(buf, "test");
97 mon_printf("hi %s %d z\n", buf, 444);