[PATCH] D154641: [ELF] Add --compress-ections

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 6 12:17:38 PDT 2023


MaskRay created this revision.
MaskRay added reviewers: andrewng, ikudrin, peter.smith, phosek.
Herald added a subscriber: emaste.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

--compress-ections <section-glib>=[zlib|zstd] is like a generalized
--compress-debug-sections that applies to arbitrary sections, including
SHF_ALLOC ones. This option has a number of candidate use cases for metadata
sections, including:

- code coverage sections https://github.com/llvm/llvm-project/issues/48499
- `__asan_globals` section
- -fexperimental-sanitize-metadata= sections

For SHF_ALLOC use cases, a supporting runtime library can identify the section
content with a pair of symbols `__start_<sectionname>` and
`__stop_<sectionname>` and check the header to know whether it is compressed or
not. Please ensure that symbols defined relative to the section have
insiginificant addresses. After decompression, the symbols are "relocated".

GNU ld feature request: https://sourceware.org/bugzilla/show_bug.cgi?id=27452

Link: https://discourse.llvm.org/t/rfc-compress-arbitrary-sections-with-ld-lld-compress-sections/71674
Link: https://groups.google.com/g/generic-abi/c/HUVhliUrTG0 ("Allow SHF_ALLOC | SHF_COMPRESSED sections")


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154641

Files:
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/LinkerScript.cpp
  lld/ELF/Options.td
  lld/ELF/OutputSections.cpp
  lld/ELF/OutputSections.h
  lld/ELF/Writer.cpp
  lld/docs/ld.lld.1
  lld/test/ELF/compress-sections-err.s
  lld/test/ELF/compress-sections.s
  lld/test/ELF/linkerscript/compress-sections.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154641.537828.patch
Type: text/x-patch
Size: 13272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230706/bdedba88/attachment.bin>


More information about the llvm-commits mailing list