[PATCH] D88468: [llvm-readobj] Fix error when printing out stabs symbols of type N_OSO

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 19:03:59 PDT 2020


int3 added inline comments.


================
Comment at: llvm/test/tools/llvm-readobj/MachO/stabs.yaml:120
+  filetype:        0x00000002
+  ncmds:           8
+  sizeofcmds:      744
----------------
grimar wrote:
> I was able to quickly reduce the number of commands here to `2` by simple removing of unused parts:
> 
> 
> ```
> ncmds:  2
> ...
> LoadCommands:
>   - cmd:             LC_SEGMENT_64
>     cmdsize:         232
>     segname:         __TEXT
>     vmaddr:          4294967296
>     vmsize:          4096
>     fileoff:         0
>     filesize:        4096
>     maxprot:         5
>     initprot:        5
>     nsects:          1
>     flags:           0
>     Sections:
>       - sectname:        __text
>         segname:         __TEXT
>         addr:            0x0000000100000FA0
>         size:            15
>         offset:          0x00000FA0
>         align:           4
>         reloff:          0x00000000
>         nreloc:          0
>         flags:           0x80000400
>         reserved1:       0x00000000
>         reserved2:       0x00000000
>         reserved3:       0x00000000
>         content:         554889E531C0C745FC000000005DC3
>   - cmd:             LC_SYMTAB
>     cmdsize:         24
>     symoff:          4152
>     nsyms:           11
>     stroff:          4328
>     strsize:         104
> ```
the resulting binary won't execute successfully though. I kept them because I thought it would be nice to have a somewhat representative input to the linker...


================
Comment at: llvm/tools/llvm-readobj/MachODumper.cpp:287
+  case MachO::N_ECOML:
+    return true;
+  default:
----------------
grimar wrote:
> I was able to comment out few cases:
> 
> ```
>   switch (Type) {
>   case MachO::N_FUN:
>   //case MachO::N_STSYM:
>   //case MachO::N_LCSYM:
>   case MachO::N_BNSYM:
>   //case MachO::N_SLINE:
>   case MachO::N_ENSYM:
>   case MachO::N_SO:
>   //case MachO::N_SOL:
>   //case MachO::N_ENTRY:
>   //case MachO::N_ECOMM:
>   //case MachO::N_ECOML:
>     return true;
>   default:
>     return false;
> ```
> 
> And the test case passed for me. I think it means these cases are not tested properly.
I got these cases from reading `stabs.h` in the macOS SDK, but I'm not actually sure how to get the linker to generate them. Would you prefer I not print out the section name for all stabs sections, as was done for llvm-objdump in D71394?

Another option would be to edit the YAML to create these stabs symbols, but as above, it seemed a bit iffy to be creating something that might not match a realistic input.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88468/new/

https://reviews.llvm.org/D88468



More information about the llvm-commits mailing list