summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objdump/MachODump.cpp
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2017-02-09 17:56:26 +0000
committerKevin Enderby <enderby@apple.com>2017-02-09 17:56:26 +0000
commit5879a48c17352192f8f3d04cb31418d80ca2ac1b (patch)
tree4cd442c2d8c54598fd05ab59a882b931cd8e1386 /llvm/tools/llvm-objdump/MachODump.cpp
parentb25f60210ffff9ea26b47984c02560b04094626f (diff)
downloadbcm5719-llvm-5879a48c17352192f8f3d04cb31418d80ca2ac1b.tar.gz
bcm5719-llvm-5879a48c17352192f8f3d04cb31418d80ca2ac1b.zip
Tweak the implementation of llvm-objdump’s -objc-meta-data option so
that it works when the ObjC metadata sections end up in the __DATA_CONST or __DATA_DIRTY segments. rdar://26315238 llvm-svn: 294599
Diffstat (limited to 'llvm/tools/llvm-objdump/MachODump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/MachODump.cpp154
1 files changed, 91 insertions, 63 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 928e4ed8511..47425823424 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -5271,42 +5271,70 @@ static void printObjc2_64bit_MetaData(MachOObjectFile *O, bool verbose) {
SectionRef CL = get_section(O, "__OBJC2", "__class_list");
if (CL == SectionRef())
CL = get_section(O, "__DATA", "__objc_classlist");
+ if (CL == SectionRef())
+ CL = get_section(O, "__DATA_CONST", "__objc_classlist");
+ if (CL == SectionRef())
+ CL = get_section(O, "__DATA_DIRTY", "__objc_classlist");
info.S = CL;
walk_pointer_list_64("class", CL, O, &info, print_class64_t);
SectionRef CR = get_section(O, "__OBJC2", "__class_refs");
if (CR == SectionRef())
CR = get_section(O, "__DATA", "__objc_classrefs");
+ if (CR == SectionRef())
+ CR = get_section(O, "__DATA_CONST", "__objc_classrefs");
+ if (CR == SectionRef())
+ CR = get_section(O, "__DATA_DIRTY", "__objc_classrefs");
info.S = CR;
walk_pointer_list_64("class refs", CR, O, &info, nullptr);
SectionRef SR = get_section(O, "__OBJC2", "__super_refs");
if (SR == SectionRef())
SR = get_section(O, "__DATA", "__objc_superrefs");
+ if (SR == SectionRef())
+ SR = get_section(O, "__DATA_CONST", "__objc_superrefs");
+ if (SR == SectionRef())
+ SR = get_section(O, "__DATA_DIRTY", "__objc_superrefs");
info.S = SR;
walk_pointer_list_64("super refs", SR, O, &info, nullptr);
SectionRef CA = get_section(O, "__OBJC2", "__category_list");
if (CA == SectionRef())
CA = get_section(O, "__DATA", "__objc_catlist");
+ if (CA == SectionRef())
+ CA = get_section(O, "__DATA_CONST", "__objc_catlist");
+ if (CA == SectionRef())
+ CA = get_section(O, "__DATA_DIRTY", "__objc_catlist");
info.S = CA;
walk_pointer_list_64("category", CA, O, &info, print_category64_t);
SectionRef PL = get_section(O, "__OBJC2", "__protocol_list");
if (PL == SectionRef())
PL = get_section(O, "__DATA", "__objc_protolist");
+ if (PL == SectionRef())
+ PL = get_section(O, "__DATA_CONST", "__objc_protolist");
+ if (PL == SectionRef())
+ PL = get_section(O, "__DATA_DIRTY", "__objc_protolist");
info.S = PL;
walk_pointer_list_64("protocol", PL, O, &info, nullptr);
SectionRef MR = get_section(O, "__OBJC2", "__message_refs");
if (MR == SectionRef())
MR = get_section(O, "__DATA", "__objc_msgrefs");
+ if (MR == SectionRef())
+ MR = get_section(O, "__DATA_CONST", "__objc_msgrefs");
+ if (MR == SectionRef())
+ MR = get_section(O, "__DATA_DIRTY", "__objc_msgrefs");
info.S = MR;
print_message_refs64(MR, &info);
SectionRef II = get_section(O, "__OBJC2", "__image_info");
if (II == SectionRef())
II = get_section(O, "__DATA", "__objc_imageinfo");
+ if (II == SectionRef())
+ II = get_section(O, "__DATA_CONST", "__objc_imageinfo");
+ if (II == SectionRef())
+ II = get_section(O, "__DATA_DIRTY", "__objc_imageinfo");
info.S = II;
print_image_info64(II, &info);
}
@@ -5337,75 +5365,75 @@ static void printObjc2_32bit_MetaData(MachOObjectFile *O, bool verbose) {
info.adrp_addr = 0;
info.adrp_inst = 0;
- const SectionRef CL = get_section(O, "__OBJC2", "__class_list");
- if (CL != SectionRef()) {
- info.S = CL;
- walk_pointer_list_32("class", CL, O, &info, print_class32_t);
- } else {
- const SectionRef CL = get_section(O, "__DATA", "__objc_classlist");
- info.S = CL;
- walk_pointer_list_32("class", CL, O, &info, print_class32_t);
- }
+ SectionRef CL = get_section(O, "__OBJC2", "__class_list");
+ if (CL == SectionRef())
+ CL = get_section(O, "__DATA", "__objc_classlist");
+ if (CL == SectionRef())
+ CL = get_section(O, "__DATA_CONST", "__objc_classlist");
+ if (CL == SectionRef())
+ CL = get_section(O, "__DATA_DIRTY", "__objc_classlist");
+ info.S = CL;
+ walk_pointer_list_32("class", CL, O, &info, print_class32_t);
- const SectionRef CR = get_section(O, "__OBJC2", "__class_refs");
- if (CR != SectionRef()) {
- info.S = CR;
- walk_pointer_list_32("class refs", CR, O, &info, nullptr);
- } else {
- const SectionRef CR = get_section(O, "__DATA", "__objc_classrefs");
- info.S = CR;
- walk_pointer_list_32("class refs", CR, O, &info, nullptr);
- }
+ SectionRef CR = get_section(O, "__OBJC2", "__class_refs");
+ if (CR == SectionRef())
+ CR = get_section(O, "__DATA", "__objc_classrefs");
+ if (CR == SectionRef())
+ CR = get_section(O, "__DATA_CONST", "__objc_classrefs");
+ if (CR == SectionRef())
+ CR = get_section(O, "__DATA_DIRTY", "__objc_classrefs");
+ info.S = CR;
+ walk_pointer_list_32("class refs", CR, O, &info, nullptr);
- const SectionRef SR = get_section(O, "__OBJC2", "__super_refs");
- if (SR != SectionRef()) {
- info.S = SR;
- walk_pointer_list_32("super refs", SR, O, &info, nullptr);
- } else {
- const SectionRef SR = get_section(O, "__DATA", "__objc_superrefs");
- info.S = SR;
- walk_pointer_list_32("super refs", SR, O, &info, nullptr);
- }
+ SectionRef SR = get_section(O, "__OBJC2", "__super_refs");
+ if (SR == SectionRef())
+ SR = get_section(O, "__DATA", "__objc_superrefs");
+ if (SR == SectionRef())
+ SR = get_section(O, "__DATA_CONST", "__objc_superrefs");
+ if (SR == SectionRef())
+ SR = get_section(O, "__DATA_DIRTY", "__objc_superrefs");
+ info.S = SR;
+ walk_pointer_list_32("super refs", SR, O, &info, nullptr);
- const SectionRef CA = get_section(O, "__OBJC2", "__category_list");
- if (CA != SectionRef()) {
- info.S = CA;
- walk_pointer_list_32("category", CA, O, &info, print_category32_t);
- } else {
- const SectionRef CA = get_section(O, "__DATA", "__objc_catlist");
- info.S = CA;
- walk_pointer_list_32("category", CA, O, &info, print_category32_t);
- }
+ SectionRef CA = get_section(O, "__OBJC2", "__category_list");
+ if (CA == SectionRef())
+ CA = get_section(O, "__DATA", "__objc_catlist");
+ if (CA == SectionRef())
+ CA = get_section(O, "__DATA_CONST", "__objc_catlist");
+ if (CA == SectionRef())
+ CA = get_section(O, "__DATA_DIRTY", "__objc_catlist");
+ info.S = CA;
+ walk_pointer_list_32("category", CA, O, &info, print_category32_t);
- const SectionRef PL = get_section(O, "__OBJC2", "__protocol_list");
- if (PL != SectionRef()) {
- info.S = PL;
- walk_pointer_list_32("protocol", PL, O, &info, nullptr);
- } else {
- const SectionRef PL = get_section(O, "__DATA", "__objc_protolist");
- info.S = PL;
- walk_pointer_list_32("protocol", PL, O, &info, nullptr);
- }
+ SectionRef PL = get_section(O, "__OBJC2", "__protocol_list");
+ if (PL == SectionRef())
+ PL = get_section(O, "__DATA", "__objc_protolist");
+ if (PL == SectionRef())
+ PL = get_section(O, "__DATA_CONST", "__objc_protolist");
+ if (PL == SectionRef())
+ PL = get_section(O, "__DATA_DIRTY", "__objc_protolist");
+ info.S = PL;
+ walk_pointer_list_32("protocol", PL, O, &info, nullptr);
- const SectionRef MR = get_section(O, "__OBJC2", "__message_refs");
- if (MR != SectionRef()) {
- info.S = MR;
- print_message_refs32(MR, &info);
- } else {
- const SectionRef MR = get_section(O, "__DATA", "__objc_msgrefs");
- info.S = MR;
- print_message_refs32(MR, &info);
- }
+ SectionRef MR = get_section(O, "__OBJC2", "__message_refs");
+ if (MR == SectionRef())
+ MR = get_section(O, "__DATA", "__objc_msgrefs");
+ if (MR == SectionRef())
+ MR = get_section(O, "__DATA_CONST", "__objc_msgrefs");
+ if (MR == SectionRef())
+ MR = get_section(O, "__DATA_DIRTY", "__objc_msgrefs");
+ info.S = MR;
+ print_message_refs32(MR, &info);
- const SectionRef II = get_section(O, "__OBJC2", "__image_info");
- if (II != SectionRef()) {
- info.S = II;
- print_image_info32(II, &info);
- } else {
- const SectionRef II = get_section(O, "__DATA", "__objc_imageinfo");
- info.S = II;
- print_image_info32(II, &info);
- }
+ SectionRef II = get_section(O, "__OBJC2", "__image_info");
+ if (II == SectionRef())
+ II = get_section(O, "__DATA", "__objc_imageinfo");
+ if (II == SectionRef())
+ II = get_section(O, "__DATA_CONST", "__objc_imageinfo");
+ if (II == SectionRef())
+ II = get_section(O, "__DATA_DIRTY", "__objc_imageinfo");
+ info.S = II;
+ print_image_info32(II, &info);
}
static bool printObjc1_32bit_MetaData(MachOObjectFile *O, bool verbose) {
OpenPOWER on IntegriCloud