xref: /llvm-project/bolt/test/R_ABS.pic.lld.cpp (revision 003b48e0cbbb69a9a1ca9ff1a6d3bda30d0c6121)
1 /*
2  * Check that we don't assert on a duplicate static relocation added by lld
3  * against _Z6myfuncv. The same address has a dynamic relocation against it.
4  *
5  * This test uses the clang driver + lld and will only succeed on Linux systems
6  * with libc available.
7  * REQUIRES: system-linux
8  *
9  * RUN: %clangxx %cxxflags -fPIC -shared %s -o %t.so -Wl,-q -fuse-ld=lld
10  * RUN: llvm-bolt %t.so -o %t.so.bolt --relocs
11  */
12 
13 unsigned long long myfunc();
14 
15 unsigned long long (*myglobal)() = myfunc;
16 
17 unsigned long long myfunc() {
18   return reinterpret_cast<unsigned long long>(myglobal);
19 }
20