Add first linker pass (StubsPass) which looks for calls to shared library symbols and replaces them with calls to a StubAtom. On ELF system, a "stub" is a PLT entry. Added a simple test case. Pass a Platform object to YAML reader and writer for converting fixup kinds between names and values. Change output of Resolver to be a File object instead of a vector of Atoms. Thus, passes operate on a File instead of just Atoms. Rework how to walk through a File's Atoms. Now iterator based instead of a method that visits each atom. llvm-svn: 152269
51 lines
1.4 KiB
Plaintext
51 lines
1.4 KiB
Plaintext
# RUN: lld-core %s -stubs_pass | FileCheck %s
|
|
|
|
#
|
|
# Test that stubs pass adds stubs and rebinds call sites to the stub
|
|
#
|
|
|
|
---
|
|
atoms:
|
|
- name: foo
|
|
type: code
|
|
content: [ E8, 00, 00, 00, 00, E8, 00, 00, 00,
|
|
00, 48 ,8B, 05, 00, 00, 00, 00 ]
|
|
fixups:
|
|
- offset: 1
|
|
kind: call32
|
|
target: malloc
|
|
- offset: 6
|
|
kind: call32
|
|
target: free
|
|
- offset: 13
|
|
kind: gotLoad32
|
|
target: malloc
|
|
|
|
- name: malloc
|
|
definition: shared-library
|
|
load-name: libc.so
|
|
|
|
- name: free
|
|
definition: shared-library
|
|
load-name: libc.so
|
|
|
|
...
|
|
|
|
# CHECK: name: foo
|
|
# CHECK: fixups:
|
|
# CHECK: kind: call32
|
|
# CHECK: target: L
|
|
# CHECK: kind: call32
|
|
# CHECK: target: L
|
|
# CHECK: kind: gotLoad32
|
|
# CHECK: target: malloc
|
|
# CHECK: name: L
|
|
# CHECK: type: stub
|
|
# CHECK: name: L
|
|
# CHECK: type: stub
|
|
# CHECK: name: malloc
|
|
# CHECK: definition: shared-library
|
|
# CHECK: name: free
|
|
# CHECK: definition: shared-library
|
|
# CHECK: ...
|