aboutsummaryrefslogtreecommitdiff
path: root/tccelf.c
diff options
context:
space:
mode:
authorgrischka <grischka>2017-11-30 15:15:22 +0100
committerMichael Matz <matz@suse.de>2017-12-05 01:54:49 +0100
commit877e164d6ade4167f9d7f6994ece8e06b5d67060 (patch)
tree51596ba9dc2733e99d4d8851b55ec16945cfc561 /tccelf.c
parentcc6cb7f0e294f0c98c4970c7ec993709fc2daa1a (diff)
downloadtinycc-877e164d6ade4167f9d7f6994ece8e06b5d67060.tar.gz
tinycc-877e164d6ade4167f9d7f6994ece8e06b5d67060.tar.bz2
tccasm: use global(_symbol)_stack
* removed asm_label stack * removed asm_free_labels() post-processing * using "impossible C type" for asm labels (VT_ASM) * tccgen.c:update_storage(): use it to refresh symbol attributes * tccelf.c:find_elf_sym(): ignore STB_LOCAL symbols * tccgen.c:unary(): asm symbols are supposed to be undeclared in C
Diffstat (limited to 'tccelf.c')
-rw-r--r--tccelf.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/tccelf.c b/tccelf.c
index 422dfd6..657aa61 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -310,8 +310,7 @@ static void rebuild_hash(Section *s, unsigned int nb_buckets)
sym = (ElfW(Sym) *)s->data + 1;
for(sym_index = 1; sym_index < nb_syms; sym_index++) {
- if (ELFW(ST_BIND)(sym->st_info) != STB_LOCAL
- || sym->st_shndx == SHN_UNDEF) {
+ if (ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
h = elf_hash(strtab + sym->st_name) % nb_buckets;
*ptr = hash[h];
hash[h] = sym_index;
@@ -350,9 +349,8 @@ ST_FUNC int put_elf_sym(Section *s, addr_t value, unsigned long size,
int *ptr, *base;
ptr = section_ptr_add(hs, sizeof(int));
base = (int *)hs->data;
- /* only add global, weak or undef symbols. The latter might
- become global late (from asm references). */
- if (ELFW(ST_BIND)(info) != STB_LOCAL || shndx == SHN_UNDEF) {
+ /* only add global or weak symbols. */
+ if (ELFW(ST_BIND)(info) != STB_LOCAL) {
/* add another hashing entry */
nbuckets = base[0];
h = elf_hash((unsigned char *) name) % nbuckets;
@@ -390,7 +388,7 @@ ST_FUNC int find_elf_sym(Section *s, const char *name)
while (sym_index != 0) {
sym = &((ElfW(Sym) *)s->data)[sym_index];
name1 = (char *) s->link->data + sym->st_name;
- if (!strcmp(name, name1))
+ if (!strcmp(name, name1) && ELFW(ST_BIND)(sym->st_info) != STB_LOCAL)
return sym_index;
sym_index = ((int *)hs->data)[2 + nbuckets + sym_index];
}