Skip to content

Commit c00ada0

Browse files
committed
[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.
1 parent 2628a5f commit c00ada0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/include/llvm/ADT/Hashing.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,16 @@ struct hash_state {
307307
};
308308

309309
/// In LLVM_ENABLE_ABI_BREAKING_CHECKS builds, the seed is non-deterministic
310-
/// (address of a variable) to prevent having users depend on the particular
311-
/// hash values. On platforms without ASLR, this is still likely
312-
/// non-deterministic per build.
310+
/// per process (address of a function in LLVMSupport) to prevent having users
311+
/// depend on the particular hash values. On platforms without ASLR, this is
312+
/// still likely non-deterministic per build.
313313
inline uint64_t get_execution_seed() {
314314
// Work around x86-64 negative offset folding for old Clang -fno-pic
315315
// https://reviews.llvm.org/D93931
316316
#if LLVM_ENABLE_ABI_BREAKING_CHECKS && \
317317
(!defined(__clang__) || __clang_major__ > 11)
318-
static const char seed = 0;
319-
return static_cast<uint64_t>(reinterpret_cast<uintptr_t>(&seed));
318+
return static_cast<uint64_t>(
319+
reinterpret_cast<uintptr_t>(&install_fatal_error_handler));
320320
#else
321321
return 0xff51afd7ed558ccdULL;
322322
#endif

0 commit comments

Comments
 (0)