drm-kmod: Export symbols
We currently rely on the kernel linker resolving undefined references against local symbols from other kernel modules. Be explicit about the symbols to export, in advance of changing that behaviour.
PR: 207898 Sponsored by: The FreeBSD Foundation
Wouldn't this be a pain to keep track of ?
It'll be a bit of a pain, but it's not too bad. I generated these largely with a sed expression: sed -E -n 's/^.*EXPORT_SYMBOL[A-Z_]*\((.*)\).*$/EXPORT_SYMS+= \1/p.
We could take the same approach as Linux and use EXPORT_SYMBOL to control this (e.g. output the symbols to a special section similar to linker sets, then process those into the export list for linking).
The alternative is to just set EXPORT_SYMS=YES but it really is a bug that we're linking against local symbols from other modules.
Also linuxkpi_video currently has EXPORT_SYMS=YES.
In my tree I've changed it to:
# drivers/video/aperture.c
EXPORT_SYMS+= __aperture_remove_legacy_vga_devices
EXPORT_SYMS+= aperture_remove_conflicting_devices
EXPORT_SYMS+= aperture_remove_conflicting_pci_devices
EXPORT_SYMS+= devm_aperture_acquire_for_platform_device
# drivers/video/hdmi.c
EXPORT_SYMS+= hdmi_audio_infoframe_check
EXPORT_SYMS+= hdmi_audio_infoframe_init
EXPORT_SYMS+= hdmi_audio_infoframe_pack
EXPORT_SYMS+= hdmi_audio_infoframe_pack_for_dp
EXPORT_SYMS+= hdmi_audio_infoframe_pack_only
EXPORT_SYMS+= hdmi_avi_infoframe_check
EXPORT_SYMS+= hdmi_avi_infoframe_init
EXPORT_SYMS+= hdmi_avi_infoframe_pack
EXPORT_SYMS+= hdmi_avi_infoframe_pack_only
EXPORT_SYMS+= hdmi_drm_infoframe_check
EXPORT_SYMS+= hdmi_drm_infoframe_init
EXPORT_SYMS+= hdmi_drm_infoframe_pack
EXPORT_SYMS+= hdmi_drm_infoframe_pack_only
EXPORT_SYMS+= hdmi_drm_infoframe_unpack_only
EXPORT_SYMS+= hdmi_infoframe_check
EXPORT_SYMS+= hdmi_infoframe_log
EXPORT_SYMS+= hdmi_infoframe_pack
EXPORT_SYMS+= hdmi_infoframe_pack_only
EXPORT_SYMS+= hdmi_infoframe_unpack
EXPORT_SYMS+= hdmi_spd_infoframe_check
EXPORT_SYMS+= hdmi_spd_infoframe_init
EXPORT_SYMS+= hdmi_spd_infoframe_pack
EXPORT_SYMS+= hdmi_spd_infoframe_pack_only
EXPORT_SYMS+= hdmi_vendor_infoframe_check
EXPORT_SYMS+= hdmi_vendor_infoframe_init
EXPORT_SYMS+= hdmi_vendor_infoframe_pack
EXPORT_SYMS+= hdmi_vendor_infoframe_pack_only
I would prefer a script in the scripts directory that can generate this and put the result in a submakefile that the main ones include.
#338 is a short-term workaround to avoid relying on kernel misbehaviour
After applying https://bugs.freebsd.org/bugzilla/attachment.cgi?id=258740&action=diff, I'm still unable to load amdgpu on powerpc64le:
root@talos-powerpc64le:~ # kldload amdgpu
link_elf: symbol drm_helper_connector_dpms undefined
kldload: can't load amdgpu: No such file or directory
root@talos-powerpc64le:~ # kldload drm
link_elf: symbol dma_fence_wait undefined
kldload: can't load drm: No such file or directory
root@talos-powerpc64le:$/boot/modules$ nm dmabuf.ko | grep dma_fence_wait
0000000000009210 T dma_fence_wait
0000000000008380 T dma_fence_wait_any_timeout
0000000000007660 T dma_fence_wait_timeout
root@talos-powerpc64le:$/boot/modules$ nm drm.ko | grep dma_fence_wait
U dma_fence_wait
That is on 6.1.128.1402000_2.
This patch isn't ready yet, please test with #338 instead.
That's what I did, the pkg version is 6.1.128.1402000_2, which includes that change. I just posted here, because the discussion is relevant to the issue (symbols not exported).