Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -1838,9 +1838,11 @@ } unlinkAsync(Config->OutputFile); + unsigned Flags = !Config->Relocatable && !Config->Shared + ? FileOutputBuffer::F_executable + : 0; Expected> BufferOrErr = - FileOutputBuffer::create(Config->OutputFile, FileSize, - FileOutputBuffer::F_executable); + FileOutputBuffer::create(Config->OutputFile, FileSize, Flags); if (!BufferOrErr) error("failed to open " + Config->OutputFile + ": " +