Skip to content

Commit 4f3f4d6

Browse files
committed
sanitizer_common: fix __sanitizer_get_module_and_offset_for_pc signature mismatch
This fixes the following error: sanitizer_interface_internal.h:77:7: error: conflicting types for '__sanitizer_get_module_and_offset_for_pc' int __sanitizer_get_module_and_offset_for_pc( common_interface_defs.h:349:5: note: previous declaration is here int __sanitizer_get_module_and_offset_for_pc(void *pc, char *module_path, I am getting it on a code that uses sanitizer_common (includes internal headers), but also transitively gets includes of the public headers in tests via an internal version of gtest. Reviewed By: melver Differential Revision: https://reviews.llvm.org/D118910
1 parent 23fc20e commit 4f3f4d6

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,9 @@ bool ReadFileToBuffer(const char *file_name, char **buff, uptr *buff_size,
739739
uptr *read_len, uptr max_len = kDefaultFileMaxSize,
740740
error_t *errno_p = nullptr);
741741

742+
int GetModuleAndOffsetForPc(uptr pc, char *module_name, uptr module_name_len,
743+
uptr *pc_offset);
744+
742745
// When adding a new architecture, don't forget to also update
743746
// script/asan_symbolize.py and sanitizer_symbolizer_libcdep.cpp.
744747
inline const char *ModuleArchToString(ModuleArch arch) {

compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static void SanitizerDumpCoverage(const uptr* unsorted_pcs, uptr len) {
7272
const uptr pc = pcs[i];
7373
if (!pc) continue;
7474

75-
if (!__sanitizer_get_module_and_offset_for_pc(pc, nullptr, 0, &pcs[i])) {
75+
if (!GetModuleAndOffsetForPc(pc, nullptr, 0, &pcs[i])) {
7676
Printf("ERROR: unknown pc 0x%zx (may happen if dlclose is used)\n", pc);
7777
continue;
7878
}
@@ -87,8 +87,7 @@ static void SanitizerDumpCoverage(const uptr* unsorted_pcs, uptr len) {
8787
last_base = module_base;
8888
module_start_idx = i;
8989
module_found = true;
90-
__sanitizer_get_module_and_offset_for_pc(pc, module_name, kMaxPathLength,
91-
&pcs[i]);
90+
GetModuleAndOffsetForPc(pc, module_name, kMaxPathLength, &pcs[i]);
9291
}
9392
}
9493

compiler-rt/lib/sanitizer_common/sanitizer_interface_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ extern "C" {
7575

7676
SANITIZER_INTERFACE_ATTRIBUTE
7777
int __sanitizer_get_module_and_offset_for_pc(
78-
__sanitizer::uptr pc, char *module_path,
79-
__sanitizer::uptr module_path_len, __sanitizer::uptr *pc_offset);
78+
void *pc, char *module_path, __sanitizer::uptr module_path_len,
79+
void **pc_offset);
8080

8181
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
8282
void __sanitizer_cov_trace_cmp();

compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ void BufferedStackTrace::Unwind(u32 max_depth, uptr pc, uptr bp, void *context,
166166
UnwindFast(pc, bp, stack_top, stack_bottom, max_depth);
167167
}
168168

169-
static int GetModuleAndOffsetForPc(uptr pc, char *module_name,
170-
uptr module_name_len, uptr *pc_offset) {
169+
int GetModuleAndOffsetForPc(uptr pc, char *module_name, uptr module_name_len,
170+
uptr *pc_offset) {
171171
const char *found_module_name = nullptr;
172172
bool ok = Symbolizer::GetOrInit()->GetModuleNameAndOffsetForPC(
173173
pc, &found_module_name, pc_offset);
@@ -216,10 +216,11 @@ void __sanitizer_symbolize_global(uptr data_addr, const char *fmt,
216216
}
217217

218218
SANITIZER_INTERFACE_ATTRIBUTE
219-
int __sanitizer_get_module_and_offset_for_pc(uptr pc, char *module_name,
219+
int __sanitizer_get_module_and_offset_for_pc(void *pc, char *module_name,
220220
uptr module_name_len,
221-
uptr *pc_offset) {
222-
return __sanitizer::GetModuleAndOffsetForPc(pc, module_name, module_name_len,
223-
pc_offset);
221+
void **pc_offset) {
222+
return __sanitizer::GetModuleAndOffsetForPc(
223+
reinterpret_cast<uptr>(pc), module_name, module_name_len,
224+
reinterpret_cast<uptr *>(pc_offset));
224225
}
225226
} // extern "C"

0 commit comments

Comments
 (0)