Index: ELF/InputFiles.h =================================================================== --- ELF/InputFiles.h +++ ELF/InputFiles.h @@ -207,6 +207,15 @@ // symbol table. StringRef SourceFile; + // Compilers set both of these per object file, although it would be + // more convenient if they did it per section, or even per symbol. + // True if the file defines functions compiled with + // -fsplit-stack. Usually false. + bool SplitStack = false; + // True if the file defines functions compiled with -fsplit-stack, + // but had one or more functions with the no_split_stack attribute. + bool SomeNoSplitStack = false; + private: void initializeSections(llvm::DenseSet &ComdatGroups); Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -639,14 +639,24 @@ if (Name == ".note.GNU-stack") return &InputSection::Discarded; - // Split stacks is a feature to support a discontiguous stack. At least - // as of 2017, it seems that the feature is not being used widely. - // Only GNU gold supports that. We don't. For the details about that, - // see https://gcc.gnu.org/wiki/SplitStacks + // Split stacks is a feature to support a discontiguous stack, + // commonly used in the programming languages Go and Rust. For the + // details, see // https://gcc.gnu.org/wiki/SplitStacks. "...each + // object file compiled in split stack mode will have an empty + // section with a special name: .note.GNU-split-stack. If an object + // file compiled in split stack mode includes some functions with + // the no_split_stack attribute, then the object file will also have + // a .note.GNU-no-split-stack section." if (Name == ".note.GNU-split-stack") { - error(toString(this) + - ": object file compiled with -fsplit-stack is not supported"); + warn(toString(this) + + ": -fsplit-stack support is incomplete."); + this->SplitStack = true; return &InputSection::Discarded; + } else { + if (Name == ".note.GNU-no-split-stack") { + this->SomeNoSplitStack = true; + return &InputSection::Discarded; + } } // The linkonce feature is a sort of proto-comdat. Some glibc i386 object Index: test/ELF/splitstacks.s =================================================================== --- test/ELF/splitstacks.s +++ test/ELF/splitstacks.s @@ -1,8 +1,8 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o -# RUN: not ld.lld %t1.o -o %t 2>&1 | FileCheck %s -# CHECK: .o: object file compiled with -fsplit-stack is not supported +# RUN: ld.lld %t1.o -o %t 2>&1 | FileCheck %s +# CHECK: .o: -fsplit-stack support is incomplete .globl _start _start: