Files
clang-p2996/lld/test/elf/sectionGroups/sectiongroup-simple.test
Shankar Easwaran 9e07346679 [ELF] Add section group/COMDAT support.
SHF_GROUP: Group Member Sections
----------------------------------
A section which is part of a group, and is to be retained or discarded with the
group as a whole, is identified by a new section header attribute: SHF_GROUP
This section is a member (perhaps the only one) of a group of sections, and the
linker should retain or discard all or none of the members. This section must be
referenced in a SHT_GROUP section. This attribute flag may be set in any section
header, and no other modification or indication is made in the grouped sections.
All additional information is contained in the associated SHT_GROUP section.

SHT_GROUP: Section Group Definition
-------------------------------------
Represents a group section.

The section group's sh_link field identifies a symbol table section, and its
sh_info field the index of a symbol in that section. The name of that symbol is
treated as the identifier of the section group.

More information: https://mentorembedded.github.io/cxx-abi/abi/prop-72-comdat.html

Added a lot of extensive tests, that tests functionality.

llvm-svn: 230195
2015-02-23 00:30:00 +00:00

147 lines
4.5 KiB
Plaintext

# Checks that the linker picks the first group in the output file when the file
# have some members dont appear in the first group.
# 1a.s
# ------
# .section .text,"axG",%progbits,foo_group,comdat
# .weak foo
#foo:
# .word 0
# 1b.s
# -----
# .section .text,"axG",%progbits,foo_group,comdat
# .global bar
#bar:
#RUN: yaml2obj -format=elf -docnum 1 %s -o %t.group1a.o
#RUN: yaml2obj -format=elf -docnum 2 %s -o %t.group1b.o
#RUN: lld -flavor gnu -target x86_64 %t.group1a.o %t.group1b.o \
#RUN: --noinhibit-exec --output-filetype=yaml -o %t2.out.yaml
#RUN: lld -flavor gnu -target x86_64 %t.group1a.o %t.group1b.o \
#RUN: --noinhibit-exec -o %t2.out
#RUN: FileCheck %s -check-prefix=CHECKGROUP < %t2.out.yaml
#RUN: llvm-readobj -sections %t2.out | FileCheck %s -check-prefix=CHECKGROUPSECTIONS
#RUN: llvm-readobj -symbols %t2.out | FileCheck %s -check-prefix=CHECKSYMBOLS
#CHECKGROUP: - name: foo
#CHECKGROUP: scope: global
#CHECKGROUP: merge: as-weak
#CHECKGROUP: section-name: .text
#CHECKGROUP: - name: foo_group
#CHECKGROUP: scope: global
#CHECKGROUP: type: group-comdat
#CHECKGROUP: section-choice: custom-required
#CHECKGROUP: section-name: .group
#CHECKGROUP: permissions: ---
#CHECKGROUP: references:
#CHECKGROUP: - kind: group-child
#CHECKGROUP: offset: 0
#CHECKGROUP: target: foo
#CHECKGROUPSECTIONS: Section {
#CHECKGROUPSECTIONS: Name: .text
#CHECKGROUPSECTIONS: Type: SHT_PROGBITS
#CHECKGROUPSECTIONS: Flags [ (0x6)
#CHECKGROUPSECTIONS: SHF_ALLOC (0x2)
#CHECKGROUPSECTIONS: SHF_EXECINSTR (0x4)
#CHECKGROUPSECTIONS: ]
#CHECKGROUPSECTIONS: Size: 2
#CHECKGROUPSECTIONS: AddressAlignment: 1
#CHECKGROUPSECTIONS: }
#CHECKSYMBOLS: Name: foo
#CHECKSYMBOLS: Type: Function
#CHECKSYMBOLS: Section: .text
---
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
OSABI: ELFOSABI_GNU
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .group
Type: SHT_GROUP
Link: .symtab
AddressAlign: 0x0000000000000004
Info: foo_group
Members:
- SectionOrType: GRP_COMDAT
- SectionOrType: .text
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x0000000000000004
Content: ''
- Name: .bss
Type: SHT_NOBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x0000000000000004
Content: ''
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
AddressAlign: 0x0000000000000001
Content: '0000'
Symbols:
Local:
- Name: foo_group
Section: .group
- Name: .text
Type: STT_SECTION
Section: .text
- Name: .data
Type: STT_SECTION
Section: .data
- Name: .bss
Type: STT_SECTION
Section: .bss
Weak:
- Name: foo
Section: .text
...
---
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
OSABI: ELFOSABI_GNU
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .group
Type: SHT_GROUP
Link: .symtab
AddressAlign: 0x0000000000000004
Info: foo_group
Members:
- SectionOrType: GRP_COMDAT
- SectionOrType: .text
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x0000000000000004
Content: ''
- Name: .bss
Type: SHT_NOBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x0000000000000004
Content: ''
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
AddressAlign: 0x0000000000000001
Content: ''
Symbols:
Local:
- Name: foo_group
Section: .group
- Name: .text
Type: STT_SECTION
Section: .text
- Name: .data
Type: STT_SECTION
Section: .data
- Name: .bss
Type: STT_SECTION
Section: .bss
Global:
- Name: bar
Section: .text
...