aboutsummaryrefslogtreecommitdiff
path: root/test/COFF
diff options
context:
space:
mode:
Diffstat (limited to 'test/COFF')
-rw-r--r--test/COFF/Inputs/combined-resources-2.rc36
-rw-r--r--test/COFF/Inputs/combined-resources-2.resbin0 -> 452 bytes
-rw-r--r--test/COFF/Inputs/combined-resources-cursor.bmpbin0 -> 822 bytes
-rw-r--r--test/COFF/Inputs/combined-resources-okay.bmpbin0 -> 822 bytes
-rw-r--r--test/COFF/Inputs/combined-resources.rc50
-rw-r--r--test/COFF/Inputs/combined-resources.resbin0 -> 2332 bytes
-rw-r--r--test/COFF/Inputs/pdb-global-gc.s4
-rw-r--r--test/COFF/Inputs/pdb-import-gc.libbin0 -> 1614 bytes
-rw-r--r--test/COFF/combined-resources.test17
-rw-r--r--test/COFF/hello32.test1
-rw-r--r--test/COFF/pdb-comdat.test67
-rw-r--r--test/COFF/pdb-global-gc.yaml116
-rw-r--r--test/COFF/pdb-import-gc.yaml114
-rw-r--r--test/COFF/pdb-safeseh.yaml24
-rw-r--r--test/COFF/pdb-secrel-absolute.yaml24
-rw-r--r--test/COFF/pdb-symbol-types.yaml134
-rw-r--r--test/COFF/reloc-discarded.s30
-rw-r--r--test/COFF/resource.test38
-rw-r--r--test/COFF/secrel-absolute.s2
19 files changed, 528 insertions, 129 deletions
diff --git a/test/COFF/Inputs/combined-resources-2.rc b/test/COFF/Inputs/combined-resources-2.rc
new file mode 100644
index 000000000000..081b3a77bebc
--- /dev/null
+++ b/test/COFF/Inputs/combined-resources-2.rc
@@ -0,0 +1,36 @@
+#include "windows.h"
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+randomdat RCDATA
+{
+ "this is a random bit of data that means nothing\0",
+ 0x23a9,
+ 0x140e,
+ 194292,
+}
+
+LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
+randomdat RCDATA
+{
+ "zhe4 shi4 yi1ge4 sui2ji1 de shu4ju4, zhe4 yi4wei4zhe shen2me\0",
+ 0x23a9,
+ 0x140e,
+ 194292,
+}
+
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_LUXEMBOURG
+randomdat RCDATA
+{
+ "Dies ist ein zufälliges Bit von Daten, die nichts bedeutet\0",
+ 0x23a9,
+ 0x140e,
+ 194292,
+}
+
+LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
+myaccelerators ACCELERATORS
+{
+ "^C", 999, VIRTKEY, ALT
+ "D", 1100, VIRTKEY, CONTROL, SHIFT
+ "^R", 444, ASCII, NOINVERT
+}
diff --git a/test/COFF/Inputs/combined-resources-2.res b/test/COFF/Inputs/combined-resources-2.res
new file mode 100644
index 000000000000..31da6166d7f6
--- /dev/null
+++ b/test/COFF/Inputs/combined-resources-2.res
Binary files differ
diff --git a/test/COFF/Inputs/combined-resources-cursor.bmp b/test/COFF/Inputs/combined-resources-cursor.bmp
new file mode 100644
index 000000000000..ce513261bc2c
--- /dev/null
+++ b/test/COFF/Inputs/combined-resources-cursor.bmp
Binary files differ
diff --git a/test/COFF/Inputs/combined-resources-okay.bmp b/test/COFF/Inputs/combined-resources-okay.bmp
new file mode 100644
index 000000000000..e4005bf5ef97
--- /dev/null
+++ b/test/COFF/Inputs/combined-resources-okay.bmp
Binary files differ
diff --git a/test/COFF/Inputs/combined-resources.rc b/test/COFF/Inputs/combined-resources.rc
new file mode 100644
index 000000000000..08bfb94c44ae
--- /dev/null
+++ b/test/COFF/Inputs/combined-resources.rc
@@ -0,0 +1,50 @@
+#include "windows.h"
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+myaccelerators ACCELERATORS
+{
+ "^C", 999, VIRTKEY, ALT
+ "D", 1100, VIRTKEY, CONTROL, SHIFT
+ "^R", 444, ASCII, NOINVERT
+}
+
+cursor BITMAP "combined-resources-cursor.bmp"
+okay BITMAP "combined-resources-okay.bmp"
+
+14432 MENU
+LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
+{
+ MENUITEM "yu", 100
+ MENUITEM "shala", 101
+ MENUITEM "kaoya", 102
+}
+
+testdialog DIALOG 10, 10, 200, 300
+STYLE WS_POPUP | WS_BORDER
+CAPTION "Test"
+{
+ CTEXT "Continue:", 1, 10, 10, 230, 14
+ PUSHBUTTON "&OK", 2, 66, 134, 161, 13
+}
+
+12 ACCELERATORS
+{
+ "X", 164, VIRTKEY, ALT
+ "H", 5678, VIRTKEY, CONTROL, SHIFT
+ "^R", 444, ASCII, NOINVERT
+}
+
+"eat" MENU
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
+{
+ MENUITEM "fish", 100
+ MENUITEM "salad", 101
+ MENUITEM "duck", 102
+}
+
+
+myresource stringarray {
+ "this is a user defined resource\0",
+ "it contains many strings\0",
+}
diff --git a/test/COFF/Inputs/combined-resources.res b/test/COFF/Inputs/combined-resources.res
new file mode 100644
index 000000000000..d422bb4904da
--- /dev/null
+++ b/test/COFF/Inputs/combined-resources.res
Binary files differ
diff --git a/test/COFF/Inputs/pdb-global-gc.s b/test/COFF/Inputs/pdb-global-gc.s
new file mode 100644
index 000000000000..4c931dca015c
--- /dev/null
+++ b/test/COFF/Inputs/pdb-global-gc.s
@@ -0,0 +1,4 @@
+.section .data,"dw",one_only,__wc_mb_cur
+.global __wc_mb_cur
+__wc_mb_cur:
+.long 42
diff --git a/test/COFF/Inputs/pdb-import-gc.lib b/test/COFF/Inputs/pdb-import-gc.lib
new file mode 100644
index 000000000000..f4682eddb6e8
--- /dev/null
+++ b/test/COFF/Inputs/pdb-import-gc.lib
Binary files differ
diff --git a/test/COFF/combined-resources.test b/test/COFF/combined-resources.test
new file mode 100644
index 000000000000..dc6c87af0f77
--- /dev/null
+++ b/test/COFF/combined-resources.test
@@ -0,0 +1,17 @@
+// Check that lld properly handles merging multiple .res files.
+// The inputs were generated with the following commands, using the original
+// Windows rc.exe
+// > rc /fo combined-resources.res /nologo combined-resources.rc
+// > rc /fo combined-resources-2.res /nologo combined-resources-2.rc
+
+# RUN: yaml2obj < %p/Inputs/ret42.yaml > %t.obj
+# RUN: lld-link /out:%t.exe /entry:main %t.obj %p/Inputs/resource.res \
+# RUN: %p/Inputs/combined-resources.res %p/Inputs/combined-resources-2.res
+
+# RUN: llvm-readobj -coff-resources -file-headers %t.exe | FileCheck %s
+
+
+CHECK: ResourceTableRVA: 0x1000
+CHECK-NEXT: ResourceTableSize: 0xC1C
+CHECK-DAG: Resources [
+CHECK-NEXT: Total Number of Resources: 13
diff --git a/test/COFF/hello32.test b/test/COFF/hello32.test
index 9464a3c114eb..e987bb953890 100644
--- a/test/COFF/hello32.test
+++ b/test/COFF/hello32.test
@@ -21,6 +21,7 @@ HEADER-NEXT: IMAGE_FILE_EXECUTABLE_IMAGE (0x2)
HEADER-NEXT: ]
HEADER-NEXT: }
HEADER-NEXT: ImageOptionalHeader {
+HEADER-NEXT: Magic: 0x10B
HEADER-NEXT: MajorLinkerVersion: 14
HEADER-NEXT: MinorLinkerVersion: 0
HEADER-NEXT: SizeOfCode: 512
diff --git a/test/COFF/pdb-comdat.test b/test/COFF/pdb-comdat.test
index 769b630d0e8d..a7b5c401ab92 100644
--- a/test/COFF/pdb-comdat.test
+++ b/test/COFF/pdb-comdat.test
@@ -41,49 +41,48 @@ CHECK-LABEL: Mod 0002 | `* Linker *`:
CHECK: Symbols
CHECK: ============================================================
CHECK-LABEL: Mod 0000 | `{{.*}}pdb_comdat_main.obj`:
-CHECK: - S_OBJNAME [size = 56] sig=0, `C:\src\llvm-project\build\pdb_comdat_main.obj`
-CHECK: - S_COMPILE3 [size = 60]
-CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c
-CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1
-CHECK: flags = security checks | hot patchable
-CHECK: - S_GPROC32_ID [size = 44] `main`
- FIXME: We need to fill in "end".
-CHECK: parent = 0, addr = 0002:0000, code size = 24, end = 0
-CHECK: debug start = 4, debug end = 19, flags = none
-CHECK: - S_FRAMEPROC [size = 32]
-CHECK: size = 40, padding size = 0, offset to padding = 0
-CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000
-CHECK: flags = has async eh | opt speed
-CHECK: - S_END [size = 4]
-CHECK: - S_GDATA32 [size = 24] `global`
-CHECK: type = 0x0074 (int), addr = 0000:0000
-CHECK: - S_BUILDINFO [size = 8] BuildId = `4106`
-CHECK: - S_GPROC32_ID [size = 44] `foo`
-CHECK: parent = 0, addr = 0002:0032, code size = 15, end = 0
-CHECK: debug start = 0, debug end = 14, flags = none
-CHECK: - S_FRAMEPROC [size = 32]
-CHECK: size = 0, padding size = 0, offset to padding = 0
-CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000
-CHECK: flags = marked inline | has async eh | opt speed
-CHECK: - S_END [size = 4]
+CHECK: 4 | S_OBJNAME [size = 56] sig=0, `C:\src\llvm-project\build\pdb_comdat_main.obj`
+CHECK: 60 | S_COMPILE3 [size = 60]
+CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c
+CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1
+CHECK: flags = security checks | hot patchable
+CHECK: 120 | S_GPROC32_ID [size = 44] `main`
+CHECK: parent = 0, end = 0, addr = 0002:0000, code size = 24
+CHECK: debug start = 4, debug end = 19, flags = none
+CHECK: 164 | S_FRAMEPROC [size = 32]
+CHECK: size = 40, padding size = 0, offset to padding = 0
+CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000
+CHECK: flags = has async eh | opt speed
+CHECK: 196 | S_END [size = 4]
+CHECK: 200 | S_GDATA32 [size = 24] `global`
+CHECK: type = 0x0074 (int), addr = 0000:0000
+CHECK: 224 | S_BUILDINFO [size = 8] BuildId = `4106`
+CHECK: 232 | S_GPROC32_ID [size = 44] `foo`
+CHECK: parent = 0, end = 0, addr = 0002:0032, code size = 15
+CHECK: debug start = 0, debug end = 14, flags = none
+CHECK: 276 | S_FRAMEPROC [size = 32]
+CHECK: size = 0, padding size = 0, offset to padding = 0
+CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000
+CHECK: flags = marked inline | has async eh | opt speed
+CHECK: 308 | S_END [size = 4]
CHECK-LABEL: Mod 0001 | `{{.*}}pdb_comdat_bar.obj`:
-CHECK: - S_OBJNAME [size = 56] sig=0, `C:\src\llvm-project\build\pdb_comdat_bar.obj`
-CHECK: - S_COMPILE3 [size = 60]
+CHECK: 4 | S_OBJNAME [size = 56] sig=0, `C:\src\llvm-project\build\pdb_comdat_bar.obj`
+CHECK: 60 | S_COMPILE3 [size = 60]
CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c
CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1
CHECK: flags = security checks | hot patchable
-CHECK: - S_GPROC32_ID [size = 44] `bar`
-CHECK: parent = 0, addr = 0002:0048, code size = 14, end = 0
+CHECK: 120 | S_GPROC32_ID [size = 44] `bar`
+CHECK: parent = 0, end = 0, addr = 0002:0048, code size = 14
CHECK: debug start = 4, debug end = 9, flags = none
-CHECK: - S_FRAMEPROC [size = 32]
+CHECK: 164 | S_FRAMEPROC [size = 32]
CHECK: size = 40, padding size = 0, offset to padding = 0
CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000
CHECK: flags = has async eh | opt speed
-CHECK: - S_END [size = 4]
-CHECK: - S_GDATA32 [size = 24] `global`
+CHECK: 196 | S_END [size = 4]
+CHECK: 200 | S_GDATA32 [size = 24] `global`
CHECK: type = 0x0074 (int), addr = 0000:0000
-CHECK: - S_BUILDINFO [size = 8] BuildId = `4109`
-CHECK-NOT: - S_GPROC32_ID {{.*}} `foo`
+CHECK: 224 | S_BUILDINFO [size = 8] BuildId = `4109`
+CHECK-NOT: S_GPROC32_ID {{.*}} `foo`
CHECK-LABEL: Mod 0002 | `* Linker *`:
Reorder the object files and verify that the other table is selected.
diff --git a/test/COFF/pdb-global-gc.yaml b/test/COFF/pdb-global-gc.yaml
new file mode 100644
index 000000000000..b66b3f2ca7b8
--- /dev/null
+++ b/test/COFF/pdb-global-gc.yaml
@@ -0,0 +1,116 @@
+# RUN: yaml2obj %s -o %t.obj
+# RUN: llvm-mc %S/Inputs/pdb-global-gc.s -triple x86_64-windows-msvc -filetype=obj -o %t2.obj
+# RUN: lld-link %t.obj %t2.obj -debug -entry:main \
+# RUN: -nodefaultlib -debug -out:%t.exe -pdb:%t.pdb -verbose
+# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s
+
+# This tests the case where an __imp_ chunk is discarded by linker GC. The debug
+# info may refer to the __imp_ symbol still.
+
+# Compile this code with MSVC to regenerate the test case:
+# extern char __declspec(dllimport) __wc_mb_cur;
+# int discarded() { return __wc_mb_cur; }
+# int main() { return g2; }
+
+# CHECK: Symbols
+# CHECK: ============================================================
+# CHECK: Mod 0000 | `{{.*}}pdb-global-gc.yaml.tmp.obj`:
+# CHECK: 4 | S_GDATA32 [size = 28] `__wc_mb_cur`
+# CHECK-NEXT: type = 0x0070 (char), addr = 0000:0000
+# CHECK: Mod 0001 | `{{.*}}pdb-global-gc.yaml.tmp2.obj`:
+# CHECK: Mod 0002 | `* Linker *`:
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: [ ]
+sections:
+ - Name: '.debug$S'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ Subsections:
+ - !Symbols
+ Records:
+ - Kind: S_GDATA32
+ DataSym:
+ Type: 112
+ DisplayName: __wc_mb_cur
+ - !StringTable
+ Strings:
+ Relocations:
+ - VirtualAddress: 20
+ SymbolName: __wc_mb_cur
+ Type: IMAGE_REL_AMD64_SECREL
+ - VirtualAddress: 24
+ SymbolName: __wc_mb_cur
+ Type: IMAGE_REL_AMD64_SECTION
+ - Name: '.text$mn'
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 16
+ SectionData: 0FBE0500000000C3
+ Relocations:
+ - VirtualAddress: 3
+ SymbolName: __wc_mb_cur
+ Type: IMAGE_REL_AMD64_REL32
+ - Name: '.text$mn'
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 16
+ SectionData: B82A000000C3
+symbols:
+ - Name: '.debug$S'
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 240
+ NumberOfRelocations: 2
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+ - Name: '.text$mn'
+ Value: 0
+ SectionNumber: 2
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 11
+ NumberOfRelocations: 1
+ NumberOfLinenumbers: 0
+ CheckSum: 2906070869
+ Number: 0
+ Selection: IMAGE_COMDAT_SELECT_NODUPLICATES
+ - Name: '.text$mn'
+ Value: 0
+ SectionNumber: 3
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 6
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 2139436471
+ Number: 0
+ Selection: IMAGE_COMDAT_SELECT_NODUPLICATES
+ - Name: discarded
+ Value: 0
+ SectionNumber: 2
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: main
+ Value: 0
+ SectionNumber: 3
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: __wc_mb_cur
+ Value: 0
+ SectionNumber: 0
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
diff --git a/test/COFF/pdb-import-gc.yaml b/test/COFF/pdb-import-gc.yaml
new file mode 100644
index 000000000000..80484cb75f4f
--- /dev/null
+++ b/test/COFF/pdb-import-gc.yaml
@@ -0,0 +1,114 @@
+# RUN: yaml2obj %s -o %t.obj
+# RUN: lld-link %t.obj %S/Inputs/pdb-import-gc.lib -debug -entry:main \
+# RUN: -nodefaultlib -debug -out:%t.exe -pdb:%t.pdb
+# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s
+
+# This tests the case where an __imp_ chunk is discarded by linker GC. The debug
+# info may refer to the __imp_ symbol still.
+
+# Compile this code with MSVC to regenerate the test case:
+# extern char __declspec(dllimport) __wc_mb_cur;
+# int discarded() { return __wc_mb_cur; }
+# int main() { return g2; }
+
+# CHECK: Symbols
+# CHECK: ============================================================
+# CHECK: Mod 0000 | `{{.*}}pdb-import-gc.yaml.tmp.obj`:
+# CHECK: 4 | S_GDATA32 [size = 32] `__imp___wc_mb_cur`
+# CHECK-NEXT: type = 0x0070 (char), addr = 0000:0000
+# CHECK: Mod 0001 | `* Linker *`:
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: [ ]
+sections:
+ - Name: '.debug$S'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ Subsections:
+ - !Symbols
+ Records:
+ - Kind: S_GDATA32
+ DataSym:
+ Type: 112
+ DisplayName: __imp___wc_mb_cur
+ - !StringTable
+ Strings:
+ Relocations:
+ - VirtualAddress: 20
+ SymbolName: __imp___wc_mb_cur
+ Type: IMAGE_REL_AMD64_SECREL
+ - VirtualAddress: 24
+ SymbolName: __imp___wc_mb_cur
+ Type: IMAGE_REL_AMD64_SECTION
+ - Name: '.text$mn'
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 16
+ SectionData: 488B05000000000FBE00C3
+ Relocations:
+ - VirtualAddress: 3
+ SymbolName: __imp___wc_mb_cur
+ Type: IMAGE_REL_AMD64_REL32
+ - Name: '.text$mn'
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 16
+ SectionData: B82A000000C3
+symbols:
+ - Name: '.debug$S'
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 240
+ NumberOfRelocations: 2
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+ - Name: '.text$mn'
+ Value: 0
+ SectionNumber: 2
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 11
+ NumberOfRelocations: 1
+ NumberOfLinenumbers: 0
+ CheckSum: 2906070869
+ Number: 0
+ Selection: IMAGE_COMDAT_SELECT_NODUPLICATES
+ - Name: '.text$mn'
+ Value: 0
+ SectionNumber: 3
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 6
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 2139436471
+ Number: 0
+ Selection: IMAGE_COMDAT_SELECT_NODUPLICATES
+ - Name: discarded
+ Value: 0
+ SectionNumber: 2
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: main
+ Value: 0
+ SectionNumber: 3
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: __imp___wc_mb_cur
+ Value: 0
+ SectionNumber: 0
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
diff --git a/test/COFF/pdb-safeseh.yaml b/test/COFF/pdb-safeseh.yaml
index 9faa5042924d..24215bd11dbe 100644
--- a/test/COFF/pdb-safeseh.yaml
+++ b/test/COFF/pdb-safeseh.yaml
@@ -8,28 +8,28 @@
# MSVC's for these absolute, linker-provided symbols.
# CHECK: Mod 0000 |
-# CHECK-NEXT: - S_GDATA32 [size = 40] `___safe_se_handler_table`
+# CHECK-NEXT: 4 | S_GDATA32 [size = 40] `___safe_se_handler_table`
# CHECK-NEXT: type = 0x0022 (unsigned long), addr = 0003:0000
# CHECK-NEXT: Mod 0001 | `* Linker *`:
--- !COFF
-header:
+header:
Machine: IMAGE_FILE_MACHINE_I386
Characteristics: [ ]
-sections:
+sections:
- Name: '.debug$S'
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
Alignment: 1
- Subsections:
+ Subsections:
- !Symbols
- Records:
+ Records:
- Kind: S_GDATA32
- DataSym:
+ DataSym:
Type: 34
DisplayName: ___safe_se_handler_table
- !StringTable
- Strings:
- Relocations:
+ Strings:
+ Relocations:
- VirtualAddress: 20
SymbolName: ___safe_se_handler_table
Type: IMAGE_REL_I386_SECREL
@@ -40,18 +40,18 @@ sections:
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
Alignment: 16
SectionData: 488D0500000000C3
- Relocations:
+ Relocations:
- VirtualAddress: 3
SymbolName: ___safe_se_handler_table
Type: IMAGE_REL_I386_REL32
-symbols:
+symbols:
- Name: '.debug$S'
Value: 0
SectionNumber: 1
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
+ SectionDefinition:
Length: 372
NumberOfRelocations: 6
NumberOfLinenumbers: 0
@@ -63,7 +63,7 @@ symbols:
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
+ SectionDefinition:
Length: 8
NumberOfRelocations: 1
NumberOfLinenumbers: 0
diff --git a/test/COFF/pdb-secrel-absolute.yaml b/test/COFF/pdb-secrel-absolute.yaml
index d74f07e32b98..c514e54e99f1 100644
--- a/test/COFF/pdb-secrel-absolute.yaml
+++ b/test/COFF/pdb-secrel-absolute.yaml
@@ -8,28 +8,28 @@
# MSVC's for these absolute, linker-provided symbols.
# CHECK: Mod 0000 |
-# CHECK-NEXT: - S_GDATA32 [size = 36] `__guard_fids_table`
+# CHECK-NEXT: 4 | S_GDATA32 [size = 36] `__guard_fids_table`
# CHECK-NEXT: type = 0x0022 (unsigned long), addr = 0003:0000
# CHECK-NEXT: Mod 0001 | `* Linker *`:
--- !COFF
-header:
+header:
Machine: IMAGE_FILE_MACHINE_AMD64
Characteristics: [ ]
-sections:
+sections:
- Name: '.debug$S'
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
Alignment: 1
- Subsections:
+ Subsections:
- !Symbols
- Records:
+ Records:
- Kind: S_GDATA32
- DataSym:
+ DataSym:
Type: 34
DisplayName: __guard_fids_table
- !StringTable
- Strings:
- Relocations:
+ Strings:
+ Relocations:
- VirtualAddress: 20
SymbolName: __guard_fids_table
Type: IMAGE_REL_AMD64_SECREL
@@ -40,18 +40,18 @@ sections:
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
Alignment: 16
SectionData: 488D0500000000C3
- Relocations:
+ Relocations:
- VirtualAddress: 3
SymbolName: __guard_fids_table
Type: IMAGE_REL_AMD64_REL32
-symbols:
+symbols:
- Name: '.debug$S'
Value: 0
SectionNumber: 1
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
+ SectionDefinition:
Length: 372
NumberOfRelocations: 6
NumberOfLinenumbers: 0
@@ -63,7 +63,7 @@ symbols:
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
+ SectionDefinition:
Length: 8
NumberOfRelocations: 1
NumberOfLinenumbers: 0
diff --git a/test/COFF/pdb-symbol-types.yaml b/test/COFF/pdb-symbol-types.yaml
index 4951aa8be379..eceb434f0d0f 100644
--- a/test/COFF/pdb-symbol-types.yaml
+++ b/test/COFF/pdb-symbol-types.yaml
@@ -16,33 +16,33 @@
# CHECK: Symbols
# CHECK: ============================================================
# CHECK-LABEL: Mod 0000 | `{{.*}}pdb-symbol-types.yaml.tmp.obj`:
-# CHECK: - S_OBJNAME [size = 52] sig=0, `C:\src\llvm-project\build\symbol-types.obj`
-# CHECK: - S_COMPILE3 [size = 60]
-# CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c
-# CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1
-# CHECK: flags = security checks | hot patchable
-# CHECK: - S_GPROC32_ID [size = 44] `main`
-# CHECK: parent = 0, addr = 0002:0000, code size = 7, end = 0
-# CHECK: debug start = 0, debug end = 6, flags = none
-# CHECK: - S_FRAMEPROC [size = 32]
-# CHECK: size = 0, padding size = 0, offset to padding = 0
-# CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000
-# CHECK: flags = has async eh | opt speed
-# CHECK: - S_END [size = 4]
-# CHECK: - S_GDATA32 [size = 28] `global_foo`
-# CHECK: type = 0x1004 (Foo), addr = 0001:0000
-# CHECK: - S_UDT [size = 16] `UDT_Foo`
-# CHECK: original type = 0x1004
-# CHECK: - S_UDT [size = 12] `Foo`
-# CHECK: original type = 0x1004
-# CHECK: - S_BUILDINFO [size = 8] BuildId = `4106`
+# CHECK: 4 | S_OBJNAME [size = 52] sig=0, `C:\src\llvm-project\build\symbol-types.obj`
+# CHECK: 56 | S_COMPILE3 [size = 60]
+# CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c
+# CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1
+# CHECK: flags = security checks | hot patchable
+# CHECK: 116 | S_GPROC32_ID [size = 44] `main`
+# CHECK: parent = 0, end = 0, addr = 0002:0000, code size = 7
+# CHECK: debug start = 0, debug end = 6, flags = none
+# CHECK: 160 | S_FRAMEPROC [size = 32]
+# CHECK: size = 0, padding size = 0, offset to padding = 0
+# CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000
+# CHECK: flags = has async eh | opt speed
+# CHECK: 192 | S_END [size = 4]
+# CHECK: 196 | S_GDATA32 [size = 28] `global_foo`
+# CHECK: type = 0x1004 (Foo), addr = 0001:0000
+# CHECK: 224 | S_UDT [size = 16] `UDT_Foo`
+# CHECK: original type = 0x1004
+# CHECK: 240 | S_UDT [size = 12] `Foo`
+# CHECK: original type = 0x1004
+# CHECK: 252 | S_BUILDINFO [size = 8] BuildId = `4106`
# CHECK-LABEL: Mod 0001 | `* Linker *`:
--- !COFF
-header:
+header:
Machine: IMAGE_FILE_MACHINE_AMD64
Characteristics: [ ]
-sections:
+sections:
- Name: .drectve
Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]
Alignment: 1
@@ -50,15 +50,15 @@ sections:
- Name: '.debug$S'
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
Alignment: 1
- Subsections:
+ Subsections:
- !Symbols
- Records:
+ Records:
- Kind: S_OBJNAME
- ObjNameSym:
+ ObjNameSym:
Signature: 0
ObjectName: 'C:\src\llvm-project\build\symbol-types.obj'
- Kind: S_COMPILE3
- Compile3Sym:
+ Compile3Sym:
Flags: [ SecurityChecks, HotPatch ]
Machine: X64
FrontendMajor: 19
@@ -71,9 +71,9 @@ sections:
BackendQFE: 1
Version: 'Microsoft (R) Optimizing Compiler'
- !Symbols
- Records:
+ Records:
- Kind: S_GPROC32_ID
- ProcSym:
+ ProcSym:
CodeSize: 7
DbgStart: 0
DbgEnd: 6
@@ -81,7 +81,7 @@ sections:
Flags: [ ]
DisplayName: main
- Kind: S_FRAMEPROC
- FrameProcSym:
+ FrameProcSym:
TotalFrameBytes: 0
PaddingFrameBytes: 0
OffsetToPadding: 0
@@ -90,15 +90,15 @@ sections:
SectionIdOfExceptionHandler: 0
Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ]
- Kind: S_PROC_ID_END
- ScopeEndSym:
+ ScopeEndSym:
- !Lines
CodeSize: 7
Flags: [ ]
RelocOffset: 0
RelocSegment: 0
- Blocks:
+ Blocks:
- FileName: 'c:\src\llvm-project\build\symbol-types.c'
- Lines:
+ Lines:
- Offset: 0
LineStart: 4
IsStatement: true
@@ -111,35 +111,35 @@ sections:
LineStart: 6
IsStatement: true
EndDelta: 0
- Columns:
+ Columns:
- !Symbols
- Records:
+ Records:
- Kind: S_GDATA32
- DataSym:
+ DataSym:
Type: 4101
DisplayName: global_foo
- Kind: S_UDT
- UDTSym:
+ UDTSym:
Type: 4101
UDTName: UDT_Foo
- Kind: S_UDT
- UDTSym:
+ UDTSym:
Type: 4101
UDTName: Foo
- !FileChecksums
- Checksums:
+ Checksums:
- FileName: 'c:\src\llvm-project\build\symbol-types.c'
Kind: MD5
Checksum: F833E1A4909FF6FEC5689A664F3BE725
- !StringTable
- Strings:
+ Strings:
- 'c:\src\llvm-project\build\symbol-types.c'
- !Symbols
- Records:
+ Records:
- Kind: S_BUILDINFO
- BuildInfoSym:
+ BuildInfoSym:
BuildId: 4111
- Relocations:
+ Relocations:
- VirtualAddress: 164
SymbolName: main
Type: IMAGE_REL_AMD64_SECREL
@@ -161,24 +161,24 @@ sections:
- Name: '.debug$T'
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
Alignment: 1
- Types:
+ Types:
- Kind: LF_ARGLIST
- ArgList:
+ ArgList:
ArgIndices: [ 0 ]
- Kind: LF_PROCEDURE
- Procedure:
+ Procedure:
ReturnType: 116
CallConv: NearC
Options: [ None ]
ParameterCount: 0
ArgumentList: 4096
- Kind: LF_FUNC_ID
- FuncId:
+ FuncId:
ParentScope: 0
FunctionType: 4097
Name: main
- Kind: LF_STRUCTURE
- Class:
+ Class:
MemberCount: 0
Options: [ None, ForwardReference, HasUniqueName ]
FieldList: 0
@@ -188,15 +188,15 @@ sections:
VTableShape: 0
Size: 0
- Kind: LF_FIELDLIST
- FieldList:
+ FieldList:
- Kind: LF_MEMBER
- DataMember:
+ DataMember:
Attrs: 3
Type: 116
FieldOffset: 0
Name: x
- Kind: LF_STRUCTURE
- Class:
+ Class:
MemberCount: 1
Options: [ None, HasUniqueName ]
FieldList: 4100
@@ -206,43 +206,43 @@ sections:
VTableShape: 0
Size: 4
- Kind: LF_STRING_ID
- StringId:
+ StringId:
Id: 0
String: 'c:\src\llvm-project\build\symbol-types.c'
- Kind: LF_UDT_SRC_LINE
- UdtSourceLine:
+ UdtSourceLine:
UDT: 4101
SourceFile: 4102
LineNumber: 1
- Kind: LF_STRING_ID
- StringId:
+ StringId:
Id: 0
String: 'C:\src\llvm-project\build'
- Kind: LF_STRING_ID
- StringId:
+ StringId:
Id: 0
String: 'C:\PROGRA~2\MICROS~1.0\VC\Bin\amd64\cl.exe'
- Kind: LF_STRING_ID
- StringId:
+ StringId:
Id: 0
String: '-c -Z7 -MT -IC:\PROGRA~2\MICROS~1.0\VC\include -IC:\PROGRA~2\MICROS~1.0\VC\atlmfc\include -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\ucrt -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\shared -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\um'
- Kind: LF_SUBSTR_LIST
- StringList:
+ StringList:
StringIndices: [ 4106 ]
- Kind: LF_STRING_ID
- StringId:
+ StringId:
Id: 4107
String: ' -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\winrt -TC -X'
- Kind: LF_STRING_ID
- StringId:
+ StringId:
Id: 0
String: symbol-types.c
- Kind: LF_STRING_ID
- StringId:
+ StringId:
Id: 0
String: 'C:\src\llvm-project\build\vc140.pdb'
- Kind: LF_BUILDINFO
- BuildInfo:
+ BuildInfo:
ArgIndices: [ 4104, 4105, 4109, 4110, 4108 ]
- Name: .data
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
@@ -252,11 +252,11 @@ sections:
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
Alignment: 16
SectionData: 8B0500000000C3
- Relocations:
+ Relocations:
- VirtualAddress: 2
SymbolName: global_foo
Type: IMAGE_REL_AMD64_REL32
-symbols:
+symbols:
- Name: '@comp.id'
Value: 17063575
SectionNumber: -1
@@ -275,7 +275,7 @@ symbols:
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
+ SectionDefinition:
Length: 47
NumberOfRelocations: 0
NumberOfLinenumbers: 0
@@ -287,7 +287,7 @@ symbols:
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
+ SectionDefinition:
Length: 432
NumberOfRelocations: 6
NumberOfLinenumbers: 0
@@ -299,7 +299,7 @@ symbols:
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
+ SectionDefinition:
Length: 732
NumberOfRelocations: 0
NumberOfLinenumbers: 0
@@ -311,7 +311,7 @@ symbols:
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
+ SectionDefinition:
Length: 4
NumberOfRelocations: 0
NumberOfLinenumbers: 0
@@ -329,7 +329,7 @@ symbols:
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
+ SectionDefinition:
Length: 7
NumberOfRelocations: 1
NumberOfLinenumbers: 0
diff --git a/test/COFF/reloc-discarded.s b/test/COFF/reloc-discarded.s
new file mode 100644
index 000000000000..94eaba998330
--- /dev/null
+++ b/test/COFF/reloc-discarded.s
@@ -0,0 +1,30 @@
+# RUN: echo -e '.section .bss,"bw",discard,main_global\n.global main_global\n main_global:\n .long 0' | \
+# RUN: llvm-mc - -filetype=obj -o %t1.obj -triple x86_64-windows-msvc
+# RUN: llvm-mc %s -filetype=obj -o %t2.obj -triple x86_64-windows-msvc
+
+# LLD should report an error and not assert regardless of whether we are doing
+# GC.
+
+# RUN: not lld-link -entry:main -nodefaultlib %t1.obj %t2.obj -out:%t.exe -opt:ref 2>&1 | FileCheck %s
+# RUN: not lld-link -entry:main -nodefaultlib %t1.obj %t2.obj -out:%t.exe -opt:noref 2>&1 | FileCheck %s
+
+# CHECK: error: relocation against symbol in discarded section: assoc_global
+
+ .section .bss,"bw",discard,main_global
+ .globl main_global
+ .p2align 2
+main_global:
+ .long 0
+
+ .section .CRT$XCU,"dr",associative,main_global
+ .p2align 3
+ .globl assoc_global
+assoc_global:
+ .quad main_global
+
+ .text
+ .globl main
+main:
+ movq assoc_global(%rip), %rax
+ movl (%rax), %eax
+ retq
diff --git a/test/COFF/resource.test b/test/COFF/resource.test
index a73a20258201..53242cdcb63a 100644
--- a/test/COFF/resource.test
+++ b/test/COFF/resource.test
@@ -6,7 +6,39 @@
EXE: {{H.e.l.l.o}}
-# RUN: llvm-readobj -file-headers %t.exe | FileCheck --check-prefix=HEADER %s
+# Verify the resource tree layout in the final executable.
+# RUN: llvm-readobj -file-headers -coff-resources -section-data %t.exe | \
+# RUN: FileCheck --check-prefix=RESOURCE_INFO %s
-HEADER: ResourceTableRVA: 0x1000
-HEADER: ResourceTableSize: 0x88
+RESOURCE_INFO: ResourceTableRVA: 0x1000
+RESOURCE_INFO-NEXT: ResourceTableSize: 0x88
+RESOURCE_INFO-DAG: Resources [
+RESOURCE_INFO-NEXT: Total Number of Resources: 1
+RESOURCE_INFO-NEXT: Base Table Address: 0x400
+RESOURCE_INFO-DAG: Number of String Entries: 0
+RESOURCE_INFO-NEXT: Number of ID Entries: 1
+RESOURCE_INFO-NEXT: Type: kRT_STRING (ID 6) [
+RESOURCE_INFO-NEXT: Table Offset: 0x18
+RESOURCE_INFO-NEXT: Number of String Entries: 0
+RESOURCE_INFO-NEXT: Number of ID Entries: 1
+RESOURCE_INFO-NEXT: Name: (ID 1) [
+RESOURCE_INFO-NEXT: Table Offset: 0x30
+RESOURCE_INFO-NEXT: Number of String Entries: 0
+RESOURCE_INFO-NEXT: Number of ID Entries: 1
+RESOURCE_INFO-NEXT: Language: (ID 1033) [
+RESOURCE_INFO-NEXT: Entry Offset: 0x48
+RESOURCE_INFO-NEXT: Time/Date Stamp: 1970-01-01 00:00:00 (0x0)
+RESOURCE_INFO-NEXT: Major Version: 0
+RESOURCE_INFO-NEXT: Minor Version: 0
+RESOURCE_INFO-NEXT: Characteristics: 0
+RESOURCE_INFO-DAG: .rsrc Data (
+RESOURCE_INFO-NEXT: 0000: 00000000 00000000 00000000 00000100 |................|
+RESOURCE_INFO-NEXT: 0010: 06000000 18000080 00000000 00000000 |................|
+RESOURCE_INFO-NEXT: 0020: 00000000 00000100 01000000 30000080 |............0...|
+RESOURCE_INFO-NEXT: 0030: 00000000 00000000 00000000 00000100 |................|
+RESOURCE_INFO-NEXT: 0040: 09040000 48000000 58100000 2A000000 |....H...X...*...|
+RESOURCE_INFO-NEXT: 0050: 00000000 00000000 00000500 48006500 |............H.e.|
+RESOURCE_INFO-NEXT: 0060: 6C006C00 6F000000 00000000 00000000 |l.l.o...........|
+RESOURCE_INFO-NEXT: 0070: 00000000 00000000 00000000 00000000 |................|
+RESOURCE_INFO-NEXT: 0080: 00000000 00000000 |........|
+RESOURCE_INFO-NEXT: )
diff --git a/test/COFF/secrel-absolute.s b/test/COFF/secrel-absolute.s
index 69b5ab92991b..bc61fb94b6b0 100644
--- a/test/COFF/secrel-absolute.s
+++ b/test/COFF/secrel-absolute.s
@@ -3,7 +3,7 @@
# secrel relocations against absolute symbols are errors.
-# CHECK: SECREL relocation points to a non-regular symbol: __guard_fids_table
+# CHECK: SECREL relocation cannot be applied to absolute symbols
.text
.global main