Unified · Split
| @@ -1323,13 +1323,14 @@ enum gotplt_entry { · 1322 unmodified lines | ||
| 1323 | 1323 | |
| 1324 | 1324 | /* what kind of relocation is it */ |
| 1325 | 1325 | struct reloc_info { |
| 1326 | + int known; /* true for known relocation */ | |
| 1326 | 1327 | int code_reloc; /* if false, that's a data reloc */ |
| 1327 | 1328 | int gotplt_entry; /* wether and when to create a GOT/PLT entry */ |
| 1328 | 1329 | int pltoff_addend; /* wether to store the PLT offset in addend */ |
| 1329 | 1330 | }; |
| 1330 | 1331 | |
| 1331 | 1332 | #define INIT_RELOC_INFO(rtype, code_reloc, gotplt_entry, pltoff_addend) \ |
| 1332 | − [rtype] = {code_reloc, gotplt_entry, pltoff_addend}, | |
| 1333 | + [rtype] = {1, code_reloc, gotplt_entry, pltoff_addend}, | |
| 1333 | 1334 | ST_DATA struct reloc_info relocs_info[R_NUM]; |
| 1334 | 1335 | |
| 1335 | 1336 | ST_DATA Section *text_section, *data_section, *bss_section; /* predefined sections */ |
| @@ -1042,6 +1042,10 @@ ST_FUNC void build_got_entries(TCCState *s1) · 1041 unmodified lines | ||
| 1042 | 1042 | type = ELFW(R_TYPE)(rel->r_info); |
| 1043 | 1043 | sym_index = ELFW(R_SYM)(rel->r_info); |
| 1044 | 1044 | sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; |
| 1045 | + | |
| 1046 | + if (type >= R_NUM || !relocs_info[type].known) | |
| 1047 | + tcc_error("Unknown relocation: %d\n", type); | |
| 1048 | + | |
| 1045 | 1049 | if (relocs_info[type].gotplt_entry == NO_GOTPLT_ENTRY) |
| 1046 | 1050 | continue; |
| 1047 | 1051 | |