From 097cf3aa5ee370bab50d6d15cef9b0af55a1a3a2 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Sat, 12 Nov 2016 23:16:09 +0800 Subject: [PATCH] Control symbol table of which to relocate symbols Pass pointer to symbol table to relocate the symbols of in relocate_syms --- tcc.h | 2 +- tccelf.c | 6 +++--- tccpe.c | 2 +- tccrun.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tcc.h b/tcc.h index 3010bb93..fbabd7a3 100644 --- a/tcc.h +++ b/tcc.h @@ -1375,7 +1375,7 @@ ST_FUNC void put_stabn(int type, int other, int desc, int value); ST_FUNC void put_stabd(int type, int other, int desc); ST_FUNC void relocate_common_syms(void); -ST_FUNC void relocate_syms(TCCState *s1, int do_resolve); +ST_FUNC void relocate_syms(TCCState *s1, Section *symtab, int do_resolve); ST_FUNC void relocate_section(TCCState *s1, Section *s); ST_FUNC void relocate_plt(TCCState *s1); diff --git a/tccelf.c b/tccelf.c index b9f16342..7d656e5d 100644 --- a/tccelf.c +++ b/tccelf.c @@ -652,13 +652,13 @@ ST_FUNC void relocate_common_syms(void) /* relocate symbol table, resolve undefined symbols if do_resolve is true and output error if undefined symbol. */ -ST_FUNC void relocate_syms(TCCState *s1, int do_resolve) +ST_FUNC void relocate_syms(TCCState *s1, Section *symtab, int do_resolve) { ElfW(Sym) *sym; int sym_bind, sh_num; const char *name; - for_each_elem(symtab_section, 1, sym, ElfW(Sym)) { + for_each_elem(symtab, 1, sym, ElfW(Sym)) { sh_num = sym->st_shndx; if (sh_num == SHN_UNDEF) { name = (char *) strtab_section->data + sym->st_name; @@ -1898,7 +1898,7 @@ static int final_sections_reloc(TCCState *s1) int i; Section *s; - relocate_syms(s1, 0); + relocate_syms(s1, s1->symtab, 0); if (s1->nb_errors != 0) return -1; diff --git a/tccpe.c b/tccpe.c index 49e983d0..e2101bb1 100644 --- a/tccpe.c +++ b/tccpe.c @@ -1872,7 +1872,7 @@ ST_FUNC int pe_output_file(TCCState *s1, const char *filename) ; else if (filename) { pe_assign_addresses(&pe); - relocate_syms(s1, 0); + relocate_syms(s1, s1->symtab, 0); for (i = 1; i < s1->nb_sections; ++i) { Section *s = s1->sections[i]; if (s->reloc) { diff --git a/tccrun.c b/tccrun.c index 37e93038..7eb47fc3 100644 --- a/tccrun.c +++ b/tccrun.c @@ -211,7 +211,7 @@ static int tcc_relocate_ex(TCCState *s1, void *ptr) } /* relocate symbols */ - relocate_syms(s1, 1); + relocate_syms(s1, s1->symtab, 1); if (s1->nb_errors) return -1; -- 2.11.4.GIT