llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.4k stars 12.15k forks source link

support for `-z unique-symbol` #69018

Open nickdesaulniers opened 1 year ago

nickdesaulniers commented 1 year ago

This was discussed briefly years ago in the context of potentially implementing "fine grain kernel address space layout randomization" for the Linux kernel, which has somewhat stalled.

https://github.com/ClangBuiltLinux/linux/issues/1184

It seems like binutils 2.36 BFD implemented implemented support for -z unique_symbol .

https://sourceware.org/binutils/docs/ld/Options.html documents this as:

Avoid duplicated local symbol names in the symbol string table. Append ".number" to duplicated local symbol names if ‘unique-symbol’ is used. nounique-symbol is the default.

Since the work on FGKASLR has somewhat stalled, the priority of this feature in LLD is low/unclear, but filing a bug "upstream" to track this request for others to follow allong.

llvmbot commented 1 year ago

@llvm/issue-subscribers-lld-elf

Author: Nick Desaulniers (nickdesaulniers)

This was discussed briefly years ago in the context of potentially implementing "fine grain kernel address space layout randomization" for the Linux kernel, which has somewhat stalled. https://github.com/ClangBuiltLinux/linux/issues/1184 It seems like [binutils 2.36 BFD implemented](https://lists.gnu.org/archive/html/info-gnu/2021-01/msg00015.html) implemented support for `-z unique_symbol` . https://sourceware.org/binutils/docs/ld/Options.html documents this as: > Avoid duplicated local symbol names in the symbol string table. Append ".number" to duplicated local symbol names if ‘unique-symbol’ is used. nounique-symbol is the default. Since the work on FGKASLR has somewhat stalled, the priority of this feature in LLD is low/unclear, but filing a bug "upstream" to track this request for others to follow allong.
MaskRay commented 1 year ago

I haven't closely followed FGKASLR efforts in the Linux kernel but my https://maskray.me/blog/2020-11-15-explain-gnu-linker-options#z-unique-symbol has some analysis: why the option is not a good design and should be discouraged. AIUI -z unique-symbol was improperly used to work around some issue that should be better improved on the Linux kernel side.

I have mentioned my concern at https://github.com/ClangBuiltLinux/linux/issues/1184 and https://lore.kernel.org/all/20220105032456.hs3od326sdl4zjv4@google.com/