History

i386: bound checking needs pic in shared library

herman ten brugge committed 9 months ago

Commit abb2f391 parent 4fccaf61 file · +18 −2Browse files

Unified · Split

i386-gen.c+18−2
@@ -1176,6 +1176,22 @@ ST_FUNC void ggoto(void) · 1175 unmodified lines
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) · 42 unmodified lines
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) · 8 unmodified lines
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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t