[all-commits] [llvm/llvm-project] ba890d: [ELF] Demote lazy symbols relative to a discarded ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Jun 9 11:27:55 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: ba890da2878299dc82b104c06f067e45162d880f
      https://github.com/llvm/llvm-project/commit/ba890da2878299dc82b104c06f067e45162d880f
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-06-09 (Tue, 09 Jun 2020)

  Changed paths:
    M lld/ELF/InputFiles.cpp
    M lld/ELF/InputFiles.h
    A lld/test/ELF/comdat-discarded-lazy.s
    M lld/test/ELF/i386-linkonce.s
    M lld/test/ELF/start-lib-comdat.s

  Log Message:
  -----------
  [ELF] Demote lazy symbols relative to a discarded section to Undefined

Fixes PR45594.

In `ObjFile<ELFT>::initializeSymbols()`, for a defined symbol relative to
a discarded section (due to section group rules), it may have been
inserted as a lazy symbol. We need to demote it to an Undefined to
enable the `discarded section` error happened in a later pass.

Add `LazyObjFile::fetched` (if true) and `ArchiveFile::parsed` (if
false) to represent that there is an ongoing lazy symbol fetch and we
should replace the current lazy symbol with an Undefined, instead of
calling `Symbol::resolve` (`Symbol::resolve` should be called if the lazy
symbol was added by an unrelated archive/lazy object).

As a side result, one small issue in start-lib-comdat.s is now fixed.
The hack motivating D51892 will be unsupported: if
`.gnu.linkonce.t.__i686.get_pc_thunk.bx` in an archive is referenced
by another section, this will likely be errored unless the function is
also defined in a regular object file.
(Bringing back rL330869 would error `undefined symbol` instead of the
more relevant `discarded section`.)

Note, glibc i386's crti.o still works (PR31215), because
`.gnu.linkonce.t.__x86.get_pc_thunk.bx` is in crti.o (one of the first
regular object files in a linker command line).

Reviewed By: psmith

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




More information about the All-commits mailing list