[llvm] c00ada0 - [Hashing] get_execution_seed: use a non-vague linkage symbol
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 29 12:56:01 PDT 2024
Author: Fangrui Song
Date: 2024-06-29T12:55:57-07:00
New Revision: c00ada070207979f092be9046a02fcfff8b9f9ce
URL: https://github.com/llvm/llvm-project/commit/c00ada070207979f092be9046a02fcfff8b9f9ce
DIFF: https://github.com/llvm/llvm-project/commit/c00ada070207979f092be9046a02fcfff8b9f9ce.diff
LOG: [Hashing] get_execution_seed: use a non-vague linkage symbol
Follow-up to #96282.
Since llvm/lib/Target files are compiled with -fvisibility=hidden,
the seed variable in libLLVM.so is hidden in a -DLLVM_BUILD_LLVM_DYLIB=on build.
This would cause `hash_value(std::string()), hash_value(StringRef())` to
fail since the former (might be part of the main executable) and the
latter (llvm/lib/Support/StringRef.cpp in libLLVM.so) use copies in
different components.
Added:
Modified:
llvm/include/llvm/ADT/Hashing.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
index 177fb0318bf80..109966257b51c 100644
--- a/llvm/include/llvm/ADT/Hashing.h
+++ b/llvm/include/llvm/ADT/Hashing.h
@@ -307,16 +307,16 @@ struct hash_state {
};
/// In LLVM_ENABLE_ABI_BREAKING_CHECKS builds, the seed is non-deterministic
-/// (address of a variable) to prevent having users depend on the particular
-/// hash values. On platforms without ASLR, this is still likely
-/// non-deterministic per build.
+/// per process (address of a function in LLVMSupport) to prevent having users
+/// depend on the particular hash values. On platforms without ASLR, this is
+/// still likely non-deterministic per build.
inline uint64_t get_execution_seed() {
// Work around x86-64 negative offset folding for old Clang -fno-pic
// https://reviews.llvm.org/D93931
#if LLVM_ENABLE_ABI_BREAKING_CHECKS && \
(!defined(__clang__) || __clang_major__ > 11)
- static const char seed = 0;
- return static_cast<uint64_t>(reinterpret_cast<uintptr_t>(&seed));
+ return static_cast<uint64_t>(
+ reinterpret_cast<uintptr_t>(&install_fatal_error_handler));
#else
return 0xff51afd7ed558ccdULL;
#endif
More information about the llvm-commits
mailing list