[PATCH] D50498: [LLD][ELF] - Fix crash when using empty --defsym.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 9 23:33:17 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL339412: [LLD][ELF] - Fix crash when using empty --defsym. (authored by grimar, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50498?vs=159881&id=160063#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50498

Files:
  lld/trunk/ELF/Driver.cpp
  lld/trunk/test/ELF/defsym.s


Index: lld/trunk/test/ELF/defsym.s
===================================================================
--- lld/trunk/test/ELF/defsym.s
+++ lld/trunk/test/ELF/defsym.s
@@ -74,6 +74,12 @@
 # RUN: not ld.lld -o %t %t.o --defsym=xxx=yyy,zzz 2>&1 | FileCheck %s -check-prefix=ERR2
 # ERR2: -defsym:1: EOF expected, but got ,
 
+# RUN: not ld.lld -o %t %t.o --defsym=foo 2>&1 | FileCheck %s -check-prefix=ERR3
+# ERR3: error: -defsym: syntax error: foo
+
+# RUN: not ld.lld -o %t %t.o --defsym= 2>&1 | FileCheck %s -check-prefix=ERR4
+# ERR4: error: -defsym: syntax error:
+
 .globl foo1
  foo1 = 0x123
 
Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -1029,7 +1029,10 @@
       StringRef From;
       StringRef To;
       std::tie(From, To) = StringRef(Arg->getValue()).split('=');
-      readDefsym(From, MemoryBufferRef(To, "-defsym"));
+      if (From.empty() || To.empty())
+        error("-defsym: syntax error: " + StringRef(Arg->getValue()));
+      else
+        readDefsym(From, MemoryBufferRef(To, "-defsym"));
       break;
     }
     case OPT_script:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50498.160063.patch
Type: text/x-patch
Size: 1173 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180810/c6538344/attachment.bin>


More information about the llvm-commits mailing list