[PATCH] D109090: [FreeBSD] avoid marking __stack_chk_guard symbol as dso_local on FreeBSD

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 8 04:52:30 PST 2021


nemanjai added a comment.

In D109090#3113552 <https://reviews.llvm.org/D109090#3113552>, @dim wrote:

> Hmm this seems to cause some trouble when building kernels and kernel modules on FreeBSD, which are built in -ffreestanding mode, and then you get weird relocations in kernel modules:
>
> % readelf -a ../src/sys/amd64/compile/X/modules/usr/home/kostik/work/DEV/src/sys/modules/ufs/ufs_vnops.o | grep GOT | head -3
> 0000000001f7  004a0000002a R_X86_64_REX_GOTP 0000000000000000 __stack_chk_guard - 4
> 00000000060d  004a0000002a R_X86_64_REX_GOTP 0000000000000000 __stack_chk_guard - 4
> 0000000007c8  004a0000002a R_X86_64_REX_GOTP 0000000000000000 __stack_chk_guard - 4
>
> Maybe this should have an additional check for freestanding mode?

Hmm, something seems odd here. I don't claim to really understand what is going on or why these relocations are a problem, but it seems bad if there is a requirement for `dso_local` for correctness.
The way I understand this attribute is that it is useful for optimization only - i.e. it is not required for anything, but if something is actually local to a DSO, a more optimal code sequence is possible. Shouldn't it be conservatively correct to just omit `dso_local` from everything?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109090



More information about the llvm-commits mailing list