[compiler-rt] c79d372 - [sanitizer_common] Only use NT_GNU_BUILD_ID in sanitizer_linux_libcdep.cpp if supported
Rainer Orth via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 11 14:51:23 PST 2022
Author: Rainer Orth
Date: 2022-01-11T23:50:37+01:00
New Revision: c79d37279156d8f2242c8f9acc6119c67aa5cf52
URL: https://github.com/llvm/llvm-project/commit/c79d37279156d8f2242c8f9acc6119c67aa5cf52
DIFF: https://github.com/llvm/llvm-project/commit/c79d37279156d8f2242c8f9acc6119c67aa5cf52.diff
LOG: [sanitizer_common] Only use NT_GNU_BUILD_ID in sanitizer_linux_libcdep.cpp if supported
D114294 <https://reviews.llvm.org/D114294> broke the Solaris buildbots:
/opt/llvm-buildbot/home/solaris11-amd64/clang-solaris11-amd64/llvm/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:613:29: error: use of undeclared identifier 'NT_GNU_BUILD_ID'
if (nhdr->n_type == NT_GNU_BUILD_ID && nhdr->n_namesz == kGnuNamesz) {
^
Like D107556 <https://reviews.llvm.org/D107556>, it forgot that
`NT_GNU_BUILD_ID` is an unportable GNU extension.
Fixed by making the code conditional on the definition of the macro.
Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.
Differential Revision: https://reviews.llvm.org/D117051
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 06654ea5ea100..b025a5e4fb644 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -604,6 +604,7 @@ static int AddModuleSegments(const char *module_name, dl_phdr_info *info,
cur_module.addAddressRange(cur_beg, cur_end, executable,
writable);
} else if (phdr->p_type == PT_NOTE) {
+# ifdef NT_GNU_BUILD_ID
uptr off = 0;
while (off + sizeof(ElfW(Nhdr)) < phdr->p_memsz) {
auto *nhdr = reinterpret_cast<const ElfW(Nhdr) *>(info->dlpi_addr +
@@ -629,6 +630,7 @@ static int AddModuleSegments(const char *module_name, dl_phdr_info *info,
off += sizeof(*nhdr) + RoundUpTo(nhdr->n_namesz, 4) +
RoundUpTo(nhdr->n_descsz, 4);
}
+# endif
}
}
modules->push_back(cur_module);
More information about the llvm-commits
mailing list