[PATCH] D72904: [ELF] Allow SHF_LINK_ORDER sections to have sh_link=0

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 17 01:02:58 PST 2020


MaskRay created this revision.
MaskRay added reviewers: eugenis, grimar, lebedev.ri, pcc, peter.smith, ruiu.
Herald added subscribers: llvm-commits, dexonsmith, arichardson, mehdi_amini, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

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 <https://reviews.llvm.org/D72899>).

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.

  .section .meta,"awo", at progbits,,unique,0
  1:
  .section .meta,"awo", at progbits,foo,unique,1
  2:
  
  .section .gc_root,"a", at progbits
  .quad 1b
  .quad 2b


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72904

Files:
  lld/ELF/InputFiles.cpp
  lld/ELF/InputSection.cpp
  lld/ELF/Writer.cpp
  lld/test/ELF/invalid/linkorder-invalid-sec2.test
  lld/test/ELF/linkorder-mixed-link.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72904.238712.patch
Type: text/x-patch
Size: 3367 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200117/d0a6acd8/attachment.bin>


More information about the llvm-commits mailing list