weak redefinition of a symbol should weaken the original

This commit is contained in:
Joe Soroka 2011-03-07 00:25:27 -08:00
parent 38cbb40e90
commit 0f0c2d9c02
2 changed files with 7 additions and 0 deletions

View File

@ -5592,6 +5592,9 @@ ST_FUNC void decl(int l)
extern */ extern */
sym = external_sym(v, &type, r, asm_label); sym = external_sym(v, &type, r, asm_label);
if (type.t & VT_WEAK)
sym->type.t |= VT_WEAK;
if (ad.alias_target) { if (ad.alias_target) {
Section tsec; Section tsec;
Elf32_Sym *esym; Elf32_Sym *esym;

View File

@ -2370,6 +2370,10 @@ extern __typeof(dummy) weak_dummy1 __attribute__((weak, alias("dummy")));
extern __typeof(dummy) __attribute__((weak, alias("dummy"))) weak_dummy2; extern __typeof(dummy) __attribute__((weak, alias("dummy"))) weak_dummy2;
extern __attribute__((weak, alias("dummy"))) __typeof(dummy) weak_dummy3; extern __attribute__((weak, alias("dummy"))) __typeof(dummy) weak_dummy3;
int some_lib_func(void);
int dummy_impl_of_slf(void) { return 444; }
int some_lib_func(void) __attribute__((weak, alias("dummy_impl_of_slf")));
void __attribute__((weak)) weak_test(void) void __attribute__((weak)) weak_test(void)
{ {
printf("weak_f1=%d\n", weak_f1 ? weak_f1() : 123); printf("weak_f1=%d\n", weak_f1 ? weak_f1() : 123);