[ELF] -r: rewrite SHT_GROUP content if some members are combined or discarded
authorFangrui Song <i@maskray.me>
Tue, 21 Jul 2020 15:49:04 +0000 (08:49 -0700)
committerFangrui Song <i@maskray.me>
Tue, 21 Jul 2020 15:49:45 +0000 (08:49 -0700)
commit86ab98b0014662f489dbee97f7d3b8d2569e37cc
tree3498f27f1ebed1164e36499a37985dfaf49ac85f
parentd080635bfca25e66edd5c5dd333bbd1f8eb70a77
[ELF] -r: rewrite SHT_GROUP content if some members are combined or discarded

* If two group members are combined, we should leave just one index in the SHT_GROUP content.
* If a group member is discarded (/DISCARD/ or upcoming -r --gc-sections combination),
  we should drop its index in the SHT_GROUP content. LLD currently crashes (`getOutputSection()` is null).

Reviewed By: psmith

Differential Revision: https://reviews.llvm.org/D84129
lld/ELF/InputSection.cpp
lld/ELF/OutputSections.cpp
lld/test/ELF/relocatable-comdat.s