Skip to content

Commit f47db34

Browse files
committed
fix handling of weakly aliased symbols
1 parent ade6f1d commit f47db34

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

symbol.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,26 @@ AddSymbol(SymbolTable *table, const char *name, int type, void *val, const char
211211
sym = sym->next;
212212
}
213213
}
214-
if (!sym) {
215-
sym = NewSymbol();
216-
sym->next = table->hash[hash];
217-
table->hash[hash] = sym;
218-
// now link into global list
219-
if (table->i_last) {
220-
table->i_last->i_next = sym;
221-
table->i_last = sym;
222-
} else {
223-
table->i_last = table->i_first = sym;
214+
215+
if (sym) {
216+
// it's OK for us to override a weak alias
217+
if (sym->kind != SYM_WEAK_ALIAS) {
218+
fprintf(stderr, "Duplicate definition for symbol `%s'\n", user_name);
224219
}
225-
}
220+
}
221+
222+
sym = NewSymbol();
223+
sym->next = table->hash[hash];
224+
table->hash[hash] = sym;
225+
// now link into global list
226+
if (table->i_last) {
227+
table->i_last->i_next = sym;
228+
table->i_last = sym;
229+
} else {
230+
table->i_last = table->i_first = sym;
231+
}
232+
sym->i_next = 0;
233+
226234
sym->our_name = name;
227235
sym->user_name = user_name ? user_name : name;
228236
sym->kind = (Symtype)type;

0 commit comments

Comments
 (0)