[all-commits] [llvm/llvm-project] 1af25a: [ELF] Fix wrapping symbols produced during LTO cod...

Shoaib Meenai via All-commits all-commits at lists.llvm.org
Fri Apr 22 16:46:16 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1af25a986069f2ae8c724133fa8649bb795a7925
  Author: Shoaib Meenai <smeenai at fb.com>
  Date:   2022-04-22 (Fri, 22 Apr 2022)

  Changed paths:
    M lld/ELF/Driver.cpp
    M lld/ELF/LTO.cpp
    M lld/ELF/SymbolTable.cpp
    M lld/ELF/Symbols.h
    A lld/test/ELF/lto/wrap-unreferenced-before-codegen.test

  Log Message:
  [ELF] Fix wrapping symbols produced during LTO codegen

We were previously not correctly wrapping symbols that were only
produced during LTO codegen and unreferenced before then, or symbols
only referenced from such symbols. The root cause was that we weren't
marking the wrapped symbol as used if we only saw the use after LTO
codegen, leading to the failed wrapping.

Fix this by explicitly tracking whether a symbol will become referenced
after wrapping is done. We can use this property to tell LTO to preserve
such symbols, instead of overload isUsedInRegularObj for this purpose.
Since we're no longer setting isUsedInRegularObj for all symbols which
will be wrapped, its value at the time of performing the wrapping in the
symbol table will accurately reflect whether the symbol was actually
used in an object (including in an LTO-generated object), and we can
propagate that value to the wrapped symbol and thereby ensure we wrap

This incorrect wrapping was the only scenario I was aware of where we
produced an invalid PLT relocation, which D123985 started diagnosing,
and with it fixed, we lose the test for that diagnosis. I think it's
worth keeping the diagnosis though, in case we run into other issues in
the future which would be caught by it.

Fixes PR50675.

Reviewed By: MaskRay

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

More information about the All-commits mailing list