Long section names are represented as a slash followed by a numeric
ASCII string. This number is an offset into a string table.
Print the appropriate entry in the string table instead of the less
enlightening /4.
N.B. yaml2obj already does the right thing, this test exercises both
sides of the (de-)serialization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219458
91177308-0d34-0410-b5e6-
96231b3b80d8
--- /dev/null
+---
+header:
+ Machine: IMAGE_FILE_MACHINE_I386
+ Characteristics: [ IMAGE_FILE_RELOCS_STRIPPED, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_32BIT_MACHINE ]
+sections:
+ - Name: .long_section_name
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: ''
+symbols:
+...
--- /dev/null
+RUN: yaml2obj %p/Inputs/COFF/long-section-name.yaml | obj2yaml | FileCheck %s --check-prefix COFF-I386
+
+COFF-I386: Name: .long_section_name
for (const auto &Section : Obj.sections()) {
const object::coff_section *Sect = Obj.getCOFFSection(Section);
COFFYAML::Section Sec;
for (const auto &Section : Obj.sections()) {
const object::coff_section *Sect = Obj.getCOFFSection(Section);
COFFYAML::Section Sec;
- Sec.Name = Sect->Name; // FIXME: check the null termination!
- uint32_t Characteristics = Sect->Characteristics;
- Sec.Header.Characteristics = Characteristics;
- Sec.Alignment = 1 << (((Characteristics >> 20) & 0xf) - 1);
+ Section.getName(Sec.Name);
+ Sec.Header.Characteristics = Sect->Characteristics;
+ Sec.Alignment = Section.getAlignment();
ArrayRef<uint8_t> sectionData;
ArrayRef<uint8_t> sectionData;
- Obj.getSectionContents(Sect, sectionData);
+ if (!Section.isBSS())
+ Obj.getSectionContents(Sect, sectionData);
Sec.SectionData = yaml::BinaryRef(sectionData);
std::vector<COFFYAML::Relocation> Relocations;
Sec.SectionData = yaml::BinaryRef(sectionData);
std::vector<COFFYAML::Relocation> Relocations;