xref: /illumos-gate/usr/src/test/elf-tests/tests/groups/no-relobj-group-merge/README.md (revision ddb365bfc9e868ad24ccdcb0dc91af18b10df082)
1This is a test that sections which are members of groups are not merged when
2creating relocatable objects.
3
4If we place an input section which is in a group in the same output section as
5another input section this leaves us with problems:
6
71. If the other input section was not previously member of a group, its data
8   becomes part of a group and we may now discard it along with that group.
92. If the other input section _was_ a member of a group we now have two groups
10   containing the same section, where discarding one will corrupt the other.
113. ... and if that section had associated relocations, which must have been
12   part of the group, we will now associate those relocations with the merged
13   output section further corrupting the group, as there is now no mapping
14   between input and output relocation sections.
15
16We test this by defining 3 sections in two groups in two input objects:
17- `.test_data_conflict` in `group1`
18- `.test_data_conflict` in `group2`
19- `.test_data_conflict` in no group at all
20
21We then link these objects together using `ld -r` and expect:
22- `.test_data_conflict` from `group1` remains in `group1`, is merged with no
23  other input section, and has the duplicate section discarded by the COMDAT
24  group logic.
25- `.test_data_conflict` from `group2` remains in `group2`, is merged with no
26  other input section, and has the duplicate section discarded by the COMDAT
27  group logic.
28- the ungrouped `.test_data_conflict` remains in no groups, and the two input
29  sections are merged into a single output section.
30