llvm.org GIT mirror llvm / f3f578d
[yaml2obj] Add default sh_entsize for dynamic sections Dynamic section holds a table, so the sh_entsize might be set. As the dynamic section entry size never changes, we can default it to the size of a dynamic entry. Differential Revision: https://reviews.llvm.org/D49619 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337725 91177308-0d34-0410-b5e6-96231b3b80d8 Paul Semel 1 year, 1 month ago
2 changed file(s) with 20 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 # Ensures that dynamic section has sh_entsize correctly set
1 # RUN: yaml2obj %s -o %t
2 # RUN: llvm-readobj -sections %t | FileCheck %s --check-prefix=SECTION
3
4 !ELF
5 FileHeader:
6 Class: ELFCLASS64
7 Data: ELFDATA2LSB
8 Type: ET_DYN
9 Machine: EM_X86_64
10 Sections:
11 - Name: .dynamic
12 Type: SHT_DYNAMIC
13 Flags: [ SHF_ALLOC, SHF_WRITE ]
14
15 # SECTION: Name: .dynamic
16 # SECTION: EntrySize: 16
114114 typedef typename ELFT::Rel Elf_Rel;
115115 typedef typename ELFT::Rela Elf_Rela;
116116 typedef typename ELFT::Relr Elf_Relr;
117 typedef typename ELFT::Dyn Elf_Dyn;
117118
118119 enum class SymtabType { Static, Dynamic };
119120
461462 OS.write(0);
462463 if (Section.Type == llvm::ELF::SHT_RELR)
463464 SHeader.sh_entsize = sizeof(Elf_Relr);
465 else if (Section.Type == llvm::ELF::SHT_DYNAMIC)
466 SHeader.sh_entsize = sizeof(Elf_Dyn);
464467 else
465468 SHeader.sh_entsize = 0;
466469 SHeader.sh_size = Section.Size;