[PATCH] D88228: [yaml2obj][obj2yaml] - Add support for SHT_ARM_EXIDX section.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 00:28:41 PDT 2020


grimar added a comment.

In D88228#2295375 <https://reviews.llvm.org/D88228#2295375>, @psmith wrote:

> Just to check I understand it, if for a relocatable object I wanted to model the R_ARM_PREL31 relocation on the first entry of the table, and optionally on the second entry for a .ARM.extab reference then I'd need to add the PREL relocations myself?

Yes.

> A possible future enhancement could do this automatically. For example all the relocations would be with respect to the section symbol of the sh_link section so the R_ARM_PREL31 relocations could be added automatically.

We probably shouldn't. yaml2obj currently does just a few minor things automatically. E.g. it links a relocation section to .symtab by default. But we never do something major, like adding sections with relocations.
To add relocations automatically we will need to create a relocation section and add relocations to it. I see the following problem of doing this implicitly:

1. yaml2obj is often used for creating broken inputs. We should be able to have a way to create any layout we want. E.g. without relocations, or with relocations of not-R_ARM_PREL31 types etc. It is also probably will be confusing that an object will contain more sections and relocations than were explicitly described in a YAML.
2. After applying of obj2yaml to an object we usually assume to get the same YAML input that we had for yaml2obj too.

If we want to add the functionality that adds R_ARM_PREL31 relocations automatically, it perhaps can be a separate command line option, or may be an explicit YAML flag.
E.g. we support the following syntax currently:

  SectionHeaderTable:
    NoHeaders: true

Which says to yaml2obj to not emit a section header table, that is created by default. Perhaps we could add such a flag, like "EmitRelocations". Honestly it feels a bit excessive to me though:
I don`t expect to see many relocations in tests and I guess it is not that hard to add them manually in favor of simplicity of code. Also having explicit tests might be better: perhaps
we can't assume that all people are so good familar with yaml2obj that knows about "auto R_ARM_PREL31 relocations" feature.


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

https://reviews.llvm.org/D88228



More information about the llvm-commits mailing list