aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-09-11 10:10:16 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-09-11 10:10:16 +0000
commitaf0fec7cd3a5363868d2e9ba06c5e993c30bd1c3 (patch)
tree86a4c44096af6ec9daf3b7bfe37e8a9cb74b32b5
parent24368d8873ce72b24c79ced3a2831fefe104a6ec (diff)
downloadsrc-af0fec7cd3a5363868d2e9ba06c5e993c30bd1c3.tar.gz
src-af0fec7cd3a5363868d2e9ba06c5e993c30bd1c3.zip
Vendor import of lld release_70 branch r341916:vendor/lld/lld-release_70-r341916
Notes
Notes: svn path=/vendor/lld/dist-release_70/; revision=338583 svn path=/vendor/lld/lld-release_70-r341916/; revision=338584; tag=vendor/lld/lld-release_70-r341916
-rw-r--r--COFF/Driver.cpp114
-rw-r--r--COFF/Driver.h1
-rw-r--r--docs/ReleaseNotes.rst85
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h9
-rw-r--r--test/COFF/entry-inference3.test10
-rw-r--r--test/COFF/entry-inference332.test39
-rw-r--r--test/COFF/entry-inference4.test56
-rw-r--r--test/COFF/guardcf-align.s1
-rw-r--r--test/COFF/subsystem-inference32.test74
-rw-r--r--test/ELF/icf13.s1
-rw-r--r--test/ELF/icf15.s1
-rw-r--r--test/ELF/icf16.s1
-rw-r--r--test/ELF/icf17.s1
-rw-r--r--test/ELF/lto/libcall-archive.ll1
14 files changed, 310 insertions, 84 deletions
diff --git a/COFF/Driver.cpp b/COFF/Driver.cpp
index da7527607ffb..e42a37f6a814 100644
--- a/COFF/Driver.cpp
+++ b/COFF/Driver.cpp
@@ -116,6 +116,19 @@ static std::future<MBErrPair> createFutureForFile(std::string Path) {
});
}
+// Symbol names are mangled by prepending "_" on x86.
+static StringRef mangle(StringRef Sym) {
+ assert(Config->Machine != IMAGE_FILE_MACHINE_UNKNOWN);
+ if (Config->Machine == I386)
+ return Saver.save("_" + Sym);
+ return Sym;
+}
+
+static bool findUnderscoreMangle(StringRef Sym) {
+ StringRef Entry = Symtab->findMangle(mangle(Sym));
+ return !Entry.empty() && !isa<Undefined>(Symtab->find(Entry));
+}
+
MemoryBufferRef LinkerDriver::takeBuffer(std::unique_ptr<MemoryBuffer> MB) {
MemoryBufferRef MBRef = *MB;
make<std::unique_ptr<MemoryBuffer>>(std::move(MB)); // take ownership
@@ -407,54 +420,38 @@ Symbol *LinkerDriver::addUndefined(StringRef Name) {
return B;
}
-// Symbol names are mangled by appending "_" prefix on x86.
-StringRef LinkerDriver::mangle(StringRef Sym) {
- assert(Config->Machine != IMAGE_FILE_MACHINE_UNKNOWN);
- if (Config->Machine == I386)
- return Saver.save("_" + Sym);
- return Sym;
-}
-
// Windows specific -- find default entry point name.
//
// There are four different entry point functions for Windows executables,
// each of which corresponds to a user-defined "main" function. This function
// infers an entry point from a user-defined "main" function.
StringRef LinkerDriver::findDefaultEntry() {
+ assert(Config->Subsystem != IMAGE_SUBSYSTEM_UNKNOWN &&
+ "must handle /subsystem before calling this");
+
// As a special case, if /nodefaultlib is given, we directly look for an
// entry point. This is because, if no default library is linked, users
// need to define an entry point instead of a "main".
- if (Config->NoDefaultLibAll) {
- for (StringRef S : {"mainCRTStartup", "wmainCRTStartup",
- "WinMainCRTStartup", "wWinMainCRTStartup"}) {
- StringRef Entry = Symtab->findMangle(S);
- if (!Entry.empty() && !isa<Undefined>(Symtab->find(Entry)))
- return mangle(S);
- }
- return "";
- }
-
- // User-defined main functions and their corresponding entry points.
- static const char *Entries[][2] = {
- {"main", "mainCRTStartup"},
- {"wmain", "wmainCRTStartup"},
- {"WinMain", "WinMainCRTStartup"},
- {"wWinMain", "wWinMainCRTStartup"},
- };
- for (auto E : Entries) {
- StringRef Entry = Symtab->findMangle(mangle(E[0]));
- if (!Entry.empty() && !isa<Undefined>(Symtab->find(Entry)))
- return mangle(E[1]);
+ bool FindMain = !Config->NoDefaultLibAll;
+ if (Config->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {
+ if (findUnderscoreMangle(FindMain ? "WinMain" : "WinMainCRTStartup"))
+ return mangle("WinMainCRTStartup");
+ if (findUnderscoreMangle(FindMain ? "wWinMain" : "wWinMainCRTStartup"))
+ return mangle("wWinMainCRTStartup");
}
+ if (findUnderscoreMangle(FindMain ? "main" : "mainCRTStartup"))
+ return mangle("mainCRTStartup");
+ if (findUnderscoreMangle(FindMain ? "wmain" : "wmainCRTStartup"))
+ return mangle("wmainCRTStartup");
return "";
}
WindowsSubsystem LinkerDriver::inferSubsystem() {
if (Config->DLL)
return IMAGE_SUBSYSTEM_WINDOWS_GUI;
- if (Symtab->findUnderscore("main") || Symtab->findUnderscore("wmain"))
+ if (findUnderscoreMangle("main") || findUnderscoreMangle("wmain"))
return IMAGE_SUBSYSTEM_WINDOWS_CUI;
- if (Symtab->findUnderscore("WinMain") || Symtab->findUnderscore("wWinMain"))
+ if (findUnderscoreMangle("WinMain") || findUnderscoreMangle("wWinMain"))
return IMAGE_SUBSYSTEM_WINDOWS_GUI;
return IMAGE_SUBSYSTEM_UNKNOWN;
}
@@ -1335,25 +1332,6 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
error("/dynamicbase:no is not compatible with " +
machineToStr(Config->Machine));
- // Handle /entry and /dll
- if (auto *Arg = Args.getLastArg(OPT_entry)) {
- Config->Entry = addUndefined(mangle(Arg->getValue()));
- } else if (!Config->Entry && !Config->NoEntry) {
- if (Args.hasArg(OPT_dll)) {
- StringRef S = (Config->Machine == I386) ? "__DllMainCRTStartup@12"
- : "_DllMainCRTStartup";
- Config->Entry = addUndefined(S);
- } else {
- // Windows specific -- If entry point name is not given, we need to
- // infer that from user-defined entry name.
- StringRef S = findDefaultEntry();
- if (S.empty())
- fatal("entry point must be defined");
- Config->Entry = addUndefined(S);
- log("Entry name inferred: " + S);
- }
- }
-
// Handle /export
for (auto *Arg : Args.filtered(OPT_export)) {
Export E = parseExport(Arg->getValue());
@@ -1379,6 +1357,34 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
return;
}
+ // Windows specific -- if no /subsystem is given, we need to infer
+ // that from entry point name. Must happen before /entry handling,
+ // and after the early return when just writing an import library.
+ if (Config->Subsystem == IMAGE_SUBSYSTEM_UNKNOWN) {
+ Config->Subsystem = inferSubsystem();
+ if (Config->Subsystem == IMAGE_SUBSYSTEM_UNKNOWN)
+ fatal("subsystem must be defined");
+ }
+
+ // Handle /entry and /dll
+ if (auto *Arg = Args.getLastArg(OPT_entry)) {
+ Config->Entry = addUndefined(mangle(Arg->getValue()));
+ } else if (!Config->Entry && !Config->NoEntry) {
+ if (Args.hasArg(OPT_dll)) {
+ StringRef S = (Config->Machine == I386) ? "__DllMainCRTStartup@12"
+ : "_DllMainCRTStartup";
+ Config->Entry = addUndefined(S);
+ } else {
+ // Windows specific -- If entry point name is not given, we need to
+ // infer that from user-defined entry name.
+ StringRef S = findDefaultEntry();
+ if (S.empty())
+ fatal("entry point must be defined");
+ Config->Entry = addUndefined(S);
+ log("Entry name inferred: " + S);
+ }
+ }
+
// Handle /delayload
for (auto *Arg : Args.filtered(OPT_delayload)) {
Config->DelayLoads.insert(StringRef(Arg->getValue()).lower());
@@ -1491,14 +1497,6 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
if (errorCount())
return;
- // Windows specific -- if no /subsystem is given, we need to infer
- // that from entry point name.
- if (Config->Subsystem == IMAGE_SUBSYSTEM_UNKNOWN) {
- Config->Subsystem = inferSubsystem();
- if (Config->Subsystem == IMAGE_SUBSYSTEM_UNKNOWN)
- fatal("subsystem must be defined");
- }
-
// Handle /safeseh.
if (Args.hasFlag(OPT_safeseh, OPT_safeseh_no, false)) {
for (ObjFile *File : ObjFile::Instances)
diff --git a/COFF/Driver.h b/COFF/Driver.h
index 627e991a9028..44bc3ba943d4 100644
--- a/COFF/Driver.h
+++ b/COFF/Driver.h
@@ -103,7 +103,6 @@ private:
std::set<std::string> VisitedLibs;
Symbol *addUndefined(StringRef Sym);
- StringRef mangle(StringRef Sym);
// Windows specific -- "main" is not the only main function in Windows.
// You can choose one from these four -- {w,}{WinMain,main}.
diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst
index 203826a089a7..96fa8e049c34 100644
--- a/docs/ReleaseNotes.rst
+++ b/docs/ReleaseNotes.rst
@@ -5,18 +5,19 @@ LLD 7.0.0 Release Notes
.. contents::
:local:
-.. warning::
- These are in-progress notes for the upcoming LLVM 7.0.0 release.
- Release notes for previous releases can be found on
- `the Download Page <http://releases.llvm.org/download.html>`_.
-
Introduction
============
-This document contains the release notes for the lld linker, release 7.0.0.
-Here we describe the status of lld, including major improvements
-from the previous release. All lld releases may be downloaded
-from the `LLVM releases web site <http://llvm.org/releases/>`_.
+lld is a high-performance linker that supports ELF (Unix), COFF (Windows),
+Mach-O (macOS), MinGW and WebAssembly. lld is command-line-compatible with GNU
+linkers and Microsoft link.exe, and is significantly faster than these system
+default linkers.
+
+lld 7 for ELF and COFF are production-ready. lld/ELF can build the entire
+FreeBSD/AMD64 and will be the default linker of the next version of the
+operating system. lld/COFF is being used to build popular large programs such as
+the Chrome web browser. Mach-O, MinGW and WebAssembly supports are still
+experimental.
Non-comprehensive list of changes in this release
=================================================
@@ -24,15 +25,61 @@ Non-comprehensive list of changes in this release
ELF Improvements
----------------
-* lld is now able to overcome MIPS GOT entries number limitation
- and generate multi-GOT if necessary.
+* Fixed a lot of long-tail compatibility issues with GNU linkers.
+
+* Added ``-z retpolineplt`` to emit a PLT entry that doesn't contain an indirect
+ jump instruction to mitigate Spectre v2 vulnerability.
+
+* Added experimental support for `SHT_RELR sections
+ <https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg>`_ to create a
+ compact dynamic relocation table.
+
+* Added support for `split stacks <https://gcc.gnu.org/wiki/SplitStacks>`_.
+
+* Added support for address significance table (section with type
+ SHT_LLVM_ADDRSIG) to improve Identical Code Folding (ICF). Combined with the
+ ``-faddrsig`` compiler option added to Clang 7, lld's ``--icf=all`` can now
+ safely merge functions and data to generate smaller outputs than before.
+
+* Improved ``--gdb-index`` so that it is faster (`r336790
+ <https://reviews.llvm.org/rL336790>`_) and uses less memory (`r336672
+ <https://reviews.llvm.org/rL336672>`_).
+
+* Reduced memory usage of ``--compress-debug-sections`` (`r338913
+ <https://reviews.llvm.org/rL338913>`_).
+
+* Added linker script OVERLAY support (`r335714 <https://reviews.llvm.org/rL335714>`_).
-* lld is now able to produce MIPS position-independent executable (PIE).
+* Added ``--warn-backref`` to make it easy to identify command line option order
+ that doesn't work with GNU linkers (`r329636 <https://reviews.llvm.org/rL329636>`_)
+
+* Added ld.lld.1 man page (`r324512 <https://reviews.llvm.org/rL324512>`_).
+
+* Added support for multi-GOT.
+
+* Added support for MIPS position-independent executable (PIE).
* Fixed MIPS TLS GOT entries for local symbols in shared libraries.
-* Fixed calculation of MIPS GP relative relocations
- in case of relocatable output.
+* Fixed calculation of MIPS GP relative relocations in case of relocatable
+ output.
+
+* Added support for PPCv2 ABI.
+
+* Removed an incomplete support of PPCv1 ABI.
+
+* Added support for Qualcomm Hexagon ISA.
+
+* Added the following flags: ``--apply-dynamic-relocs``, ``--check-sections``,
+ ``--cref``, ``--just-symbols``, ``--keep-unique``,
+ ``--no-allow-multiple-definition``, ``--no-apply-dynamic-relocs``,
+ ``--no-check-sections``, ``--no-gnu-unique, ``--no-pic-executable``,
+ ``--no-undefined-version``, ``--no-warn-common``, ``--pack-dyn-relocs=relr``,
+ ``--pop-state``, ``--print-icf-sections``, ``--push-state``,
+ ``--thinlto-index-only``, ``--thinlto-object-suffix-replace``,
+ ``--thinlto-prefix-replace``, ``--warn-backref``, ``-z combreloc``, ``-z
+ copyreloc``, ``-z initfirst``, ``-z keep-text-section-prefix``, ``-z lazy``,
+ ``-z noexecstack``, ``-z relro``, ``-z retpolineplt``, ``-z text``
COFF Improvements
-----------------
@@ -45,7 +92,11 @@ COFF Improvements
* Improved compatibility of output binaries with GNU binutils objcopy/strip.
-MachO Improvements
-------------------
+* Sped up PDB file creation.
+
+* Changed section layout to improve compatibility with link.exe.
-* Item 1.
+* Added the following flags: ``--color-diagnostics={always,never,auto}``,
+ ``--no-color-diagnostics``, ``/brepro``, ``/debug:full``, ``/debug:ghash``,
+ ``/guard:cf``, ``/guard:longjmp``, ``/guard:nolongjmp``, ``/integritycheck``,
+ ``/order``, ``/pdbsourcepath``, ``/timestamp``
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
index 407bd9b97020..ee9e174b82e0 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
@@ -186,11 +186,10 @@ packRelocation(const Relocation &r, bool swap, bool isBigEndian) {
}
inline StringRef getString16(const char s[16]) {
- StringRef x = s;
- if ( x.size() > 16 )
- return x.substr(0, 16);
- else
- return x;
+ // The StringRef(const char *) constructor passes the const char * to
+ // strlen(), so we can't use this constructor here, because if there is no
+ // null terminator in s, then strlen() will read past the end of the array.
+ return StringRef(s, strnlen(s, 16));
}
inline void setString16(StringRef str, char s[16]) {
diff --git a/test/COFF/entry-inference3.test b/test/COFF/entry-inference3.test
index 7de14e10fe8d..53550f75c6c4 100644
--- a/test/COFF/entry-inference3.test
+++ b/test/COFF/entry-inference3.test
@@ -1,5 +1,9 @@
-# RUN: yaml2obj < %s > %t.obj
-# RUN: not lld-link /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1
+# RUN: sed -e s/ENTRYNAME/mainCRTStartup/ %s | yaml2obj > %t.obj
+# RUN: lld-link /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1
+# RUN: FileCheck %s < %t.log
+
+# RUN: sed -e s/ENTRYNAME/?mainCRTStartup@@YAHXZ/ %s | yaml2obj > %t.obj
+# RUN: lld-link /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1
# RUN: FileCheck %s < %t.log
# CHECK: Entry name inferred: mainCRTStartup
@@ -26,7 +30,7 @@ symbols:
NumberOfLinenumbers: 0
CheckSum: 0
Number: 0
- - Name: mainCRTStartup
+ - Name: "ENTRYNAME"
Value: 0
SectionNumber: 1
SimpleType: IMAGE_SYM_TYPE_NULL
diff --git a/test/COFF/entry-inference332.test b/test/COFF/entry-inference332.test
new file mode 100644
index 000000000000..75c557af47e8
--- /dev/null
+++ b/test/COFF/entry-inference332.test
@@ -0,0 +1,39 @@
+# RUN: sed -e s/ENTRYNAME/_mainCRTStartup/ %s | yaml2obj > %t.obj
+# RUN: lld-link /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1
+# RUN: FileCheck %s < %t.log
+
+# RUN: sed -e s/ENTRYNAME/?mainCRTStartup@@YAHXZ/ %s | yaml2obj > %t.obj
+# RUN: lld-link /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1
+# RUN: FileCheck %s < %t.log
+
+# CHECK: Entry name inferred: _mainCRTStartup
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_I386
+ Characteristics: []
+sections:
+ - Name: .text
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 4
+ SectionData: B82A000000C3
+symbols:
+ - Name: .text
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 6
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+ - Name: "ENTRYNAME"
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
diff --git a/test/COFF/entry-inference4.test b/test/COFF/entry-inference4.test
new file mode 100644
index 000000000000..513c9cf8f86f
--- /dev/null
+++ b/test/COFF/entry-inference4.test
@@ -0,0 +1,56 @@
+# RUN: sed 's/ENTRY1/WinMain/;s/ENTRY2/main/' %s | yaml2obj > %t.obj
+# RUN: not lld-link /subsystem:windows /out:%t.exe %t.obj > %t.log 2>&1
+# RUN: FileCheck -check-prefix=WINMAIN %s < %t.log
+
+# RUN: sed 's/ENTRY1/wWinMain/;s/ENTRY2/main/' %s | yaml2obj > %t.obj
+# RUN: not lld-link /subsystem:windows /out:%t.exe %t.obj > %t.log 2>&1
+# RUN: FileCheck -check-prefix=WWINMAIN %s < %t.log
+
+# RUN: sed 's/ENTRY1/WinMain/;s/ENTRY2/main/' %s | yaml2obj > %t.obj
+# RUN: not lld-link /subsystem:console /out:%t.exe %t.obj > %t.log 2>&1
+# RUN: FileCheck -check-prefix=MAIN %s < %t.log
+
+# RUN: sed 's/ENTRY1/WinMain/;s/ENTRY2/wmain/' %s | yaml2obj > %t.obj
+# RUN: not lld-link /subsystem:console /out:%t.exe %t.obj > %t.log 2>&1
+# RUN: FileCheck -check-prefix=WMAIN %s < %t.log
+
+# MAIN: error: <root>: undefined symbol: mainCRTStartup
+# WMAIN: error: <root>: undefined symbol: wmainCRTStartup
+# WINMAIN: error: <root>: undefined symbol: WinMainCRTStartup
+# WWINMAIN: error: <root>: undefined symbol: wWinMainCRTStartup
+
+--- !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: 4
+ SectionData: B82A000000C3
+symbols:
+ - Name: .text
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 6
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+ - Name: ENTRY1
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: ENTRY2
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
diff --git a/test/COFF/guardcf-align.s b/test/COFF/guardcf-align.s
index a0caabc92b0d..449d3fcd2a74 100644
--- a/test/COFF/guardcf-align.s
+++ b/test/COFF/guardcf-align.s
@@ -1,3 +1,4 @@
+# REQUIRES: x86
# RUN: llvm-mc -triple x86_64-windows-msvc -filetype=obj -o %t.obj %s
# RUN: yaml2obj < %p/Inputs/guardcf-align-foobar.yaml \
# RUN: > %T/guardcf-align-foobar.obj
diff --git a/test/COFF/subsystem-inference32.test b/test/COFF/subsystem-inference32.test
new file mode 100644
index 000000000000..8e66a85a7920
--- /dev/null
+++ b/test/COFF/subsystem-inference32.test
@@ -0,0 +1,74 @@
+# RUN: sed -e s/ENTRYNAME/_main/ %s | yaml2obj > %t.obj
+# RUN: lld-link /out:%t.exe %t.obj
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=MAIN %s
+
+# RUN: sed s/ENTRYNAME/_wmain/ %s | yaml2obj > %t.obj
+# RUN: lld-link /out:%t.exe %t.obj
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=WMAIN %s
+
+# RUN: sed s/ENTRYNAME/_WinMain@16/ %s | yaml2obj > %t.obj
+# RUN: lld-link /out:%t.exe %t.obj
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=WINMAIN %s
+
+# RUN: sed s/ENTRYNAME/_wWinMain@16/ %s | yaml2obj > %t.obj
+# RUN: lld-link /out:%t.exe %t.obj
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=WWINMAIN %s
+
+# MAIN: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI
+# WMAIN: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI
+# WINMAIN: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI
+# WWINMAIN: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_I386
+ Characteristics: []
+sections:
+ - Name: .text
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 4
+ SectionData: B82A000000C3
+symbols:
+ - Name: .text
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 6
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+ - Name: ENTRYNAME
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: _mainCRTStartup
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: _wmainCRTStartup
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: _WinMainCRTStartup
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: _wWinMainCRTStartup
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
diff --git a/test/ELF/icf13.s b/test/ELF/icf13.s
index 2fe707f11c76..c0d4935cca40 100644
--- a/test/ELF/icf13.s
+++ b/test/ELF/icf13.s
@@ -1,3 +1,4 @@
+# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
# RUN: ld.lld -shared -z notext %t1 -o /dev/null --icf=all --print-icf-sections 2>&1 | FileCheck -allow-empty %s
diff --git a/test/ELF/icf15.s b/test/ELF/icf15.s
index 57c1735e1518..5c651fbd65ff 100644
--- a/test/ELF/icf15.s
+++ b/test/ELF/icf15.s
@@ -1,3 +1,4 @@
+# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
# RUN: ld.lld %t1 -o /dev/null --icf=all --print-icf-sections 2>&1 | FileCheck -allow-empty %s
diff --git a/test/ELF/icf16.s b/test/ELF/icf16.s
index e7650af37c3b..13cb8ecd2994 100644
--- a/test/ELF/icf16.s
+++ b/test/ELF/icf16.s
@@ -1,3 +1,4 @@
+# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
# RUN: ld.lld -shared -z notext %t1 -o /dev/null --icf=all --print-icf-sections 2>&1 | FileCheck -allow-empty %s
diff --git a/test/ELF/icf17.s b/test/ELF/icf17.s
index 5d28aeb869c1..cab5c12d214e 100644
--- a/test/ELF/icf17.s
+++ b/test/ELF/icf17.s
@@ -1,3 +1,4 @@
+# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
# RUN: ld.lld %t1 -o /dev/null --icf=all --print-icf-sections 2>&1 | FileCheck -allow-empty %s
diff --git a/test/ELF/lto/libcall-archive.ll b/test/ELF/lto/libcall-archive.ll
index 731e25938bd3..043532942da3 100644
--- a/test/ELF/lto/libcall-archive.ll
+++ b/test/ELF/lto/libcall-archive.ll
@@ -1,3 +1,4 @@
+; REQUIRES: x86
; RUN: rm -f %t.a
; RUN: llvm-as -o %t.o %s
; RUN: llvm-as -o %t2.o %S/Inputs/libcall-archive.ll