Text relocations in kernel modules

Richard Yao ryao at cs.stonybrook.edu
Fri Mar 30 20:13:19 UTC 2012


On 03/30/12 15:46, Konstantin Belousov wrote:
> On Fri, Mar 30, 2012 at 03:42:22PM -0400, Richard Yao wrote:
>> On 03/30/12 15:07, Konstantin Belousov wrote:
>>>> Is this a bug?
>>> No. This is by design.
>>>
>>> Why do you consider this a bug ?
>>
>> It occurs on i386, but not amd64. It could be that something is wrong
>> with how things are being compiled i386, or it could be that i386
>> requires things to be compiled this way. I do not know which.
>>
> Again, let me repeat my question. Why do you consider the presence
> of relocations against text section a problem ?

The linker emits warnings:
i686-gentoo-freebsd9.0-ld: warning: creating a DT_TEXTREL in object.

Furthermore, this triggers a QA check in Gentoo/FreeBSD's package manager.

 * QA Notice: The following files contain runtime text relocations
 *  Text relocations force the dynamic linker to perform extra
 *  work at startup, waste system resources, and may pose a security
 *  risk.  On some architectures, the code may not even function
 *  properly, if at all.
 *  For more information, see http://hardened.gentoo.org/pic-fix-guide.xml
 *  Please include the following list of files in your report:
 * TEXTREL boot/modules/if_vtnet.ko
 * TEXTREL boot/modules/virtio_blk.ko
 * TEXTREL boot/modules/virtio.ko
 * TEXTREL boot/modules/virtio_balloon.ko
 * TEXTREL boot/modules/virtio_pci.ko

I wrote that ebuild as part of something entirely unrelated. If it is a
feature, I can disable the QA check, but I should at least know why the
text relocations are needed.

Gentoo maintainers are expected to patch text relocations and send
patches upstream. The only exception is in the case of binary packages,
which they cannot patch.

Investigating the text relocations in my port of emulators/virtio-kmod
revealed that all kernel modules on i386 Gentoo/FreeBSD have text
relocations, yet none have them on amd64 FreeBSD, so I do not know
whether this is a bug or a feature.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20120330/bd3bc7ef/signature.pgp


More information about the freebsd-stable mailing list