[ELF] Move section assignment from initializeSymbols to postParse
authorFangrui Song <i@maskray.me>
Mon, 14 Mar 2022 21:13:41 +0000 (14:13 -0700)
committerFangrui Song <i@maskray.me>
Mon, 14 Mar 2022 21:13:41 +0000 (14:13 -0700)
commitc30e6447c0225f675773d07f2b6d4e3c2b962155
tree54b6500a2f803946b7add169788a3c20de5b1af3
parent0c3156bd43842d8f0ea54bea3fea628e8fee93d2
[ELF] Move section assignment from initializeSymbols to postParse

https://discourse.llvm.org/t/parallel-input-file-parsing/60164

initializeSymbols currently sets Defined::section and handles non-prevailing
COMDAT groups. Move the code to the parallel postParse to reduce work from the
single-threading code path and make parallel section initialization infeasible.

Postpone reporting duplicate symbol errors so that the messages have the
section information. (`Defined::section` is assigned in postParse and another
thread may not have the information).

* duplicated-synthetic-sym.s: BinaryFile duplicate definition (very rare) now
  has no section information
* comdat-binding: `%t/w.o %t/g.o` leads to an undesired undefined symbol. This
  is not ideal but we report a diagnostic to inform that this is unsupported.
  (See release note)
* comdat-discarded-lazy.s: %tdef.o is unextracted. The new behavior (discarded
  section error) makes more sense

Depends on D120640

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D120626
13 files changed:
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/InputFiles.cpp
lld/ELF/Relocations.cpp
lld/ELF/Symbols.cpp
lld/ELF/Symbols.h
lld/docs/ReleaseNotes.rst
lld/test/ELF/comdat-binding.s
lld/test/ELF/comdat-discarded-error.s
lld/test/ELF/comdat-discarded-lazy.s
lld/test/ELF/duplicated-synthetic-sym.s
lld/test/ELF/exclude-discarded-error2.s
lld/test/ELF/lto/comdat-mixed-archive.test