[ELF] - Do not merge sections from SHT_GROUP when -relocatable
authorGeorge Rimar <grimar@accesssoftek.com>
Tue, 19 Sep 2017 09:40:31 +0000 (09:40 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Tue, 19 Sep 2017 09:40:31 +0000 (09:40 +0000)
commit072a43b501aa26f16c86d83367215a863017ca23
tree24e5462e4cd2f0c541ea1722418b44d90e8bfba8
parentaf52534e8ae440ced6cd66bf7d8e4d3357b83b82
[ELF] - Do not merge sections from SHT_GROUP when -relocatable

This is PR34506.

Imagine we have 2 sections the same name but different COMDAT groups:

.section        .foo,"axG",@progbits,bar,comdat
.section        .foo,"axG",@progbits,zed,comdat
When linking relocatable we do not merge SHT_GROUP sections. But still would merge
both input sections .foo into single output section .foo.
As a result we will have 2 different SHT_GROUPs containing the same section, what
is wrong.

Patch fixes the issue, preventing merging SHF_GROUP sections with any others.

Differential revision: https://reviews.llvm.org/D37574

llvm-svn: 313621
lld/ELF/OutputSections.cpp
lld/test/ELF/relocatable-comdat2.s [new file with mode: 0644]