[PATCH] D69313: Handle more crt*.o filename variants.
Sterling Augustine via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 24 09:46:26 PDT 2019
saugustine updated this revision to Diff 226282.
saugustine marked 3 inline comments as done.
saugustine added a comment.
- Address additional comments.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69313/new/
https://reviews.llvm.org/D69313
Files:
lld/ELF/OutputSections.cpp
Index: lld/ELF/OutputSections.cpp
===================================================================
--- lld/ELF/OutputSections.cpp
+++ lld/ELF/OutputSections.cpp
@@ -20,6 +20,7 @@
#include "llvm/Support/MD5.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/SHA1.h"
+#include <regex>
using namespace llvm;
using namespace llvm::dwarf;
@@ -384,18 +385,23 @@
flags |= SHF_INFO_LINK;
}
-// Returns true if S matches /Filename.?\.o$/.
-static bool isCrtBeginEnd(StringRef s, StringRef filename) {
- if (!s.endswith(".o"))
- return false;
- s = s.drop_back(2);
- if (s.endswith(filename))
- return true;
- return !s.empty() && s.drop_back().endswith(filename);
+// Returns true if S is in one of the many forms the driver may
+// pass crtbegin files.
+//
+// Gcc uses any of crtbegin[<empty>|S|T].o.
+// Clang uses Gcc's plus clang_rt.crtbegin[<empty>|S|T][-<arch>|<empty>].o.
+
+static bool isCrtbegin(StringRef s) {
+ s = llvm::sys::path::filename(s);
+ static std::regex re(R"((clang_rt\.)?crtbegin[ST]?(\-.*)?\.o)");
+ return std::regex_match(s.data(), re);
}
-static bool isCrtbegin(StringRef s) { return isCrtBeginEnd(s, "crtbegin"); }
-static bool isCrtend(StringRef s) { return isCrtBeginEnd(s, "crtend"); }
+static bool isCrtend(StringRef s) {
+ s = llvm::sys::path::filename(s);
+ static std::regex re(R"((clang_rt\.)?crtend[ST]?(\-.*)?\.o)");
+ return std::regex_match(s.data(), re);
+}
// .ctors and .dtors are sorted by this priority from highest to lowest.
//
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69313.226282.patch
Type: text/x-patch
Size: 1519 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191024/032272e2/attachment.bin>
More information about the llvm-commits
mailing list