From ed5bb932a202dd5ede1cb70a032f094b35bbd176 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Wed, 26 Sep 2018 20:50:39 +0000 Subject: [PATCH] Allow later -z name= args to override earlier args Summary: lld already gives later -z options precedence in getZFlag(). This matches the behavior of ld.bfd and ld.gold, where later options override earlier ones. (I tested with -z max-page-size and -z stack-size.) Reviewers: ruiu, espindola, grimar Reviewed By: ruiu, grimar Subscribers: grimar, emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D52526 llvm-svn: 343145 --- lld/Common/Args.cpp | 2 +- lld/test/ELF/zstack-size.s | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lld/Common/Args.cpp b/lld/Common/Args.cpp index 854b50a..3f0671d 100644 --- a/lld/Common/Args.cpp +++ b/lld/Common/Args.cpp @@ -41,7 +41,7 @@ std::vector lld::args::getStrings(opt::InputArgList &Args, int Id) { uint64_t lld::args::getZOptionValue(opt::InputArgList &Args, int Id, StringRef Key, uint64_t Default) { - for (auto *Arg : Args.filtered(Id)) { + for (auto *Arg : Args.filtered_reverse(Id)) { std::pair KV = StringRef(Arg->getValue()).split('='); if (KV.first == Key) { uint64_t Result = Default; diff --git a/lld/test/ELF/zstack-size.s b/lld/test/ELF/zstack-size.s index 23eed0a..bec2b20 100644 --- a/lld/test/ELF/zstack-size.s +++ b/lld/test/ELF/zstack-size.s @@ -6,6 +6,9 @@ # RUN: ld.lld -z stack-size=0 %t -o %t2 # RUN: llvm-readobj -program-headers %t2 | FileCheck %s -check-prefix=CHECK2 +# RUN: ld.lld -z stack-size=0x2000 -z stack-size=0x1000 %t -o %t3 +# RUN: llvm-readobj -program-headers %t3 | FileCheck %s -check-prefix=CHECK1 + .global _start _start: nop -- 2.7.4