Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-boot/grub/, sys-boot/grub/files/
Date: Sat, 01 Sep 2018 22:07:08
Message-Id: 1535839611.3a9f20b6a3b8d98097de02d997defcbda65edc50.whissi@gentoo
1 commit: 3a9f20b6a3b8d98097de02d997defcbda65edc50
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Sat Sep 1 22:06:36 2018 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Sat Sep 1 22:06:51 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3a9f20b6
7
8 sys-boot/grub: treat R_X86_64_PLT32 as R_X86_64_PC32
9
10 Closes: https://bugs.gentoo.org/665066
11 Package-Manager: Portage-2.3.48, Repoman-2.3.10
12 RepoMan-Options: --force
13
14 sys-boot/grub/files/2.02-X86_64_PLT32.patch | 75 +++++++
15 sys-boot/grub/grub-2.02-r3.ebuild | 313 ++++++++++++++++++++++++++++
16 2 files changed, 388 insertions(+)
17
18 diff --git a/sys-boot/grub/files/2.02-X86_64_PLT32.patch b/sys-boot/grub/files/2.02-X86_64_PLT32.patch
19 new file mode 100644
20 index 00000000000..2c65cb78a5d
21 --- /dev/null
22 +++ b/sys-boot/grub/files/2.02-X86_64_PLT32.patch
23 @@ -0,0 +1,75 @@
24 +From 02702bdfe14d8a04643a45b03715f734ae34dbac Mon Sep 17 00:00:00 2001
25 +From: "H.J. Lu" <hjl.tools@×××××.com>
26 +Date: Sat, 17 Feb 2018 06:47:28 -0800
27 +Subject: x86-64: Treat R_X86_64_PLT32 as R_X86_64_PC32
28 +
29 +Starting from binutils commit bd7ab16b4537788ad53521c45469a1bdae84ad4a:
30 +
31 +https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=bd7ab16b4537788ad53521c45469a1bdae84ad4a
32 +
33 +x86-64 assembler generates R_X86_64_PLT32, instead of R_X86_64_PC32, for
34 +32-bit PC-relative branches. Grub2 should treat R_X86_64_PLT32 as
35 +R_X86_64_PC32.
36 +
37 +Signed-off-by: H.J. Lu <hjl.tools@×××××.com>
38 +Reviewed-by: Daniel Kiper <daniel.kiper@××××××.com>
39 +
40 +Origin: upstream, https://git.savannah.gnu.org/cgit/grub.git/commit/?id=842c390469e2c2e10b5aa36700324cd3bde25875
41 +Last-Update: 2018-07-30
42 +
43 +Patch-Name: R_X86_64_PLT32.patch
44 +---
45 + grub-core/efiemu/i386/loadcore64.c | 1 +
46 + grub-core/kern/x86_64/dl.c | 1 +
47 + util/grub-mkimagexx.c | 1 +
48 + util/grub-module-verifier.c | 1 +
49 + 4 files changed, 4 insertions(+)
50 +
51 +diff --git a/grub-core/efiemu/i386/loadcore64.c b/grub-core/efiemu/i386/loadcore64.c
52 +index e49d0b6ff..18facf47f 100644
53 +--- a/grub-core/efiemu/i386/loadcore64.c
54 ++++ b/grub-core/efiemu/i386/loadcore64.c
55 +@@ -98,6 +98,7 @@ grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
56 + break;
57 +
58 + case R_X86_64_PC32:
59 ++ case R_X86_64_PLT32:
60 + err = grub_efiemu_write_value (addr,
61 + *addr32 + rel->r_addend
62 + + sym.off
63 +diff --git a/grub-core/kern/x86_64/dl.c b/grub-core/kern/x86_64/dl.c
64 +index 440690673..3a73e6e6c 100644
65 +--- a/grub-core/kern/x86_64/dl.c
66 ++++ b/grub-core/kern/x86_64/dl.c
67 +@@ -70,6 +70,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
68 + break;
69 +
70 + case R_X86_64_PC32:
71 ++ case R_X86_64_PLT32:
72 + {
73 + grub_int64_t value;
74 + value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value -
75 +diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
76 +index e63f148e4..f20255a28 100644
77 +--- a/util/grub-mkimagexx.c
78 ++++ b/util/grub-mkimagexx.c
79 +@@ -832,6 +832,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
80 + break;
81 +
82 + case R_X86_64_PC32:
83 ++ case R_X86_64_PLT32:
84 + {
85 + grub_uint32_t *t32 = (grub_uint32_t *) target;
86 + *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32)
87 +diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c
88 +index 9179285a5..a79271f66 100644
89 +--- a/util/grub-module-verifier.c
90 ++++ b/util/grub-module-verifier.c
91 +@@ -19,6 +19,7 @@ struct grub_module_verifier_arch archs[] = {
92 + -1
93 + }, (int[]){
94 + R_X86_64_PC32,
95 ++ R_X86_64_PLT32,
96 + -1
97 + }
98 + },
99
100 diff --git a/sys-boot/grub/grub-2.02-r3.ebuild b/sys-boot/grub/grub-2.02-r3.ebuild
101 new file mode 100644
102 index 00000000000..d4640dd767b
103 --- /dev/null
104 +++ b/sys-boot/grub/grub-2.02-r3.ebuild
105 @@ -0,0 +1,313 @@
106 +# Copyright 1999-2018 Gentoo Foundation
107 +# Distributed under the terms of the GNU General Public License v2
108 +
109 +EAPI="6"
110 +
111 +GRUB_AUTOGEN=1
112 +GRUB_AUTORECONF=1
113 +
114 +if [[ -n ${GRUB_AUTOGEN} ]]; then
115 + PYTHON_COMPAT=( python{2_7,3_3,3_4,3_5,3_6} )
116 + inherit python-any-r1
117 +fi
118 +
119 +if [[ -n ${GRUB_AUTORECONF} ]]; then
120 + WANT_LIBTOOL=none
121 + inherit autotools
122 +fi
123 +
124 +inherit bash-completion-r1 flag-o-matic multibuild pax-utils toolchain-funcs
125 +
126 +if [[ ${PV} != 9999 ]]; then
127 + if [[ ${PV} == *_alpha* || ${PV} == *_beta* || ${PV} == *_rc* ]]; then
128 + # The quote style is to work with <=bash-4.2 and >=bash-4.3 #503860
129 + MY_P=${P/_/'~'}
130 + SRC_URI="mirror://gnu-alpha/${PN}/${MY_P}.tar.xz"
131 + S=${WORKDIR}/${MY_P}
132 + else
133 + SRC_URI="mirror://gnu/${PN}/${P}.tar.xz"
134 + S=${WORKDIR}/${P%_*}
135 + fi
136 + KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86"
137 +else
138 + inherit git-r3
139 + EGIT_REPO_URI="git://git.sv.gnu.org/grub.git
140 + http://git.savannah.gnu.org/r/grub.git"
141 +fi
142 +
143 +PATCHES=(
144 + "${FILESDIR}"/gfxpayload.patch
145 + "${FILESDIR}"/grub-2.02_beta2-KERNEL_GLOBS.patch
146 + "${FILESDIR}"/2.02-multiple-early-initrd.patch
147 + "${FILESDIR}"/2.02-freetype-capitalise-variables.patch
148 + "${FILESDIR}"/2.02-freetype-pkg-config.patch
149 + "${FILESDIR}"/2.02-xfs-sparse-inodes.patch
150 + "${FILESDIR}"/2.02-X86_64_PLT32.patch
151 +)
152 +
153 +DEJAVU=dejavu-sans-ttf-2.37
154 +UNIFONT=unifont-9.0.06
155 +SRC_URI+=" fonts? ( mirror://gnu/unifont/${UNIFONT}/${UNIFONT}.pcf.gz )
156 + themes? ( mirror://sourceforge/dejavu/${DEJAVU}.zip )"
157 +
158 +DESCRIPTION="GNU GRUB boot loader"
159 +HOMEPAGE="https://www.gnu.org/software/grub/"
160 +
161 +# Includes licenses for dejavu and unifont
162 +LICENSE="GPL-3 fonts? ( GPL-2-with-font-exception ) themes? ( BitstreamVera )"
163 +SLOT="2/${PVR}"
164 +IUSE="debug device-mapper doc efiemu +fonts mount multislot nls static sdl test +themes truetype libzfs"
165 +
166 +GRUB_ALL_PLATFORMS=( coreboot efi-32 efi-64 emu ieee1275 loongson multiboot qemu qemu-mips pc uboot xen xen-32 )
167 +IUSE+=" ${GRUB_ALL_PLATFORMS[@]/#/grub_platforms_}"
168 +
169 +REQUIRED_USE="
170 + grub_platforms_coreboot? ( fonts )
171 + grub_platforms_qemu? ( fonts )
172 + grub_platforms_ieee1275? ( fonts )
173 + grub_platforms_loongson? ( fonts )
174 +"
175 +
176 +# os-prober: Used on runtime to detect other OSes
177 +# xorriso (dev-libs/libisoburn): Used on runtime for mkrescue
178 +COMMON_DEPEND="
179 + app-arch/xz-utils
180 + >=sys-libs/ncurses-5.2-r5:0=
181 + debug? (
182 + sdl? ( media-libs/libsdl )
183 + )
184 + device-mapper? ( >=sys-fs/lvm2-2.02.45 )
185 + libzfs? ( sys-fs/zfs )
186 + mount? ( sys-fs/fuse:0 )
187 + truetype? ( media-libs/freetype:2= )
188 + ppc? ( >=sys-apps/ibm-powerpc-utils-1.3.5 )
189 + ppc64? ( >=sys-apps/ibm-powerpc-utils-1.3.5 )
190 +"
191 +DEPEND="${COMMON_DEPEND}
192 + ${PYTHON_DEPS}
193 + app-misc/pax-utils
194 + sys-devel/flex
195 + sys-devel/bison
196 + sys-apps/help2man
197 + sys-apps/texinfo
198 + fonts? (
199 + media-libs/freetype:2
200 + virtual/pkgconfig
201 + )
202 + grub_platforms_xen? ( app-emulation/xen-tools:= )
203 + grub_platforms_xen-32? ( app-emulation/xen-tools:= )
204 + static? (
205 + app-arch/xz-utils[static-libs(+)]
206 + truetype? (
207 + app-arch/bzip2[static-libs(+)]
208 + media-libs/freetype[static-libs(+)]
209 + sys-libs/zlib[static-libs(+)]
210 + virtual/pkgconfig
211 + )
212 + )
213 + test? (
214 + app-admin/genromfs
215 + app-arch/cpio
216 + app-arch/lzop
217 + app-emulation/qemu
218 + dev-libs/libisoburn
219 + sys-apps/miscfiles
220 + sys-block/parted
221 + sys-fs/squashfs-tools
222 + )
223 + themes? (
224 + app-arch/unzip
225 + media-libs/freetype:2
226 + virtual/pkgconfig
227 + )
228 + truetype? ( virtual/pkgconfig )
229 +"
230 +RDEPEND="${COMMON_DEPEND}
231 + kernel_linux? (
232 + grub_platforms_efi-32? ( sys-boot/efibootmgr )
233 + grub_platforms_efi-64? ( sys-boot/efibootmgr )
234 + )
235 + !multislot? ( !sys-boot/grub:0 !sys-boot/grub-static )
236 + nls? ( sys-devel/gettext )
237 +"
238 +
239 +RESTRICT="strip !test? ( test )"
240 +
241 +QA_EXECSTACK="usr/bin/grub*-emu* usr/lib/grub/*"
242 +QA_WX_LOAD="usr/lib/grub/*"
243 +QA_MULTILIB_PATHS="usr/lib/grub/.*"
244 +
245 +src_unpack() {
246 + if [[ ${PV} == 9999 ]]; then
247 + git-r3_src_unpack
248 + fi
249 + default
250 +}
251 +
252 +src_prepare() {
253 + default
254 +
255 + sed -i -e /autoreconf/d autogen.sh || die
256 +
257 + if use multislot; then
258 + # fix texinfo file name, bug 416035
259 + sed -i -e 's/^\* GRUB:/* GRUB2:/' -e 's/(grub)/(grub2)/' docs/grub.texi || die
260 + fi
261 +
262 + # Nothing in Gentoo packages 'american-english' in the exact path
263 + # wanted for the test, but all that is needed is a compressible text
264 + # file, and we do have 'words' from miscfiles in the same path.
265 + sed -i \
266 + -e '/CFILESSRC.*=/s,american-english,words,' \
267 + tests/util/grub-fs-tester.in \
268 + || die
269 +
270 + if [[ -n ${GRUB_AUTOGEN} ]]; then
271 + python_setup
272 + bash autogen.sh || die
273 + fi
274 +
275 + if [[ -n ${GRUB_AUTORECONF} ]]; then
276 + autopoint() { :; }
277 + eautoreconf
278 + fi
279 +}
280 +
281 +grub_do() {
282 + multibuild_foreach_variant run_in_build_dir "$@"
283 +}
284 +
285 +grub_do_once() {
286 + multibuild_for_best_variant run_in_build_dir "$@"
287 +}
288 +
289 +grub_configure() {
290 + local platform
291 +
292 + case ${MULTIBUILD_VARIANT} in
293 + efi*) platform=efi ;;
294 + xen*) platform=xen ;;
295 + guessed) ;;
296 + *) platform=${MULTIBUILD_VARIANT} ;;
297 + esac
298 +
299 + case ${MULTIBUILD_VARIANT} in
300 + *-32)
301 + if [[ ${CTARGET:-${CHOST}} == x86_64* ]]; then
302 + local CTARGET=i386
303 + fi ;;
304 + *-64)
305 + if [[ ${CTARGET:-${CHOST}} == i?86* ]]; then
306 + local CTARGET=x86_64
307 + local -x TARGET_CFLAGS="-Os -march=x86-64 ${TARGET_CFLAGS}"
308 + local -x TARGET_CPPFLAGS="-march=x86-64 ${TARGET_CPPFLAGS}"
309 + fi ;;
310 + esac
311 +
312 + local myeconfargs=(
313 + --disable-werror
314 + --program-prefix=
315 + --libdir="${EPREFIX}"/usr/lib
316 + --htmldir="${EPREFIX}"/usr/share/doc/${PF}/html
317 + $(use_enable debug mm-debug)
318 + $(use_enable device-mapper)
319 + $(use_enable mount grub-mount)
320 + $(use_enable nls)
321 + $(use_enable themes grub-themes)
322 + $(use_enable truetype grub-mkfont)
323 + $(use_enable libzfs)
324 + $(use sdl && use_enable debug grub-emu-sdl)
325 + ${platform:+--with-platform=}${platform}
326 +
327 + # Let configure detect this where supported
328 + $(usex efiemu '' '--disable-efiemu')
329 + )
330 +
331 + if use multislot; then
332 + myeconfargs+=( --program-transform-name="s,grub,grub2," )
333 + fi
334 +
335 + # Set up font symlinks
336 + ln -s "${WORKDIR}/${UNIFONT}.pcf" unifont.pcf || die
337 + if use themes; then
338 + ln -s "${WORKDIR}/${DEJAVU}/ttf/DejaVuSans.ttf" DejaVuSans.ttf || die
339 + fi
340 +
341 + local ECONF_SOURCE="${S}"
342 + econf "${myeconfargs[@]}"
343 +}
344 +
345 +src_configure() {
346 + # Bug 508758.
347 + replace-flags -O3 -O2
348 +
349 + # We don't want to leak flags onto boot code.
350 + export HOST_CCASFLAGS=${CCASFLAGS}
351 + export HOST_CFLAGS=${CFLAGS}
352 + export HOST_CPPFLAGS=${CPPFLAGS}
353 + export HOST_LDFLAGS=${LDFLAGS}
354 + unset CCASFLAGS CFLAGS CPPFLAGS LDFLAGS
355 +
356 + use static && HOST_LDFLAGS+=" -static"
357 +
358 + tc-ld-disable-gold #439082 #466536 #526348
359 + export TARGET_LDFLAGS="${TARGET_LDFLAGS} ${LDFLAGS}"
360 + unset LDFLAGS
361 +
362 + tc-export CC NM OBJCOPY RANLIB STRIP
363 + tc-export BUILD_CC # Bug 485592
364 +
365 + MULTIBUILD_VARIANTS=()
366 + local p
367 + for p in "${GRUB_ALL_PLATFORMS[@]}"; do
368 + use "grub_platforms_${p}" && MULTIBUILD_VARIANTS+=( "${p}" )
369 + done
370 + [[ ${#MULTIBUILD_VARIANTS[@]} -eq 0 ]] && MULTIBUILD_VARIANTS=( guessed )
371 + grub_do grub_configure
372 +}
373 +
374 +src_compile() {
375 + # Sandbox bug 404013.
376 + use libzfs && addpredict /etc/dfs:/dev/zfs
377 +
378 + grub_do emake
379 + use doc && grub_do_once emake -C docs html
380 +}
381 +
382 +src_test() {
383 + # The qemu dependency is a bit complex.
384 + # You will need to adjust QEMU_SOFTMMU_TARGETS to match the cpu/platform.
385 + grub_do emake check
386 +}
387 +
388 +src_install() {
389 + grub_do emake install DESTDIR="${D}" bashcompletiondir="$(get_bashcompdir)"
390 + use doc && grub_do_once emake -C docs install-html DESTDIR="${D}"
391 +
392 + einstalldocs
393 +
394 + if use multislot; then
395 + mv "${ED%/}"/usr/share/info/grub{,2}.info || die
396 + fi
397 +
398 + insinto /etc/default
399 + newins "${FILESDIR}"/grub.default-3 grub
400 +}
401 +
402 +pkg_postinst() {
403 + elog "For information on how to configure GRUB2 please refer to the guide:"
404 + elog " https://wiki.gentoo.org/wiki/GRUB2_Quick_Start"
405 +
406 + if has_version 'sys-boot/grub:0'; then
407 + elog "A migration guide for GRUB Legacy users is available:"
408 + elog " https://wiki.gentoo.org/wiki/GRUB2_Migration"
409 + fi
410 +
411 + if [[ -z ${REPLACING_VERSIONS} ]]; then
412 + elog
413 + elog "You may consider installing the following optional packages:"
414 + optfeature "Detect other operating systems (grub-mkconfig)" sys-boot/os-prober
415 + optfeature "Create rescue media (grub-mkrescue)" dev-libs/libisoburn
416 + optfeature "Enable RAID device detection" sys-fs/mdadm
417 + fi
418 +}