1//===- StripSwiftForceLoad.h ------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLD_MACHO_STRIP_SWIFT_FORCE_LOAD_H
10#define LLD_MACHO_STRIP_SWIFT_FORCE_LOAD_H
11
12namespace lld::macho {
13
14// Drop `__DATA,__const` sections that exist only to force-load Swift overlays.
15//
16// The Swift compiler emits `__swift_FORCE_LOAD_$_swift<overlay>` pointers in
17// `__DATA,__const` that bind to the imported symbol of the same name in a
18// dependent overlay dylib. These pointers are never dereferenced -- they exist
19// only to keep the overlay dylib linked in. When a section consists entirely of
20// such pointers (and is not anchored by any externally visible symbol clients
21// might link against), this pass drops the whole section, reclaiming its bytes
22// and removing the dyld binds.
23//
24// The imported FORCE_LOAD DylibSymbols are intentionally left referenced, so
25// the overlays' LC_LOAD_DYLIB dependencies are preserved.
26//
27// NOTE: Must be run after markLive().
28void stripSwiftForceLoadFixups();
29
30} // namespace lld::macho
31
32#endif
33