[lld/mac] Implement support for section$start and section$ end symbols
authorNico Weber <thakis@chromium.org>
Thu, 15 Jul 2021 16:54:42 +0000 (12:54 -0400)
committerNico Weber <thakis@chromium.org>
Fri, 23 Jul 2021 20:01:09 +0000 (16:01 -0400)
commit04e8d0b62dca05c396422048b467bea31988cac3
treef48b87e5110c70adf4c8bbe48650327c0880c81a
parenta085c23aa3c8f91866d7f4588d4f683407dc775d
[lld/mac] Implement support for section$start and section$ end symbols

With this, libclang_rt.profile_osx.a can be linked, that is coverage
and PGO-instrumented builds should now work with lld.

section$start and section$end symbols can create non-existing sections.
They're also undefined symbols that are only magic if there isn't a
regular symbol with their name, which means the need to be handled
in treatUndefined() instead of just looping over all existing
sections and adding start and end symbols like the ELF port does.

To represent the actual symbols, this uses absolute symbols that
get their value updated once an output section is layed out.

segment$start and segment$end are still missing for now, but they produce a
nicer error message after this patch.

Main part of PR50760.

Differential Revision: https://reviews.llvm.org/D106629
lld/MachO/OutputSection.cpp
lld/MachO/OutputSection.h
lld/MachO/SymbolTable.cpp
lld/MachO/Writer.cpp
lld/test/MachO/start-end.s [new file with mode: 0644]