Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JITLink][COFF] Implement IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY/LIBRARY.
Implement IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY/LIBRARY characteristics flag. Since COFFObjectFile class will set undefined flag for symbols with no alias flag, ORC ObjectFileInterface will not pull in this symbol. So, we only need to make sure the scope is local. NOLIBRARY and LIBRARY are handled in the same way for now. (which is what lld does right now) Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D129939
- Loading branch information
Showing
4 changed files
with
127 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
llvm/test/ExecutionEngine/JITLink/X86/COFF_nolibrary_search.s
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# RUN: rm -rf %t && mkdir -p %t | ||
# RUN: yaml2obj %S/Inputs/COFF_weak_nolibrary_serach_def.yaml -o %t/COFF_weak.o | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc %s -o %t/COFF_main.o | ||
# RUN: not llvm-jitlink -noexec -abs __ImageBase=0xfff00000 \ | ||
# RUN: -slab-allocate 100Kb -slab-address 0xfff00000 -slab-page-size 4096 \ | ||
# RUN: %t/COFF_weak.o %t/COFF_main.o 2>&1 | FileCheck %s | ||
# | ||
# Check weak external symbol with IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY Characteristics | ||
# does not export symbol. | ||
# | ||
# CHECK: llvm-jitlink error: Symbols not found: [ func ] | ||
|
||
.text | ||
|
||
.def main; | ||
.scl 2; | ||
.type 32; | ||
.endef | ||
.globl main | ||
.p2align 4, 0x90 | ||
main: | ||
callq func | ||
retq |
80 changes: 80 additions & 0 deletions
80
llvm/test/ExecutionEngine/JITLink/X86/Inputs/COFF_weak_nolibrary_serach_def.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- !COFF | ||
header: | ||
Machine: IMAGE_FILE_MACHINE_AMD64 | ||
Characteristics: [ ] | ||
sections: | ||
- Name: .text | ||
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] | ||
Alignment: 16 | ||
SectionData: C3662E0F1F8400000000000F1F440000E800000000C3 | ||
Relocations: | ||
- VirtualAddress: 17 | ||
SymbolName: func | ||
Type: IMAGE_REL_AMD64_REL32 | ||
- Name: .data | ||
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] | ||
Alignment: 4 | ||
SectionData: '' | ||
- Name: .bss | ||
Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] | ||
Alignment: 4 | ||
SectionData: '' | ||
SizeOfRawData: 0 | ||
symbols: | ||
- Name: .text | ||
Value: 0 | ||
SectionNumber: 1 | ||
SimpleType: IMAGE_SYM_TYPE_NULL | ||
ComplexType: IMAGE_SYM_DTYPE_NULL | ||
StorageClass: IMAGE_SYM_CLASS_STATIC | ||
SectionDefinition: | ||
Length: 22 | ||
NumberOfRelocations: 1 | ||
NumberOfLinenumbers: 0 | ||
CheckSum: 1179995423 | ||
Number: 1 | ||
- Name: .data | ||
Value: 0 | ||
SectionNumber: 2 | ||
SimpleType: IMAGE_SYM_TYPE_NULL | ||
ComplexType: IMAGE_SYM_DTYPE_NULL | ||
StorageClass: IMAGE_SYM_CLASS_STATIC | ||
SectionDefinition: | ||
Length: 0 | ||
NumberOfRelocations: 0 | ||
NumberOfLinenumbers: 0 | ||
CheckSum: 0 | ||
Number: 2 | ||
- Name: .bss | ||
Value: 0 | ||
SectionNumber: 3 | ||
SimpleType: IMAGE_SYM_TYPE_NULL | ||
ComplexType: IMAGE_SYM_DTYPE_NULL | ||
StorageClass: IMAGE_SYM_CLASS_STATIC | ||
SectionDefinition: | ||
Length: 0 | ||
NumberOfRelocations: 0 | ||
NumberOfLinenumbers: 0 | ||
CheckSum: 0 | ||
Number: 3 | ||
- Name: func | ||
Value: 0 | ||
SectionNumber: 0 | ||
SimpleType: IMAGE_SYM_TYPE_NULL | ||
ComplexType: IMAGE_SYM_DTYPE_NULL | ||
StorageClass: IMAGE_SYM_CLASS_WEAK_EXTERNAL | ||
WeakExternal: | ||
TagIndex: 8 | ||
Characteristics: IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY | ||
- Name: .weak.func.default.main | ||
Value: 0 | ||
SectionNumber: 1 | ||
SimpleType: IMAGE_SYM_TYPE_NULL | ||
ComplexType: IMAGE_SYM_DTYPE_FUNCTION | ||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL | ||
- Name: using_func | ||
Value: 16 | ||
SectionNumber: 1 | ||
SimpleType: IMAGE_SYM_TYPE_NULL | ||
ComplexType: IMAGE_SYM_DTYPE_FUNCTION | ||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL |