Unified · Split
| @@ -1176,6 +1176,22 @@ ST_FUNC void ggoto(void) · 1175 unmodified lines | ||
| 1176 | 1176 | /* bound check support functions */ |
| 1177 | 1177 | #ifdef CONFIG_TCC_BCHECK |
| 1178 | 1178 | |
| 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 | + | |
| 1179 | 1195 | static void gen_bounds_prolog(void) |
| 1180 | 1196 | { |
| 1181 | 1197 | /* leave some room for bound checking code */ |
| @@ -1224,7 +1240,7 @@ static void gen_bounds_epilog(void) · 42 unmodified lines | ||
| 1224 | 1240 | greloc(cur_text_section, sym_data, ind + 1, R_386_32); |
| 1225 | 1241 | ind = ind + 5; |
| 1226 | 1242 | #endif |
| 1227 | − gen_static_call(TOK___bound_local_new); | |
| 1243 | + gen_bound_call(TOK___bound_local_new); | |
| 1228 | 1244 | ind = saved_ind; |
| 1229 | 1245 | } |
| 1230 | 1246 | |
| @@ -1239,7 +1255,7 @@ static void gen_bounds_epilog(void) · 8 unmodified lines | ||
| 1239 | 1255 | greloc(cur_text_section, sym_data, ind + 1, R_386_32); |
| 1240 | 1256 | oad(0xb8, 0); /* mov %eax, xxx */ |
| 1241 | 1257 | #endif |
| 1242 | − gen_static_call(TOK___bound_local_delete); | |
| 1258 | + gen_bound_call(TOK___bound_local_delete); | |
| 1243 | 1259 | o(0x585a); /* restore returned value, if any */ |
| 1244 | 1260 | } |
| 1245 | 1261 | #endif |