Skip to content

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

@vahur

Description

@vahur

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: ac31d64. If I roll back that commit for SymbolTable.cpp, linking succeeds again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions