From c79d37279156d8f2242c8f9acc6119c67aa5cf52 Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Tue, 11 Jan 2022 23:50:37 +0100 Subject: [PATCH] [sanitizer_common] Only use NT_GNU_BUILD_ID in sanitizer_linux_libcdep.cpp if supported 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 , 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 --- compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp | 2 ++ 1 file changed, 2 insertions(+) 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(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);