[PATCH] D85056: [ELF] Add --keep-section to expose linkerscript KEEP directive as a linker flag

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 31 16:29:12 PDT 2020


MaskRay added a comment.

> --gc-sections throw away all unreferenced sections, but we sometimes need to keep some of them.

If an input section defines a non-local symbol, you can use `-u` to retain the section.

> Although it's possible to use a linkerscript with the KEEP directive, it is often cumbersome for large repositories where each binary might have its own linkerscript.

-T can be specified multiple times. The linker scripts are essentially concatenated. What might be inconvenient is that once a linker script (unless the INSERT AFTER|BEFORE) is specified, it is considered an external linker script (GNU ld --verbose), and several built-in rules (!hasSectionsCommand) are disabled. If such requests are common, we should communicate with binutils to get a syntax.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85056/new/

https://reviews.llvm.org/D85056



More information about the llvm-commits mailing list