[llvm] 07bb667 - [llvm-readobj] Fix std::abs overflow after D156821
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 18 13:21:41 PDT 2023
Author: Fangrui Song
Date: 2023-08-18T13:21:37-07:00
New Revision: 07bb66784c17ef6b98ce38f9cc74d1d92f1aac08
URL: https://github.com/llvm/llvm-project/commit/07bb66784c17ef6b98ce38f9cc74d1d92f1aac08
DIFF: https://github.com/llvm/llvm-project/commit/07bb66784c17ef6b98ce38f9cc74d1d92f1aac08.diff
LOG: [llvm-readobj] Fix std::abs overflow after D156821
Tested by llvm/test/tools/llvm-readobj/ELF/relocations.test
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 aa924823e5548c..bc8e0413b33902 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -3775,7 +3775,7 @@ void GNUELFDumper<ELFT>::printRelRelaReloc(const Relocation<ELFT> &R,
if (!Fields[4].Str.empty()) {
if (RelAddend < 0) {
Addend = " - ";
- RelAddend = std::abs(RelAddend);
+ RelAddend = -static_cast<uint64_t>(RelAddend);
} else {
Addend = " + ";
}
More information about the llvm-commits
mailing list