Page MenuHomeFreeBSD

Formalize the use of linker scripts for kernel modules.
ClosedPublic

Authored by markj on Oct 3 2019, 4:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 17, 12:44 AM
Unknown Object (File)
Feb 24 2024, 1:16 AM
Unknown Object (File)
Feb 24 2024, 1:16 AM
Unknown Object (File)
Feb 24 2024, 1:16 AM
Unknown Object (File)
Feb 24 2024, 1:16 AM
Unknown Object (File)
Feb 23 2024, 12:22 PM
Unknown Object (File)
Sep 22 2023, 1:53 PM
Unknown Object (File)
Sep 3 2023, 2:54 AM
Subscribers
None

Details

Summary

Automatically use ldscript.kmod.${MACHINE_CPUARCH} if it exists.
We already have an i386-specific linker script; rename it accordingly.
I plan to add an amd64 linker script to insert padding after .text
and .rodata*, so that permission boundaries are page-aligned. (It turns
out that my plan to use DSOs on amd64 will not work because of issues
that arise when combining -mcmodel=kernel and -fPIC.)

Note that the linker script is applied during the partial link. For
amd64 (which uses .o's), this is also the final link. I think this is
probably fine, though maybe it will be useful someday to be able to
script the final link instead.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26867
Build 25185: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Oct 3 2019, 6:19 PM
sys/conf/kmod.mk
252

So this is 'mips' for all mips things and 'powerpc' for all powerpc things.
History has shown that we really want to have both the ability to check MACHINE_ARCH as well as the more generic MACHINE_CPUARCH.
Would it be possible to update to do that?

sys/conf/kmod.mk
252

We can probably wait to fix that until an actual use case turns up. My inclination would be to actually use MACHINE_ARCH instead of MACHINE_CPUARCH for now (a no-op on i386 and amd64), though it really doesn't matter. I'm somewhat surprised the original code used CPUARCH for this.

Use MACHINE_ARCH instead of MACHINE_CPUARCH.

This revision now requires review to proceed.Oct 4 2019, 5:18 PM

I'm cool with jhb's reasoning, so this looks ready to land.

This revision is now accepted and ready to land.Oct 4 2019, 5:26 PM