[PATCH] D98903: [SanitizerCoverage] Make __start_/__stop_ symbols extern_weak

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 18 15:04:29 PDT 2021


MaskRay created this revision.
MaskRay added reviewers: aeubanks, morehouse, vitalybuka.
Herald added subscribers: steven_wu, hiraditya.
MaskRay requested review of this revision.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.

On ELF, we place the metadata sections (`__sancov_guards`, `__sancov_cntrs`,
`__sancov_bools`, `__sancov_pcs` in section groups (either `comdat any` or
`comdat noduplicates`).

With `--gc-sections`, LLD since D96753 <https://reviews.llvm.org/D96753> and GNU ld `-z start-stop-gc` may garbage
collection such sections. If all `__sancov_bools` are discarded, LLD will error
`error: undefined hidden symbol: __start___sancov_cntrs` (other sections are similar).

Use the `extern_weak` linkage (lowered to undefined weak symbols) to avoid the
undefined error.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98903

Files:
  compiler-rt/test/lsan/TestCases/suppressions_default.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCParser/MCAsmParser.h
  llvm/lib/LTO/LTO.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/ELFAsmParser.cpp
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/inline-8bit-counters.ll
  llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
  llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98903.331698.patch
Type: text/x-patch
Size: 14318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210318/71c47854/attachment.bin>


More information about the llvm-commits mailing list