From owner-dev-commits-src-branches@freebsd.org Wed Jul 21 16:18:59 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9AC8F666F03; Wed, 21 Jul 2021 16:18:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GVLPH25lQz3Mnc; Wed, 21 Jul 2021 16:18:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8E9B5211C7; Wed, 21 Jul 2021 16:18:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 16LGIwdg081558; Wed, 21 Jul 2021 16:18:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16LGIwQp081557; Wed, 21 Jul 2021 16:18:58 GMT (envelope-from git) Date: Wed, 21 Jul 2021 16:18:58 GMT Message-Id: <202107211618.16LGIwQp081557@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 7028ae849a54 - stable/12 - boot: fix OBJS to not include BTX's crt0.o MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 7028ae849a54552f399a3d221e906a467fee09f3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jul 2021 16:19:00 -0000 The branch stable/12 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=7028ae849a54552f399a3d221e906a467fee09f3 commit 7028ae849a54552f399a3d221e906a467fee09f3 Author: Warner Losh AuthorDate: 2021-05-06 19:05:09 +0000 Commit: Warner Losh CommitDate: 2021-07-21 16:16:33 +0000 boot: fix OBJS to not include BTX's crt0.o According to comments in the Makefile, to make pxeboot work we need to have crt0.o first. This is needed because the simplified loader in pxeboot assumes that the startup code is at offset 0 in this binary. In normal booting, the start address can be obtained from headers of the binary, but since pxeboot encodes this as a pure binary, it has no way of knowing where that is and assumes 0. Added comments to that effect in the Makefile. We've done this by adding it to OBJS before all the other .o's are added. However, there's a problem. This also adds it to the CLEANFILES variable, which causes it to be removed from multiple places. The dependencies may also cause it to be re-built at a time that's after boot2 is built. This causes installs to fail because at install time boot2 is considered to be out of date and the programs to rebuild it are no longer in the path. Cope with this problem by just adding it to LDFLAGS instead. Glanced at by: kevans ("I thought that went in ages ago") Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D28876 (cherry picked from commit e713d3a013882893fceb84dd14569052271497a9) --- stand/i386/loader/Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/stand/i386/loader/Makefile b/stand/i386/loader/Makefile index b74ef9007d97..8fbea355d726 100644 --- a/stand/i386/loader/Makefile +++ b/stand/i386/loader/Makefile @@ -75,8 +75,18 @@ LINKS+= ${BINDIR}/${LOADER} ${BINDIR}/loader FILES+= ${LOADER} FILESMODE_${LOADER}= ${BINMODE} -b -# XXX crt0.o needs to be first for pxeboot(8) to work -OBJS= ${BTXCRT} +# Note: crt0.o needs to be first for pxeboot(8) to work. It assumes that the +# startup code is located at the start of the loader and will jump +# there. Although btx is more flexible than this, the emulated boot2 environment +# that pxeloader provides has none of that flexibility because it lacks access +# to the a.out/elf headers and assumes an entry point of 0. +# +# We must add it to the LDFLAGS instead of the OBJS becauce the former won't try +# to clean it. When it is in OBJS, this cleaning can lead to races where +# btxcrt.o is rebuilt, but boot2 isn't, leading to errors at installation time. +# LDFLAGS does not have this baggage and will be included first in the list of +# files. +LDFLAGS+= ${BTXCRT} DPADD= ${LDR_INTERP32} ${LIBFIREWIRE} ${LIBI386} ${LIBSA32} LDADD= ${LDR_INTERP32} ${LIBFIREWIRE} ${LIBI386} ${LIBSA32}