
A few tests generate a statically-linked position-independent executable with `-nostdlib -Wl,--unresolved-symbols=ignore-all -pie` (`%clang`) and test PLT handling. (--unresolved-symbols=ignore-all suppresses undefined symbol errors and serves as a convenience hack.) This relies on an unguaranteed linker behavior: a statically-linked PIE does not necessarily generate PLT entries. While current lld generates a PLT entry, it will change to suppress the PLT entry to simplify internal handling and improve consistency. (The behavior has no consistency in GNU ld, some ports generated a .dynsym entry while some don't. While most seem to generate a PLT entry but some ports use a weird `R_*_NONE` relocation.)
24 lines
647 B
C++
24 lines
647 B
C++
// Verify that PLT optimization in BOLT preserves exception-handling info.
|
|
|
|
// REQUIRES: system-linux
|
|
|
|
// RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
|
|
// Link against a DSO to ensure PLT entries.
|
|
// RUN: %clangxx %cxxflags -O1 -Wl,-q,-znow %s %t.so -o %t.exe
|
|
// RUN: llvm-bolt %t.exe -o %t.bolt.exe --plt=all --print-only=.*main.* \
|
|
// RUN: --print-finalized 2>&1 | FileCheck %s
|
|
|
|
// CHECK-LABEL: Binary Function
|
|
// CHECK: adrp {{.*}}__cxa_throw
|
|
// CHECK-NEXT: ldr {{.*}}__cxa_throw
|
|
// CHECK-NEXT: blr x17 {{.*}} handler: {{.*}} PLTCall:
|
|
|
|
int main() {
|
|
try {
|
|
throw new int;
|
|
} catch (...) {
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|