Page MenuHomeFreeBSD

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

Authored by on Nov 11 2019, 6:00 PM.



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

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

removed compiler check to address gcc+lld possible use case

jhibbits added inline comments.Nov 13 2019, 9:13 PM
172 ↗(On Diff #64193)

Can't this just be:

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

? marked an inline comment as done.Thu, Nov 14, 1:19 PM added inline comments.
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/	-Wl,--no-rosegment
jhibbits accepted this revision.Thu, Nov 14, 2:49 PM

Thanks for testing the alternative.

This revision is now accepted and ready to land.Thu, Nov 14, 2:49 PM
bdragon accepted this revision.Thu, Nov 14, 7:38 PM

Looks good to me too.