https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68178
Bug ID: 68178 Summary: [arm] Relative address expressions bind at as-time, even if symbol is weak Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: bugdal at aerifal dot cx Target Milestone: --- This bug is almost identical to #66609 for [sh], except the conditions needed to trigger it are slightly different. Minimal test case (compile with -fPIC; -O level does not matter): __attribute__((__weak__,__visibility__("hidden"))) void foo() { } void *bar() { return (void *)foo; } The expected output should have a relocation for foo, since the weak definition is replaceable by a strong definition from another TU. The actual output has a PC-relative constant pointing to the weak definition. This bug seriously broke musl libc's pthread_cancel.c, where the weak version of the symbol used for updating PC upon cancellation has the wrong contract for stack state, and the strong version from arm-specific asm needs to be used. I still question whether this issue should be fixed on the binutils side for all targets; see: https://sourceware.org/bugzilla/show_bug.cgi?id=18561