[PATCH] D73621: [yaml2obj] - Add a way to set sh_entsize for relocation sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 05:11:27 PST 2020


grimar added a comment.

In D73621#1848843 <https://reviews.llvm.org/D73621#1848843>, @grimar wrote:

> In D73621#1848823 <https://reviews.llvm.org/D73621#1848823>, @jhenderson wrote:
>
> > Idle thought: I wonder if it's worth introducing some kind of command-line macro option to yaml2obj? E.g. `-DMACHINE=EM_X86_64` would replace `Machine: MACHINE` (or some similar syntax). There are a growing number of cases where we have two identical YAML blobs except for some minor difference.
>
>
> Sounds good. I'd give it a try.


One more idea: what if we make `FileHeader` to be optional?
e.g. a valid YAML can be something like this:

  --- !ELF
  Sections:
  .....
  Symbols:
  ....

When there is no `FileHeader`, yaml2obj could require `--platform=X` option (or alike) to be specified.
It can be similar to linker's `-m` (emulation) option and can accept the same strings for `X`:

    std::pair<ELFKind, uint16_t> ret =
        StringSwitch<std::pair<ELFKind, uint16_t>>(s)
            .Cases("aarch64elf", "aarch64linux", "aarch64_elf64_le_vec",
                   {ELF64LEKind, EM_AARCH64})
            .Cases("armelf", "armelf_linux_eabi", {ELF32LEKind, EM_ARM})
  ...
            .Cases("elf_amd64", "elf_x86_64", {ELF64LEKind, EM_X86_64})
            .Case("elf_i386", {ELF32LEKind, EM_386})
            .Case("elf_iamcu", {ELF32LEKind, EM_IAMCU})
            .Default({ELFNoneKind, EM_NONE});

Perhaps we also could add `--elf-type=X` to switch the output type: ET_DYN/ET_REL/ET_EXEC
(and have something by default).

A benefit is that we often do not need or use fields of the file header in our tests.
Making it optional can reduce the YAML descriptions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73621





More information about the llvm-commits mailing list