[llvm-dev] Support for zero flag ELF section groups in LLVM IR

Petr Hosek via llvm-dev llvm-dev at lists.llvm.org
Thu Feb 11 00:00:23 PST 2021


D95851 introduces support for zero flag ELF section groups to LLVM. LLVM
already supports COMDAT sections, which in ELF are a special type of ELF
section groups. These are generally useful to enable linker GC where you
want a group of sections to always travel together, that is to be either
retained or discarded as a whole, but without the COMDAT semantics. Other
ELF assemblers and linkers already support zero flag ELF section groups and
this change helps us reach feature parity.

An open question is how to best represent these in LLVM IR.

We represent COMDAT sections as global variables and other global variables
can be included in COMDAT sections, see
https://llvm.org/docs/LangRef.html#comdats for details.

We want to capture the fact that COMDAT sections are a special type of ELF
section groups and we also want to preserve the existing syntax and API for
backwards compatibility, but also because other formats like COFF support
COMDAT sections, but not section groups.

Our proposal is to introduce ELF section groups as a new type of global
variable akin to COMDAT sections. We would extend the language by changing:

  [, comdat[($name)]]

when declaring a global variable to:

  [, \(group[($name)] | [group] comdat[($name)]\)]

When it comes to C++ API, we would introduce Group as a superclass of
Comdat:

  class Group {
    StringRef getName() const;
  };
  class Comdat : public Group {
    ...
  };
  class GlobalObject : public GlobalValue {
    ...
    bool hasGroup();
    Group *getGroup();
    void setGroup(Group G);
    // has/get/setComdat functions re-implemented in terms of
has/get/setGroup
    ...
  };

Does this make sense? Can anyone think of a better representation?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210211/4cae0fdb/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3996 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210211/4cae0fdb/attachment.bin>


More information about the llvm-dev mailing list