summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ObjectYAML/ELFEmitter.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-10-01 09:45:59 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-10-01 09:45:59 +0000
commite5163ebf8d9e4262c8adc1309f70e8cabef10f3a (patch)
treecceebce3cbe56a07f2869f59db1691c150216ec1 /llvm/lib/ObjectYAML/ELFEmitter.cpp
parentc2c377ea584d17060fd44151af0c3f2259423d8c (diff)
downloadbcm5719-llvm-e5163ebf8d9e4262c8adc1309f70e8cabef10f3a.tar.gz
bcm5719-llvm-e5163ebf8d9e4262c8adc1309f70e8cabef10f3a.zip
[yaml2obj/obj2yaml] - Add support for SHT_HASH sections.
SHT_HASH specification is: http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#hash In short the format is the following: it has 2 uint32 fields in its header: nbucket and nchain followed by (nbucket + nchain) uint32 values. This patch allows dumping and parsing such sections. Differential revision: https://reviews.llvm.org/D68085 llvm-svn: 373315
Diffstat (limited to 'llvm/lib/ObjectYAML/ELFEmitter.cpp')
-rw-r--r--llvm/lib/ObjectYAML/ELFEmitter.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index 6edc3c8e763..5acb02a5a57 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -171,6 +171,9 @@ template <class ELFT> class ELFState {
void writeSectionContent(Elf_Shdr &SHeader,
const ELFYAML::StackSizesSection &Section,
ContiguousBlobAccumulator &CBA);
+ void writeSectionContent(Elf_Shdr &SHeader,
+ const ELFYAML::HashSection &Section,
+ ContiguousBlobAccumulator &CBA);
ELFState(ELFYAML::Object &D, yaml::ErrorHandler EH);
public:
@@ -417,7 +420,9 @@ void ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
} else if (auto S = dyn_cast<ELFYAML::VerdefSection>(Sec)) {
writeSectionContent(SHeader, *S, CBA);
} else if (auto S = dyn_cast<ELFYAML::StackSizesSection>(Sec)) {
- writeSectionContent(SHeader, *S, CBA);
+ writeSectionContent(SHeader, *S, CBA);
+ } else if (auto S = dyn_cast<ELFYAML::HashSection>(Sec)) {
+ writeSectionContent(SHeader, *S, CBA);
} else {
llvm_unreachable("Unknown section type");
}
@@ -810,6 +815,34 @@ void ELFState<ELFT>::writeSectionContent(
template <class ELFT>
void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
+ const ELFYAML::HashSection &Section,
+ ContiguousBlobAccumulator &CBA) {
+ raw_ostream &OS =
+ CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);
+
+ unsigned Link = 0;
+ if (SN2I.lookup(".dynsym", Link))
+ SHeader.sh_link = Link;
+
+ if (Section.Content) {
+ SHeader.sh_size = writeContent(OS, Section.Content, None);
+ return;
+ }
+
+ support::endian::write<uint32_t>(OS, Section.Bucket->size(),
+ ELFT::TargetEndianness);
+ support::endian::write<uint32_t>(OS, Section.Chain->size(),
+ ELFT::TargetEndianness);
+ for (uint32_t Val : *Section.Bucket)
+ support::endian::write<uint32_t>(OS, Val, ELFT::TargetEndianness);
+ for (uint32_t Val : *Section.Chain)
+ support::endian::write<uint32_t>(OS, Val, ELFT::TargetEndianness);
+
+ SHeader.sh_size = (2 + Section.Bucket->size() + Section.Chain->size()) * 4;
+}
+
+template <class ELFT>
+void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
const ELFYAML::VerdefSection &Section,
ContiguousBlobAccumulator &CBA) {
typedef typename ELFT::Verdef Elf_Verdef;
OpenPOWER on IntegriCloud