diff --git a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp index 2929e1fa32fb..f9402e2a62ac 100644 --- a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp @@ -155,6 +155,9 @@ public: llvm::COFF::IMAGE_FILE_EXECUTABLE_IMAGE; if (context.getLargeAddressAware()) characteristics |= llvm::COFF::IMAGE_FILE_LARGE_ADDRESS_AWARE; + if (!context.getBaseRelocationEnabled()) + characteristics |= llvm::COFF::IMAGE_FILE_RELOCS_STRIPPED; + _coffHeader.Characteristics = characteristics; // 0x10b indicates a normal PE32 executable. For PE32+ it should be 0x20b. diff --git a/lld/test/pecoff/base-reloc.test b/lld/test/pecoff/base-reloc.test index 5b8b319ad2a0..dc4906b1a89b 100644 --- a/lld/test/pecoff/base-reloc.test +++ b/lld/test/pecoff/base-reloc.test @@ -19,12 +19,14 @@ NOBASEREL-SECTION-NOT: Contents of section .reloc: # RUN: lld -flavor link /out:%t1 /subsystem:console /force -- %t.obj \ # RUN: && llvm-readobj -file-headers %t1 \ -# RUN: | FileCheck %s --check-prefix=BASEREL-HEADER +# RUN: | FileCheck %s --check-prefix=BASEREL1 # # RUN: lld -flavor link /out:%t1 /subsystem:console /force /fixed -- %t.obj \ # RUN: && llvm-readobj -file-headers %t1 \ -# RUN: | FileCheck %s --check-prefix=NOBASEREL-HEADER +# RUN: | FileCheck %s --check-prefix=BASEREL2 -BASEREL-HEADER: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE +BASEREL1-NOT: IMAGE_FILE_RELOCS_STRIPPED +BASEREL1: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE -NOBASEREL-HEADER-NOT: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE \ No newline at end of file +BASEREL2: IMAGE_FILE_RELOCS_STRIPPED +BASEREL2-NOT: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE