[all-commits] [llvm/llvm-project] b216c8: [ELF] Allow SHF_LINK_ORDER sections to have sh_link=0

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Aug 5 16:18:02 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b216c80cc2496b87bf827260ce7e24dc62247d71
      https://github.com/llvm/llvm-project/commit/b216c80cc2496b87bf827260ce7e24dc62247d71
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-08-05 (Wed, 05 Aug 2020)

  Changed paths:
    M lld/ELF/InputFiles.cpp
    M lld/ELF/InputSection.cpp
    M lld/ELF/Writer.cpp
    R lld/test/ELF/invalid/linkorder-invalid-sec2.test
    A lld/test/ELF/linkorder-mixed.s

  Log Message:
  -----------
  [ELF] Allow SHF_LINK_ORDER sections to have sh_link=0

Part of https://bugs.llvm.org/show_bug.cgi?id=41734

The semantics of SHF_LINK_ORDER have been extended to represent metadata
sections associated with some other sections (usually text).

The associated text section may be discarded (e.g. LTO) and we want the
metadata section to have sh_link=0 (D72899, D76802).

Normally the metadata section is only referenced by the associated text
section. sh_link=0 means the associated text section is discarded, and
the metadata section will be garbage collected. If there is another
section (.gc_root) referencing the metadata section, the metadata
section will be retained. It's the .gc_root consumer's job to validate
the metadata sections.

  # This creates a SHF_LINK_ORDER .meta with sh_link=0
  .section .meta,"awo", at progbits,0
  1:
  .section .meta,"awo", at progbits,foo
  2:

  .section .gc_root,"a", at progbits
  .quad 1b
  .quad 2b

Reviewed By: pcc, jhenderson

Differential Revision: https://reviews.llvm.org/D72904




More information about the All-commits mailing list