From 82c5edb31cd0bb2ee699992c45557006f1681e0e Mon Sep 17 00:00:00 2001 From: grischka Date: Wed, 30 Jun 2010 20:25:04 +0200 Subject: [PATCH] Avoid crash with "Avoid a crash with weak symbols for "make test"" This fixes commit 197a6acb30940068d1dc3d0fa53c9f0863309885 which fixed commit 95b9a477b6743004e0e9bf728b25bf63d2908777 Also remove useless example files --- examples/ex_weak.c | 11 ----------- examples/weak_f.c | 6 ------ libtcc.c | 2 +- 3 files changed, 1 insertion(+), 18 deletions(-) delete mode 100755 examples/ex_weak.c delete mode 100644 examples/weak_f.c diff --git a/examples/ex_weak.c b/examples/ex_weak.c deleted file mode 100755 index 2a2bd19..0000000 --- a/examples/ex_weak.c +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/local/bin/tcc -run -#include - -extern void weak_f (void) __attribute__ ((weak)); - -int main () -{ - if (weak_f) { - weak_f(); - } -} diff --git a/examples/weak_f.c b/examples/weak_f.c deleted file mode 100644 index e744531..0000000 --- a/examples/weak_f.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -void weak_f (void) -{ - printf("Weak\n"); -} diff --git a/libtcc.c b/libtcc.c index 5f064dd..2575a05 100644 --- a/libtcc.c +++ b/libtcc.c @@ -429,7 +429,7 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, if (sym->type.t & VT_STATIC) sym_bind = STB_LOCAL; else { - if (sym->type.ref && FUNC_WEAK(sym->type.ref->r)) + if (sym_type == STT_FUNC && sym->type.ref && FUNC_WEAK(sym->type.ref->r)) sym_bind = STB_WEAK; else sym_bind = STB_GLOBAL;