commit: f1de25303bd07f70781ec37d648b62fe7c1d3916 Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> AuthorDate: Mon Dec 5 05:19:25 2022 +0000 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> CommitDate: Mon Dec 5 05:24:44 2022 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f1de2530
sys-boot/mbr-gpt: fix PHDR/LOAD mess "PHDR segment not covered by LOAD segment", an error meaningless for MBR code. The solution is buried in binutils changelogs: --no-dynamic-linker for obscure cases like this. Reference: https://inbox.sourceware.org/binutils/20200222023739.GB5570 <AT> bubble.grove.modra.org/T/#u Closes: https://bugs.gentoo.org/870913 Closes: https://bugs.gentoo.org/709510 Closes: https://bugs.gentoo.org/722206 Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> sys-boot/mbr-gpt/mbr-gpt-0.0.1-r2.ebuild | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/sys-boot/mbr-gpt/mbr-gpt-0.0.1-r2.ebuild b/sys-boot/mbr-gpt/mbr-gpt-0.0.1-r2.ebuild new file mode 100644 index 000000000000..df636e06b770 --- /dev/null +++ b/sys-boot/mbr-gpt/mbr-gpt-0.0.1-r2.ebuild @@ -0,0 +1,69 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit toolchain-funcs + +DESCRIPTION="An MBR that can handle BIOS-based boot on GPT" +MY_P="${PN}_${PV}" +HOMEPAGE="https://web.archive.org/web/20080704173538/http://aybabtu.com/mbr-gpt/" +SRC_URI="https://dev.gentoo.org/~robbat2/distfiles/${MY_P}.tar.gz" + +LICENSE="GPL-3" +SLOT="0" +# This should probably NEVER go to stable. It's crazy advanced dangerous magic. +# It's also pure ASM, so not suitable for elsewhere anyway. +# Please don't remove it, robbat2 has a box that depends on it for # booting! +KEYWORDS="~amd64 ~x86" + +# It only depends on binutils/gcc/make, and doesn't link against libc even. +DEPEND="" +RDEPEND="" + +# It's a mostly an MBR block and it does use the executable stack. +QA_WX_LOAD="usr/lib/${PN}/boot.elf" +QA_PRESTRIPPED="${QA_WX_LOAD}" +QA_FLAGS_IGNORED="${QA_WX_LOAD}" + +# Don't strip it either; this binary reboots your host! +RESTRICT="binchecks strip" + +src_prepare() { + default + + # Messy upstream + emake clean + + # Need to build it 32-bit for the MBR + # Btw, no CFLAGS are respected, it's ASM! + # + # This is not meant to be used by a dynamic linker either! + # https://inbox.sourceware.org/binutils/20200222023739.gb5...@bubble.grove.modra.org/T/#u + # Shows the --no-dynamic-linker option to ld + sed -i -e 's/-Wall/-Wall -m32 -Wl,--no-dynamic-linker/g' "${S}"/Makefile || die +} + +src_compile() { + emake CC="$(tc-getCC)" +} + +src_install() { + # get_libdir is not correct here. We want this to go into a 32-bit library + # location. + insinto /usr/lib/${PN} + doins mbr + + exeinto /usr/lib/${PN} + exeopts -m 700 + doexe boot.elf + + dodoc AUTHORS +} + +pkg_postinst() { + einfo "See the instructions on the homepage, and make sure you know what" + einfo "you are doing before touching this. The mbr file does into your" + einfo "MBR, or alternatively you can do a creative reboot utilizing the" + einfo "boot.elf binary." +}