[all-commits] [llvm/llvm-project] 7cc328: [ELF] Prevent LTO stripping of wrapped script-refe...

Shoaib Meenai via All-commits all-commits at lists.llvm.org
Tue Apr 26 18:49:27 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7cc328600e250ef44f86da34e93fcdd0635339e0
      https://github.com/llvm/llvm-project/commit/7cc328600e250ef44f86da34e93fcdd0635339e0
  Author: Shoaib Meenai <smeenai at fb.com>
  Date:   2022-04-26 (Tue, 26 Apr 2022)

  Changed paths:
    M lld/ELF/Driver.cpp
    A lld/test/ELF/lto/wrap-script-referenced.ll

  Log Message:
  -----------
  [ELF] Prevent LTO stripping of wrapped script-referenced symbols

After 1af25a986069f2ae8c724133fa8649bb795a7925, we stop unconditionally
retaining wrapped symbols, which means that LTO's summary-based global
dead stripping can eliminate them even if they'll be referenced by a
linker script after the wrapping is performed. Mark symbols referenced
in linker scripts as `referenced` in addition to `isUsedInRegularObj`,
so that the wrapping logic correctly sets `referencedAfterWrap` for the
symbols which will be referenced after wrapping, which will prevent LTO
from eliminating them.

An alternative would have been to change the `referencedAfterWrap` logic
to look at `isUsedInRegularObj` in addition to `referenced`, but
`isUsedInRegularObj` is also set in other places (e.g. for the entry
symbol), and it's not clear that we want `referencedAfterWrap` to take
all those places into account, so it seemed better to keep that logic
as-is and instead set `referenced` for linker script-referenced symbols.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D124433




More information about the All-commits mailing list