mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 20:56:06 +00:00

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.)
14 lines
469 B
Plaintext
14 lines
469 B
Plaintext
// Verify that PLTCall optimization works.
|
|
|
|
RUN: %clang %cflags -fpic -shared -xc /dev/null -o %t.so
|
|
// Link against a DSO to ensure PLT entries.
|
|
RUN: %clang %cflags %p/../Inputs/plt-tailcall.c %t.so \
|
|
RUN: -o %t -Wl,-q
|
|
RUN: llvm-bolt %t -o %t.bolt --plt=all --print-plt --print-only=foo | FileCheck %s
|
|
|
|
// Call to printf
|
|
CHECK: callq *printf@GOT(%rip) # PLTCall: 1
|
|
|
|
// Call to puts, that was tail-call optimized
|
|
CHECK: jmpl *puts@GOT(%rip) # TAILCALL # PLTCall: 1
|