[llvm] f6ba5c4 - [llvm-readobj] Check ELFType value first when checking for OpenBSD notes.
Frederic Cambus via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 20 07:33:09 PST 2021
Author: Frederic Cambus
Date: 2021-12-20T16:32:02+01:00
New Revision: f6ba5c4d5f228366a016534e7d1cf099d274fced
URL: https://github.com/llvm/llvm-project/commit/f6ba5c4d5f228366a016534e7d1cf099d274fced
DIFF: https://github.com/llvm/llvm-project/commit/f6ba5c4d5f228366a016534e7d1cf099d274fced.diff
LOG: [llvm-readobj] Check ELFType value first when checking for OpenBSD notes.
Checking ELFType == ELF::ET_CORE first skips string comparison for the
majority of cases.
Suggested by Fangrui Song in D114635 for a similar construct.
Added:
Modified:
llvm/tools/llvm-readobj/ELFDumper.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 2f64b079d612d..9d9c222347267 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5492,7 +5492,7 @@ StringRef getNoteTypeName(const typename ELFT::Note &Note, unsigned ELFType) {
return Result;
return FindNote(CoreNoteTypes);
}
- if (Name.startswith("OpenBSD") && ELFType == ELF::ET_CORE) {
+ if (ELFType == ELF::ET_CORE && Name.startswith("OpenBSD")) {
// OpenBSD also places the generic core notes in the OpenBSD namespace.
StringRef Result = FindNote(OpenBSDCoreNoteTypes);
if (!Result.empty())
More information about the llvm-commits
mailing list