[llvm] r337725 - [yaml2obj] Add default sh_entsize for dynamic sections
Paul Semel via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 23 11:49:04 PDT 2018
Author: paulsemel
Date: Mon Jul 23 11:49:04 2018
New Revision: 337725
URL: http://llvm.org/viewvc/llvm-project?rev=337725&view=rev
Log:
[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
Added:
llvm/trunk/test/tools/yaml2obj/dynamic-section.yaml
Modified:
llvm/trunk/tools/yaml2obj/yaml2elf.cpp
Added: llvm/trunk/test/tools/yaml2obj/dynamic-section.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/dynamic-section.yaml?rev=337725&view=auto
==============================================================================
--- llvm/trunk/test/tools/yaml2obj/dynamic-section.yaml (added)
+++ llvm/trunk/test/tools/yaml2obj/dynamic-section.yaml Mon Jul 23 11:49:04 2018
@@ -0,0 +1,17 @@
+# Ensures that dynamic section has sh_entsize correctly set
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj -sections %t | FileCheck %s --check-prefix=SECTION
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Flags: [ SHF_ALLOC, SHF_WRITE ]
+
+# SECTION: Name: .dynamic
+# SECTION: EntrySize: 16
Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=337725&r1=337724&r2=337725&view=diff
==============================================================================
--- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)
+++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Mon Jul 23 11:49:04 2018
@@ -115,6 +115,7 @@ class ELFState {
typedef typename ELFT::Rel Elf_Rel;
typedef typename ELFT::Rela Elf_Rela;
typedef typename ELFT::Relr Elf_Relr;
+ typedef typename ELFT::Dyn Elf_Dyn;
enum class SymtabType { Static, Dynamic };
@@ -462,6 +463,8 @@ ELFState<ELFT>::writeSectionContent(Elf_
OS.write(0);
if (Section.Type == llvm::ELF::SHT_RELR)
SHeader.sh_entsize = sizeof(Elf_Relr);
+ else if (Section.Type == llvm::ELF::SHT_DYNAMIC)
+ SHeader.sh_entsize = sizeof(Elf_Dyn);
else
SHeader.sh_entsize = 0;
SHeader.sh_size = Section.Size;
More information about the llvm-commits
mailing list