Files
llvm/test/tools/obj2yaml/section-group.test
George Rimar 38d4353156 [yaml2obj][obj2yaml] - Do not create a symbol table by default.
This patch tries to resolve problems faced in D68943
and uses some of the code written by Konrad Wilhelm Kleine
in that patch.

Previously, yaml2obj tool always created a .symtab section.
This patch changes that. With it we only create it when
have a "Symbols:" tag in the YAML document or when
we need to create it because it is used by another section(s).

obj2yaml follows the new behavior and does not print "Symbols:"
anymore when there is no symbol table.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375361 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-20 14:47:17 +00:00

72 lines
1.7 KiB
Plaintext

## Checks that the tool is able to read section groups from ELF.
# RUN: yaml2obj --docnum=1 %s > %t1.o
# RUN: llvm-readobj --elf-section-groups %t1.o | FileCheck %s -check-prefix=OBJ
# RUN: obj2yaml %t1.o | FileCheck %s --check-prefix YAML
# OBJ: Groups {
# OBJ-NEXT: Group {
# OBJ-NEXT: Name: .group
# OBJ-NEXT: Index: 1
# OBJ-NEXT: Link: 3
# OBJ-NEXT: Info: 1
# OBJ-NEXT: Type: COMDAT (0x1)
# OBJ-NEXT: Signature: signature
# OBJ-NEXT: Section(s) in group [
# OBJ-NEXT: .rodata (2)
# OBJ-NEXT: ]
# OBJ-NEXT: }
# OBJ-NEXT: }
# YAML: - Name: .group
# YAML: Type: SHT_GROUP
# YAML: Link: .symtab
# YAML: Info: signature
# YAML: Members:
# YAML: - SectionOrType: GRP_COMDAT
# YAML: - SectionOrType: .rodata
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .group
Type: SHT_GROUP
Link: .symtab
Info: signature
Members:
- SectionOrType: GRP_COMDAT
- SectionOrType: .rodata
- Name: .rodata
Type: SHT_PROGBITS
Symbols:
- Name: signature
Type: STT_OBJECT
Section: .rodata
## Check obj2yaml report an error when sh_info field of
## group section contains invalid (too large) signature symbol index.
# RUN: yaml2obj --docnum=2 %s > %t2.o
# RUN: not obj2yaml %t2.o 2>&1 | FileCheck %s --check-prefix ERR
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .group
Type: SHT_GROUP
Link: .symtab
Info: 0xFF
Members:
- SectionOrType: GRP_COMDAT
Symbols: []
# ERR: Error reading file: {{.*}}2.o: unable to get symbol from section [index 2]: invalid symbol index (255)