summaryrefslogtreecommitdiff
path: root/tools/yaml2obj/yaml2elf.cpp
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2015-07-03 23:00:54 +0000
committerSimon Atanasyan <simon@atanasyan.com>2015-07-03 23:00:54 +0000
commitafc0340d960f3cb3179ada4907b7cd748a703db8 (patch)
tree244dc5109779b8734bb77704991881b3fbc8bd2b /tools/yaml2obj/yaml2elf.cpp
parentb8115096135a3d64166c72672d44a98c859a92ef (diff)
[ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj tools
SHT_NOBITS sections do not have content in an object file. Now the yaml2obj tool does not accept `Content` field for such sections, and the obj2yaml tool does not attempt to read the section content from a file. Restore r241350 and r241352. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241377 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/yaml2obj/yaml2elf.cpp')
-rw-r--r--tools/yaml2obj/yaml2elf.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/yaml2obj/yaml2elf.cpp b/tools/yaml2obj/yaml2elf.cpp
index 772b5b918ec..2cbc3380358 100644
--- a/tools/yaml2obj/yaml2elf.cpp
+++ b/tools/yaml2obj/yaml2elf.cpp
@@ -241,6 +241,12 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
} else if (auto S = dyn_cast<ELFYAML::MipsABIFlags>(Sec.get())) {
if (!writeSectionContent(SHeader, *S, CBA))
return false;
+ } else if (auto S = dyn_cast<ELFYAML::NoBitsSection>(Sec.get())) {
+ SHeader.sh_entsize = 0;
+ SHeader.sh_size = S->Size;
+ // SHT_NOBITS section does not have content
+ // so just to setup the section offset.
+ CBA.getOSAndAlignedOffset(SHeader.sh_offset);
} else
llvm_unreachable("Unknown section type");