
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.)
18 lines
664 B
Plaintext
18 lines
664 B
Plaintext
// This test checks that the pointers to PLT are properly updated.
|
|
// The test uses lld and links against a DSO to ensure PLT entries.
|
|
RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
|
|
|
|
// Non-PIE:
|
|
RUN: %clang %cflags -no-pie %p/../Inputs/plt.c %t.so -fuse-ld=lld \
|
|
RUN: -o %t.lld.exe -Wl,-q
|
|
RUN: llvm-bolt %t.lld.exe -o %t.lld.bolt.exe --use-old-text=0 --lite=0
|
|
RUN: %t.lld.bolt.exe | FileCheck %s
|
|
|
|
// PIE:
|
|
RUN: %clang %cflags -fPIC -pie %p/../Inputs/plt.c %t.so -fuse-ld=lld \
|
|
RUN: -o %t.lld.pie.exe -Wl,-q
|
|
RUN: llvm-bolt %t.lld.pie.exe -o %t.lld.bolt.pie.exe --use-old-text=0 --lite=0
|
|
RUN: %t.lld.bolt.pie.exe | FileCheck %s
|
|
|
|
CHECK: Test completed
|