16
16
#include " llvm-c/Disassembler.h"
17
17
#include " llvm/ADT/STLExtras.h"
18
18
#include " llvm/ADT/StringExtras.h"
19
- #include " llvm/ADT/StringSet.h"
20
19
#include " llvm/ADT/Triple.h"
21
20
#include " llvm/BinaryFormat/MachO.h"
22
21
#include " llvm/Config/config.h"
@@ -178,11 +177,7 @@ static cl::list<std::string>
178
177
ArchFlags (" arch" , cl::desc(" architecture(s) from a Mach-O file to dump" ),
179
178
cl::ZeroOrMore, cl::cat(MachOCat));
180
179
181
- namespace llvm {
182
-
183
- extern StringSet<> FoundSectionSet;
184
-
185
- bool ArchAll = false ;
180
+ static bool ArchAll = false ;
186
181
187
182
static std::string ThumbTripleName;
188
183
@@ -224,6 +219,7 @@ static const Target *GetTarget(const MachOObjectFile *MachOObj,
224
219
return nullptr ;
225
220
}
226
221
222
+ namespace {
227
223
struct SymbolSorter {
228
224
bool operator ()(const SymbolRef &A, const SymbolRef &B) {
229
225
Expected<SymbolRef::Type> ATypeOrErr = A.getType ();
@@ -239,6 +235,7 @@ struct SymbolSorter {
239
235
return AAddr < BAddr;
240
236
}
241
237
};
238
+ } // namespace
242
239
243
240
// Types for the storted data in code table that is built before disassembly
244
241
// and the predicate function to sort them.
@@ -488,9 +485,9 @@ static void printRelocationTargetName(const MachOObjectFile *O,
488
485
Fmt << S;
489
486
}
490
487
491
- Error getMachORelocationValueString (const MachOObjectFile *Obj,
492
- const RelocationRef &RelRef,
493
- SmallVectorImpl<char > &Result) {
488
+ Error objdump:: getMachORelocationValueString (const MachOObjectFile *Obj,
489
+ const RelocationRef &RelRef,
490
+ SmallVectorImpl<char > &Result) {
494
491
DataRefImpl Rel = RelRef.getRawDataRefImpl ();
495
492
MachO::any_relocation_info RE = Obj->getRelocation (Rel);
496
493
@@ -2313,7 +2310,7 @@ static bool ValidateArchFlags() {
2313
2310
// -arch flags selecting just those slices as specified by them and also parses
2314
2311
// archive files. Then for each individual Mach-O file ProcessMachO() is
2315
2312
// called to process the file based on the command line options.
2316
- void parseInputMachO (StringRef Filename) {
2313
+ void objdump:: parseInputMachO (StringRef Filename) {
2317
2314
if (!ValidateArchFlags ())
2318
2315
return ;
2319
2316
@@ -2371,7 +2368,7 @@ void parseInputMachO(StringRef Filename) {
2371
2368
llvm_unreachable (" Input object can't be invalid at this point" );
2372
2369
}
2373
2370
2374
- void parseInputMachO (MachOUniversalBinary *UB) {
2371
+ void objdump:: parseInputMachO (MachOUniversalBinary *UB) {
2375
2372
if (!ValidateArchFlags ())
2376
2373
return ;
2377
2374
@@ -2557,6 +2554,7 @@ void parseInputMachO(MachOUniversalBinary *UB) {
2557
2554
}
2558
2555
}
2559
2556
2557
+ namespace {
2560
2558
// The block of info used by the Symbolizer call backs.
2561
2559
struct DisassembleInfo {
2562
2560
DisassembleInfo (MachOObjectFile *O, SymbolAddressMap *AddrMap,
@@ -2576,6 +2574,7 @@ struct DisassembleInfo {
2576
2574
std::unique_ptr<SymbolAddressMap> bindtable;
2577
2575
uint32_t depth = 0 ;
2578
2576
};
2577
+ } // namespace
2579
2578
2580
2579
// SymbolizerGetOpInfo() is the operand information call back function.
2581
2580
// This is called to get the symbolic information for operand(s) of an
@@ -3384,6 +3383,8 @@ static const char *get_symbol_32(uint32_t sect_offset, SectionRef S,
3384
3383
return get_symbol_64 (sect_offset, S, info, n_value64, ReferenceValue);
3385
3384
}
3386
3385
3386
+ namespace {
3387
+
3387
3388
// These are structs in the Objective-C meta data and read to produce the
3388
3389
// comments for disassembly. While these are part of the ABI they are no
3389
3390
// public defintions. So the are here not in include/llvm/BinaryFormat/MachO.h
@@ -3969,6 +3970,8 @@ inline void swapStruct(struct objc_method_description_t &md) {
3969
3970
sys::swapByteOrder (md.types );
3970
3971
}
3971
3972
3973
+ } // namespace
3974
+
3972
3975
static const char *get_dyld_bind_info_symbolname (uint64_t ReferenceValue,
3973
3976
struct DisassembleInfo *info);
3974
3977
@@ -6468,7 +6471,7 @@ static void DumpProtocolSection(MachOObjectFile *O, const char *sect,
6468
6471
}
6469
6472
6470
6473
#ifdef HAVE_LIBXAR
6471
- inline void swapStruct (struct xar_header &xar) {
6474
+ static inline void swapStruct (struct xar_header &xar) {
6472
6475
sys::swapByteOrder (xar.magic );
6473
6476
sys::swapByteOrder (xar.size );
6474
6477
sys::swapByteOrder (xar.version );
@@ -8189,7 +8192,7 @@ static void printMachOUnwindInfoSection(const MachOObjectFile *Obj,
8189
8192
}
8190
8193
}
8191
8194
8192
- void printMachOUnwindInfo (const MachOObjectFile *Obj) {
8195
+ void objdump:: printMachOUnwindInfo (const MachOObjectFile *Obj) {
8193
8196
std::map<uint64_t , SymbolRef> Symbols;
8194
8197
for (const SymbolRef &SymRef : Obj->symbols ()) {
8195
8198
// Discard any undefined or absolute symbols. They're not going to take part
@@ -10197,12 +10200,12 @@ static void PrintMachHeader(const MachOObjectFile *Obj, bool verbose) {
10197
10200
}
10198
10201
}
10199
10202
10200
- void printMachOFileHeader (const object::ObjectFile *Obj) {
10203
+ void objdump:: printMachOFileHeader (const object::ObjectFile *Obj) {
10201
10204
const MachOObjectFile *file = dyn_cast<const MachOObjectFile>(Obj);
10202
10205
PrintMachHeader (file, !NonVerbose);
10203
10206
}
10204
10207
10205
- void printMachOLoadCommands (const object::ObjectFile *Obj) {
10208
+ void objdump:: printMachOLoadCommands (const object::ObjectFile *Obj) {
10206
10209
const MachOObjectFile *file = dyn_cast<const MachOObjectFile>(Obj);
10207
10210
uint32_t filetype = 0 ;
10208
10211
uint32_t cputype = 0 ;
@@ -10224,7 +10227,7 @@ void printMachOLoadCommands(const object::ObjectFile *Obj) {
10224
10227
// export trie dumping
10225
10228
// ===----------------------------------------------------------------------===//
10226
10229
10227
- void printMachOExportsTrie (const object::MachOObjectFile *Obj) {
10230
+ static void printMachOExportsTrie (const object::MachOObjectFile *Obj) {
10228
10231
uint64_t BaseSegmentAddress = 0 ;
10229
10232
for (const auto &Command : Obj->load_commands ()) {
10230
10233
if (Command.C .cmd == MachO::LC_SEGMENT) {
@@ -10303,7 +10306,7 @@ void printMachOExportsTrie(const object::MachOObjectFile *Obj) {
10303
10306
// rebase table dumping
10304
10307
// ===----------------------------------------------------------------------===//
10305
10308
10306
- void printMachORebaseTable (object::MachOObjectFile *Obj) {
10309
+ static void printMachORebaseTable (object::MachOObjectFile *Obj) {
10307
10310
outs () << " segment section address type\n " ;
10308
10311
Error Err = Error::success ();
10309
10312
for (const object::MachORebaseEntry &Entry : Obj->rebaseTable (Err)) {
@@ -10345,7 +10348,7 @@ static StringRef ordinalName(const object::MachOObjectFile *Obj, int Ordinal) {
10345
10348
// bind table dumping
10346
10349
// ===----------------------------------------------------------------------===//
10347
10350
10348
- void printMachOBindTable (object::MachOObjectFile *Obj) {
10351
+ static void printMachOBindTable (object::MachOObjectFile *Obj) {
10349
10352
// Build table of sections so names can used in final output.
10350
10353
outs () << " segment section address type "
10351
10354
" addend dylib symbol\n " ;
@@ -10376,7 +10379,7 @@ void printMachOBindTable(object::MachOObjectFile *Obj) {
10376
10379
// lazy bind table dumping
10377
10380
// ===----------------------------------------------------------------------===//
10378
10381
10379
- void printMachOLazyBindTable (object::MachOObjectFile *Obj) {
10382
+ static void printMachOLazyBindTable (object::MachOObjectFile *Obj) {
10380
10383
outs () << " segment section address "
10381
10384
" dylib symbol\n " ;
10382
10385
Error Err = Error::success ();
@@ -10401,7 +10404,7 @@ void printMachOLazyBindTable(object::MachOObjectFile *Obj) {
10401
10404
// weak bind table dumping
10402
10405
// ===----------------------------------------------------------------------===//
10403
10406
10404
- void printMachOWeakBindTable (object::MachOObjectFile *Obj) {
10407
+ static void printMachOWeakBindTable (object::MachOObjectFile *Obj) {
10405
10408
outs () << " segment section address "
10406
10409
" type addend symbol\n " ;
10407
10410
Error Err = Error::success ();
@@ -10451,7 +10454,7 @@ static const char *get_dyld_bind_info_symbolname(uint64_t ReferenceValue,
10451
10454
return !name.empty () ? name.data () : nullptr ;
10452
10455
}
10453
10456
10454
- void printLazyBindTable (ObjectFile *o) {
10457
+ void objdump:: printLazyBindTable (ObjectFile *o) {
10455
10458
outs () << " Lazy bind table:\n " ;
10456
10459
if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
10457
10460
printMachOLazyBindTable (MachO);
@@ -10461,7 +10464,7 @@ void printLazyBindTable(ObjectFile *o) {
10461
10464
" for Mach-O executable files.\n " ;
10462
10465
}
10463
10466
10464
- void printWeakBindTable (ObjectFile *o) {
10467
+ void objdump:: printWeakBindTable (ObjectFile *o) {
10465
10468
outs () << " Weak bind table:\n " ;
10466
10469
if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
10467
10470
printMachOWeakBindTable (MachO);
@@ -10471,7 +10474,7 @@ void printWeakBindTable(ObjectFile *o) {
10471
10474
" for Mach-O executable files.\n " ;
10472
10475
}
10473
10476
10474
- void printExportsTrie (const ObjectFile *o) {
10477
+ void objdump:: printExportsTrie (const ObjectFile *o) {
10475
10478
outs () << " Exports trie:\n " ;
10476
10479
if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
10477
10480
printMachOExportsTrie (MachO);
@@ -10481,7 +10484,7 @@ void printExportsTrie(const ObjectFile *o) {
10481
10484
" for Mach-O executable files.\n " ;
10482
10485
}
10483
10486
10484
- void printRebaseTable (ObjectFile *o) {
10487
+ void objdump:: printRebaseTable (ObjectFile *o) {
10485
10488
outs () << " Rebase table:\n " ;
10486
10489
if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
10487
10490
printMachORebaseTable (MachO);
@@ -10491,7 +10494,7 @@ void printRebaseTable(ObjectFile *o) {
10491
10494
" for Mach-O executable files.\n " ;
10492
10495
}
10493
10496
10494
- void printBindTable (ObjectFile *o) {
10497
+ void objdump:: printBindTable (ObjectFile *o) {
10495
10498
outs () << " Bind table:\n " ;
10496
10499
if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
10497
10500
printMachOBindTable (MachO);
@@ -10500,4 +10503,3 @@ void printBindTable(ObjectFile *o) {
10500
10503
<< " This operation is only currently supported "
10501
10504
" for Mach-O executable files.\n " ;
10502
10505
}
10503
- } // namespace llvm
0 commit comments