llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

-mbranch-protection=bti and -fexperimental-relative-c++-abi-vtables are not compatible

Open DanielKristofKiss opened this issue 1 year ago • 1 comments

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

DanielKristofKiss avatar Jun 28 '23 13:06 DanielKristofKiss

@llvm/issue-subscribers-backend-aarch64

llvmbot avatar Jun 28 '23 13:06 llvmbot

Patch: https://reviews.llvm.org/D153264

MaskRay avatar Jun 28 '23 22:06 MaskRay

@llvm/issue-subscribers-lld-elf

llvmbot avatar Jun 28 '23 22:06 llvmbot