Index: test/tools/yaml2obj/raw-content-section-info.yaml =================================================================== --- /dev/null +++ test/tools/yaml2obj/raw-content-section-info.yaml @@ -0,0 +1,26 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-readobj -sections %t | FileCheck %s + +# CHECK: Name: .raw.content (1) +# CHECK-NEXT: Type: SHT_PROGBITS (0x1) +# CHECK-NEXT: Flags [ (0x2) +# CHECK-NEXT: SHF_ALLOC (0x2) +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x0 +# CHECK-NEXT: Offset: 0x180 +# CHECK-NEXT: Size: 2 +# CHECK-NEXT: Link: 0 +# CHECK-NEXT: Info: 4660 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .raw.content + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Info: 0x1234 + Content: 1234 Index: tools/yaml2obj/yaml2elf.cpp =================================================================== --- tools/yaml2obj/yaml2elf.cpp +++ tools/yaml2obj/yaml2elf.cpp @@ -253,9 +253,18 @@ SHeader.sh_link = Index; } - if (auto S = dyn_cast(Sec.get())) + if (auto S = dyn_cast(Sec.get())) { + if (!Sec->Info.empty()) { + unsigned Index; + if (SN2I.lookup(Sec->Info, Index) && !to_integer(Sec->Info, Index)) { + WithColor::error() << "Unknown section referenced: '" << Sec->Info + << "' at YAML section '" << Sec->Name << "'.\n"; + return false; + } + SHeader.sh_info = Index; + } writeSectionContent(SHeader, *S, CBA); - else if (auto S = dyn_cast(Sec.get())) { + } else if (auto S = dyn_cast(Sec.get())) { if (S->Link.empty()) // For relocation section set link to .symtab by default. SHeader.sh_link = getDotSymTabSecNo();