[PATCH] D12570: [llvm-readobj] Dump Macho indirect symbols

Eric Christopher via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 2 11:36:19 PDT 2015


LGTM, and thanks again for doing all this.

On Wed, Sep 2, 2015, 11:27 AM Davide Italiano <dccitaliano at gmail.com> wrote:

> davide created this revision.
> davide added reviewers: grosbach, rafael, echristo.
> davide added a subscriber: llvm-commits.
> davide set the repository for this revision to rL LLVM.
>
> This is *probably* the last bit we need. After this lands, it's just a lot
> of fun converting all the remaining tests to the new format.
>
> Also, example output:
>
> File: <stdin>
> Format: Mach-O 32-bit i386
> Arch: i386
> AddressSize: 32bit
> Indirect Symbols {
>   Number: 6
>   Symbols [
>     Entry {
>       Entry Index: 0
>       Symbol Index: 0x4
>     }
>     Entry {
>       Entry Index: 1
>       Symbol Index: 0x0
>     }
>     Entry {
>       Entry Index: 2
>       Symbol Index: 0x1
>     }
>     Entry {
>       Entry Index: 3
>       Symbol Index: 0x5
>     }
>     Entry {
>       Entry Index: 4
>       Symbol Index: 0x80000000
>     }
>     Entry {
>       Entry Index: 5
>       Symbol Index: 0xC0000000
>     }
>   ]
> }
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D12570
>
> Files:
>   tools/llvm-readobj/MachODumper.cpp
>   tools/llvm-readobj/ObjDumper.h
>   tools/llvm-readobj/llvm-readobj.cpp
>
> Index: tools/llvm-readobj/llvm-readobj.cpp
> ===================================================================
> --- tools/llvm-readobj/llvm-readobj.cpp
> +++ tools/llvm-readobj/llvm-readobj.cpp
> @@ -187,6 +187,11 @@
>    MachODataInCode("macho-data-in-code",
>                    cl::desc("Display MachO Data in Code command"));
>
> +  // -macho-indirect-symbols
> +  cl::opt<bool>
> +  MachOIndirectSymbols("macho-indirect-symbols",
> +                  cl::desc("Display MachO indirect symbols"));
> +
>    // -macho-segment
>    cl::opt<bool>
>    MachOSegment("macho-segment",
> @@ -336,6 +341,8 @@
>    if (Obj->isMachO()) {
>      if (opts::MachODataInCode)
>        Dumper->printMachODataInCode();
> +    if (opts::MachOIndirectSymbols)
> +      Dumper->printMachOIndirectSymbols();
>      if (opts::MachOSegment)
>        Dumper->printMachOSegment();
>      if (opts::MachOVersionMin)
> Index: tools/llvm-readobj/ObjDumper.h
> ===================================================================
> --- tools/llvm-readobj/ObjDumper.h
> +++ tools/llvm-readobj/ObjDumper.h
> @@ -60,6 +60,7 @@
>    virtual void printMachOVersionMin() { }
>    virtual void printMachODysymtab() { }
>    virtual void printMachOSegment() { }
> +  virtual void printMachOIndirectSymbols() { }
>
>    virtual void printStackMap() const = 0;
>
> Index: tools/llvm-readobj/MachODumper.cpp
> ===================================================================
> --- tools/llvm-readobj/MachODumper.cpp
> +++ tools/llvm-readobj/MachODumper.cpp
> @@ -45,6 +45,7 @@
>    void printMachOVersionMin() override;
>    void printMachODysymtab() override;
>    void printMachOSegment() override;
> +  void printMachOIndirectSymbols() override;
>
>  private:
>    template<class MachHeader>
> @@ -774,3 +775,19 @@
>      }
>    }
>  }
> +
> +void MachODumper::printMachOIndirectSymbols() {
> +  for (const auto &Load : Obj->load_commands()) {
> +    if (Load.C.cmd == MachO::LC_DYSYMTAB) {
> +      MachO::dysymtab_command DLC = Obj->getDysymtabLoadCommand();
> +      DictScope Group(W, "Indirect Symbols");
> +      W.printNumber("Number", DLC.nindirectsyms);
> +      ListScope D(W, "Symbols");
> +      for (unsigned i = 0; i < DLC.nindirectsyms; ++i) {
> +        DictScope Group(W, "Entry");
> +        W.printNumber("Entry Index", i);
> +        W.printHex("Symbol Index", Obj->getIndirectSymbolTableEntry(DLC,
> i));
> +      }
> +    }
> +  }
> +}
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150902/7388466f/attachment.html>


More information about the llvm-commits mailing list