[PATCH] D55845: Reject .so files if -static is given.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 18 12:41:46 PST 2018


MaskRay added a comment.

LG, but not sure if the comment should mention `-static`. I think bfd's comment is better

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;hb=2d5d5a8f0a8b5a03454bf168b7fa7024bb1ebbd8;f=ld/ldfile.c#l276

  % ld.bfd t.o -static t.so
  ld.bfd: attempted static link of dynamic object `t.so'

In gold, `-static` is a separate state, different from `-Bdynamic/-Bstatic`.

    if (!doing_static_link && options.is_static())
      {
        // We print out just the first .so we see; there may be others.
        gold_assert(input_objects->dynobj_begin() != input_objects->dynobj_end());
        gold_error(_("cannot mix -static with dynamic object %s"),
  		 (*input_objects->dynobj_begin())->name().c_str());
      }



  % gold t.o -static t.so
  gold: error: cannot mix -static with dynamic object t.so



================
Comment at: lld/test/ELF/static-error.s:7
+// RUN: ld.lld -o /dev/null %t.o %t.so
+// RUN: not ld.lld -o /dev/null -static %t.o %t.so >& %t.log
+// RUN: FileCheck %s < %t.log
----------------
POSIX sh does not support `>&` (but supports `>&fd`)

You may use `2>&1 >/dev/null | FileCheck` if you want to emphasize stderr is checked.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55845/new/

https://reviews.llvm.org/D55845





More information about the llvm-commits mailing list