[RFC PATCH 2/2] arm64: kernel: switch to PIE code generation for relocatable kernels
Nick Desaulniers
ndesaulniers at google.com
Thu Apr 28 11:53:28 PDT 2022
On Wed, Apr 27, 2022 at 11:57 PM Fangrui Song <maskray at google.com> wrote:
>
> On 2022-04-28, Ard Biesheuvel wrote:
> >On Thu, 28 Apr 2022 at 04:40, Fangrui Song <maskray at google.com> wrote:
> >>
> >> On 2022-04-27, Ard Biesheuvel wrote:
> >> >Fortunately, we can convince the compiler to handle this in a way that
> >> >is a bit more suitable for freestanding binaries such as the kernel, by
> >> >setting the 'hidden' visibility #pragma, which informs the compiler that
> >> >symbol preemption or CoW footprint are of no concern to us, and so
> >> >PC-relative references that are resolved at link time are perfectly
> >> >fine.
> >>
> >> Agree
> >>
> >
> >The only unfortunate thing is that -fvisibility=hidden does not give
> >us the behavior we want, and we are forced to use the #pragma instead.
>
> Right. For a very long time there had been no option controlling the
> access mode for undefined symbols (-fvisibility= is for defined
> symbols).
>
> I added -fdirect-access-external-data to Clang which supports
> many architectures (x86, aarch64, arm, riscv, ...).
> GCC's x86 port added -mdirect-extern-access in 2022-02 (not available on aarch64).
>
> The use of `#pragma GCC visibility push(hidden)` looks good as a
> portable solution.
Portable, sure, which is fine for now.
But there's just something about injecting a header into ever TU via
-include in order to set a pragma and that there's such pragmas
effecting codegen that makes my skin crawl.
Perhaps we can come up with a formal feature request for toolchain
vendors for an actual command line flag?
Does the pragma have the same effect as
`-fdirect-access-external-data`/`-mdirect-extern-access`, or would
this feature request look like yet another distinct flag?
--
Thanks,
~Nick Desaulniers
More information about the linux-arm-kernel
mailing list