summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Driver/DarwinLdDriver.cpp11
-rw-r--r--lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp1
-rw-r--r--lib/ReaderWriter/MachO/MachOLinkingContext.cpp1
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h9
4 files changed, 13 insertions, 9 deletions
diff --git a/lib/Driver/DarwinLdDriver.cpp b/lib/Driver/DarwinLdDriver.cpp
index ad22845207e17..bbac230df4536 100644
--- a/lib/Driver/DarwinLdDriver.cpp
+++ b/lib/Driver/DarwinLdDriver.cpp
@@ -382,10 +382,13 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx) {
if (arch == MachOLinkingContext::arch_unknown &&
!parsedArgs.getLastArg(OPT_test_file_usage)) {
// If no -arch and no options at all, print usage message.
- if (parsedArgs.size() == 0)
- table.PrintHelp(llvm::outs(), args[0], "LLVM Linker", false);
- else
+ if (parsedArgs.size() == 0) {
+ table.PrintHelp(llvm::outs(),
+ (std::string(args[0]) + " [options] file...").c_str(),
+ "LLVM Linker", false);
+ } else {
error("-arch not specified and could not be inferred");
+ }
return false;
}
}
@@ -1143,7 +1146,7 @@ static void createFiles(MachOLinkingContext &ctx, bool Implicit) {
/// This is where the link is actually performed.
bool link(llvm::ArrayRef<const char *> args, bool CanExitEarly,
raw_ostream &Error) {
- errorHandler().LogName = llvm::sys::path::filename(args[0]);
+ errorHandler().LogName = args::getFilenameWithoutExe(args[0]);
errorHandler().ErrorLimitExceededMsg =
"too many errors emitted, stopping now (use "
"'-error-limit 0' to see all errors)";
diff --git a/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp b/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
index 8cb6710857e3e..fba3d530e484c 100644
--- a/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
+++ b/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
@@ -80,6 +80,7 @@ public:
switch (ref->kindValue()) {
case ripRel32Got:
assert(targetNowGOT && "target must be GOT");
+ LLVM_FALLTHROUGH;
case ripRel32GotLoad:
const_cast<Reference *>(ref)
->setKindValue(targetNowGOT ? ripRel32 : ripRel32GotLoadNowLea);
diff --git a/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index ce423d03aae34..61583963ddd7d 100644
--- a/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -262,6 +262,7 @@ void MachOLinkingContext::configure(HeaderFileType type, Arch arch, OS os,
case llvm::MachO::MH_OBJECT:
_printRemainingUndefines = false;
_allowRemainingUndefines = true;
+ break;
default:
break;
}
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
index 407bd9b970205..ee9e174b82e0d 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
@@ -186,11 +186,10 @@ packRelocation(const Relocation &r, bool swap, bool isBigEndian) {
}
inline StringRef getString16(const char s[16]) {
- StringRef x = s;
- if ( x.size() > 16 )
- return x.substr(0, 16);
- else
- return x;
+ // The StringRef(const char *) constructor passes the const char * to
+ // strlen(), so we can't use this constructor here, because if there is no
+ // null terminator in s, then strlen() will read past the end of the array.
+ return StringRef(s, strnlen(s, 16));
}
inline void setString16(StringRef str, char s[16]) {