diff options
Diffstat (limited to 'llvm/tools/llvm-objdump')
-rw-r--r-- | llvm/tools/llvm-objdump/MachODump.cpp | 16 | ||||
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 8 |
2 files changed, 15 insertions, 9 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index d6e29a3..6dccf21 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -1749,7 +1749,7 @@ static void DumpLiteralPointerSection(MachOObjectFile *O, StringRef BytesStr = unwrapOrError(Sect->getContents(), O->getFileName()); - const char *Contents = reinterpret_cast<const char *>(BytesStr.data()); + const char *Contents = BytesStr.data(); switch (section_type) { case MachO::S_CSTRING_LITERALS: @@ -1965,7 +1965,7 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O, StringRef BytesStr = unwrapOrError(Section.getContents(), O->getFileName()); - const char *sect = reinterpret_cast<const char *>(BytesStr.data()); + const char *sect = BytesStr.data(); uint32_t sect_size = BytesStr.size(); uint64_t sect_addr = Section.getAddress(); @@ -2049,7 +2049,7 @@ static void DumpInfoPlistSectionContents(StringRef Filename, outs() << "Contents of (" << SegName << "," << SectName << ") section\n"; StringRef BytesStr = unwrapOrError(Section.getContents(), O->getFileName()); - const char *sect = reinterpret_cast<const char *>(BytesStr.data()); + const char *sect = BytesStr.data(); outs() << format("%.*s", BytesStr.size(), sect) << "\n"; return; } @@ -3237,7 +3237,7 @@ static const char *GuessCstringPointer(uint64_t ReferenceValue, uint64_t object_offset = Sec.offset + sect_offset; StringRef MachOContents = info->O->getData(); uint64_t object_size = MachOContents.size(); - const char *object_addr = (const char *)MachOContents.data(); + const char *object_addr = MachOContents.data(); if (object_offset < object_size) { const char *name = object_addr + object_offset; return name; @@ -3258,7 +3258,7 @@ static const char *GuessCstringPointer(uint64_t ReferenceValue, uint64_t object_offset = Sec.offset + sect_offset; StringRef MachOContents = info->O->getData(); uint64_t object_size = MachOContents.size(); - const char *object_addr = (const char *)MachOContents.data(); + const char *object_addr = MachOContents.data(); if (object_offset < object_size) { const char *name = object_addr + object_offset; return name; @@ -3447,7 +3447,7 @@ static uint64_t GuessPointerPointer(uint64_t ReferenceValue, uint64_t object_offset = Sec.offset + sect_offset; StringRef MachOContents = info->O->getData(); uint64_t object_size = MachOContents.size(); - const char *object_addr = (const char *)MachOContents.data(); + const char *object_addr = MachOContents.data(); if (object_offset < object_size) { uint64_t pointer_value; memcpy(&pointer_value, object_addr + object_offset, @@ -4350,7 +4350,7 @@ walk_pointer_list_64(const char *listname, const SectionRef S, outs() << "Contents of (" << SegName << "," << SectName << ") section\n"; StringRef BytesStr = unwrapOrError(S.getContents(), O->getFileName()); - const char *Contents = reinterpret_cast<const char *>(BytesStr.data()); + const char *Contents = BytesStr.data(); for (uint32_t i = 0; i < S.getSize(); i += sizeof(uint64_t)) { uint32_t left = S.getSize() - i; @@ -4399,7 +4399,7 @@ walk_pointer_list_32(const char *listname, const SectionRef S, outs() << "Contents of (" << SegName << "," << SectName << ") section\n"; StringRef BytesStr = unwrapOrError(S.getContents(), O->getFileName()); - const char *Contents = reinterpret_cast<const char *>(BytesStr.data()); + const char *Contents = BytesStr.data(); for (uint32_t i = 0; i < S.getSize(); i += sizeof(uint32_t)) { uint32_t left = S.getSize() - i; diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index c19c698..815759d 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -636,8 +636,14 @@ static bool isCSKYElf(const ObjectFile &Obj) { return Elf && Elf->getEMachine() == ELF::EM_CSKY; } +static bool isRISCVElf(const ObjectFile &Obj) { + const auto *Elf = dyn_cast<ELFObjectFileBase>(&Obj); + return Elf && Elf->getEMachine() == ELF::EM_RISCV; +} + static bool hasMappingSymbols(const ObjectFile &Obj) { - return isArmElf(Obj) || isAArch64Elf(Obj) || isCSKYElf(Obj); + return isArmElf(Obj) || isAArch64Elf(Obj) || isCSKYElf(Obj) || + isRISCVElf(Obj); } static void printRelocation(formatted_raw_ostream &OS, StringRef FileName, |