Issue Details (XML | Word | Printable)

Key: PCC-429
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

weakref symbol is referenced wrongly with -fPIC

Created: 10/May/14 10:24 PM   Updated: 11/May/14 11:57 AM
Component/s: C frontend, i386 target
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386

 Description  « Hide
A function symbol with a weak reference seems to be referenced wrongly, when compiled with -fPIC. The following code segment

static void foo(void) __attribute__((__weakref__("FOO")));

        if (foo != 0)


when compiled with "pcc -fPIC -S test.c", shows that the first reference is emitted as

    addl $foo@GOTOFF,%eax

but I believe this should be @GOT .. and then the second instance when the call is made, is emitted as

    call foo

but I believe that this should be @PLT

(in any case, both gcc and clang produce references like those, and ld is complaining about the pcc version :)

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 11/May/14 11:43 AM
Yetch, all weakref stuff is a maze :-/
A static function is always called directly if PIC; i.e. no @PLT. ...unless it has a static storage class with attribute weakref, then it is handled like an external function.

Anders Magnusson added a comment - 11/May/14 11:57 AM
Handle PIC static weakref calls like extern calls.