Skip to content

Commit abb2f39

Browse files
committed
i386: bound checking needs pic in shared library
1 parent 4fccaf6 commit abb2f39

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

i386-gen.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,22 @@ ST_FUNC void ggoto(void)
11761176
/* bound check support functions */
11771177
#ifdef CONFIG_TCC_BCHECK
11781178

1179+
/* Need PIC for shared libraries */
1180+
static void gen_bound_call(int v)
1181+
{
1182+
Sym *sym;
1183+
1184+
sym = external_helper_sym(v);
1185+
#if defined CONFIG_TCC_PIC
1186+
get_pc_thunk(TREG_EBX, 1);
1187+
oad(0xe8, -4);
1188+
greloc(cur_text_section, sym, ind - 4, R_386_PLT32);
1189+
#else
1190+
oad(0xe8, -4);
1191+
greloc(cur_text_section, sym, ind - 4, R_386_PC32);
1192+
#endif
1193+
}
1194+
11791195
static void gen_bounds_prolog(void)
11801196
{
11811197
/* leave some room for bound checking code */
@@ -1224,7 +1240,7 @@ static void gen_bounds_epilog(void)
12241240
greloc(cur_text_section, sym_data, ind + 1, R_386_32);
12251241
ind = ind + 5;
12261242
#endif
1227-
gen_static_call(TOK___bound_local_new);
1243+
gen_bound_call(TOK___bound_local_new);
12281244
ind = saved_ind;
12291245
}
12301246

@@ -1239,7 +1255,7 @@ static void gen_bounds_epilog(void)
12391255
greloc(cur_text_section, sym_data, ind + 1, R_386_32);
12401256
oad(0xb8, 0); /* mov %eax, xxx */
12411257
#endif
1242-
gen_static_call(TOK___bound_local_delete);
1258+
gen_bound_call(TOK___bound_local_delete);
12431259
o(0x585a); /* restore returned value, if any */
12441260
}
12451261
#endif

0 commit comments

Comments
 (0)