[PATCH] D46653: Start support for linking object files with split stacks

Sterling Augustine via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 9 11:34:59 PDT 2018


saugustine created this revision.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: espindola.

First in a series of patches to implement linking
object files compiled with -fsplit-stack. First, convert a
hard-error when encountering split-stack object files to a
warning, and to start tracking which object files were compiled
with -fsplit-stack.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D46653

Files:
  ELF/InputFiles.cpp
  ELF/InputFiles.h
  test/ELF/splitstacks.s


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:
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<llvm::CachedHashStringRef> &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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46653.145973.patch
Type: text/x-patch
Size: 2790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180509/7ba55193/attachment.bin>


More information about the llvm-commits mailing list