[PATCH] D142163: [LLD][ELF] Add --lto-export-symbol-list

Sami Tolvanen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 15:48:56 PST 2023


samitolvanen created this revision.
Herald added subscribers: ormris, steven_wu, hiraditya, arichardson, inglorion, emaste.
Herald added a reviewer: MaskRay.
Herald added a project: All.
samitolvanen requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Normally when compiling bitcode in a relocatable link, LLD sets
the VisibleToRegularObj flag in the symbol resolution for all
globals, which prevents LTO from dropping globals that may be
needed later. However, in situations where we know which globals
we want to export, LTO could better optimize the code if we
marked only the exported symbols visible. This is the case in the
Linux kernel, for example, where all the bitcode in the kernel
is compiled during a relocatable link, and we have a list of
exported symbols.

Add an --lto-export-symbol-list flag to LLD, which accepts a list
of exported globals in the version script format, and uses the
list to set the bindings for non-exported globals to STB_LOCAL,
and sets the VisibleToRegularObj flag in symbol resolution only
for the exported symbols.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142163

Files:
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/DriverUtils.cpp
  lld/ELF/LTO.cpp
  lld/ELF/Options.td
  lld/ELF/ScriptParser.cpp
  lld/ELF/ScriptParser.h
  lld/ELF/SymbolTable.cpp
  lld/ELF/SymbolTable.h
  lld/ELF/Symbols.cpp
  lld/ELF/Symbols.h
  lld/test/ELF/driver.test
  lld/test/ELF/lto/lto-export-symbol-list-locals.s
  lld/test/ELF/lto/lto-export-symbol-list-unexpected-end.s
  lld/test/ELF/lto/lto-export-symbol-list.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142163.490680.patch
Type: text/x-patch
Size: 13081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230119/fb528378/attachment-0001.bin>


More information about the llvm-commits mailing list