forked from OSchip/llvm-project
[llvm-objdump] Suppress spurious warnings when parsing Mach-O binaries.
Summary:
llvm-objdump started warning when asked to disassemble a section that
isn't present in the input files, in Yuanfang Chen's change:
d16c162c94
. The problem is that the
logic was restricted only to the generic llvm-objdump parser, not to the
Mach-O-specific parser used for Apple toolchain compatibility. The
solution is to log section names from the Mach-O parser.
The macho-cstring-dump.test has been updated to fail if it encounters
this new warning in the future.
Reviewers: pete, ab, lhames, jhenderson, grimar, MaskRay, ychen
Reviewed By: jhenderson, grimar
Subscribers: rupprecht, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73586
This commit is contained in:
parent
3014efe071
commit
0ad18bf37b
|
@ -1,9 +1,9 @@
|
|||
RUN: llvm-objdump -m -section __TEXT,__cstring %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s
|
||||
RUN: llvm-objdump -m -section __TEXT,__cstring -no-leading-addr %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s -check-prefix=NO_ADDR
|
||||
RUN: llvm-objdump -m -section __TEXT,__cstring -non-verbose %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s -check-prefix=NON_VERBOSE
|
||||
RUN: llvm-objdump -m -section __TEXT,__cstring %p/Inputs/hello.obj.macho-x86_64 2>&1 | FileCheck %s --implicit-check-not="warning:"
|
||||
RUN: llvm-objdump -m -section __TEXT,__cstring -no-leading-addr %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s -check-prefix=NO_ADDR --implicit-check-not="warning:"
|
||||
RUN: llvm-objdump -m -section __TEXT,__cstring -non-verbose %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s -check-prefix=NON_VERBOSE --implicit-check-not="warning:"
|
||||
|
||||
CHECK: Contents of (__TEXT,__cstring) section
|
||||
CHECK: 000000000000003b Hello world\n
|
||||
CHECK-NEXT: 000000000000003b Hello world\n
|
||||
|
||||
NO_ADDR: Contents of (__TEXT,__cstring) section
|
||||
NO_ADDR: Hello world\n
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "llvm-c/Disassembler.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/BinaryFormat/MachO.h"
|
||||
#include "llvm/Config/config.h"
|
||||
|
@ -191,6 +192,8 @@ static cl::list<std::string>
|
|||
ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
|
||||
cl::ZeroOrMore, cl::cat(MachOCat));
|
||||
|
||||
extern StringSet<> FoundSectionSet;
|
||||
|
||||
bool ArchAll = false;
|
||||
|
||||
static std::string ThumbTripleName;
|
||||
|
@ -1754,6 +1757,9 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O,
|
|||
else
|
||||
consumeError(SecNameOrErr.takeError());
|
||||
|
||||
if (!DumpSection.empty())
|
||||
FoundSectionSet.insert(DumpSection);
|
||||
|
||||
DataRefImpl Ref = Section.getRawDataRefImpl();
|
||||
StringRef SegName = O->getSectionFinalSegmentName(Ref);
|
||||
if ((DumpSegName.empty() || SegName == DumpSegName) &&
|
||||
|
|
|
@ -338,7 +338,7 @@ static cl::extrahelp
|
|||
HelpResponse("\nPass @FILE as argument to read options from FILE.\n");
|
||||
|
||||
static StringSet<> DisasmFuncsSet;
|
||||
static StringSet<> FoundSectionSet;
|
||||
StringSet<> FoundSectionSet;
|
||||
static StringRef ToolName;
|
||||
|
||||
typedef std::vector<std::tuple<uint64_t, StringRef, uint8_t>> SectionSymbolsTy;
|
||||
|
|
Loading…
Reference in New Issue