http://sourceware.org/bugzilla/show_bug.cgi?id=14851
Bug #: 14851 Summary: broken relocations for weak symbols on mingw32 Product: binutils Version: unspecified Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassig...@sourceware.org ReportedBy: bonz...@gnu.org Classification: Unclassified I'm assigning this to ld, but it's possible that gas is buggy, or both are. Relocations are broken for both overridden and non-overridden symbols. Minimal testcase: g1.c: int f() { return 82; } int g() { return 83; } g2.c: #include <stdio.h> static int weak_f() { printf("strong"); return 42; } static int weak_g() { printf("strong"); return 43; } typeof(weak_f) f __attribute__((__weak__, __alias__("weak_f"))); typeof(weak_g) g __attribute__((__weak__, __alias__("weak_g"))); int main() { printf("%d/%d\n", f(), g()); } Output on ELF is: - 42/43 for "gcc g2.c" - 82/83 for "gcc g1.c g2.c" Output on Windows is: - 42/42 for "gcc g2.c" - segfault for "gcc g1.c g2.c" The relocation is completely broken, which causes the difference in the weak case. In addition, it assumes that symbols have the same size in the weak and strong versions, which causes the crash in the strong case. The person who reported the bug said that weakrefs did not work for him either, but they seem to work in this particular case, replacing g2.c with this: #include <stdio.h> static int default_f() { return 42; } static int default_g() { return 43; } static typeof(default_f) weak_f __attribute__((__weakref__("f"))); static typeof(default_g) weak_g __attribute__((__weakref__("g"))); int main() { printf("%d/%d\n", (weak_f?:default_f)(), (weak_g?:default_g)()); } and I see no reason why they shouldn't work... -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils