diff options
author | George Rimar <grimar@accesssoftek.com> | 2019-09-02 09:47:17 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2019-09-02 09:47:17 +0000 |
commit | 86cc736df1fccfe804a6fe3f4a7f8c65f17ae50a (patch) | |
tree | d23b0bd24a71be880be64d844243ae547db5ad84 /llvm/lib/ObjectYAML | |
parent | 5c6b82a7567cd16072a0424fb564c9d3ede11716 (diff) | |
download | bcm5719-llvm-86cc736df1fccfe804a6fe3f4a7f8c65f17ae50a.tar.gz bcm5719-llvm-86cc736df1fccfe804a6fe3f4a7f8c65f17ae50a.zip |
[yaml2obj] - Allow overriding sh_name fields of the sections.
This is in line with the previous changes which allowed to
override the sh_offset/sh_size and useful for writing test cases.
Differential revision: https://reviews.llvm.org/D66998
llvm-svn: 370633
Diffstat (limited to 'llvm/lib/ObjectYAML')
-rw-r--r-- | llvm/lib/ObjectYAML/ELFEmitter.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/ObjectYAML/ELFYAML.cpp | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp index 44af64eadef..9c74d8ba205 100644 --- a/llvm/lib/ObjectYAML/ELFEmitter.cpp +++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp @@ -292,8 +292,10 @@ bool ELFState<ELFT>::initImplicitHeader(ELFState<ELFT> &State, else return false; - // Override the sh_offset/sh_size fields if requested. + // Override the fields if requested. if (YAMLSec) { + if (YAMLSec->ShName) + Header.sh_name = *YAMLSec->ShName; if (YAMLSec->ShOffset) Header.sh_offset = *YAMLSec->ShOffset; if (YAMLSec->ShSize) @@ -395,8 +397,10 @@ bool ELFState<ELFT>::initSectionHeaders(ELFState<ELFT> &State, } else llvm_unreachable("Unknown section type"); - // Override the sh_offset/sh_size fields if requested. + // Override the fields if requested. if (Sec) { + if (Sec->ShName) + SHeader.sh_name = *Sec->ShName; if (Sec->ShOffset) SHeader.sh_offset = *Sec->ShOffset; if (Sec->ShSize) diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index 04084e990c0..6f05d7ddc1a 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -986,10 +986,11 @@ static void commonSectionMapping(IO &IO, ELFYAML::Section &Section) { IO.mapOptional("EntSize", Section.EntSize); // obj2yaml does not dump these fields. They are expected to be empty when we - // are producing YAML, because yaml2obj sets appropriate values for sh_offset - // and sh_size automatically when they are not explicitly defined. + // are producing YAML, because yaml2obj sets appropriate values for them + // automatically when they are not explicitly defined. assert(!IO.outputting() || (!Section.ShOffset.hasValue() && !Section.ShSize.hasValue())); + IO.mapOptional("ShName", Section.ShName); IO.mapOptional("ShOffset", Section.ShOffset); IO.mapOptional("ShSize", Section.ShSize); } |