Skip to content

[CFI] missing .cfi symbols when alias override weak function #150075

@vitalybuka

Description

@vitalybuka

cat ../a.c

__attribute__((alias("g"), visibility("default"))) void f(void);
__attribute__((visibility("default"))) void g(void) {}

cat ../b.c

__attribute__((weak, visibility("default"))) void f(void) { }

int main(int argc, char **argv) {
  argv[0] = (char *)f;
  void (*fp)(void) = (void (*)(void))argv[0];
  fp();
}

clang ../a.c ../b.c -fsanitize=cfi-icall -flto=thin -fvisibility=hidden -fuse-ld=lld -o x -Wl,-save-temps -Wl,--thinlto-jobs=1

ld.lld: error: undefined hidden symbol: f.cfi
>>> referenced by ld-temp.o
>>>               x.lto.o:(f)
>>> did you mean: g.cfi
>>> defined in: /tmp/x.lto.a-3b6dcc.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    LTOLink time optimization (regular/full LTO or ThinLTO)compiler-rt:cfiControl Flow Integrity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions