[XCOFF] Add functionality for parsing AIX XCOFF object file headers
Summary:
1. Add functionality for parsing AIX XCOFF object files headers.
2. Only support 32-bit AIX XCOFF object files in this patch.
3. Print out the AIX XCOFF object file header in YAML format.
Reviewers: sfertile, hubert.reinterpretcast, jasonliu, mstorsjo, zturner, rnk
Reviewed By: sfertile, hubert.reinterpretcast
Subscribers: jsji, mgorny, hiraditya, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59419
Patch by Digger Lin
llvm-svn: 357663
2019-04-04 02:53:21 +02:00
|
|
|
//===-- XCOFFYAML.cpp - XCOFF YAMLIO implementation -------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines classes for handling the YAML representation of XCOFF.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/ObjectYAML/XCOFFYAML.h"
|
2019-05-28 16:37:59 +02:00
|
|
|
#include "llvm/BinaryFormat/XCOFF.h"
|
[XCOFF] Add functionality for parsing AIX XCOFF object file headers
Summary:
1. Add functionality for parsing AIX XCOFF object files headers.
2. Only support 32-bit AIX XCOFF object files in this patch.
3. Print out the AIX XCOFF object file header in YAML format.
Reviewers: sfertile, hubert.reinterpretcast, jasonliu, mstorsjo, zturner, rnk
Reviewed By: sfertile, hubert.reinterpretcast
Subscribers: jsji, mgorny, hiraditya, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59419
Patch by Digger Lin
llvm-svn: 357663
2019-04-04 02:53:21 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace XCOFFYAML {
|
|
|
|
|
|
|
|
Object::Object() { memset(&Header, 0, sizeof(Header)); }
|
|
|
|
|
|
|
|
} // namespace XCOFFYAML
|
|
|
|
|
|
|
|
namespace yaml {
|
|
|
|
|
2021-06-07 06:14:44 +02:00
|
|
|
void ScalarBitSetTraits<XCOFF::SectionTypeFlags>::bitset(
|
|
|
|
IO &IO, XCOFF::SectionTypeFlags &Value) {
|
|
|
|
#define ECase(X) IO.bitSetCase(Value, #X, XCOFF::X)
|
|
|
|
ECase(STYP_PAD);
|
|
|
|
ECase(STYP_DWARF);
|
|
|
|
ECase(STYP_TEXT);
|
|
|
|
ECase(STYP_DATA);
|
|
|
|
ECase(STYP_BSS);
|
|
|
|
ECase(STYP_EXCEPT);
|
|
|
|
ECase(STYP_INFO);
|
|
|
|
ECase(STYP_TDATA);
|
|
|
|
ECase(STYP_TBSS);
|
|
|
|
ECase(STYP_LOADER);
|
|
|
|
ECase(STYP_DEBUG);
|
|
|
|
ECase(STYP_TYPCHK);
|
|
|
|
ECase(STYP_OVRFLO);
|
|
|
|
#undef ECase
|
|
|
|
}
|
|
|
|
|
2019-05-28 16:37:59 +02:00
|
|
|
void ScalarEnumerationTraits<XCOFF::StorageClass>::enumeration(
|
|
|
|
IO &IO, XCOFF::StorageClass &Value) {
|
|
|
|
#define ECase(X) IO.enumCase(Value, #X, XCOFF::X)
|
|
|
|
ECase(C_NULL);
|
|
|
|
ECase(C_AUTO);
|
|
|
|
ECase(C_EXT);
|
|
|
|
ECase(C_STAT);
|
|
|
|
ECase(C_REG);
|
|
|
|
ECase(C_EXTDEF);
|
|
|
|
ECase(C_LABEL);
|
|
|
|
ECase(C_ULABEL);
|
|
|
|
ECase(C_MOS);
|
|
|
|
ECase(C_ARG);
|
|
|
|
ECase(C_STRTAG);
|
|
|
|
ECase(C_MOU);
|
|
|
|
ECase(C_UNTAG);
|
|
|
|
ECase(C_TPDEF);
|
|
|
|
ECase(C_USTATIC);
|
|
|
|
ECase(C_ENTAG);
|
|
|
|
ECase(C_MOE);
|
|
|
|
ECase(C_REGPARM);
|
|
|
|
ECase(C_FIELD);
|
|
|
|
ECase(C_BLOCK);
|
|
|
|
ECase(C_FCN);
|
|
|
|
ECase(C_EOS);
|
|
|
|
ECase(C_FILE);
|
|
|
|
ECase(C_LINE);
|
|
|
|
ECase(C_ALIAS);
|
|
|
|
ECase(C_HIDDEN);
|
|
|
|
ECase(C_HIDEXT);
|
|
|
|
ECase(C_BINCL);
|
|
|
|
ECase(C_EINCL);
|
|
|
|
ECase(C_INFO);
|
|
|
|
ECase(C_WEAKEXT);
|
|
|
|
ECase(C_DWARF);
|
|
|
|
ECase(C_GSYM);
|
|
|
|
ECase(C_LSYM);
|
|
|
|
ECase(C_PSYM);
|
|
|
|
ECase(C_RSYM);
|
|
|
|
ECase(C_RPSYM);
|
|
|
|
ECase(C_STSYM);
|
|
|
|
ECase(C_TCSYM);
|
|
|
|
ECase(C_BCOMM);
|
|
|
|
ECase(C_ECOML);
|
|
|
|
ECase(C_ECOMM);
|
|
|
|
ECase(C_DECL);
|
|
|
|
ECase(C_ENTRY);
|
|
|
|
ECase(C_FUN);
|
|
|
|
ECase(C_BSTAT);
|
|
|
|
ECase(C_ESTAT);
|
|
|
|
ECase(C_GTLS);
|
|
|
|
ECase(C_STTLS);
|
|
|
|
ECase(C_EFCN);
|
|
|
|
#undef ECase
|
|
|
|
}
|
|
|
|
|
2021-06-07 06:14:44 +02:00
|
|
|
struct NSectionFlags {
|
|
|
|
NSectionFlags(IO &) : Flags(XCOFF::SectionTypeFlags(0)) {}
|
|
|
|
NSectionFlags(IO &, uint32_t C) : Flags(XCOFF::SectionTypeFlags(C)) {}
|
|
|
|
|
|
|
|
uint32_t denormalize(IO &) { return Flags; }
|
|
|
|
|
|
|
|
XCOFF::SectionTypeFlags Flags;
|
|
|
|
};
|
|
|
|
|
[XCOFF] Add functionality for parsing AIX XCOFF object file headers
Summary:
1. Add functionality for parsing AIX XCOFF object files headers.
2. Only support 32-bit AIX XCOFF object files in this patch.
3. Print out the AIX XCOFF object file header in YAML format.
Reviewers: sfertile, hubert.reinterpretcast, jasonliu, mstorsjo, zturner, rnk
Reviewed By: sfertile, hubert.reinterpretcast
Subscribers: jsji, mgorny, hiraditya, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59419
Patch by Digger Lin
llvm-svn: 357663
2019-04-04 02:53:21 +02:00
|
|
|
void MappingTraits<XCOFFYAML::FileHeader>::mapping(
|
|
|
|
IO &IO, XCOFFYAML::FileHeader &FileHdr) {
|
2021-06-07 06:14:44 +02:00
|
|
|
IO.mapOptional("MagicNumber", FileHdr.Magic);
|
|
|
|
IO.mapOptional("NumberOfSections", FileHdr.NumberOfSections);
|
|
|
|
IO.mapOptional("CreationTime", FileHdr.TimeStamp);
|
|
|
|
IO.mapOptional("OffsetToSymbolTable", FileHdr.SymbolTableOffset);
|
|
|
|
IO.mapOptional("EntriesInSymbolTable", FileHdr.NumberOfSymTableEntries);
|
|
|
|
IO.mapOptional("AuxiliaryHeaderSize", FileHdr.AuxHeaderSize);
|
|
|
|
IO.mapOptional("Flags", FileHdr.Flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MappingTraits<XCOFFYAML::Relocation>::mapping(IO &IO,
|
|
|
|
XCOFFYAML::Relocation &R) {
|
|
|
|
IO.mapOptional("Address", R.VirtualAddress);
|
|
|
|
IO.mapOptional("Symbol", R.SymbolIndex);
|
|
|
|
IO.mapOptional("Info", R.Info);
|
|
|
|
IO.mapOptional("Type", R.Type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MappingTraits<XCOFFYAML::Section>::mapping(IO &IO,
|
|
|
|
XCOFFYAML::Section &Sec) {
|
|
|
|
MappingNormalization<NSectionFlags, uint32_t> NC(IO, Sec.Flags);
|
|
|
|
IO.mapOptional("Name", Sec.SectionName);
|
|
|
|
IO.mapOptional("Address", Sec.Address);
|
|
|
|
IO.mapOptional("Size", Sec.Size);
|
|
|
|
IO.mapOptional("FileOffsetToData", Sec.FileOffsetToData);
|
|
|
|
IO.mapOptional("FileOffsetToRelocations", Sec.FileOffsetToRelocations);
|
|
|
|
IO.mapOptional("FileOffsetToLineNumbers", Sec.FileOffsetToLineNumbers);
|
|
|
|
IO.mapOptional("NumberOfRelocations", Sec.NumberOfRelocations);
|
|
|
|
IO.mapOptional("NumberOfLineNumbers", Sec.NumberOfLineNumbers);
|
|
|
|
IO.mapOptional("Flags", NC->Flags);
|
|
|
|
IO.mapOptional("SectionData", Sec.SectionData);
|
|
|
|
IO.mapOptional("Relocations", Sec.Relocations);
|
[XCOFF] Add functionality for parsing AIX XCOFF object file headers
Summary:
1. Add functionality for parsing AIX XCOFF object files headers.
2. Only support 32-bit AIX XCOFF object files in this patch.
3. Print out the AIX XCOFF object file header in YAML format.
Reviewers: sfertile, hubert.reinterpretcast, jasonliu, mstorsjo, zturner, rnk
Reviewed By: sfertile, hubert.reinterpretcast
Subscribers: jsji, mgorny, hiraditya, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59419
Patch by Digger Lin
llvm-svn: 357663
2019-04-04 02:53:21 +02:00
|
|
|
}
|
|
|
|
|
2019-05-28 16:37:59 +02:00
|
|
|
void MappingTraits<XCOFFYAML::Symbol>::mapping(IO &IO, XCOFFYAML::Symbol &S) {
|
|
|
|
IO.mapRequired("Name", S.SymbolName);
|
2021-06-07 06:14:44 +02:00
|
|
|
IO.mapOptional("Value", S.Value);
|
|
|
|
IO.mapOptional("Section", S.SectionName);
|
|
|
|
IO.mapOptional("Type", S.Type);
|
|
|
|
IO.mapOptional("StorageClass", S.StorageClass);
|
|
|
|
IO.mapOptional("NumberOfAuxEntries", S.NumberOfAuxEntries);
|
2019-05-28 16:37:59 +02:00
|
|
|
}
|
|
|
|
|
[XCOFF] Add functionality for parsing AIX XCOFF object file headers
Summary:
1. Add functionality for parsing AIX XCOFF object files headers.
2. Only support 32-bit AIX XCOFF object files in this patch.
3. Print out the AIX XCOFF object file header in YAML format.
Reviewers: sfertile, hubert.reinterpretcast, jasonliu, mstorsjo, zturner, rnk
Reviewed By: sfertile, hubert.reinterpretcast
Subscribers: jsji, mgorny, hiraditya, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59419
Patch by Digger Lin
llvm-svn: 357663
2019-04-04 02:53:21 +02:00
|
|
|
void MappingTraits<XCOFFYAML::Object>::mapping(IO &IO, XCOFFYAML::Object &Obj) {
|
|
|
|
IO.mapTag("!XCOFF", true);
|
|
|
|
IO.mapRequired("FileHeader", Obj.Header);
|
2021-06-07 06:14:44 +02:00
|
|
|
IO.mapOptional("Sections", Obj.Sections);
|
|
|
|
IO.mapOptional("Symbols", Obj.Symbols);
|
[XCOFF] Add functionality for parsing AIX XCOFF object file headers
Summary:
1. Add functionality for parsing AIX XCOFF object files headers.
2. Only support 32-bit AIX XCOFF object files in this patch.
3. Print out the AIX XCOFF object file header in YAML format.
Reviewers: sfertile, hubert.reinterpretcast, jasonliu, mstorsjo, zturner, rnk
Reviewed By: sfertile, hubert.reinterpretcast
Subscribers: jsji, mgorny, hiraditya, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59419
Patch by Digger Lin
llvm-svn: 357663
2019-04-04 02:53:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace yaml
|
|
|
|
} // namespace llvm
|