[llvm] [llvm-objdump][macho] Add support for ObjC relative method lists (PR #84250)

Daniel Rodríguez Troitiño via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 13 13:00:10 PDT 2024


================
@@ -3673,6 +3683,12 @@ struct method_list32_t {
   /* struct method32_t first;  These structures follow inline */
 };
 
+struct method_list_delta_t {
+  uint32_t entsize;
+  uint32_t count;
+  /* struct method_delta_t first;  These structures follow inline */
+};
+
----------------
drodriguez wrote:

If you notice in `print_method_list32_t` and `print_method_list64_t` they already compromise and print "method_list_t entends [sic] past the end of the section", not `method_list32_t` or `method_list64_t`. Those two are actually the same struct, with different names (the only difference is if they keep `method32_t`, `method64_t`, or the new `method_delta_t`).

I think the code doesn't interlink too much, but that's an opinion:

```
static void print_method_list64_t(uint64_t p, struct DisassembleInfo *info,
                                const char *indent) {
  struct method_list64_t ml;
  struct method64_t m;
  const char *r;
  uint32_t offset, xoffset, left, i;
  SectionRef S, xS;
  const char *name, *sym_name;
  uint64_t n_value;

  r = get_pointer_64(p, offset, left, S, info);
  if (r == nullptr)
    return;
  memset(&ml, '\0', sizeof(struct method_list64_t));
  if (left < sizeof(struct method_list64_t)) {
    memcpy(&ml, r, left);
    outs() << "   (method_list_t entends past the end of the section)\n";
  } else
    memcpy(&ml, r, sizeof(struct method_list64_t));
  if (info->O->isLittleEndian() != sys::IsLittleEndianHost)
    swapStruct(ml);

  if ((ml.entsize & ML_HAS_DELTAS) != 0) {
    print_method_list_delta_t(ml, p, info, indent);
    return;
  }
  
  // The rest of the code
```

https://github.com/llvm/llvm-project/pull/84250


More information about the llvm-commits mailing list