Skip to content

[ARM] [bug] Weak Symbols as Function Pointer Fails to be overrided by Strong Symbol #183916

@Zhenhang1213

Description

@Zhenhang1213

test.c

#include <stdio.h>

#pragma GCC visibility push(hidden)

void __attribute__((__weak__)) xxx(void)
{
        printf("weak\n");
}

void call_func(void (*f)(void));

int main()
{
        call_func(xxx);
        return 0;
}

test1.c

#include <stdio.h>

#pragma GCC visibility push(hidden)
void xxx(void)
{
        printf("default\n");
}

void call_func(void (*f)(void))
{
        f();
}

opts:
arm32-clang test.c test1.c -fpic
result:

weak

arm32-gcc test.c test1.c -fpic
result:

default

godbolt:
https://godbolt.org/z/jrT49YKM1

I believe this issue is closely related to how weak symbol function pointers are loaded. How can we fix this problem to align with GCC's behavior?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions