Page MenuHomeFreeBSD

Formalize the use of linker scripts for kernel modules.

Authored by markj on Thu, Oct 3, 4:05 PM.



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

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

markj created this revision.Thu, Oct 3, 4:05 PM
kib accepted this revision.Thu, Oct 3, 6:19 PM
This revision is now accepted and ready to land.Thu, Oct 3, 6:19 PM
imp added inline comments.Thu, Oct 3, 6:21 PM
252 ↗(On Diff #62875)

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?

jhb added inline comments.Thu, Oct 3, 6:36 PM
252 ↗(On Diff #62875)

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.

markj updated this revision to Diff 62908.Fri, Oct 4, 5:18 PM


This revision now requires review to proceed.Fri, Oct 4, 5:18 PM
imp accepted this revision.Fri, Oct 4, 5:26 PM

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

This revision is now accepted and ready to land.Fri, Oct 4, 5:26 PM
This revision was automatically updated to reflect the committed changes.