Page MenuHomeFreeBSD

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

Authored by alfredo.junior_eldorado.org.br on Nov 11 2019, 6:00 PM.

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
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
sys/conf/kmod.mk
172 ↗(On Diff #64193)

Can't this just be:

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

?

alfredo.junior_eldorado.org.br marked an inline comment as done.Thu, Nov 14, 1:19 PM
alfredo.junior_eldorado.org.br 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
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.