diff options
Diffstat (limited to 'lib/ReaderWriter/MachO')
-rw-r--r-- | lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp | 1 | ||||
-rw-r--r-- | lib/ReaderWriter/MachO/MachOLinkingContext.cpp | 1 | ||||
-rw-r--r-- | lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h | 9 |
3 files changed, 6 insertions, 5 deletions
diff --git a/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp b/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp index 8cb6710857e3..fba3d530e484 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 ce423d03aae3..61583963ddd7 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 407bd9b97020..ee9e174b82e0 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]) { |