Skip to content

Commit

Permalink
Merged master:d04eb253c71 into amd-gfx:c147dad29f0
Browse files Browse the repository at this point in the history
Local branch amd-gfx c147dad Merged master:07e8a780d81 into amd-gfx:243518ce51b
Remote branch master d04eb25 [llvm-objdump] Delete unneeeded namespace llvm {}
  • Loading branch information
Sw authored and Sw committed May 31, 2020
2 parents c147dad + d04eb25 commit 6794d4c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 34 deletions.
1 change: 1 addition & 0 deletions llvm/tools/llvm-objdump/COFFDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "llvm/Support/raw_ostream.h"

using namespace llvm;
using namespace llvm::objdump;
using namespace llvm::object;
using namespace llvm::Win64EH;

Expand Down
61 changes: 30 additions & 31 deletions llvm/tools/llvm-objdump/llvm-objdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,8 @@ static FilterResult checkSectionFilter(object::SectionRef S) {
/*IncrementIndex=*/true};
}

namespace llvm {

SectionFilter ToolSectionFilter(object::ObjectFile const &O, uint64_t *Idx) {
SectionFilter objdump::ToolSectionFilter(object::ObjectFile const &O,
uint64_t *Idx) {
// Start at UINT64_MAX so that the first index returned after an increment is
// zero (after the unsigned wrap).
if (Idx)
Expand All @@ -403,8 +402,8 @@ SectionFilter ToolSectionFilter(object::ObjectFile const &O, uint64_t *Idx) {
O);
}

std::string getFileNameForError(const object::Archive::Child &C,
unsigned Index) {
std::string objdump::getFileNameForError(const object::Archive::Child &C,
unsigned Index) {
Expected<StringRef> NameOrErr = C.getName();
if (NameOrErr)
return std::string(NameOrErr.get());
Expand All @@ -414,36 +413,35 @@ std::string getFileNameForError(const object::Archive::Child &C,
return "<file index: " + std::to_string(Index) + ">";
}

void reportWarning(Twine Message, StringRef File) {
void objdump::reportWarning(Twine Message, StringRef File) {
// Output order between errs() and outs() matters especially for archive
// files where the output is per member object.
outs().flush();
WithColor::warning(errs(), ToolName)
<< "'" << File << "': " << Message << "\n";
errs().flush();
}

LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Twine Message) {
LLVM_ATTRIBUTE_NORETURN void objdump::reportError(StringRef File,
Twine Message) {
outs().flush();
WithColor::error(errs(), ToolName) << "'" << File << "': " << Message << "\n";
exit(1);
}

LLVM_ATTRIBUTE_NORETURN void reportError(Error E, StringRef FileName,
StringRef ArchiveName,
StringRef ArchitectureName) {
LLVM_ATTRIBUTE_NORETURN void objdump::reportError(Error E, StringRef FileName,
StringRef ArchiveName,
StringRef ArchitectureName) {
assert(E);
outs().flush();
WithColor::error(errs(), ToolName);
if (ArchiveName != "")
errs() << ArchiveName << "(" << FileName << ")";
else
errs() << "'" << FileName << "'";
if (!ArchitectureName.empty())
errs() << " (for architecture " << ArchitectureName << ")";
std::string Buf;
raw_string_ostream OS(Buf);
logAllUnhandledErrors(std::move(E), OS);
OS.flush();
errs() << ": " << Buf;
errs() << ": ";
logAllUnhandledErrors(std::move(E), errs());
exit(1);
}

Expand Down Expand Up @@ -497,7 +495,7 @@ static const Target *getTarget(const ObjectFile *Obj) {
return TheTarget;
}

bool isRelocAddressLess(RelocationRef A, RelocationRef B) {
bool objdump::isRelocAddressLess(RelocationRef A, RelocationRef B) {
return A.getOffset() < B.getOffset();
}

Expand Down Expand Up @@ -1151,7 +1149,8 @@ static void dumpELFData(uint64_t SectionAddr, uint64_t Index, uint64_t End,
}
}

SymbolInfoTy createSymbolInfo(const ObjectFile *Obj, const SymbolRef &Symbol) {
SymbolInfoTy objdump::createSymbolInfo(const ObjectFile *Obj,
const SymbolRef &Symbol) {
const StringRef FileName = Obj->getFileName();
const uint64_t Addr = unwrapOrError(Symbol.getAddress(), FileName);
const StringRef Name = unwrapOrError(Symbol.getName(), FileName);
Expand All @@ -1171,8 +1170,9 @@ SymbolInfoTy createSymbolInfo(const ObjectFile *Obj, const SymbolRef &Symbol) {
: (uint8_t)ELF::STT_NOTYPE);
}

SymbolInfoTy createDummySymbolInfo(const ObjectFile *Obj, const uint64_t Addr,
StringRef &Name, uint8_t Type) {
static SymbolInfoTy createDummySymbolInfo(const ObjectFile *Obj,
const uint64_t Addr, StringRef &Name,
uint8_t Type) {
if (Obj->isXCOFF() && SymbolDescription)
return SymbolInfoTy(Addr, Name, None, None, false);
else
Expand Down Expand Up @@ -1715,7 +1715,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
SP, InlineRelocs);
}

void printRelocations(const ObjectFile *Obj) {
void objdump::printRelocations(const ObjectFile *Obj) {
StringRef Fmt = Obj->getBytesInAddress() > 4 ? "%016" PRIx64 :
"%08" PRIx64;
// Regular objdump doesn't print relocations in non-relocatable object
Expand Down Expand Up @@ -1769,7 +1769,7 @@ void printRelocations(const ObjectFile *Obj) {
}
}

void printDynamicRelocations(const ObjectFile *Obj) {
void objdump::printDynamicRelocations(const ObjectFile *Obj) {
// For the moment, this option is for ELF only
if (!Obj->isELF())
return;
Expand Down Expand Up @@ -1821,7 +1821,7 @@ static size_t getMaxSectionNameWidth(const ObjectFile *Obj) {
return MaxWidth;
}

void printSectionHeaders(const ObjectFile *Obj) {
void objdump::printSectionHeaders(const ObjectFile *Obj) {
size_t NameWidth = getMaxSectionNameWidth(Obj);
size_t AddressWidth = 2 * Obj->getBytesInAddress();
bool HasLMAColumn = shouldDisplayLMA(Obj);
Expand Down Expand Up @@ -1866,7 +1866,7 @@ void printSectionHeaders(const ObjectFile *Obj) {
outs() << "\n";
}

void printSectionContents(const ObjectFile *Obj) {
void objdump::printSectionContents(const ObjectFile *Obj) {
for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
StringRef Name = unwrapOrError(Section.getName(), Obj->getFileName());
uint64_t BaseAddr = Section.getAddress();
Expand Down Expand Up @@ -1910,8 +1910,8 @@ void printSectionContents(const ObjectFile *Obj) {
}
}

void printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
StringRef ArchitectureName, bool DumpDynamic) {
void objdump::printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
StringRef ArchitectureName, bool DumpDynamic) {
if (O->isCOFF() && !DumpDynamic) {
outs() << "SYMBOL TABLE:\n";
printCOFFSymbolTable(cast<const COFFObjectFile>(O));
Expand Down Expand Up @@ -1941,9 +1941,9 @@ void printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
printSymbol(O, *I, FileName, ArchiveName, ArchitectureName, DumpDynamic);
}

void printSymbol(const ObjectFile *O, const SymbolRef &Symbol,
StringRef FileName, StringRef ArchiveName,
StringRef ArchitectureName, bool DumpDynamic) {
void objdump::printSymbol(const ObjectFile *O, const SymbolRef &Symbol,
StringRef FileName, StringRef ArchiveName,
StringRef ArchitectureName, bool DumpDynamic) {
const MachOObjectFile *MachO = dyn_cast<const MachOObjectFile>(O);
uint64_t Address = unwrapOrError(Symbol.getAddress(), FileName, ArchiveName,
ArchitectureName);
Expand Down Expand Up @@ -2091,7 +2091,7 @@ static void printUnwindInfo(const ObjectFile *O) {

/// Dump the raw contents of the __clangast section so the output can be piped
/// into llvm-bcanalyzer.
void printRawClangAST(const ObjectFile *Obj) {
static void printRawClangAST(const ObjectFile *Obj) {
if (outs().is_displayed()) {
WithColor::error(errs(), ToolName)
<< "The -raw-clang-ast option will dump the raw binary contents of "
Expand Down Expand Up @@ -2420,7 +2420,6 @@ static void dumpInput(StringRef file) {
else
reportError(errorCodeToError(object_error::invalid_file_type), file);
}
} // namespace llvm

int main(int argc, char **argv) {
using namespace llvm;
Expand Down
4 changes: 1 addition & 3 deletions llvm/tools/llvm-objdump/llvm-objdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ extern cl::opt<bool> UnwindInfo;

extern StringSet<> FoundSectionSet;

} // namespace objdump

typedef std::function<bool(llvm::object::SectionRef const &)> FilterPredicate;

/// A filtered iterator for SectionRefs that skips sections based on some given
Expand Down Expand Up @@ -118,7 +116,6 @@ SectionFilter ToolSectionFilter(llvm::object::ObjectFile const &O,
uint64_t *Idx = nullptr);

bool isRelocAddressLess(object::RelocationRef A, object::RelocationRef B);
void printRawClangAST(const object::ObjectFile *O);
void printRelocations(const object::ObjectFile *O);
void printDynamicRelocations(const object::ObjectFile *O);
void printSectionHeaders(const object::ObjectFile *O);
Expand Down Expand Up @@ -147,6 +144,7 @@ std::string getFileNameForError(const object::Archive::Child &C,
SymbolInfoTy createSymbolInfo(const object::ObjectFile *Obj,
const object::SymbolRef &Symbol);

} // namespace objdump
} // end namespace llvm

#endif

0 comments on commit 6794d4c

Please sign in to comment.