Files
clang-p2996/llvm/test/tools/obj2yaml/section-group.test
George Rimar 224816ba16 Recommit r366052 "[obj2yaml] - Rework tool's error reporting logic for ELF target."
No changes, LLD code was updated in r366057.

Original commit message:

ELF.h contains two getSymbol methods
which seems to be used only from obj2yaml.

One of these methods calls another, which in turn
contains untested error message which doesn't
provide enough information.

Problem is that after improving only just that message,
obj2yaml will not show it,
("Error reading file: yaml: Invalid data was
encountered while parsing the file" message will be shown instead),
because internal errors handling of tool is based on ErrorOr<> class which
stores a error code and as a result can only show a predefined error string, what
actually isn't very useful.

In this patch, I rework obj2yaml's error reporting system
for ELF targets to use Error  Expected<> classes.
Also, I improve the error message produced
by getSymbol for demonstration of the new functionality.

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

llvm-svn: 366058
2019-07-15 11:53:39 +00:00

71 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
# ERR: Error reading file: {{.*}}2.o: unable to get symbol from section [index 2]: invalid symbol index (255)