llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.79k stars 10.98k forks source link

[ARM32] clang do not generate plt when call function in same translation unit #87470

Open SihangZhu opened 3 months ago

SihangZhu commented 3 months ago

code as follow

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

void Func(void)
{
        printf("this is a.so\n");
        char *pStr = strdup("hello");
        if (pStr == NULL) {
                printf("strdup fail\n");
                return;
        }
        printf("pStr:%s %p\n", pStr, pStr);
        free(pStr);
        return;
}

void test_main(void)
{
        Func();
}

option

clang -shared -fPIC demo.c -o demo.out

In clang's aarch64 and gcc arm32/aarch64, test_main call Func through plt,while clang's arm don't generate plt call.

It makes the Func symbol be non-preemptible. Is there a compile option to align clang's behavior on arm32 with gcc?

llvmbot commented 3 months ago

@llvm/issue-subscribers-backend-arm

Author: None (SihangZhu)

code as follow ```c++ #include <string.h> #include <stdio.h> #include <stdlib.h> void Func(void) { printf("this is a.so\n"); char *pStr = strdup("hello"); if (pStr == NULL) { printf("strdup fail\n"); return; } printf("pStr:%s %p\n", pStr, pStr); free(pStr); return; } void test_main(void) { Func(); } ``` option ``` clang -shared -fPIC demo.c -o demo.out ``` In clang's aarch64 and gcc arm32/aarch64, test_main call Func through plt,while clang's arm don't generate plt call. It makes the Func symbol be non-preemptible. Is there a compile option to align clang's behavior on arm32 with gcc?