This patch makes the kernel's .SUNW_ctf section loadable on amd64 using linker scripts and objcopy.
It is the first of two patches that enable ddb to use CTF data.
This patch adds the following:
- The ability to include the kernel's .SUNW_ctf section in a loadable ELF segment
- A new 'SUNW_LOADABLE' makeoptions variable that controls this feature
- Kernel support to initialize relevant kernel CTF structures if a loadable section is present
- A new 'linker_kernel_ctf_get_ddb' method to fetch loaded CTF data
Retrieving the kernel's CTF data from ddb requires a different approach as ddb
cannot use the existing linker_kernel_ctf_get linker method since it performs dynamic memory allocation and IO.
Since the CTF data must available without IO, it must be integrated into the kernel's image and loaded during boot.
Unfortunately, ctfmerge always assumes that the .SUNW_ctf section is not included in any loadable segments and generates
a non-SHF_ALLOC'd section, making it impossible to load it during boot.
I've tinkered with ctfmerge to try and "append" a new loadable segment, but this did not yield any results and
generally felt inappropriate as this is not something ctfmerge should implement. Instead, I've opted for a series
of objcopy operations and an additional kernel linking to achieve this.
This is done post-compilation after the kernel has been linked and after ctfmerge is run.
The CTF data gets dumped from the kernel into a placeholder file and the kernel gets linked once again.
During this second linking, the linker script places the CTF data from the placeholder file into a loadable segment.
The .SUNW_ctf section's data and properties are preserved and compatible with existing kernel CTF interfaces but are now accessible from ddb.