[LLVMdev] [yaml2obj] ELF relocation support

Sean Silva silvas at purdue.edu
Mon Apr 7 11:50:06 PDT 2014


On Wed, Apr 2, 2014 at 1:54 PM, Simon Atanasyan <simon at atanasyan.com> wrote:

> Hi,
>
> On Wed, Apr 2, 2014 at 1:03 AM, Michael Spencer <bigcheesegs at gmail.com>
> wrote:
> > On Mon, Mar 31, 2014 at 10:54 AM, Simon Atanasyan <simon at atanasyan.com>
> wrote:
> >> As far as I understand now it is impossible to generate ELF object
> >> file with relocation sections using yaml2obj tool. I plan to support
> >> ELF relocations in the yaml2obj. Does anybody work on it already or
> >> plan to start this task soon?
> >
> > I know of nobody working on this. It would be great to have, thanks!
>
> I am going to add "Relocations" optional list to the "Section"
> element. So a YAML file will look like below. An alternative option is
> to introduce new top-level list "Relocation Sections" with "Relocation
> Section" entries. But I think this solution is a little bit over
> designed.
>
> Any objections / suggestions?
>
> [[
> Sections:
>   - Name: .text
>     Type: SHT_PROGBITS
>     Content: "0000000000000000"
>     AddressAlign: 16
>     Flags: [SHF_ALLOC]
>
>   - Name: .rel.text
>     Type: SHT_REL
>     Info: .text
>     AddressAlign: 4
>     Relocations:
>       - !Relocation
>         Offset: 0x1
>         SymbolName: glob1
>         Type: R_MIPS_32
>       - !Relocation
>         Offset: 0x2
>         SymbolName: glob2
>         Type: R_MIPS_CALL16
> ]]
>

This makes sense to me. It is basically how I imagined this feature being
implemented. I.e. for certain sections there are keys that represent the
"Content" in a smarter way than just a hex string.

It would be really nice to be able to use `!Relocations` to tag the section
like Michael said; I think of it as a "dyn_cast" for choosing the set of
keys that are used to fill in the `Content`. I don't know how easy it is to
do this with YAMLIO but this would be a really great feature to add if it
isn't already implemented. If that is a pain, then I think it would be
acceptable to have both `Content` and `Relocations` in `struct Section` and
use YAMLIO validation <http://llvm.org/docs/YamlIO.html#validation> to make
sure that they both aren't specified.

-- Sean Silva




>
> --
> Simon Atanasyan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140407/a9f260b1/attachment.html>


More information about the llvm-dev mailing list