This is an archive of the discontinued LLVM Phabricator instance.

[profile] Add back zero-sized dummy sections
Needs ReviewPublic

Authored by pirama on Aug 20 2021, 2:20 PM.

Details

Summary

These were removed in dc93b1127c5e0621e672745d26bce5a11f68d943 (D97648).
In addition to adding them back, mark them as "retained".

This change is needed for allowing continuous-mode profile creation for
Linux (and Android in particular).

  • We're relying on 'OVERWRITE_SECTIONS' linker feature to set alignment

of llvm_prf_data and llvm_prf_cnts. If an OVERWRITE_SECTIONS is
present, lld adds the start/stop symbols for these sections even if
the eventual binary doesn't have these sections leading to
llvm-objcopy/llvm-strip complaining about malformed binaries. Adding
these dummy sections ensures that the start/stop symbols point to a
valid, albeit zero-sized section.

  • We also need to mark these symbols with attribute "retain" to ensure

these symbols and sections are not removed with --gc-sections.

Diff Detail

Event Timeline

pirama created this revision.Aug 20 2021, 2:20 PM
pirama requested review of this revision.Aug 20 2021, 2:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2021, 2:20 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript