mirror of
https://github.com/frida/tinycc
synced 2024-11-24 00:29:38 +03:00
Ignore relocs to ignored sections as well
relocs to sections which we ignore should be ignored as well, they have no meaning and currently would segfault.
This commit is contained in:
parent
4c2b55f962
commit
eaf5f3fa52
22
tccelf.c
22
tccelf.c
@ -2302,7 +2302,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1,
|
||||
ElfW(Ehdr) ehdr;
|
||||
ElfW(Shdr) *shdr, *sh;
|
||||
int size, i, j, offset, offseti, nb_syms, sym_index, ret, seencompressed;
|
||||
unsigned char *strsec, *strtab;
|
||||
char *strsec, *strtab;
|
||||
int *old_to_new_syms;
|
||||
char *sh_name, *name;
|
||||
SectionMergeInfo *sm_table, *sm;
|
||||
@ -2368,10 +2368,10 @@ ST_FUNC int tcc_load_object_file(TCCState *s1,
|
||||
if (i == ehdr.e_shstrndx)
|
||||
continue;
|
||||
sh = &shdr[i];
|
||||
sh_name = (char *) strsec + sh->sh_name;
|
||||
/* ignore sections types we do not handle */
|
||||
if (sh->sh_type == SHT_RELX)
|
||||
sh = &shdr[sh->sh_info];
|
||||
/* ignore sections types we do not handle (plus relocs to those) */
|
||||
if (sh->sh_type != SHT_PROGBITS &&
|
||||
sh->sh_type != SHT_RELX &&
|
||||
#ifdef TCC_ARM_EABI
|
||||
sh->sh_type != SHT_ARM_EXIDX &&
|
||||
#endif
|
||||
@ -2379,15 +2379,15 @@ ST_FUNC int tcc_load_object_file(TCCState *s1,
|
||||
sh->sh_type != SHT_PREINIT_ARRAY &&
|
||||
sh->sh_type != SHT_INIT_ARRAY &&
|
||||
sh->sh_type != SHT_FINI_ARRAY &&
|
||||
strcmp(sh_name, ".stabstr")
|
||||
strcmp(strsec + sh->sh_name, ".stabstr")
|
||||
)
|
||||
continue;
|
||||
if (seencompressed
|
||||
&& (!strncmp(sh_name, ".debug_", sizeof(".debug_")-1)
|
||||
|| (sh->sh_type == SHT_RELX
|
||||
&& !strncmp((char*)strsec + shdr[sh->sh_info].sh_name,
|
||||
".debug_", sizeof(".debug_")-1))))
|
||||
&& !strncmp(strsec + sh->sh_name, ".debug_", sizeof(".debug_")-1))
|
||||
continue;
|
||||
|
||||
sh = &shdr[i];
|
||||
sh_name = strsec + sh->sh_name;
|
||||
if (sh->sh_addralign < 1)
|
||||
sh->sh_addralign = 1;
|
||||
/* find corresponding section, if any */
|
||||
@ -2505,7 +2505,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1,
|
||||
already defined symbol. It is very important to get
|
||||
correct relocations */
|
||||
if (ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
|
||||
name = (char *) strtab + sym->st_name;
|
||||
name = strtab + sym->st_name;
|
||||
sym_index = find_elf_sym(symtab_section, name);
|
||||
if (sym_index)
|
||||
old_to_new_syms[i] = sym_index;
|
||||
@ -2521,7 +2521,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1,
|
||||
sym->st_value += sm->offset;
|
||||
}
|
||||
/* add symbol */
|
||||
name = (char *) strtab + sym->st_name;
|
||||
name = strtab + sym->st_name;
|
||||
sym_index = set_elf_sym(symtab_section, sym->st_value, sym->st_size,
|
||||
sym->st_info, sym->st_other,
|
||||
sym->st_shndx, name);
|
||||
|
Loading…
Reference in New Issue
Block a user