[PATCH] D56569: [ObjectYAML][yaml2obj][ELF] Add basic support for dynamic entries

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 10 17:13:21 PST 2019


ruiu added a comment.

I wonder if you really want to distinguish d_val from d_ptr. Here is the definition of the Elf_Dyn struct:

  struct Elf32_Dyn {
    Elf32_Sword d_tag; // Type of dynamic table entry.
    union {
      Elf32_Word d_val; // Integer value of entry.
      Elf32_Addr d_ptr; // Pointer value of entry.
    } d_un;
  };

d_val and d_ptr are exclusive and are just aliases to each other. As far as I know, people don't usually try to distinguish them; instead just use d_val.

You could distinguish them and use either d_val and d_ptr depending on a d_tag value, but if you actually to do that, you have to explicitly specify which field, d_val or d_ptr, you want to use for *every* d_tag value. That's perhaps isn't worth it.

So, if I were you, I'd simply use d_val for all d_tag values and don't use d_ptr. In other words, I'd define `DynamicEntry` as follows:

  struct DynamicEntry {
    ELF_DT Tag;
    int64 Val;
  };

instead of this:

  struct DynamicEntry {
    ELF_DT Tag;
    Optional<uint64_t> Val;
    Optional<llvm::yaml::Hex64> Ptr;
  };


Repository:
  rL LLVM

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

https://reviews.llvm.org/D56569





More information about the llvm-commits mailing list