summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2015-01-25 13:29:25 +0000
committerSimon Atanasyan <simon@atanasyan.com>2015-01-25 13:29:25 +0000
commit5d19c67a68533d716fd791ea5a4cdb6b13a26ab1 (patch)
tree44a69f5e7273e2994174c1ae21f78505e8a35e7d /llvm/tools
parent1a603b3f13e10a378602a1ed164e59b61e2fa485 (diff)
downloadbcm5719-llvm-5d19c67a68533d716fd791ea5a4cdb6b13a26ab1.tar.gz
bcm5719-llvm-5d19c67a68533d716fd791ea5a4cdb6b13a26ab1.zip
[ELFYAML] Support mips64 relocation record format in yaml2obj/obj2yaml
MIPS64 ELF file has a very specific relocation record format. Each record might specify up to three relocation operations. So the `r_info` field in fact consists of three relocation type sub-fields and optional code of "special" symbols. http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf page 40 The patch implements support of the MIPS64 relocation record format in yaml2obj/obj2yaml tools by introducing new optional Relocation fields: Type2, Type3, and SpecSym. These fields are recognized only if the object/YAML file relates to the MIPS64 target. Differential Revision: http://reviews.llvm.org/D7136 llvm-svn: 227044
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/yaml2obj/yaml2elf.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/tools/yaml2obj/yaml2elf.cpp b/llvm/tools/yaml2obj/yaml2elf.cpp
index 44c8c12da89..c8d4b887576 100644
--- a/llvm/tools/yaml2obj/yaml2elf.cpp
+++ b/llvm/tools/yaml2obj/yaml2elf.cpp
@@ -321,6 +321,12 @@ ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
SHeader.sh_size = Section.Size;
}
+static bool isMips64EL(const ELFYAML::Object &Doc) {
+ return Doc.Header.Machine == ELFYAML::ELF_EM(llvm::ELF::EM_MIPS) &&
+ Doc.Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64) &&
+ Doc.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB);
+}
+
template <class ELFT>
bool
ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
@@ -351,13 +357,13 @@ ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
zero(REntry);
REntry.r_offset = Rel.Offset;
REntry.r_addend = Rel.Addend;
- REntry.setSymbolAndType(SymIdx, Rel.Type);
+ REntry.setSymbolAndType(SymIdx, Rel.Type, isMips64EL(Doc));
OS.write((const char *)&REntry, sizeof(REntry));
} else {
Elf_Rel REntry;
zero(REntry);
REntry.r_offset = Rel.Offset;
- REntry.setSymbolAndType(SymIdx, Rel.Type);
+ REntry.setSymbolAndType(SymIdx, Rel.Type, isMips64EL(Doc));
OS.write((const char *)&REntry, sizeof(REntry));
}
}
OpenPOWER on IntegriCloud