2 * X86 code generator for TCC
4 * Copyright (c) 2001-2004 Fabrice Bellard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /* number of available registers */
24 /* a register can belong to several classes. The classes must be
25 sorted from more general to more precise (see gv2() code which does
26 assumptions on it). */
27 #define RC_INT 0x0001 /* generic integer register */
28 #define RC_FLOAT 0x0002 /* generic float register */
33 #define RC_IRET RC_EAX /* function return: integer register */
34 #define RC_LRET RC_EDX /* function return: second integer register */
35 #define RC_FRET RC_ST0 /* function return: float register */
37 /* pretty names for the registers */
45 const int reg_classes
[NB_REGS
] = {
46 /* eax */ RC_INT
| RC_EAX
,
47 /* ecx */ RC_INT
| RC_ECX
,
48 /* edx */ RC_INT
| RC_EDX
,
49 /* st0 */ RC_FLOAT
| RC_ST0
,
52 /* return registers for function */
53 #define REG_IRET TREG_EAX /* single word int return register */
54 #define REG_LRET TREG_EDX /* second word return register (for long long) */
55 #define REG_FRET TREG_ST0 /* float return register */
57 /* defined if function parameters must be evaluated in reverse order */
58 #define INVERT_FUNC_PARAMS
60 /* defined if structures are passed as pointers. Otherwise structures
61 are directly pushed on stack. */
62 //#define FUNC_STRUCT_PARAM_AS_PTR
64 /* pointer size, in bytes */
67 /* long double size and alignment, in bytes */
68 #define LDOUBLE_SIZE 12
69 #define LDOUBLE_ALIGN 4
70 /* maximum alignment (for aligned attribute support) */
73 /******************************************************/
76 #define EM_TCC_TARGET EM_386
78 /* relocation type for 32 bit data relocation */
79 #define R_DATA_32 R_386_32
80 #define R_DATA_PTR R_386_32
81 #define R_JMP_SLOT R_386_JMP_SLOT
82 #define R_COPY R_386_COPY
84 #define ELF_START_ADDR 0x08048000
85 #define ELF_PAGE_SIZE 0x1000
87 /******************************************************/
89 static unsigned long func_sub_sp_offset
;
90 static unsigned long func_bound_offset
;
91 static int func_ret_sub
;
93 /* XXX: make it faster ? */
98 if (ind1
> cur_text_section
->data_allocated
)
99 section_realloc(cur_text_section
, ind1
);
100 cur_text_section
->data
[ind
] = c
;
104 void o(unsigned int c
)
126 /* output a symbol and patch all calls to it */
127 void gsym_addr(int t
, int a
)
131 ptr
= (int *)(cur_text_section
->data
+ t
);
132 n
= *ptr
; /* next value */
143 /* psym is used to put an instruction with a data field which is a
144 reference to a symbol. It is in fact the same as oad ! */
147 /* instruction + 4 bytes data. Return the address of the data */
148 static int oad(int c
, int s
)
154 if (ind1
> cur_text_section
->data_allocated
)
155 section_realloc(cur_text_section
, ind1
);
156 *(int *)(cur_text_section
->data
+ ind
) = s
;
162 /* output constant with relocation if 'r & VT_SYM' is true */
163 static void gen_addr32(int r
, Sym
*sym
, int c
)
166 greloc(cur_text_section
, sym
, ind
, R_386_32
);
170 static void gen_addrpc32(int r
, Sym
*sym
, int c
)
173 greloc(cur_text_section
, sym
, ind
, R_386_PC32
);
177 /* generate a modrm reference. 'op_reg' contains the addtionnal 3
179 static void gen_modrm(int op_reg
, int r
, Sym
*sym
, int c
)
181 op_reg
= op_reg
<< 3;
182 if ((r
& VT_VALMASK
) == VT_CONST
) {
183 /* constant memory reference */
185 gen_addr32(r
, sym
, c
);
186 } else if ((r
& VT_VALMASK
) == VT_LOCAL
) {
187 /* currently, we use only ebp as base */
189 /* short reference */
193 oad(0x85 | op_reg
, c
);
196 g(0x00 | op_reg
| (r
& VT_VALMASK
));
200 /* load 'r' from value 'sv' */
201 void load(int r
, SValue
*sv
)
203 int v
, t
, ft
, fc
, fr
;
207 if (pe_dllimport(r
, sv
, load
))
216 if (v
== VT_LLOCAL
) {
218 v1
.r
= VT_LOCAL
| VT_LVAL
;
223 if ((ft
& VT_BTYPE
) == VT_FLOAT
) {
226 } else if ((ft
& VT_BTYPE
) == VT_DOUBLE
) {
229 } else if ((ft
& VT_BTYPE
) == VT_LDOUBLE
) {
232 } else if ((ft
& VT_TYPE
) == VT_BYTE
) {
233 o(0xbe0f); /* movsbl */
234 } else if ((ft
& VT_TYPE
) == (VT_BYTE
| VT_UNSIGNED
)) {
235 o(0xb60f); /* movzbl */
236 } else if ((ft
& VT_TYPE
) == VT_SHORT
) {
237 o(0xbf0f); /* movswl */
238 } else if ((ft
& VT_TYPE
) == (VT_SHORT
| VT_UNSIGNED
)) {
239 o(0xb70f); /* movzwl */
243 gen_modrm(r
, fr
, sv
->sym
, fc
);
246 o(0xb8 + r
); /* mov $xx, r */
247 gen_addr32(fr
, sv
->sym
, fc
);
248 } else if (v
== VT_LOCAL
) {
249 o(0x8d); /* lea xxx(%ebp), r */
250 gen_modrm(r
, VT_LOCAL
, sv
->sym
, fc
);
251 } else if (v
== VT_CMP
) {
252 oad(0xb8 + r
, 0); /* mov $0, r */
253 o(0x0f); /* setxx %br */
256 } else if (v
== VT_JMP
|| v
== VT_JMPI
) {
258 oad(0xb8 + r
, t
); /* mov $1, r */
259 o(0x05eb); /* jmp after */
261 oad(0xb8 + r
, t
^ 1); /* mov $0, r */
264 o(0xc0 + r
+ v
* 8); /* mov v, r */
269 /* store register 'r' in lvalue 'v' */
270 void store(int r
, SValue
*v
)
275 if (pe_dllimport(r
, v
, store
))
280 fr
= v
->r
& VT_VALMASK
;
282 /* XXX: incorrect if float reg to reg */
283 if (bt
== VT_FLOAT
) {
286 } else if (bt
== VT_DOUBLE
) {
289 } else if (bt
== VT_LDOUBLE
) {
290 o(0xc0d9); /* fld %st(0) */
296 if (bt
== VT_BYTE
|| bt
== VT_BOOL
)
301 if (fr
== VT_CONST
||
304 gen_modrm(r
, v
->r
, v
->sym
, fc
);
305 } else if (fr
!= r
) {
306 o(0xc0 + fr
+ r
* 8); /* mov r, fr */
310 static void gadd_sp(int val
)
312 if (val
== (char)val
) {
316 oad(0xc481, val
); /* add $xxx, %esp */
320 /* 'is_jmp' is '1' if it is a jump */
321 static void gcall_or_jmp(int is_jmp
)
324 if ((vtop
->r
& (VT_VALMASK
| VT_LVAL
)) == VT_CONST
) {
326 if (vtop
->r
& VT_SYM
) {
327 /* relocation case */
328 greloc(cur_text_section
, vtop
->sym
,
329 ind
+ 1, R_386_PC32
);
331 /* put an empty PC32 relocation */
332 put_elf_reloc(symtab_section
, cur_text_section
,
333 ind
+ 1, R_386_PC32
, 0);
335 oad(0xe8 + is_jmp
, vtop
->c
.ul
- 4); /* call/jmp im */
337 /* otherwise, indirect call */
339 o(0xff); /* call/jmp *r */
340 o(0xd0 + r
+ (is_jmp
<< 4));
344 static uint8_t fastcall_regs
[3] = { TREG_EAX
, TREG_EDX
, TREG_ECX
};
345 static uint8_t fastcallw_regs
[2] = { TREG_ECX
, TREG_EDX
};
347 /* Generate function call. The function address is pushed first, then
348 all the parameters in call order. This functions pops all the
349 parameters and the function address. */
350 void gfunc_call(int nb_args
)
352 int size
, align
, r
, args_size
, i
, func_call
;
356 for(i
= 0;i
< nb_args
; i
++) {
357 if ((vtop
->type
.t
& VT_BTYPE
) == VT_STRUCT
) {
358 size
= type_size(&vtop
->type
, &align
);
359 /* align to stack align size */
360 size
= (size
+ 3) & ~3;
361 /* allocate the necessary size on stack */
362 oad(0xec81, size
); /* sub $xxx, %esp */
363 /* generate structure store */
365 o(0x89); /* mov %esp, r */
367 vset(&vtop
->type
, r
| VT_LVAL
, 0);
371 } else if (is_float(vtop
->type
.t
)) {
372 gv(RC_FLOAT
); /* only one float register */
373 if ((vtop
->type
.t
& VT_BTYPE
) == VT_FLOAT
)
375 else if ((vtop
->type
.t
& VT_BTYPE
) == VT_DOUBLE
)
379 oad(0xec81, size
); /* sub $xxx, %esp */
383 o(0x5cd9 + size
- 4); /* fstp[s|l] 0(%esp) */
388 /* simple type (currently always same size) */
389 /* XXX: implicit cast ? */
391 if ((vtop
->type
.t
& VT_BTYPE
) == VT_LLONG
) {
393 o(0x50 + vtop
->r2
); /* push r */
397 o(0x50 + r
); /* push r */
402 save_regs(0); /* save used temporary registers */
403 func_sym
= vtop
->type
.ref
;
404 func_call
= FUNC_CALL(func_sym
->r
);
406 if ((func_call
>= FUNC_FASTCALL1
&& func_call
<= FUNC_FASTCALL3
) ||
407 func_call
== FUNC_FASTCALLW
) {
408 int fastcall_nb_regs
;
409 uint8_t *fastcall_regs_ptr
;
410 if (func_call
== FUNC_FASTCALLW
) {
411 fastcall_regs_ptr
= fastcallw_regs
;
412 fastcall_nb_regs
= 2;
414 fastcall_regs_ptr
= fastcall_regs
;
415 fastcall_nb_regs
= func_call
- FUNC_FASTCALL1
+ 1;
417 for(i
= 0;i
< fastcall_nb_regs
; i
++) {
420 o(0x58 + fastcall_regs_ptr
[i
]); /* pop r */
421 /* XXX: incorrect for struct/floats */
428 if ((func_sym
->type
.t
& VT_BTYPE
) == VT_STRUCT
)
431 if (args_size
&& func_call
!= FUNC_STDCALL
)
437 #define FUNC_PROLOG_SIZE 10
439 #define FUNC_PROLOG_SIZE 9
442 /* generate function prolog of type 't' */
443 void gfunc_prolog(CType
*func_type
)
445 int addr
, align
, size
, func_call
, fastcall_nb_regs
;
446 int param_index
, param_addr
;
447 uint8_t *fastcall_regs_ptr
;
451 sym
= func_type
->ref
;
452 func_call
= FUNC_CALL(sym
->r
);
457 if (func_call
>= FUNC_FASTCALL1
&& func_call
<= FUNC_FASTCALL3
) {
458 fastcall_nb_regs
= func_call
- FUNC_FASTCALL1
+ 1;
459 fastcall_regs_ptr
= fastcall_regs
;
460 } else if (func_call
== FUNC_FASTCALLW
) {
461 fastcall_nb_regs
= 2;
462 fastcall_regs_ptr
= fastcallw_regs
;
464 fastcall_nb_regs
= 0;
465 fastcall_regs_ptr
= NULL
;
469 ind
+= FUNC_PROLOG_SIZE
;
470 func_sub_sp_offset
= ind
;
471 /* if the function returns a structure, then add an
472 implicit pointer parameter */
474 if ((func_vt
.t
& VT_BTYPE
) == VT_STRUCT
) {
475 /* XXX: fastcall case ? */
480 /* define parameters */
481 while ((sym
= sym
->next
) != NULL
) {
483 size
= type_size(type
, &align
);
484 size
= (size
+ 3) & ~3;
485 #ifdef FUNC_STRUCT_PARAM_AS_PTR
486 /* structs are passed as pointer */
487 if ((type
->t
& VT_BTYPE
) == VT_STRUCT
) {
491 if (param_index
< fastcall_nb_regs
) {
492 /* save FASTCALL register */
495 gen_modrm(fastcall_regs_ptr
[param_index
], VT_LOCAL
, NULL
, loc
);
501 sym_push(sym
->v
& ~SYM_FIELD
, type
,
502 VT_LOCAL
| lvalue_type(type
->t
), param_addr
);
506 /* pascal type call ? */
507 if (func_call
== FUNC_STDCALL
)
508 func_ret_sub
= addr
- 8;
514 /* leave some room for bound checking code */
515 if (tcc_state
->do_bounds_check
) {
516 oad(0xb8, 0); /* lbound section pointer */
517 oad(0xb8, 0); /* call to function */
518 func_bound_offset
= lbounds_section
->data_offset
;
522 /* generate function epilog */
523 void gfunc_epilog(void)
527 #ifdef CONFIG_TCC_BCHECK
528 if (tcc_state
->do_bounds_check
529 && func_bound_offset
!= lbounds_section
->data_offset
) {
533 /* add end of table info */
534 bounds_ptr
= section_ptr_add(lbounds_section
, sizeof(int));
536 /* generate bound local allocation */
538 ind
= func_sub_sp_offset
;
539 sym_data
= get_sym_ref(&char_pointer_type
, lbounds_section
,
540 func_bound_offset
, lbounds_section
->data_offset
);
541 greloc(cur_text_section
, sym_data
,
543 oad(0xb8, 0); /* mov %eax, xxx */
544 sym
= external_global_sym(TOK___bound_local_new
, &func_old_type
, 0);
545 greloc(cur_text_section
, sym
,
546 ind
+ 1, R_386_PC32
);
549 /* generate bound check local freeing */
550 o(0x5250); /* save returned value, if any */
551 greloc(cur_text_section
, sym_data
,
553 oad(0xb8, 0); /* mov %eax, xxx */
554 sym
= external_global_sym(TOK___bound_local_delete
, &func_old_type
, 0);
555 greloc(cur_text_section
, sym
,
556 ind
+ 1, R_386_PC32
);
558 o(0x585a); /* restore returned value, if any */
562 if (func_ret_sub
== 0) {
567 g(func_ret_sub
>> 8);
569 /* align local size to word & save local variables */
573 ind
= func_sub_sp_offset
- FUNC_PROLOG_SIZE
;
576 Sym
*sym
= external_global_sym(TOK___chkstk
, &func_old_type
, 0);
577 oad(0xb8, v
); /* mov stacksize, %eax */
578 oad(0xe8, -4); /* call __chkstk, (does the stackframe too) */
579 greloc(cur_text_section
, sym
, ind
-4, R_386_PC32
);
583 o(0xe58955); /* push %ebp, mov %esp, %ebp */
584 o(0xec81); /* sub esp, stacksize */
586 #if FUNC_PROLOG_SIZE == 10
587 o(0x90); /* adjust to FUNC_PROLOG_SIZE */
593 /* generate a jump to a label */
596 return psym(0xe9, t
);
599 /* generate a jump to a fixed address */
600 void gjmp_addr(int a
)
608 oad(0xe9, a
- ind
- 5);
612 /* generate a test. set 'inv' to invert test. Stack entry is popped */
613 int gtst(int inv
, int t
)
617 v
= vtop
->r
& VT_VALMASK
;
619 /* fast case : can jump directly since flags are set */
621 t
= psym((vtop
->c
.i
- 16) ^ inv
, t
);
622 } else if (v
== VT_JMP
|| v
== VT_JMPI
) {
623 /* && or || optimization */
624 if ((v
& 1) == inv
) {
625 /* insert vtop->c jump list in t */
628 p
= (int *)(cur_text_section
->data
+ *p
);
636 if (is_float(vtop
->type
.t
) ||
637 (vtop
->type
.t
& VT_BTYPE
) == VT_LLONG
) {
641 if ((vtop
->r
& (VT_VALMASK
| VT_LVAL
| VT_SYM
)) == VT_CONST
) {
642 /* constant jmp optimization */
643 if ((vtop
->c
.i
!= 0) != inv
)
650 t
= psym(0x85 ^ inv
, t
);
657 /* generate an integer binary operation */
664 case TOK_ADDC1
: /* add with carry generation */
667 if ((vtop
->r
& (VT_VALMASK
| VT_LVAL
| VT_SYM
)) == VT_CONST
) {
674 /* XXX: generate inc and dec for smaller code ? */
676 o(0xc0 | (opc
<< 3) | r
);
680 oad(0xc0 | (opc
<< 3) | r
, c
);
686 o((opc
<< 3) | 0x01);
687 o(0xc0 + r
+ fr
* 8);
690 if (op
>= TOK_ULT
&& op
<= TOK_GT
) {
696 case TOK_SUBC1
: /* sub with carry generation */
699 case TOK_ADDC2
: /* add with carry use */
702 case TOK_SUBC2
: /* sub with carry use */
719 o(0xaf0f); /* imul fr, r */
720 o(0xc0 + fr
+ r
* 8);
731 opc
= 0xc0 | (opc
<< 3);
732 if ((vtop
->r
& (VT_VALMASK
| VT_LVAL
| VT_SYM
)) == VT_CONST
) {
737 c
= vtop
->c
.i
& 0x1f;
738 o(0xc1); /* shl/shr/sar $xxx, r */
742 /* we generate the shift in ecx */
745 o(0xd3); /* shl/shr/sar %cl, r */
756 /* first operand must be in eax */
757 /* XXX: need better constraint for second operand */
763 if (op
== TOK_UMULL
) {
764 o(0xf7); /* mul fr */
769 if (op
== TOK_UDIV
|| op
== TOK_UMOD
) {
770 o(0xf7d231); /* xor %edx, %edx, div fr, %eax */
773 o(0xf799); /* cltd, idiv fr, %eax */
776 if (op
== '%' || op
== TOK_UMOD
)
789 /* generate a floating point operation 'v = t1 op t2' instruction. The
790 two operands are guaranted to have the same floating point type */
791 /* XXX: need to use ST1 too */
794 int a
, ft
, fc
, swapped
, r
;
796 /* convert constants to memory references */
797 if ((vtop
[-1].r
& (VT_VALMASK
| VT_LVAL
)) == VT_CONST
) {
802 if ((vtop
[0].r
& (VT_VALMASK
| VT_LVAL
)) == VT_CONST
)
805 /* must put at least one value in the floating point register */
806 if ((vtop
[-1].r
& VT_LVAL
) &&
807 (vtop
[0].r
& VT_LVAL
)) {
813 /* swap the stack if needed so that t1 is the register and t2 is
814 the memory reference */
815 if (vtop
[-1].r
& VT_LVAL
) {
819 if (op
>= TOK_ULT
&& op
<= TOK_GT
) {
820 /* load on stack second operand */
821 load(TREG_ST0
, vtop
);
822 save_reg(TREG_EAX
); /* eax is used by FP comparison code */
823 if (op
== TOK_GE
|| op
== TOK_GT
)
825 else if (op
== TOK_EQ
|| op
== TOK_NE
)
828 o(0xc9d9); /* fxch %st(1) */
829 o(0xe9da); /* fucompp */
830 o(0xe0df); /* fnstsw %ax */
832 o(0x45e480); /* and $0x45, %ah */
833 o(0x40fC80); /* cmp $0x40, %ah */
834 } else if (op
== TOK_NE
) {
835 o(0x45e480); /* and $0x45, %ah */
836 o(0x40f480); /* xor $0x40, %ah */
838 } else if (op
== TOK_GE
|| op
== TOK_LE
) {
839 o(0x05c4f6); /* test $0x05, %ah */
842 o(0x45c4f6); /* test $0x45, %ah */
849 /* no memory reference possible for long double operations */
850 if ((vtop
->type
.t
& VT_BTYPE
) == VT_LDOUBLE
) {
851 load(TREG_ST0
, vtop
);
876 if ((ft
& VT_BTYPE
) == VT_LDOUBLE
) {
877 o(0xde); /* fxxxp %st, %st(1) */
880 /* if saved lvalue, then we must reload it */
882 if ((r
& VT_VALMASK
) == VT_LLOCAL
) {
886 v1
.r
= VT_LOCAL
| VT_LVAL
;
892 if ((ft
& VT_BTYPE
) == VT_DOUBLE
)
896 gen_modrm(a
, r
, vtop
->sym
, fc
);
902 /* convert integers to fp 't' type. Must handle 'int', 'unsigned int'
903 and 'long long' cases. */
904 void gen_cvt_itof(int t
)
908 if ((vtop
->type
.t
& VT_BTYPE
) == VT_LLONG
) {
909 /* signed long long to float/double/long double (unsigned case
910 is handled generically) */
911 o(0x50 + vtop
->r2
); /* push r2 */
912 o(0x50 + (vtop
->r
& VT_VALMASK
)); /* push r */
913 o(0x242cdf); /* fildll (%esp) */
914 o(0x08c483); /* add $8, %esp */
915 } else if ((vtop
->type
.t
& (VT_BTYPE
| VT_UNSIGNED
)) ==
916 (VT_INT
| VT_UNSIGNED
)) {
917 /* unsigned int to float/double/long double */
918 o(0x6a); /* push $0 */
920 o(0x50 + (vtop
->r
& VT_VALMASK
)); /* push r */
921 o(0x242cdf); /* fildll (%esp) */
922 o(0x08c483); /* add $8, %esp */
924 /* int to float/double/long double */
925 o(0x50 + (vtop
->r
& VT_VALMASK
)); /* push r */
926 o(0x2404db); /* fildl (%esp) */
927 o(0x04c483); /* add $4, %esp */
932 /* convert fp to int 't' type */
933 /* XXX: handle long long case */
934 void gen_cvt_ftoi(int t
)
940 ushort_type
.t
= VT_SHORT
| VT_UNSIGNED
;
948 o(0x2dd9); /* ldcw xxx */
949 sym
= external_global_sym(TOK___tcc_int_fpu_control
,
950 &ushort_type
, VT_LVAL
);
951 greloc(cur_text_section
, sym
,
955 oad(0xec81, size
); /* sub $xxx, %esp */
957 o(0x1cdb); /* fistpl */
959 o(0x3cdf); /* fistpll */
961 o(0x2dd9); /* ldcw xxx */
962 sym
= external_global_sym(TOK___tcc_fpu_control
,
963 &ushort_type
, VT_LVAL
);
964 greloc(cur_text_section
, sym
,
969 o(0x58 + r
); /* pop r */
972 vtop
->r
= r
; /* mark reg as used */
973 r2
= get_reg(RC_INT
);
974 o(0x58 + r2
); /* pop r2 */
977 o(0x04c483); /* add $4, %esp */
983 /* convert from one floating point type to another */
984 void gen_cvt_ftof(int t
)
986 /* all we have to do on i386 is to put the float in a register */
990 /* computed goto support */
997 /* bound check support functions */
998 #ifdef CONFIG_TCC_BCHECK
1000 /* generate a bounded pointer addition */
1001 void gen_bounded_ptr_add(void)
1005 /* prepare fast i386 function call (args in eax and edx) */
1006 gv2(RC_EAX
, RC_EDX
);
1007 /* save all temporary registers */
1010 /* do a fast function call */
1011 sym
= external_global_sym(TOK___bound_ptr_add
, &func_old_type
, 0);
1012 greloc(cur_text_section
, sym
,
1013 ind
+ 1, R_386_PC32
);
1015 /* returned pointer is in eax */
1017 vtop
->r
= TREG_EAX
| VT_BOUNDED
;
1018 /* address of bounding function call point */
1019 vtop
->c
.ul
= (cur_text_section
->reloc
->data_offset
- sizeof(Elf32_Rel
));
1022 /* patch pointer addition in vtop so that pointer dereferencing is
1024 void gen_bounded_ptr_deref(void)
1032 /* XXX: put that code in generic part of tcc */
1033 if (!is_float(vtop
->type
.t
)) {
1034 if (vtop
->r
& VT_LVAL_BYTE
)
1036 else if (vtop
->r
& VT_LVAL_SHORT
)
1040 size
= type_size(&vtop
->type
, &align
);
1042 case 1: func
= TOK___bound_ptr_indir1
; break;
1043 case 2: func
= TOK___bound_ptr_indir2
; break;
1044 case 4: func
= TOK___bound_ptr_indir4
; break;
1045 case 8: func
= TOK___bound_ptr_indir8
; break;
1046 case 12: func
= TOK___bound_ptr_indir12
; break;
1047 case 16: func
= TOK___bound_ptr_indir16
; break;
1049 error("unhandled size when derefencing bounded pointer");
1054 /* patch relocation */
1055 /* XXX: find a better solution ? */
1056 rel
= (Elf32_Rel
*)(cur_text_section
->reloc
->data
+ vtop
->c
.ul
);
1057 sym
= external_global_sym(func
, &func_old_type
, 0);
1059 put_extern_sym(sym
, NULL
, 0, 0);
1060 rel
->r_info
= ELF32_R_INFO(sym
->c
, ELF32_R_TYPE(rel
->r_info
));
1064 /* end of X86 code generator */
1065 /*************************************************************/