[PATCH] D60974: Clang IFSO driver action.

Puyan Lotfi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 29 15:08:15 PDT 2019


plotfi added a comment.

So, @compnerd and I have discussed and we'd like to propose a yaml schema that can express what we need for ifsos for the Sections and the Symbols.

For the Symbols we want:

  Symbols:
    - Name:            _dataA
      Type:            STT_OBJECT
      Section:         .data
      Binding:         STB_GLOBAL
    - Name:            __ZN3qux3barEii
      Type:            STT_FUNC
      Section:         .text
      Binding:         STB_GLOBAL

Because this expresses the bare minimum of the symbol name, whether its a function or an exported object, which section it belongs to, and if it is bound globally or locally or weakly.

For the sections, this yaml schema gives us what we need to set the name, type and flags properly:

  Sections:
    - Name:            .text
      Type:            SHT_PROGBITS
      Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
    - Name:            .data
      Type:            SHT_PROGBITS
      Flags:           [ SHF_WRITE, SHF_ALLOC ]

We also think that the existing FileHeader works for emitting ELF ifsos:

  
FileHeader:
    Class:           ELFCLASS64
    Data:            ELFDATA2LSB
    Type:            ET_REL
    Machine:         EM_X86_64
  


I could see us compacting this (something like "Kind: ELF_64_LSB_X86-64") but I don't see why we'd want to deviate from what ELF already lays out.
The file type is important because ET_REL vs ET_DYN can be used to denote if this is an ifso artifact that is meant to be merged or if it is already merged. 
I think we could have one stage that does the merging of the ET_RELs and one that assembles the final binary from a merged ET_DYN ifso.

We looked at other formats like TBD, and the major thing we also want to add is:

  --- !ifso-elf-v1

at the beginning of the yaml to denote that this is an ifso specifically for ELF and to denote the versioning.
I think the versioning could be used to direct how we read the FileHeader.

So the yaml ifso file syntax:

  --- !ifso-elf-<version>
  FileHeader:
    Class:           <ELFCLASS64 | ELFCLASS32>
    Data:            <ELFDATA2LSB | ELFDATA2MSB>
    Type:            <ET_REL, ET_DYN, etc>
    Machine:         <machine>
  Sections: 
    # One or more of these:
    - Name:            <section name>
      Type:            <SHT_ section type>
      Flags:           [ <section flags> ]
  Symbols:
    # One or more of these:
    - Name:            <symbol name>
      Type:            <STT_ symbol type, ie STT_OBJECT, STT_FUNC etc>
      Section:         <section>
      Binding:         <STB_ symbol binding, ie STB_GLOBAL, STB_WEAK etc>

How does this sound?

PL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974





More information about the cfe-commits mailing list