History

Error on unrecognized relocations

Thomas Preud'homme committed 9 years ago

Commit e22249b1 parent 557c5c12 files · +6 −1Browse files

Unified · Split

2 files
  1. tcc.h +2 −1
  2. tccelf.c +4 −0
tcc.h+2−1
@@ -1323,13 +1323,14 @@ enum gotplt_entry { · 1322 unmodified lines
13231323
13241324 /* what kind of relocation is it */
13251325 struct reloc_info {
1326+ int known; /* true for known relocation */
13261327 int code_reloc; /* if false, that's a data reloc */
13271328 int gotplt_entry; /* wether and when to create a GOT/PLT entry */
13281329 int pltoff_addend; /* wether to store the PLT offset in addend */
13291330 };
13301331
13311332 #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},
13331334 ST_DATA struct reloc_info relocs_info[R_NUM];
13341335
13351336 ST_DATA Section *text_section, *data_section, *bss_section; /* predefined sections */
tccelf.c+4−0
@@ -1042,6 +1042,10 @@ ST_FUNC void build_got_entries(TCCState *s1) · 1041 unmodified lines
10421042 type = ELFW(R_TYPE)(rel->r_info);
10431043 sym_index = ELFW(R_SYM)(rel->r_info);
10441044 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+
10451049 if (relocs_info[type].gotplt_entry == NO_GOTPLT_ENTRY)
10461050 continue;
10471051

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