libtcc: tcc_get_symbol uses the TCCState parameter
This allows using tcc_get_symbol on some other than the current TCCState. (Suggested by David Mertens)
This commit is contained in:
parent
32a411914b
commit
f98c2306a0
3 changed files with 6 additions and 2 deletions
1
libtcc.c
1
libtcc.c
|
@ -1001,6 +1001,7 @@ LIBTCCAPI TCCState *tcc_new(void)
|
||||||
".strtab",
|
".strtab",
|
||||||
".hashtab", SHF_PRIVATE);
|
".hashtab", SHF_PRIVATE);
|
||||||
strtab_section = symtab_section->link;
|
strtab_section = symtab_section->link;
|
||||||
|
s->symtab = symtab_section;
|
||||||
|
|
||||||
/* private symbol table for dynamic symbols */
|
/* private symbol table for dynamic symbols */
|
||||||
s->dynsymtab_section = new_symtab(s, ".dynsymtab", SHT_SYMTAB, SHF_PRIVATE,
|
s->dynsymtab_section = new_symtab(s, ".dynsymtab", SHT_SYMTAB, SHF_PRIVATE,
|
||||||
|
|
3
tcc.h
3
tcc.h
|
@ -527,6 +527,9 @@ struct TCCState {
|
||||||
/* exported dynamic symbol section */
|
/* exported dynamic symbol section */
|
||||||
Section *dynsym;
|
Section *dynsym;
|
||||||
|
|
||||||
|
/* copy of the gobal symtab_section variable */
|
||||||
|
Section *symtab;
|
||||||
|
|
||||||
int nostdinc; /* if true, no standard headers are added */
|
int nostdinc; /* if true, no standard headers are added */
|
||||||
int nostdlib; /* if true, no standard libraries are added */
|
int nostdlib; /* if true, no standard libraries are added */
|
||||||
int nocommon; /* if true, do not use common symbols for .bss data */
|
int nocommon; /* if true, do not use common symbols for .bss data */
|
||||||
|
|
4
tccelf.c
4
tccelf.c
|
@ -162,8 +162,8 @@ static void *get_elf_sym_addr(TCCState *s, const char *name, int err)
|
||||||
int sym_index;
|
int sym_index;
|
||||||
ElfW(Sym) *sym;
|
ElfW(Sym) *sym;
|
||||||
|
|
||||||
sym_index = find_elf_sym(symtab_section, name);
|
sym_index = find_elf_sym(s->symtab, name);
|
||||||
sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
|
sym = &((ElfW(Sym) *)s->symtab->data)[sym_index];
|
||||||
if (!sym_index || sym->st_shndx == SHN_UNDEF) {
|
if (!sym_index || sym->st_shndx == SHN_UNDEF) {
|
||||||
if (err)
|
if (err)
|
||||||
tcc_error("%s not defined", name);
|
tcc_error("%s not defined", name);
|
||||||
|
|
Loading…
Reference in a new issue