/// valid.
DataExtractor(StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
: Data(Data), IsLittleEndian(IsLittleEndian), AddressSize(AddressSize) {}
+ DataExtractor(ArrayRef<uint8_t> Data, bool IsLittleEndian,
+ uint8_t AddressSize)
+ : Data(StringRef(reinterpret_cast<const char *>(Data.data()),
+ Data.size())),
+ IsLittleEndian(IsLittleEndian), AddressSize(AddressSize) {}
/// Get the data pointed to by this extractor.
StringRef getData() const { return Data; }
W.printString("Corresponding Section", *SectionName);
}
- DataExtractor DE(
- StringRef(reinterpret_cast<const char *>(Obj->base()) + EHFrameHdrOffset,
- EHFrameHdrSize),
- ELFT::TargetEndianness == support::endianness::little,
- ELFT::Is64Bits ? 8 : 4);
+ DataExtractor DE(makeArrayRef(Obj->base() + EHFrameHdrOffset, EHFrameHdrSize),
+ ELFT::TargetEndianness == support::endianness::little,
+ ELFT::Is64Bits ? 8 : 4);
DictScope D(W, "Header");
uint64_t Offset = 0;
OS << " " << N.Type << ":\n " << N.Value << '\n';
} else if (Name == "CORE") {
if (Type == ELF::NT_FILE) {
- DataExtractor DescExtractor(
- StringRef(reinterpret_cast<const char *>(Descriptor.data()),
- Descriptor.size()),
- ELFT::TargetEndianness == support::little, sizeof(Elf_Addr));
+ DataExtractor DescExtractor(Descriptor,
+ ELFT::TargetEndianness == support::little,
+ sizeof(Elf_Addr));
Expected<CoreNote> Note = readCoreNote(DescExtractor);
if (Note)
printCoreNote<ELFT>(OS, *Note);
const Elf_Shdr *ElfSec = Obj->getSection(Sec.getRawDataRefImpl());
ArrayRef<uint8_t> Contents =
unwrapOrError(this->FileName, EF->getSectionContents(ElfSec));
- DataExtractor Data(
- StringRef(reinterpret_cast<const char *>(Contents.data()),
- Contents.size()),
- Obj->isLittleEndian(), sizeof(Elf_Addr));
+ DataExtractor Data(Contents, Obj->isLittleEndian(), sizeof(Elf_Addr));
// A .stack_sizes section header's sh_link field is supposed to point
// to the section that contains the functions whose stack sizes are
// described in it.
RelocationResolver Resolver;
std::tie(IsSupportedFn, Resolver) = getRelocationResolver(*Obj);
auto Contents = unwrapOrError(this->FileName, StackSizesSec.getContents());
- DataExtractor Data(
- StringRef(reinterpret_cast<const char *>(Contents.data()),
- Contents.size()),
- Obj->isLittleEndian(), sizeof(Elf_Addr));
+ DataExtractor Data(Contents, Obj->isLittleEndian(), sizeof(Elf_Addr));
for (const RelocationRef &Reloc : RelocSec.relocations()) {
if (!IsSupportedFn(Reloc.getType()))
reportError(createStringError(
W.printString(N.Type, N.Value);
} else if (Name == "CORE") {
if (Type == ELF::NT_FILE) {
- DataExtractor DescExtractor(
- StringRef(reinterpret_cast<const char *>(Descriptor.data()),
- Descriptor.size()),
- ELFT::TargetEndianness == support::little, sizeof(Elf_Addr));
+ DataExtractor DescExtractor(Descriptor,
+ ELFT::TargetEndianness == support::little,
+ sizeof(Elf_Addr));
Expected<CoreNote> Note = readCoreNote(DescExtractor);
if (Note)
printCoreNoteLLVMStyle(*Note, W);