Bug 252459 - kldxref: /boot/kernel/kernel: too many segments
Summary: kldxref: /boot/kernel/kernel: too many segments
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: arm64 Any
: --- Affects Some People
Assignee: Ed Maste
URL: https://cgit.freebsd.org/src/commit/?...
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2021-01-06 07:09 UTC by Matthias Apitz
Modified: 2024-03-13 11:44 UTC (History)
11 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Apitz 2021-01-06 07:09:34 UTC
# make installkernel KERNCONF=GENERIC                                                     
                                                                                          
ends with the following messages                                                         
...                                                                                      
install -T release -o root -g wheel -m 555   zlib.ko /boot/kernel/                        
install -T dbg -o root -g wheel -m 555   zlib.ko.debug /usr/lib/debug/boot/kernel/        
kldxref /boot/kernel                                                                      
kldxref: /boot/kernel/kernel: too many segments                                           
--------------------------------------------------------------                            
>>> Installing kernel GENERIC completed on Tue Jan  5 12:50:59 CET 2021

The kernel boots fine, though.

There seems to be a thread in mails already:

https://lists.freebsd.org/pipermail/freebsd-current/2020-August/076754.html
Comment 1 Herbert J. Skuhra 2021-01-06 08:52:35 UTC
Obviously, this is already fixed in 05c312a339096ac54d404029ddfcd0114d452a4c (SVN: r364435):

https://cgit.freebsd.org/src/commit/?id=05c312a339096ac54d404029ddfcd0114d452a4c

https://svnweb.freebsd.org/base?view=revision&revision=364435
Comment 2 Matthias Apitz 2021-01-06 09:22:05 UTC
The system which was compiled was SVN rev. r368166
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2021-01-06 09:24:52 UTC
The message itself was fixed by base r364435, but it can still appear if you upgrade from an older source checkout.

At some point kldxref should be made into a bootstrap tool, or some other trick should be used to force installkernel to use a fresh copy.
Comment 4 Dan Langille freebsd_committer freebsd_triage 2021-04-15 15:29:31 UTC
We saw it today when installing a 13.0 RELEASE kernel on a 12.2 host
Comment 5 Brian Whalen 2021-11-22 01:54:38 UTC
Similar to the previous poster, I have an esxi vm with v 12 stable on it, where code was gotten via svnlite. I then deleted /usr/src, rebooted, and got v 13 stable via git clone. After the make kernel completed, I also saw this error.
Comment 6 Terry Kennedy 2022-01-14 09:34:29 UTC
I am also seeing this on 12-STABLE r371492. My build script builds and installs world before the kernel, so this doesn't seem to be from a stale toolchain:

cd /usr/obj
rm -Rf usr
cd ../src
make -j24 buildworld && make installworld && make -j24 kernel
Comment 7 Terry Kennedy 2022-01-14 09:39:26 UTC
(In reply to Terry Kennedy from comment #6)

Applying the patch from base r364435 seems to fix the problem, so it seems we may just be looking at a missing MFC.
Comment 8 commit-hook freebsd_committer freebsd_triage 2022-01-14 15:47:12 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d53b44084e66e4d21bec7143f00a8677c90a09d2

commit d53b44084e66e4d21bec7143f00a8677c90a09d2
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2020-08-20 18:50:46 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-01-14 15:45:14 +0000

    Bump kldxref's MAXSEGS to 16, to stop complaints about the kernel
    supposedly having too many segments, when lld 11 links it. Such kernels
    should load just fine.

    Note that we may still do some tweaking of our kernel linker scripts, to
    lower the number of segments, although the exact benefit is not entirely
    clear.

    PR:             252459

    (cherry picked from commit 05c312a339096ac54d404029ddfcd0114d452a4c)

 usr.sbin/kldxref/ef.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 9 Vladyslav V. Prodan 2022-06-22 07:12:33 UTC
The problem is still relevant for 12-STABLE.

# make installkernel 'KERNCONF=universal-12-3'

...
===> zlib (install)
install -T release -o root -g wheel -m 555   zlib.ko /boot/kernel/
install -T debug -o root -g wheel -m 555   zlib.ko.debug /usr/lib/debug/boot/kernel/
kldxref /boot/kernel
kldxref: /boot/kernel/kernel: too many segments
--------------------------------------------------------------
>>> Installing kernel universal-12-3 completed on Wed Jun 22 10:05:41 EEST 2022
--------------------------------------------------------------

# uname -KUr
12.3-STABLE 1203500 1203500

# svnlite info /usr/src | awk '/Revision:/ {print$2;}'
372167
Comment 10 Miroslav Lachman 2022-12-12 15:47:44 UTC
I don't know what and where was fixed but something was probably forgotten. I see this error on FreeBSD 12.3-RELEASE-p10 amd64 GENERIC machine building update to 12.4-RELEASE

# make installkernel DESTDIR=/vol0/12.4-RELEASE_amd64
kldxref: /vol0/12.4-RELEASE_amd64/boot/kernel/kernel: too many segments
Comment 11 Graham Perrin freebsd_committer freebsd_triage 2022-12-12 17:38:58 UTC
Triage: assignment to the committer of d53b44084e66e4d21bec7143f00a8677c90a09d2
Comment 12 Vladyslav V. Prodan 2024-03-13 11:44:54 UTC
(In reply to Vladyslav V. Prodan from comment #9)

Up. 

#make installkernel 'KERNCONF=universal-13-3'
...
kldxref /usr/obj/usr/src/amd64.amd64/release/dist/kernel/boot/kernel
kldxref: error while reading /usr/obj/usr/src/amd64.amd64/release/dist/kernel/boot/kernel/iwlwifi-9000-pu-b0-jf-b0-46.ucode.ko: Bad address
kldxref: error while reading /usr/obj/usr/src/amd64.amd64/release/dist/kernel/boot/kernel/iwlwifi-9260-th-b0-jf-b0-46.ucode.ko: Bad address
kldxref: /usr/obj/usr/src/amd64.amd64/release/dist/kernel/boot/kernel/kernel: too many segments

# uname -KUr
12.3-STABLE 1203500 1203500

# awk -F: '{print $2}' /usr/src/.gituprevision | head -1
6766a47c0