llvm-project
llvm-project copied to clipboard
-mbranch-protection=bti and -fexperimental-relative-c++-abi-vtables are not compatible
LLD doesn't generate a landing pad for the PLT entry that belong to the relative vtables.
Small reproducer:
main.cpp
#include "v.hpp"
int main() {
A* a = new B();
a->do_something2();
return 0;
}
v.hpp
struct A {
virtual void do_something() = 0;
virtual void do_something2();
};
struct B : public A
{
void do_something() override;
void do_something2() override;
};
v.cpp
#include "v.hpp"
void A::do_something2() { }
void B::do_something() { }
void B::do_something2() { }
CC="clang++ --target=aarch64-unknown-linux-gnu -fuse-ld=lld -mbranch-protection=bti"
F=-fexperimental-relative-c++-abi-vtables
${=CC} $F -shared v.cpp -o v.so -z force-bti
${=CC} $F main.cpp -L./ v.so -Wl,-rpath=. -z force-bti
qemu-aarch64-static -L /usr/aarch64-linux-gnu -cpu max ./a.out
@llvm/issue-subscribers-backend-aarch64
Patch: https://reviews.llvm.org/D153264
@llvm/issue-subscribers-lld-elf