Index: llvm-readobj/MachODumper.cpp =================================================================== --- llvm-readobj/MachODumper.cpp +++ llvm-readobj/MachODumper.cpp @@ -268,7 +268,6 @@ struct MachOSegment { StringRef CmdName; - StringRef SegName; uint64_t cmdsize; uint64_t vmaddr; uint64_t vmsize; @@ -336,7 +335,6 @@ if (!Obj->is64Bit()) { MachO::segment_command SC = Obj->getSegmentLoadCommand(L); Segment.CmdName = "LC_SEGMENT"; - Segment.SegName = SC.segname; Segment.cmdsize = SC.cmdsize; Segment.vmaddr = SC.vmaddr; Segment.vmsize = SC.vmsize; @@ -350,7 +348,6 @@ } MachO::segment_command_64 SC = Obj->getSegment64LoadCommand(L); Segment.CmdName = "LC_SEGMENT_64"; - Segment.SegName = SC.segname; Segment.cmdsize = SC.cmdsize; Segment.vmaddr = SC.vmaddr; Segment.vmsize = SC.vmsize; @@ -760,10 +757,18 @@ for (const auto &Load : Obj->load_commands()) { if (Load.C.cmd == MachO::LC_SEGMENT || Load.C.cmd == MachO::LC_SEGMENT_64) { MachOSegment MOSegment; + StringRef SegName; getSegment(Obj, Load, MOSegment); + if (!Obj->is64Bit()) { + MachO::segment_command SC = Obj->getSegmentLoadCommand(Load); + SegName = SC.segname; + } else { + MachO::segment_command_64 SC = Obj->getSegment64LoadCommand(Load); + SegName = SC.segname; + } DictScope Group(W, "Segment"); W.printString("Cmd", MOSegment.CmdName); - W.printString("Name", MOSegment.SegName); + W.printString("Name", SegName); W.printNumber("Size", MOSegment.cmdsize); W.printHex("vmaddr", MOSegment.vmaddr); W.printHex("vmsize", MOSegment.vmsize);