Page MenuHomeFreeBSD

[PowerPC64] Fix broken kernel modules due to LLD 9+ TOC optimization
ClosedPublic

Authored by alfredo on Nov 11 2019, 6:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 15, 9:31 AM
Unknown Object (File)
Fri, Mar 15, 9:31 AM
Unknown Object (File)
Fri, Mar 15, 9:31 AM
Unknown Object (File)
Fri, Mar 15, 9:31 AM
Unknown Object (File)
Mon, Mar 11, 2:14 PM
Unknown Object (File)
Feb 6 2024, 1:09 PM
Unknown Object (File)
Jan 8 2024, 9:04 AM
Unknown Object (File)
Jan 8 2024, 9:04 AM
Subscribers

Details

Summary

LLD9 introduced a TOC optimization that isn't compatible with kernel dynamic linker causing panic when loading kernel modules (pf, linuxkpi and so)

This patch disables TOC optimization when building kernel modules

Test Plan

Tested kldload on powerpc64 (QEMU)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

removed compiler check to address gcc+lld possible use case

sys/conf/kmod.mk
172 ↗(On Diff #64193)

Can't this just be:

LDFLAGS.lld+= --no-toc-optimize

?

alfredo added inline comments.
sys/conf/kmod.mk
172 ↗(On Diff #64193)

I tried it in the past and it didn't work. Anyway I just double checked it and this mechanism still not working, unfortunately.

In fact, there's only one place using it (and probably isn't working too)

# grep -R "LDFLAGS.lld" /usr/src/*
stand/i386/Makefile.inc:LDFLAGS.lld+=	-Wl,--no-rosegment

Thanks for testing the alternative.

This revision is now accepted and ready to land.Nov 14 2019, 2:49 PM