Skip to content

Commit 5290af8

Browse files
author
George Rimar
committedAug 15, 2018
[yaml2obj] - Teach tool to produce SHT_GROUP section with a custom type.
Currently, it is possible to use yaml2obj for producing SHT_GROUP sections of type GRP_COMDAT. For LLD test case I need to produce an object with a broken (different from GRP_COMDAT) type. The patch teaches tool to do such things. Differential revision: https://reviews.llvm.org/D50761 llvm-svn: 339764
1 parent 4b2317e commit 5290af8

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed
 
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# RUN: yaml2obj %s -o %t
2+
# RUN: llvm-readobj -sections -elf-section-groups %t | FileCheck %s
3+
4+
--- !ELF
5+
FileHeader:
6+
Class: ELFCLASS64
7+
Data: ELFDATA2LSB
8+
Type: ET_REL
9+
Machine: EM_X86_64
10+
Sections:
11+
- Name: .group
12+
Type: SHT_GROUP
13+
Link: .symtab
14+
Info: foo
15+
Members:
16+
- SectionOrType: 0xFF
17+
- SectionOrType: 3
18+
Symbols:
19+
Global:
20+
- Name: foo
21+
22+
## Check we are able to produce SHT_GROUP section with a custom Type (0xFF).
23+
# CHECK: Groups {
24+
# CHECK-NEXT: Group {
25+
# CHECK-NEXT: Name: .group
26+
# CHECK-NEXT: Index: 1
27+
# CHECK-NEXT: Link: 2
28+
# CHECK-NEXT: Info: 1
29+
# CHECK-NEXT: Type: COMDAT (0xFF)
30+
# CHECK-NEXT: Signature: foo
31+
# CHECK-NEXT: Section(s) in group [
32+
# CHECK-NEXT: .strtab (3)
33+
# CHECK-NEXT: ]
34+
# CHECK-NEXT: }

‎llvm/tools/yaml2obj/yaml2elf.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ bool ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
537537
unsigned int sectionIndex = 0;
538538
if (member.sectionNameOrType == "GRP_COMDAT")
539539
sectionIndex = llvm::ELF::GRP_COMDAT;
540-
else if (SN2I.lookup(member.sectionNameOrType, sectionIndex)) {
540+
else if (SN2I.lookup(member.sectionNameOrType, sectionIndex) &&
541+
!to_integer(member.sectionNameOrType, sectionIndex)) {
541542
WithColor::error() << "Unknown section referenced: '"
542543
<< member.sectionNameOrType << "' at YAML section' "
543544
<< Section.Name << "\n";

0 commit comments

Comments
 (0)