Index: ELF/Config.h =================================================================== --- ELF/Config.h +++ ELF/Config.h @@ -113,6 +113,7 @@ bool ICF; bool Mips64EL = false; bool MipsN32Abi = false; + bool NoDynamicLinker; bool NoGnuUnique; bool NoUndefinedVersion; bool Nostdlib; Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -529,6 +529,7 @@ Config->GcSections = getArg(Args, OPT_gc_sections, OPT_no_gc_sections, false); Config->GdbIndex = Args.hasArg(OPT_gdb_index); Config->ICF = Args.hasArg(OPT_icf); + Config->NoDynamicLinker = Args.hasArg(OPT_no_dynamic_linker); Config->NoGnuUnique = Args.hasArg(OPT_no_gnu_unique); Config->NoUndefinedVersion = Args.hasArg(OPT_no_undefined_version); Config->Nostdlib = Args.hasArg(OPT_nostdlib); Index: ELF/Options.td =================================================================== --- ELF/Options.td +++ ELF/Options.td @@ -148,6 +148,8 @@ def no_demangle: F<"no-demangle">, HelpText<"Do not demangle symbol names">; +def no_dynamic_linker: F<"no-dynamic-linker">; + def no_export_dynamic: F<"no-export-dynamic">; def no_fatal_warnings: F<"no-fatal-warnings">; @@ -357,7 +359,6 @@ def no_allow_shlib_undefined: F<"no-allow-shlib-undefined">; def no_copy_dt_needed_entries: F<"no-copy-dt-needed-entries">, Alias; -def no_dynamic_linker: F<"no-dynamic-linker">; def no_mmap_output_file: F<"no-mmap-output-file">; def no_warn_common: F<"no-warn-common">; def no_warn_mismatch: F<"no-warn-mismatch">; Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -132,7 +132,8 @@ } template static bool needsInterpSection() { - return !Symtab::X->getSharedFiles().empty() && + return !Config->NoDynamicLinker && + !Symtab::X->getSharedFiles().empty() && !Config->DynamicLinker.empty() && !Script::X->ignoreInterpSection(); } Index: test/ELF/no-dynamic-linker.s =================================================================== --- test/ELF/no-dynamic-linker.s +++ test/ELF/no-dynamic-linker.s @@ -0,0 +1,8 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %tso.o +# RUN: ld.lld -shared %tso.o -o %t.so +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld --no-dynamic-linker -dynamic-linker foo %t.o %t.so -o %t +# RUN: llvm-readobj --program-headers %t | FileCheck %s + +# CHECK-NOT: PT_INTERP