Skip to content

Commit

Permalink
[llvm-objdump][Wasm][NFC] Create WasmDump.h
Browse files Browse the repository at this point in the history
Summary:
Continuing from D77285, the external interfaces implemented by
`WasmDump.cpp` are now declared in `WasmDump.h` and moved into the
`llvm::objdump` namespace.

Reviewers: jhenderson, MaskRay, DiggerLin, jasonliu, daltenty

Reviewed By: jhenderson, MaskRay

Differential Revision: https://reviews.llvm.org/D77990
  • Loading branch information
hubert-reinterpretcast committed Apr 14, 2020
1 parent fe06e23 commit 5ea2819
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
13 changes: 7 additions & 6 deletions llvm/tools/llvm-objdump/WasmDump.cpp
Expand Up @@ -11,13 +11,15 @@
///
//===----------------------------------------------------------------------===//

#include "WasmDump.h"

#include "llvm-objdump.h"
#include "llvm/Object/Wasm.h"

using namespace llvm;
using namespace llvm::object;

namespace llvm {
void printWasmFileHeader(const object::ObjectFile *Obj) {
void objdump::printWasmFileHeader(const object::ObjectFile *Obj) {
const auto *File = dyn_cast<const WasmObjectFile>(Obj);

outs() << "Program Header:\n";
Expand All @@ -26,9 +28,9 @@ void printWasmFileHeader(const object::ObjectFile *Obj) {
outs() << "\n";
}

Error getWasmRelocationValueString(const WasmObjectFile *Obj,
const RelocationRef &RelRef,
SmallVectorImpl<char> &Result) {
Error objdump::getWasmRelocationValueString(const WasmObjectFile *Obj,
const RelocationRef &RelRef,
SmallVectorImpl<char> &Result) {
const wasm::WasmRelocation &Rel = Obj->getWasmRelocation(RelRef);
symbol_iterator SI = RelRef.getSymbol();
std::string FmtBuf;
Expand All @@ -49,4 +51,3 @@ Error getWasmRelocationValueString(const WasmObjectFile *Obj,
Result.append(FmtBuf.begin(), FmtBuf.end());
return Error::success();
}
} // namespace llvm
35 changes: 35 additions & 0 deletions llvm/tools/llvm-objdump/WasmDump.h
@@ -0,0 +1,35 @@
//===-- WasmDump.h - wasm-specific dumper -----------------------*- 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
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TOOLS_LLVM_OBJDUMP_WASMDUMP_H
#define LLVM_TOOLS_LLVM_OBJDUMP_WASMDUMP_H

#include "llvm/ADT/SmallVector.h"

namespace llvm {

class Error;

namespace object {
class WasmObjectFile;
class ObjectFile;
class RelocationRef;
} // namespace object

namespace objdump {

Error getWasmRelocationValueString(const object::WasmObjectFile *Obj,
const object::RelocationRef &RelRef,
llvm::SmallVectorImpl<char> &Result);

void printWasmFileHeader(const object::ObjectFile *O);

} // namespace objdump
} // namespace llvm

#endif
1 change: 1 addition & 0 deletions llvm/tools/llvm-objdump/llvm-objdump.cpp
Expand Up @@ -18,6 +18,7 @@
#include "llvm-objdump.h"
#include "COFFDump.h"
#include "MachODump.h"
#include "WasmDump.h"
#include "XCOFFDump.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
Expand Down
4 changes: 0 additions & 4 deletions llvm/tools/llvm-objdump/llvm-objdump.h
Expand Up @@ -118,17 +118,13 @@ SectionFilter ToolSectionFilter(llvm::object::ObjectFile const &O,
Error getELFRelocationValueString(const object::ELFObjectFileBase *Obj,
const object::RelocationRef &Rel,
llvm::SmallVectorImpl<char> &Result);
Error getWasmRelocationValueString(const object::WasmObjectFile *Obj,
const object::RelocationRef &RelRef,
llvm::SmallVectorImpl<char> &Result);

uint64_t getELFSectionLMA(const object::ELFSectionRef& Sec);

bool isRelocAddressLess(object::RelocationRef A, object::RelocationRef B);
void printELFFileHeader(const object::ObjectFile *O);
void printELFDynamicSection(const object::ObjectFile *Obj);
void printELFSymbolVersionInfo(const object::ObjectFile *Obj);
void printWasmFileHeader(const object::ObjectFile *O);
void printRawClangAST(const object::ObjectFile *O);
void printRelocations(const object::ObjectFile *O);
void printDynamicRelocations(const object::ObjectFile *O);
Expand Down

0 comments on commit 5ea2819

Please sign in to comment.