PR #2098: Fix AbslInternalGetFileMappingHint to obey ABSL_OPTION_USE_INLINE_NAMESPACE Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/2098 The purpose of `ABSL_OPTION_USE_INLINE_NAMESPACE` is to allow multiple independent copies of abseil-cpp to be linked into the same binary, in different (linker) namespaces. For symbols marked `extern "C"`, we need to manually mangle their names to accomplish the same effect. Abseil provides the `ABSL_INTERNAL_C_SYMBOL` macro for this purpose, but it wasn't used on `AbslInternalGetFileMappingHint`, leading to symbol conflicts when multiple different copies are linked under the same name. Fix this by annotating `AbslInternalGetFileMappingHint` with `ABSL_INTERNAL_C_SYMBOL`. --- Note that an alternative solution is also possible: the `AbslInternalGetFileMappingHint` appears to be dead code in the open-source export of abseil-cpp. (I assume there is nearby google-internal code that uses it.) Instead of mangling the function name, you could also simply remove this code (declaration and definition) from the github export. Merge ba8863afae0f2dc17ae9990ffc07a59091917222 into 865577e2c14c9ed6b9d2f591579a30c688868742 Merging this change closes #2098 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/2098 from jwnimmer-tri:namespace-AbslInternalGetFileMappingHint ba8863afae0f2dc17ae9990ffc07a59091917222 PiperOrigin-RevId: 943313542 Change-Id: I5a87023a08de6d1cba98c4df5179866ea40a7a17
diff --git a/absl/debugging/internal/symbolize.h b/absl/debugging/internal/symbolize.h index a994dba..3360af5 100644 --- a/absl/debugging/internal/symbolize.h +++ b/absl/debugging/internal/symbolize.h
@@ -155,9 +155,8 @@ #ifdef __cplusplus extern "C" #endif // __cplusplus - - bool - AbslInternalGetFileMappingHint(const void** start, const void** end, - uint64_t* offset, const char** filename); + bool ABSL_INTERNAL_C_SYMBOL(AbslInternalGetFileMappingHint)( + const void** start, const void** end, uint64_t* offset, + const char** filename); #endif // ABSL_DEBUGGING_INTERNAL_SYMBOLIZE_H_
diff --git a/absl/debugging/symbolize_elf.inc b/absl/debugging/symbolize_elf.inc index 14b23c1..f0f02a1 100644 --- a/absl/debugging/symbolize_elf.inc +++ b/absl/debugging/symbolize_elf.inc
@@ -1697,10 +1697,9 @@ ABSL_NAMESPACE_END } // namespace absl -extern "C" bool AbslInternalGetFileMappingHint(const void **start, - const void **end, - uint64_t *offset, - const char **filename) { +extern "C" bool ABSL_INTERNAL_C_SYMBOL(AbslInternalGetFileMappingHint)( + const void** start, const void** end, uint64_t* offset, + const char** filename) { return absl::debugging_internal::GetFileMappingHint(start, end, offset, filename); }