Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/lib/ObjectYAML/ELFYAML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,8 @@ void MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::mapping(
// When the Type string does not have a "SHT_" prefix, we know it is not a
// description of a regular ELF output section.
TypeStr = getStringValue(IO, "Type");
// To for fallback to `default` in switch below on error.
Type = ELF::SHT_NULL;
if (TypeStr.starts_with("SHT_") || isInteger(TypeStr))
IO.mapRequired("Type", Type);
}
Expand Down
16 changes: 16 additions & 0 deletions llvm/test/tools/yaml2obj/ELF/section-headers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,19 @@ Sections:
# LINK-NEXT: [ 2] .ref.first PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] [[#%x,]] 1
# LINK-NEXT: [ 3] .ref.last PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] [[#%x,]] 4
# LINK-NEXT: [ 4] .shstrtab

# Must not crash under Msan.
# RUN: not yaml2obj %s --docnum=15 -o %t15 2>&1 | FileCheck %s --check-prefix=FOO_SECTION

--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Sections:
- Name: .foo
Type: FOO_SECTION
Size: 0x10
Content: [[<none>]]

# FOO_SECTION: invalid hex32 number
Loading