Skip to content

Commit

Permalink
[sanitizer_common] Only use NT_GNU_BUILD_ID in sanitizer_linux_libcde…
Browse files Browse the repository at this point in the history
…p.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
  • Loading branch information
rorth committed Jan 11, 2022
1 parent 4993eff commit c79d372
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
Expand Up @@ -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 +
Expand All @@ -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);
Expand Down

0 comments on commit c79d372

Please sign in to comment.