Skip to content

Commit 942e8ed

Browse files
author
George Rimar
committedAug 15, 2018
[yaml2obj] - Teach yaml2obj to produce SHT_GROUP section with a custom Info field.
This allows to set custom Info field value for SHT_GROUP sections. It is useful to allow this because we would be able to replace at least one binary object committed in LLD and replace it with the yaml2obj based test. Differential revision: https://reviews.llvm.org/D50776 llvm-svn: 339772
1 parent e1a04b4 commit 942e8ed

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# RUN: yaml2obj %s -o %t
2+
# RUN: llvm-readobj -sections %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: 12345
15+
Members:
16+
- SectionOrType: GRP_COMDAT
17+
18+
## Check we are able to produce SHT_GROUP section with a custom Info value (12345).
19+
# CHECK: Name: .group
20+
# CHECK-NEXT: Type: SHT_GROUP
21+
# CHECK-NEXT: Flags [
22+
# CHECK-NEXT: ]
23+
# CHECK-NEXT: Address:
24+
# CHECK-NEXT: Offset:
25+
# CHECK-NEXT: Size:
26+
# CHECK-NEXT: Link:
27+
# CHECK-NEXT: Info: 12345

‎llvm/tools/yaml2obj/yaml2elf.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
274274
return false;
275275
} else if (auto S = dyn_cast<ELFYAML::Group>(Sec.get())) {
276276
unsigned SymIdx;
277-
if (SymN2I.lookup(S->Info, SymIdx)) {
277+
if (SymN2I.lookup(S->Info, SymIdx) && !to_integer(S->Info, SymIdx)) {
278278
WithColor::error() << "Unknown symbol referenced: '" << S->Info
279279
<< "' at YAML section '" << S->Name << "'.\n";
280280
return false;

0 commit comments

Comments
 (0)
Please sign in to comment.