llvm.org GIT mirror llvm / b40956f
[yaml2obj] - Add a support for changing EntSize. I was trying to add a test case for LLD and found that it is impossible to set sh_entsize via yaml. The patch implements the missing part. Differential revision: https://reviews.llvm.org/D50235 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339113 91177308-0d34-0410-b5e6-96231b3b80d8 George Rimar 1 year, 1 month ago
4 changed file(s) with 55 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
122122 StringRef Link;
123123 StringRef Info;
124124 llvm::yaml::Hex64 AddressAlign;
125 Optional EntSize;
125126
126127 Section(SectionKind Kind) : Kind(Kind) {}
127128 virtual ~Section();
815815 IO.mapOptional("Address", Section.Address, Hex64(0));
816816 IO.mapOptional("Link", Section.Link, StringRef());
817817 IO.mapOptional("AddressAlign", Section.AddressAlign, Hex64(0));
818 IO.mapOptional("EntSize", Section.EntSize);
818819 IO.mapOptional("Info", Section.Info, StringRef());
819820 }
820821
0 # RUN: yaml2obj %s -o %t
1 # RUN: llvm-readobj -sections %t | FileCheck %s
2
3 !ELF
4 FileHeader:
5 Class: ELFCLASS64
6 Data: ELFDATA2LSB
7 OSABI: ELFOSABI_FREEBSD
8 Type: ET_REL
9 Machine: EM_X86_64
10 Sections:
11 - Type: SHT_PROGBITS
12 Name: .strings
13 Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
14 AddressAlign: 0x04
15 Content: "FFFFFFFFFFFFFFFF"
16 EntSize: 0x1
17 - Name: .mydynamic
18 Type: SHT_DYNAMIC
19 EntSize: 0x0
20
21
22 ## Check we were able to set entry size for .strings and .mydynamic
23 # CHECK: Name: .strings
24 # CHECK-NEXT: Type: SHT_PROGBITS
25 # CHECK-NEXT: Flags [
26 # CHECK-NEXT: SHF_ALLOC
27 # CHECK-NEXT: SHF_MERGE
28 # CHECK-NEXT: SHF_STRINGS
29 # CHECK-NEXT: ]
30 # CHECK-NEXT: Address:
31 # CHECK-NEXT: Offset:
32 # CHECK-NEXT: Size:
33 # CHECK-NEXT: Link:
34 # CHECK-NEXT: Info:
35 # CHECK-NEXT: AddressAlignment:
36 # CHECK-NEXT: EntrySize: 1
37 # CHECK-NEXT: }
38 # CHECK: Name: .mydynamic
39 # CHECK-NEXT: Type: SHT_DYNAMIC
40 # CHECK-NEXT: Flags [
41 # CHECK-NEXT: ]
42 # CHECK-NEXT: Address:
43 # CHECK-NEXT: Offset:
44 # CHECK-NEXT: Size:
45 # CHECK-NEXT: Link:
46 # CHECK-NEXT: Info:
47 # CHECK-NEXT: AddressAlignment:
48 # CHECK-NEXT: EntrySize: 0
49 # CHECK-NEXT: }
460460 Section.Content.writeAsBinary(OS);
461461 for (auto i = Section.Content.binary_size(); i < Section.Size; ++i)
462462 OS.write(0);
463 if (Section.Type == llvm::ELF::SHT_RELR)
463 if (Section.EntSize)
464 SHeader.sh_entsize = *Section.EntSize;
465 else if (Section.Type == llvm::ELF::SHT_RELR)
464466 SHeader.sh_entsize = sizeof(Elf_Relr);
465467 else if (Section.Type == llvm::ELF::SHT_DYNAMIC)
466468 SHeader.sh_entsize = sizeof(Elf_Dyn);