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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 6 12:05:08 PST 2023


MaskRay added a comment.

In D113443#4105131 <https://reviews.llvm.org/D113443#4105131>, @myfreeweb wrote:

> Encountering this as well with llvm16, decided to research this bit:
>
>> Not handling R_X86_64_REX_GOTPCRELX is FreeBSD's limitation which should be fixed
>
> ..I can't find any dynamic loader that would handle `GOTPCREL` stuff? I've looked at glibc <https://github.com/bminor/glibc/blob/359a0b9dbcd46475f443a33e0062a14b252e327d/sysdeps/x86_64/dl-machine.h#L245> and the Linux kernel <https://elixir.bootlin.com/linux/v6.1.9/source/arch/x86/kernel/module.c#L162> and it really doesn't seem like these are ever handled in a loader?

`R_X86_64_REX_GOTPCRELX` is a static relocation type. Only link editors need to inspect it, not loaders, so you don't find them in glibc/musl/FreeBSD rtld.

Referencing an undefined symbol directly (not through a GOT-generating or PLT-generating relocation type) is a bad idea. If the symbol ends up to be defined in a shared object, you need a copy relocation.
See https://maskray.me/blog/2021-08-29-all-about-global-offset-table#undefined-symbols


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

https://reviews.llvm.org/D113443



More information about the llvm-commits mailing list