aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrischka <grischka>2012-04-18 18:48:26 +0200
committergrischka <grischka>2012-04-18 18:48:26 +0200
commitf98c2306a0857ad3f8800f91e0554a27adc7f675 (patch)
treeee3546311e05e66d1bce05d1cff80915f6b1b4df
parent32a411914b5bc5ad9549c43f25c737d891016f68 (diff)
downloadtinycc-f98c2306a0857ad3f8800f91e0554a27adc7f675.tar.gz
tinycc-f98c2306a0857ad3f8800f91e0554a27adc7f675.tar.bz2
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)
-rw-r--r--libtcc.c1
-rw-r--r--tcc.h3
-rw-r--r--tccelf.c4
3 files changed, 6 insertions, 2 deletions
diff --git a/libtcc.c b/libtcc.c
index 1c5e619..c6b8d38 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1001,6 +1001,7 @@ LIBTCCAPI TCCState *tcc_new(void)
".strtab",
".hashtab", SHF_PRIVATE);
strtab_section = symtab_section->link;
+ s->symtab = symtab_section;
/* private symbol table for dynamic symbols */
s->dynsymtab_section = new_symtab(s, ".dynsymtab", SHT_SYMTAB, SHF_PRIVATE,
diff --git a/tcc.h b/tcc.h
index 3e297a1..95d5030 100644
--- a/tcc.h
+++ b/tcc.h
@@ -527,6 +527,9 @@ struct TCCState {
/* exported dynamic symbol section */
Section *dynsym;
+ /* copy of the gobal symtab_section variable */
+ Section *symtab;
+
int nostdinc; /* if true, no standard headers are added */
int nostdlib; /* if true, no standard libraries are added */
int nocommon; /* if true, do not use common symbols for .bss data */
diff --git a/tccelf.c b/tccelf.c
index 04975d9..90e4815 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -162,8 +162,8 @@ static void *get_elf_sym_addr(TCCState *s, const char *name, int err)
int sym_index;
ElfW(Sym) *sym;
- sym_index = find_elf_sym(symtab_section, name);
- sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
+ sym_index = find_elf_sym(s->symtab, name);
+ sym = &((ElfW(Sym) *)s->symtab->data)[sym_index];
if (!sym_index || sym->st_shndx == SHN_UNDEF) {
if (err)
tcc_error("%s not defined", name);