llvm / llvm/llvm-project

[lld] Alternate name referring another alternate name is not resolved

Open
#159,669 5 comments 0 reactions 0 assignees View on GitHub
lld:COFF
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Steps to reproduce on Windows:

test.c
```
#pragma comment(linker, "/alternatename:x=y")
#pragma comment(linker, "/alternatename:y=puts")

extern int x(const char *str);

int main(void) {
x("Hello");
return 0;
}

```
Compile and link:
```
clang-cl /c test.c
lld-link /OUT:test.exe /SUBSYSTEM:console test.obj

```
It works with lld-link <=20 and MS link.exe, but fails with lld-link 21.1.1:
```
lld-link: error: undefined symbol: x
>>> referenced by test.obj:(main)
```

I think it's caused by this commit: https://github.com/llvm/llvm-project/commit/ac31d64a64e8a648f6834f4cf9de10c56c8d1083. If I roll back that commit for SymbolTable.cpp, linking succeeds again.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.