[PATCH] D33461: ELF: The later of --build-id and --build-id= wins.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 23 14:12:54 PDT 2017


pcc updated this revision to Diff 99988.
pcc added a comment.

- Add null check


https://reviews.llvm.org/D33461

Files:
  lld/ELF/Driver.cpp
  lld/test/ELF/build-id.s


Index: lld/test/ELF/build-id.s
===================================================================
--- lld/test/ELF/build-id.s
+++ lld/test/ELF/build-id.s
@@ -33,6 +33,10 @@
 
 # RUN: ld.lld --build-id=md5 --build-id=none %t -o %t2
 # RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=NONE %s
+# RUN: ld.lld --build-id --build-id=none %t -o %t2
+# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=NONE %s
+# RUN: ld.lld --build-id=none --build-id %t -o %t2
+# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=DEFAULT %s
 
 .globl _start
 _start:
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -572,10 +572,14 @@
 // -build-id=sha1 are actually tree hashes for performance reasons.
 static std::pair<BuildIdKind, std::vector<uint8_t>>
 getBuildId(opt::InputArgList &Args) {
-  if (Args.hasArg(OPT_build_id))
+  auto *Arg = Args.getLastArg(OPT_build_id, OPT_build_id_eq);
+  if (!Arg)
+    return {BuildIdKind::None, {}};
+
+  if (Arg->getOption().getID() == OPT_build_id)
     return {BuildIdKind::Fast, {}};
 
-  StringRef S = getString(Args, OPT_build_id_eq, "none");
+  StringRef S = Arg->getValue();
   if (S == "md5")
     return {BuildIdKind::Md5, {}};
   if (S == "sha1" || S == "tree")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33461.99988.patch
Type: text/x-patch
Size: 1294 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170523/83d0a223/attachment.bin>


More information about the llvm-commits mailing list