Compare commits

..
Author SHA1 Message Date
Vladimir Serbinenko 67a51e8e15 Include arrows and lines in ascii.h 2013-12-07 13:59:15 +01:00
Vladimir Serbinenko 5ff249072d * configure.ac: Make unifont mandatory on coreboot. 2013-12-07 11:47:19 +01:00
Vladimir Serbinenko 0277eab701 * configure.ac: Skip unifont 6.3 pcf and bdf. 2013-12-07 11:46:46 +01:00
Vladimir Serbinenko 4861b6c851 * Makefile.am: Remove partial font files if generation failed. 2013-12-07 11:39:35 +01:00
Andrey Borzenkov 3100cdc7f9 add grub_qsort_strcmp to use when sorting array of strings
Compare function used in qsort gets arguments by reference, so strcmp
cannot be used directly - it expects pointer to char, but gets pointer
to pointer to char.

Introduce new helper grub_qsort_strcmp and use it in grub-install.
This helper is going to be used in a couple more places as well so
add it to global file, not in grub-install.c.
2013-12-07 14:29:00 +04:00
Andrey Borzenkov ad73cc3312 fix use of grub-probe instead of ${grub_probe} 2013-12-07 14:24:25 +04:00
Vladimir Serbinenko 4182262560 Don't add -mlong-calls when compiling with clang. 2013-12-06 11:58:17 +01:00
Vladimir Serbinenko 896f483d49 * configure.ac: Fix a typo. 2013-12-06 10:02:24 +01:00
Vladimir Serbinenko 8c534b85f1 Revamp relocation handling.
Move more code to common dl.c. Add missing veneers for arm and arm64.
	Decreases kernel size by 70 bytes on i386-pc (40-50 compressed)
2013-12-06 09:18:55 +01:00
Vladimir Serbinenko a846dd4b3a * util/grub-mkimagexx.c: Fix reloc section generation for ia64. 2013-12-05 23:07:10 +01:00
Mike Gilbert aa437b5890 gentpl.py: Use python3-style print function 2013-12-05 16:07:15 +00:00
Vladimir Serbinenko b0f311f412 * util/grub-install.c: Mention Boot* variable. 2013-12-05 17:05:21 +01:00
Colin Watson 59b38922a1 Pacify compiler warning
* grub-core/osdep/linux/hostdisk.c
(grub_util_find_partition_start_os): Initialise start to avoid
spurious compiler warning.
2013-12-05 15:48:27 +00:00
Colin Watson 0480665b9d On Linux, read partition start offsets from sysfs if possible
This lets us cope with block device drivers that don't implement
HDIO_GETGEO.  Fixes Ubuntu bug #1237519.

* grub-core/osdep/linux/hostdisk.c (sysfs_partition_path): New
function.
(sysfs_partition_start): Likewise.
(grub_util_find_partition_start_os): Try sysfs_partition_start
before HDIO_GETGEO.
2013-12-05 13:51:52 +00:00
Leif Lindholm bbeee1c4a3 grub-core/lib/fdt.c: correctly update size_dt_struct in add_subnode() 2013-12-05 11:44:41 +00:00
Vladimir Serbinenko e5ed2f6947 Handle unaligned .bss on sparc64.
Current code improperly assumes that both __bss_start and _end are
	aligned to 8-bytes. Eliminating this assumption and explicitly align
	modules.
2013-12-05 06:35:19 +01:00
Vladimir Serbinenko 4a73746a04 * grub-core/boot/sparc64/ieee1275/boot.S [CDBOOT]: Move scratchpad
so it doesn't land in the middle of loaded image.
2013-12-04 19:54:37 +01:00
Vladimir Serbinenko 382b500ebe * configure.ac: Move all warning options that may be absent in
gcc >= 3.1 to optional.

	Note: while this allows to compile with older GCC, official requirements
	remain the same and no support for older GCC.
2013-12-04 14:53:25 +01:00
Colin Watson 3a82f8bb48 Fix grub-shell to avoid breaking "make distcheck"
Copying the themes directory in grub-shell isn't
parallel-test-friendly and breaks on the second test when the source
directory is read-only (as in "make distcheck").  Instead, add a
hidden --themes-directory option to grub-mkrescue et al, and use it
in grub-shell.
2013-12-04 13:36:34 +00:00
Vladimir Serbinenko e3046431da * conf/Makefile.common (CFLAGS_GNULIB): Remove -Wno-old-style-definition
as it's no longer necessarry.
2013-12-04 14:32:04 +01:00
Vladimir Serbinenko bdb6090d83 * configure.ac: Allow compilation with older GCC for ARM. 2013-12-04 12:42:09 +01:00
Vladimir Serbinenko b73b70ebca * configure.ac: Add -no-integrated-as if {addme|ame} isn't supported.
* INSTALL: Note that GRUBwas successfully compiled with clang 3.2 for
	ppc.
2013-12-04 12:20:56 +01:00
Vladimir Serbinenko 8a3f0a24b5 * grub-core/kern/emu/main.c: Ignore missing prototype for main. 2013-12-04 10:28:23 +01:00
Vladimir Serbinenko 6f07c4e407 Pass font config to config.h and not by TARGET_CFLAGS as adding
arguments doesn't work if TARGET_CFLAGS is specified on command
	line.
2013-12-04 10:25:53 +01:00
Vladimir Serbinenko 60d5e9cbd9 * configure.ac: Add -Wvla if compiler supports it. 2013-12-04 10:08:57 +01:00
Vladimir Serbinenko cd15c394cc * grub-core/osdep/windows/emuconsole.c (grub_console_putchar):
Remove variable length arrays.
	* grub-core/term/efi/console.c (grub_console_putchar): Likewise.
2013-12-04 10:05:33 +01:00
Vladimir Serbinenko bb6e299ccb * grub-core/kern/i386/qemu/init.c: Remove variable length arrays. 2013-12-04 09:48:36 +01:00
Vladimir Serbinenko 85eb579ad9 * include/grub/types.h: Declare all byteswaps as inline functions
except compile-time ones.

	Solves variable shadowing in constructions like
	cpu_to_le (le_to_cpu(x) + 1).
2013-12-04 08:42:35 +01:00
Vladimir Serbinenko 47f88cc94e * grub-core/kern/efi/efi.c: Remove variable length arrays. 2013-12-04 08:39:22 +01:00
Vladimir Serbinenko 40b5739ff9 * grub-core/kern/uboot/init.c (uboot_timer_ms): Fix overflow after 71
minutes.
2013-12-04 08:26:39 +01:00
Vladimir Serbinenko 234d93464a * grub-core/disk/ieee1275/ofdisk.c: Remove variable length arrays.
* grub-core/net/drivers/ieee1275/ofnet.c: Likewise.
2013-12-04 08:10:01 +01:00
Colin Watson 0c0eab527f * grub-core/Makefile.core.def (setjmp): Distribute
lib/arm64/setjmp.S.
2013-12-03 18:11:18 +00:00
Colin Watson 44d4884779 Merge branch 'cjwatson/timeout-style' 2013-12-03 16:15:45 +00:00
Colin Watson 10955cda06 Credit and bug reference. 2013-12-03 16:14:01 +00:00
Colin Watson f315b508ae Reduce nesting level. 2013-12-03 16:11:00 +00:00
Vladimir Serbinenko 9e4e6ddfbf * util/config.c: Add missing pointer adjustment.
Reported by: qwertial
2013-12-02 06:51:13 +01:00
Andrey Borzenkov 5037aa9a7b fix libgrub.pp build post arm64 merge
grub-core/kern/arm64/dl_helper.c:26:28: fatal error: grub/cpu/reloc.h: No such file or directory
2013-11-30 22:36:10 +04:00
Vladimir Serbinenko 8a952d20d1 Missing ChangeLog entry 2013-11-30 16:51:35 +01:00
Leif Lindholm b29b77fee2 New port arm64-efi 2013-11-30 16:50:31 +01:00
Andrey Borzenkov be0d45555e document sleep command exit codes 2013-11-30 14:57:11 +04:00
Vladimir Serbinenko d74b9a1d1a Ensure that -mno-unaligned-access or some equivalent option is used. 2013-11-30 11:31:14 +01:00
Vladimir Serbinenko 35de6d4bac * grub-core/lib/libgcrypt/mpi/longlong.h: Fix compilation error with
-march=armv3.
2013-11-30 11:19:06 +01:00
Vladimir Serbinenko ce55ed0389 Remove leftover GRUB_IA64_DL_TRAMP_SIZE. 2013-11-30 11:14:30 +01:00
Colin Watson f70ab525f9 Remove a few references to GRUB_HIDDEN_TIMEOUT*
Reported by Andrey Borzenkov.
2013-11-29 17:19:37 +00:00
Colin Watson 9b70860ecc Consolidate timeout generation code a bit. 2013-11-29 16:11:53 +00:00
Colin Watson 095588ef34 Consistently ignore GRUB_TIMEOUT if GRUB_HIDDEN_TIMEOUT is set
Pointed out by Vladimir Serbinenko.
2013-11-29 15:30:44 +00:00
Colin Watson 2dbda2215c Fix documentation of behaviour after pressing ESC
Pointed out by Andrey Borzenkov.
2013-11-29 15:25:43 +00:00
Colin Watson 53cc63bf85 Add GRUB_TIMEOUT_STYLE_BUTTON support
Suggested by Vladimir Serbinenko.
2013-11-29 15:18:05 +00:00
Colin Watson 471b2683e7 Move deprecated grub-mkconfig options to a separate table
Suggested by Andrey Borzenkov.
2013-11-29 14:59:25 +00:00
Colin Watson 8ddf84bfb8 Fix "make -C docs dvi"
* docs/grub-dev.texi (Font Metrics): Exclude @image command from DVI
builds, since we don't have an EPS version of font_char_metrics.png.
Add leading dot to image extension per the Texinfo documentation.
2013-11-29 13:48:23 +00:00
Colin Watson fd0df6d098 Fix build with FreeType 2.5.1
* util/grub-gen-asciih.c: Include FT_SYNTHESIS_H rather than
<freetype/ftsynth.h>, fixing build with FreeType 2.5.1.
* util/grub-gen-widthspec.c: Likewise.
* util/grub-mkfont.c: Likewise.
2013-11-29 12:19:36 +00:00
Andrey Borzenkov 69ca97c820 fix using grub device name as install device
Shell version of grub-install called grub-setup which resolved
install device name and called main setup routine. C version of
grub-install calls main setup routine directly, which leads
to the error:

grub2-install: info: grub-bios-setup  --verbose  --force  --skip-fs-probe --directory='/boot/grub2/i386-pc' --device-map='/boot/grub2/device.map' '(hd2)'.
grub2-install: info: reading /boot/grub2/i386-pc/boot.img.
grub2-install: info: reading /boot/grub2/i386-pc/core.img.
grub2-install: info: root is `(null)', dest is `(hd2)'.
grub2-install: info: Opening dest.
grub2-install: info: drive = -1.
grub2-install: error: disk `(hd2)' not found.

Move resolving of destination device name into main setup routine
so it is done consistently in both cases.
2013-11-29 11:32:34 +04:00
Vladimir Serbinenko eec893ae49 * grub-core/kern/emu/hostfs.c (is_dir): Remove variable length arrays. 2013-11-29 05:52:20 +01:00
Vladimir Serbinenko 621e167fd6 * util/grub-fstest.c: Remove variable length arrays. 2013-11-29 05:50:32 +01:00
Vladimir Serbinenko d54f647a4a * grub-core/osdep/linux/ofpath.c: Check return value of read. 2013-11-29 05:46:19 +01:00
Vladimir Serbinenko c8a0f1b229 * util/mkimage.c (grub_install_generate_image): Use grub_crypto_hash for
computing crc32 rather than handling with md fundtions directly.
2013-11-29 04:14:26 +01:00
Vladimir Serbinenko 726409a513 * util/mkimage.c (grub_install_generate_image): Use grub_crypto_hash for
checking fwstart.img rather than md fundtions directly.
2013-11-29 04:05:44 +01:00
Vladimir Serbinenko 422e6e886c * util/grub-mkrescue.c (main): Check that fread succeeded. 2013-11-29 03:54:21 +01:00
Vladimir Serbinenko af1faca3f8 * conf/Makefile.common: Remove -mexplicit-relocs and -DUSE_ASCII_FALLBACK on yeeloong.
-DUSE_ASCII_FALLBACK is already added by font snippets.
	-mexplicit-relocs isn't needed is compiler/assemblera are
	configured properly.
	If they're not we shouldn't attempt to fix it by ourselves.
	Binary compare between before and after shows no difference.
2013-11-29 03:45:50 +01:00
Vladimir Serbinenko 469021b4b3 Remove libgnulib.a and use its sources in dependencies directly.
This was the only instance of "library" in core config. A bug was
	reported that -fno-stack-protector wasn't passed to it. Instead of
	figuring out why it failed just remove this construction used
	needlessly.
2013-11-29 03:36:50 +01:00
Vladimir Serbinenko 83c256ba42 * grub-core/osdep/unix/password.c (grub_password_get): Check that
fgets succeeded.
2013-11-29 03:32:57 +01:00
Francesco Lavra b67422d33d Fix command description in case of a device name passed as argument. 2013-11-28 17:25:52 +04:00
Colin Watson 827d87e9d6 Fix documentation of timeout expiry. 2013-11-28 11:01:53 +00:00
Colin Watson 8f236c1419 Revamp hidden timeout handling
Add a new timeout_style environment variable and a corresponding
GRUB_TIMEOUT_STYLE configuration key for grub-mkconfig.  This
controls hidden-timeout handling more simply than the previous
arrangements, and pressing any hotkeys associated with menu entries
during the hidden timeout will now boot the corresponding menu entry
immediately.

GRUB_HIDDEN_TIMEOUT=<non-empty> + GRUB_TIMEOUT=<non-zero> now
generates a warning, and if it shows the menu it will do so as if
the second timeout were not present.  Other combinations are
translated into reasonable equivalents.
2013-11-28 02:29:15 +00:00
Vladimir Serbinenko 2d76b4d81e Eliminate variable length arrays in grub_vsnprintf_real.
A bit tricky because this function has to continue to work without
	heap for short strings. Fixing prealloc to 32 arguments is reasonable
	but make all stack references use 32-bit offset rather than 8-bit one.
	So split va_args preparsing to separate function and put the prealloc
	into the caller.
2013-11-27 15:16:09 +01:00
Vladimir Serbinenko 4f9541226c Introduce grub_util_file_sync and use it instead of fsync(fileno(f)).
Fixes build for windows.
2013-11-27 14:13:50 +01:00
Vladimir Serbinenko b1f742c103 * gentpl.py: Don't generate platform-dependent conditionals for
platform-independent targets.
2013-11-27 14:10:04 +01:00
Colin Watson 16ef26fd3a * grub-core/osdep/unix/exec.c (grub_util_exec_redirect): Remove
references to mdadm from otherwise generic code.
(grub_util_exec_pipe): Likewise.
(grub_util_exec_pipe_stderr): Likewise.
* grub-core/osdep/unix/getroot.c (grub_util_pull_lvm_by_command):
This function calls vgs, not mdadm; adjust variable names
accordingly.
2013-11-27 11:22:31 +00:00
Colin Watson cf8c80ff77 Merge branch 'new-autogen' 2013-11-27 10:57:27 +00:00
Colin Watson 5c7206e45e Speed up test suite by avoiding fsync
Add grub_util_disable_fd_syncs call to turn grub_util_fd_sync calls into
no-ops, and use it in programs that copy files but do not need to take
special care to sync writes (grub-mknetdir, grub-rescue,
grub-mkstandalone).

On my laptop, this reduces partmap_test's runtime from 1236 seconds to
204 seconds.
2013-11-27 10:10:22 +00:00
Colin Watson fc3f2b72cd * tests/util/grub-fs-tester.in: Execute xorriso from $PATH rather
than hardcoding /usr/local/bin/xorriso.
2013-11-26 23:51:48 +00:00
Colin Watson 34b2003def Handle #if/#endif and C-style comments in AutoGen definitions files. 2013-11-26 17:48:20 +00:00
Colin Watson 7e90f5ad25 Show file name in error messages from AutogenParser. 2013-11-26 17:42:56 +00:00
Colin Watson ab4f15013a Generate Makefile.*.am directly from gentpl.py, eliminating the use of Autogen. The Autogen definitions files remain intact as they offer a useful abstraction. 2013-11-26 17:13:01 +00:00
Vladimir Serbinenko 1e4b358720 Add PCI command activation to all PCI drivers as required for coreboot
and maybe some other firmwares.
2013-11-26 14:21:11 +01:00
Vladimir Serbinenko 9208367d3f * grub-core/Makefile.am: Reduce gratuituous differences between Apple
and non-Apple variants of efiemu compile.
2013-11-26 11:38:12 +01:00
Andrey Borzenkov 67b9b7afd7 Add ChangeLog entry for previous commit 2013-11-25 23:14:04 +04:00
Andrey Borzenkov c2b70d0981 Explicitly check for linking format to use for efiemu64 module
Similar to check for target linking format, also check for efiemu64
instead of hardcoding -melf_x86_64. This fixes compilation on *BSD
variants. We cannot easily reuse main target check because platforms
are different (main target is 32 bit and efiemu64 - 64 bit).

This commit adds EFIEMU64_LINK_FORMAT that contains detected
link option and is used in efiemu64.o linking instead of hardcoded
value.

Reported-By: Beeblebrox <zaphod@berentweb.com>
2013-11-25 22:32:55 +04:00
Vladimir Serbinenko bee1b5ce3f * util/grub-mknetdir.c: Look for platform directories under pkglibdir
and not pkgdatadir.
2013-11-25 19:16:05 +01:00
Colin Watson 07e3b04742 Add a --locale-directory option to grub-install and related tools.
* include/grub/util/install.h (GRUB_INSTALL_OPTIONS): Add
--locale-directory option.
(enum grub_install_options): Add
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY.
* util/grub-install-common.c (grub_install_help_filter): Handle
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY.
(grub_install_parse): Likewise.
(get_localedir): New function to check for a user-provided option
before trying grub_util_get_localedir.
(copy_locales): Use get_localedir rather than
grub_util_get_localedir.  Handle differing locale directory layouts.
(grub_install_copy_files): Likewise.
2013-11-25 18:04:50 +00:00
95 changed files with 3439 additions and 2012 deletions

No files matched your search

-1
View File
@@ -159,7 +159,6 @@ GPATH
GRTAGS GRTAGS
GSYMS GSYMS
GTAGS GTAGS
Makefile.tpl
compile compile
depcomp depcomp
mdate-sh mdate-sh
+382
View File
@@ -1,3 +1,385 @@
2013-12-07 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Make unifont mandatory on coreboot.
2013-12-07 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Skip unifont 6.3 pcf and bdf.
2013-12-07 Vladimir Serbinenko <phcoder@gmail.com>
* Makefile.am: Remove partial font files if generation failed.
2013-12-07 Andrey Borzenkov <arvidjaar@gmail.com>
* util/misc.c (grub_qsort_strcmp): Add qsort helper function to sort
strings.
* include/grub/util/misc.h: Define it ...
* util/grub-install.c (device_map_check_duplicates): ... and use it.
2013-12-07 Andrey Borzenkov <arvidjaar@gmail.com>
* util/grub.d/30_os-prober.in: Fix use of grub-probe instead of
${grub_probe}.
2013-12-06 Vladimir Serbinenko <phcoder@gmail.com>
Don't add -mlong-calls when compiling with clang.
2013-12-06 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Fix a typo.
2013-12-06 Vladimir Serbinenko <phcoder@gmail.com>
Revamp relocation handling.
Move more code to common dl.c. Add missing veneers for arm and arm64.
Decreases kernel size by 70 bytes on i386-pc (40-50 compressed)
2013-12-05 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkimagexx.c: Fix reloc section generation for ia64.
2013-12-05 Mike Gilbert <floppym@gentoo.org>
* INSTALL: Raise minimum python version to 2.6.
* gentpl.py: Use python3-style print function.
2013-12-05 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-install.c: Mention Boot* variable.
2013-12-05 Colin Watson <cjwatson@ubuntu.com>
* grub-core/osdep/linux/hostdisk.c
(grub_util_find_partition_start_os): Initialise start to avoid
spurious compiler warning.
2013-12-05 Colin Watson <cjwatson@ubuntu.com>
On Linux, read partition start offsets from sysfs if possible, to
cope with block device drivers that don't implement HDIO_GETGEO.
Fixes Ubuntu bug #1237519.
* grub-core/osdep/linux/hostdisk.c (sysfs_partition_path): New
function.
(sysfs_partition_start): Likewise.
(grub_util_find_partition_start_os): Try sysfs_partition_start
before HDIO_GETGEO.
2013-12-05 Leif Lindholm <leif.lindholm@linaro.org>
* grub-core/kern/fdt.c: Update struct size when adding node.
2013-12-05 Vladimir Serbinenko <phcoder@gmail.com>
Handle unaligned .bss on sparc64.
Current code improperly assumes that both __bss_start and _end are
aligned to 8-bytes. Eliminating this assumption and explicitly align
modules.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/boot/sparc64/ieee1275/boot.S [CDBOOT]: Move scratchpad
so it doesn't land in the middle of loaded image.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Move all warning options that may be absent in
gcc >= 3.1 to optional.
Note: while this allows to compile with older GCC, official requirements
remain the same and no support for older GCC.
2013-12-04 Colin Watson <cjwatson@ubuntu.com>
Copying the themes directory in grub-shell isn't
parallel-test-friendly and breaks on the second test when the source
directory is read-only (as in "make distcheck"). Instead, add a
hidden --themes-directory option to grub-mkrescue et al, and use it
in grub-shell.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* conf/Makefile.common (CFLAGS_GNULIB): Remove -Wno-old-style-definition
as it's no longer necessarry.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Allow compilation with older GCC for ARM.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Add -no-integrated-as if {addme|ame} isn't supported.
* INSTALL: Note that GRUBwas successfully compiled with clang 3.2 for
ppc.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/emu/main.c: Ignore missing prototype for main.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
Pass font config to config.h and not by TARGET_CFLAGS as adding
arguments doesn't work if TARGET_CFLAGS is specified on command
line.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Add -Wvla if compiler supports it.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/windows/emuconsole.c (grub_console_putchar):
Remove variable length arrays.
* grub-core/term/efi/console.c (grub_console_putchar): Likewise.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/i386/qemu/init.c: Remove variable length arrays.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/types.h: Declare all byteswaps as inline functions
except compile-time ones.
Solves variable shadowing in constructions like
cpu_to_le (le_to_cpu(x) + 1).
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/efi/efi.c: Remove variable length arrays.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/uboot/init.c (uboot_timer_ms): Fix overflow after 71
minutes.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/ieee1275/ofdisk.c: Remove variable length arrays.
* grub-core/net/drivers/ieee1275/ofnet.c: Likewise.
2013-12-03 Colin Watson <cjwatson@ubuntu.com>
* grub-core/Makefile.core.def (setjmp): Distribute
lib/arm64/setjmp.S.
2013-12-03 Colin Watson <cjwatson@ubuntu.com>
Add a new timeout_style environment variable and a corresponding
GRUB_TIMEOUT_STYLE configuration key for grub-mkconfig. This
controls hidden-timeout handling more simply than the previous
arrangements, and pressing any hotkeys associated with menu entries
during the hidden timeout will now boot the corresponding menu entry
immediately.
GRUB_HIDDEN_TIMEOUT=<non-empty> + GRUB_TIMEOUT=<non-zero> now
generates a warning, and if it shows the menu it will do so as if
the second timeout were not present. Other combinations are
translated into reasonable equivalents.
Based loosely on work by Franz Hsieh. Fixes Ubuntu bug #1178618.
2013-12-02 Vladimir Serbinenko <phcoder@gmail.com>
* util/config.c: Add missing pointer adjustment.
Reported by: qwertial
2013-11-30 Andrey Borzenkov <arvidjaar@gmail.com>
* grub-core/kern/arm64/dl_helper.c: Include grub/arm64/reloc.h
directly, not via `cpu' link, to fix libgrub.pp generation.
2013-11-30 Leif Lindholm <leif.lindholm@linaro.org>
New port arm64-efi.
2013-11-30 Andrey Borzenkov <arvidjaar@gmail.com>
* docs/grub.texi (sleep): Document exit codes.
2013-11-30 Vladimir Serbinenko <phcoder@gmail.com>
Ensure that -mno-unaligned-access or some equivalent option is used.
2013-11-30 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/libgcrypt/mpi/longlong.h: Fix compilation error with
-march=armv3.
2013-11-30 Vladimir Serbinenko <phcoder@gmail.com>
Remove leftover GRUB_IA64_DL_TRAMP_SIZE.
2013-11-29 Colin Watson <cjwatson@ubuntu.com>
* docs/grub-dev.texi (Font Metrics): Exclude @image command from DVI
builds, since we don't have an EPS version of font_char_metrics.png.
Add leading dot to image extension per the Texinfo documentation.
2013-11-29 Colin Watson <cjwatson@ubuntu.com>
* util/grub-gen-asciih.c: Include FT_SYNTHESIS_H rather than
<freetype/ftsynth.h>, fixing build with FreeType 2.5.1.
* util/grub-gen-widthspec.c: Likewise.
* util/grub-mkfont.c: Likewise.
2013-11-29 Andrey Borzenkov <arvidjaar@gmail.com>
* util/grub-setup.c (main): Move parsing of (hdX) syntax to ...
* util/setup.c (SETUP): ... here. Fixes regression: grub-install
failed to install on (hdX).
* util/grub-setup.c (get_device_name): Remove, not needed after
above change.
2013-11-29 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/emu/hostfs.c (is_dir): Remove variable length arrays.
2013-11-29 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-fstest.c: Remove variable length arrays.
2013-11-29 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/linux/ofpath.c: Check return value of read.
2013-11-29 Vladimir Serbinenko <phcoder@gmail.com>
* util/mkimage.c (grub_install_generate_image): Use grub_crypto_hash for
computing crc32 rather than handling with md fundtions directly.
2013-11-29 Vladimir Serbinenko <phcoder@gmail.com>
* util/mkimage.c (grub_install_generate_image): Use grub_crypto_hash for
checking fwstart.img rather than md fundtions directly.
2013-11-29 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkrescue.c (main): Check that fread succeeded.
2013-11-29 Vladimir Serbinenko <phcoder@gmail.com>
* conf/Makefile.common: Remove -mexplicit-relocs and
-DUSE_ASCII_FALLBACK on yeeloong.
-DUSE_ASCII_FALLBACK is already added by font snippets.
-mexplicit-relocs isn't needed is compiler/assemblera are
configured properly.
If they're not we shouldn't attempt to fix it by ourselves.
Binary compare between before and after shows no difference.
2013-11-29 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/Makefile.core.def: Remove libgnulib.a and use its
sources in dependencies directly.
This was the only instance of "library" in core config. A bug was
reported that -fno-stack-protector wasn't passed to it. Instead of
figuring out why it failed just remove this construction used
needlessly.
2013-11-29 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/unix/password.c (grub_password_get): Check that
fgets succeeded.
2013-11-27 Francesco Lavra <francescolavra.fl@gmail.com>
* docs/grub.texi (ls): Fix command description in case of a device name
passed as argument.
2013-11-27 Vladimir Serbinenko <phcoder@gmail.com>
Eliminate variable length arrays in grub_vsnprintf_real.
A bit tricky because this function has to continue to work without
heap for short strings. Fixing prealloc to 32 arguments is reasonable
but make all stack references use 32-bit offset rather than 8-bit one.
So split va_args preparsing to separate function and put the prealloc
into the caller.
2013-11-27 Vladimir Serbinenko <phcoder@gmail.com>
Introduce grub_util_file_sync and use it instead of fsync(fileno(f)).
Fixes build for windows.
2013-11-27 Vladimir Serbinenko <phcoder@gmail.com>
* gentpl.py: Don't generate platform-dependent conditionals for
platform-independent targets.
2013-11-27 Colin Watson <cjwatson@ubuntu.com>
* grub-core/osdep/unix/exec.c (grub_util_exec_redirect): Remove
references to mdadm from otherwise generic code.
(grub_util_exec_pipe): Likewise.
(grub_util_exec_pipe_stderr): Likewise.
* grub-core/osdep/unix/getroot.c (grub_util_pull_lvm_by_command):
This function calls vgs, not mdadm; adjust variable names
accordingly.
2013-11-27 Colin Watson <cjwatson@ubuntu.com>
Generate Makefile.*.am directly from gentpl.py, eliminating the use
of Autogen. The Autogen definitions files remain intact as they
offer a useful abstraction.
2013-11-27 Colin Watson <cjwatson@ubuntu.com>
Add grub_util_disable_fd_syncs call to turn grub_util_fd_sync calls
into no-ops, and use it in programs that copy files but do not need
to take special care to sync writes (grub-mknetdir, grub-rescue,
grub-mkstandalone).
2013-11-26 Colin Watson <cjwatson@ubuntu.com>
* tests/util/grub-fs-tester.in: Execute xorriso from $PATH rather
than hardcoding /usr/local/bin/xorriso.
2013-11-26 Vladimir Serbinenko <phcoder@gmail.com>
Add PCI command activation to all PCI drivers as required for coreboot
and maybe some other firmwares.
2013-11-26 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/Makefile.am: Reduce gratuituous differences between Apple
and non-Apple variants of efiemu compile.
2013-11-25 Andrey Borzenkov <arvidjaar@gmail.com>
* configure.ac: Add explicit check for linking format of
efiemu64; save it as EFIEMU64_LINK_FORMAT.
* grub-core/Makefile.am: Use EFIEMU64_LINK_FORMAT instead of
hardcoding linking format.
2013-11-25 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mknetdir.c: Look for platform directories under pkglibdir
and not pkgdatadir.
2013-11-25 Colin Watson <cjwatson@ubuntu.com>
2013-11-25 Vladimir Serbinenko <phcoder@gmail.com>
Add a --locale-directory option to grub-install and related tools.
* include/grub/util/install.h (GRUB_INSTALL_OPTIONS): Add
--locale-directory option.
(enum grub_install_options): Add
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY.
* util/grub-install-common.c (grub_install_help_filter): Handle
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY.
(grub_install_parse): Likewise.
(get_localedir): New function to check for a user-provided option
before trying grub_util_get_localedir.
(copy_locales): Use get_localedir rather than
grub_util_get_localedir. Handle differing locale directory layouts.
(grub_install_copy_files): Likewise.
2013-11-25 Vladimir Serbinenko <phcoder@gmail.com> 2013-11-25 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/unix/platform.c (get_ofpathname): Trim ending newline. * grub-core/osdep/unix/platform.c (get_ofpathname): Trim ending newline.
+3 -4
View File
@@ -23,8 +23,8 @@ configuring the GRUB.
Note: clang 3.3 or later works for mips(el) Note: clang 3.3 or later works for mips(el)
earlier versions fail to generate .reginfo and hence gprel relocations earlier versions fail to generate .reginfo and hence gprel relocations
fail. fail.
Note: clang 3.4 or later works for powerpc Note: clang 3.2 or later works for powerpc
earlier versions suffer from vacopy bug (#15286) earlier versions not tested
Note: clang has no support for generating 64-bit sparc code and hence you Note: clang has no support for generating 64-bit sparc code and hence you
can't compile GRUB for sparc64 with clang can't compile GRUB for sparc64 with clang
Note: clang has no support for ia64 and hence you can't compile GRUB Note: clang has no support for ia64 and hence you can't compile GRUB
@@ -54,10 +54,9 @@ To build GRUB's graphical terminal (gfxterm), you need:
If you use a development snapshot or want to hack on GRUB you may If you use a development snapshot or want to hack on GRUB you may
need the following. need the following.
* Python 2.5.2 or later * Python 2.6 or later
* Autoconf 2.60 or later * Autoconf 2.60 or later
* Automake 1.10.1 or later * Automake 1.10.1 or later
* Autogen 5.10 or later
Prerequisites for make-check: Prerequisites for make-check:
+5 -5
View File
@@ -103,7 +103,7 @@ EXTRA_DIST += $(starfield_theme_files)
EXTRA_DIST += $(srcdir)/themes/starfield/src/slider_s.xcf $(srcdir)/themes/starfield/src/slider_n.xcf $(srcdir)/themes/starfield/src/slider_c.xcf $(srcdir)/themes/starfield/src/blob_nw.xcf $(srcdir)/themes/starfield/src/bootmenu/center.xcf $(srcdir)/themes/starfield/src/bootmenu/corner.xcf $(srcdir)/themes/starfield/src/bootmenu/side.xcf $(srcdir)/themes/starfield/src/terminalbox/side.xcf $(srcdir)/themes/starfield/src/terminalbox/corner.xcf $(srcdir)/themes/starfield/src/terminalbox/center.xcf EXTRA_DIST += $(srcdir)/themes/starfield/src/slider_s.xcf $(srcdir)/themes/starfield/src/slider_n.xcf $(srcdir)/themes/starfield/src/slider_c.xcf $(srcdir)/themes/starfield/src/blob_nw.xcf $(srcdir)/themes/starfield/src/bootmenu/center.xcf $(srcdir)/themes/starfield/src/bootmenu/corner.xcf $(srcdir)/themes/starfield/src/bootmenu/side.xcf $(srcdir)/themes/starfield/src/terminalbox/side.xcf $(srcdir)/themes/starfield/src/terminalbox/corner.xcf $(srcdir)/themes/starfield/src/terminalbox/center.xcf
unicode.pf2: $(FONT_SOURCE) build-grub-mkfont unicode.pf2: $(FONT_SOURCE) build-grub-mkfont
./build-grub-mkfont -o $@ $(FONT_SOURCE) ./build-grub-mkfont -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1)
CLEANFILES += unicode.pf2 CLEANFILES += unicode.pf2
# Arrows and lines are needed to draw the menu, so always include them # Arrows and lines are needed to draw the menu, so always include them
@@ -111,19 +111,19 @@ UNICODE_ARROWS=0x2190-0x2193
UNICODE_LINES=0x2501-0x251B UNICODE_LINES=0x2501-0x251B
ascii.pf2: $(FONT_SOURCE) build-grub-mkfont ascii.pf2: $(FONT_SOURCE) build-grub-mkfont
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) ./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
CLEANFILES += ascii.pf2 CLEANFILES += ascii.pf2
euro.pf2: $(FONT_SOURCE) build-grub-mkfont euro.pf2: $(FONT_SOURCE) build-grub-mkfont
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) ./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
CLEANFILES += euro.pf2 CLEANFILES += euro.pf2
ascii.h: $(FONT_SOURCE) build-grub-gen-asciih ascii.h: $(FONT_SOURCE) build-grub-gen-asciih
./build-grub-gen-asciih $(FONT_SOURCE) $@ ./build-grub-gen-asciih $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
CLEANFILES += ascii.h CLEANFILES += ascii.h
widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec
./build-grub-gen-widthspec $(FONT_SOURCE) $@ ./build-grub-gen-widthspec $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
CLEANFILES += widthspec.h CLEANFILES += widthspec.h
# Install config.h into platformdir # Install config.h into platformdir
-20
View File
@@ -474,23 +474,3 @@ dnl program.
AC_DEFUN([grub_TRANSFORM],[dnl AC_DEFUN([grub_TRANSFORM],[dnl
AC_SUBST(AS_TR_SH([$1]), [`AS_ECHO([$1]) | sed "$program_transform_name"`])dnl AC_SUBST(AS_TR_SH([$1]), [`AS_ECHO([$1]) | sed "$program_transform_name"`])dnl
]) ])
dnl Check if the C compiler supports `-mno-unaligned-access'.
AC_DEFUN([grub_CHECK_NO_UNALIGNED_ACCESS],[
[# foobar
nua_possible=yes]
AC_MSG_CHECKING([whether `$CC' supports `-mno-unaligned-access'])
AC_LANG_CONFTEST([AC_LANG_SOURCE([[
int main() {
return 0;
}
]])])
[if eval "$ac_compile -S -mno-unaligned-access -o conftest.s" 2> /dev/null; then]
AC_MSG_RESULT([yes])
[rm -f conftest.s
else
nua_possible=no]
AC_MSG_RESULT([no])
[fi]
])
+3 -8
View File
@@ -8,8 +8,6 @@ unset LC_ALL
find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' |sort > po/POTFILES.in find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' |sort > po/POTFILES.in
find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in
autogen --version >/dev/null || exit 1
echo "Importing unicode..." echo "Importing unicode..."
python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
@@ -32,10 +30,7 @@ for x in mpi-asm-defs.h mpih-add1.c mpih-sub1.c mpih-mul1.c mpih-mul2.c mpih-mul
ln -s generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x" ln -s generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
done done
echo "Creating Makefile.tpl..." echo "Generating Automake input..."
python gentpl.py | sed -e '/^$/{N;/^\n$/D;}' > Makefile.tpl
echo "Running autogen..."
# Automake doesn't like including files from a path outside the project. # Automake doesn't like including files from a path outside the project.
rm -f contrib grub-core/contrib rm -f contrib grub-core/contrib
@@ -59,8 +54,8 @@ for extra in contrib/*/Makefile.core.def; do
fi fi
done done
cat $UTIL_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > Makefile.util.am python gentpl.py $UTIL_DEFS > Makefile.util.am
cat $CORE_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.core.am python gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
for extra in contrib/*/Makefile.common; do for extra in contrib/*/Makefile.common; do
if test -e "$extra"; then if test -e "$extra"; then
+7 -16
View File
@@ -6,16 +6,12 @@ export LC_COLLATE := C
unexport LC_ALL unexport LC_ALL
# Platform specific options # Platform specific options
if COND_mips_loongson
CFLAGS_PLATFORM += -mexplicit-relocs
CPPFLAGS_PLATFORM = -DUSE_ASCII_FALLBACK
endif
if COND_sparc64_ieee1275 if COND_sparc64_ieee1275
CFLAGS_PLATFORM += -mno-app-regs CFLAGS_PLATFORM += -mno-app-regs
LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax
endif endif
if COND_arm if COND_arm
CFLAGS_PLATFORM += -mthumb-interwork -mlong-calls CFLAGS_PLATFORM += -mthumb-interwork
CCASFLAGS_PLATFORM = -mthumb-interwork CCASFLAGS_PLATFORM = -mthumb-interwork
LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache
endif endif
@@ -77,7 +73,7 @@ grubconfdir = $(sysconfdir)/grub.d
platformdir = $(pkglibdir)/$(target_cpu)-$(platform) platformdir = $(pkglibdir)/$(target_cpu)-$(platform)
starfielddir = $(pkgdatadir)/themes/starfield starfielddir = $(pkgdatadir)/themes/starfield
CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-old-style-definition CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion
CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib
CFLAGS_POSIX = -fno-builtin CFLAGS_POSIX = -fno-builtin
@@ -134,20 +130,15 @@ EXTRA_DIST =
CLEANFILES = CLEANFILES =
BUILT_SOURCES = BUILT_SOURCES =
# Rules for autogen definition files # Rules for Automake input
.PRECIOUS: $(top_srcdir)/Makefile.tpl
$(top_srcdir)/Makefile.tpl: $(top_srcdir)/gentpl.py
python $< | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
mv $@.new $@
.PRECIOUS: $(top_srcdir)/Makefile.util.am .PRECIOUS: $(top_srcdir)/Makefile.util.am
$(top_srcdir)/Makefile.util.am: $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def $(top_srcdir)/Makefile.tpl $(top_srcdir)/Makefile.util.am: $(top_srcdir)/gentpl.py $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def
cat $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def | autogen -T $(top_srcdir)/Makefile.tpl | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1) python $^ > $@.new || (rm -f $@.new; exit 1)
mv $@.new $@ mv $@.new $@
.PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am .PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am
$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def $(top_srcdir)/Makefile.tpl $(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/gentpl.py $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def
if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./autogen.sh manually." >&2; exit 1; fi if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./autogen.sh manually." >&2; exit 1; fi
cat $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def | autogen -T $(top_srcdir)/Makefile.tpl | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1) python $^ > $@.new || (rm -f $@.new; exit 1)
mv $@.new $@ mv $@.new $@
-1
View File
@@ -2,7 +2,6 @@ EXTRA_DIST += autogen.sh
EXTRA_DIST += geninit.sh EXTRA_DIST += geninit.sh
EXTRA_DIST += gentpl.py EXTRA_DIST += gentpl.py
EXTRA_DIST += Makefile.tpl
EXTRA_DIST += Makefile.util.def EXTRA_DIST += Makefile.util.def
EXTRA_DIST += Makefile.utilgcry.def EXTRA_DIST += Makefile.utilgcry.def
+1
View File
@@ -28,6 +28,7 @@
#elif defined (GRUB_UTIL) || !defined (GRUB_MACHINE) #elif defined (GRUB_UTIL) || !defined (GRUB_MACHINE)
#include <config-util.h> #include <config-util.h>
#else #else
#define HAVE_FONT_SOURCE @HAVE_FONT_SOURCE@
/* Define if C symbols get an underscore after compilation. */ /* Define if C symbols get an underscore after compilation. */
#define HAVE_ASM_USCORE @HAVE_ASM_USCORE@ #define HAVE_ASM_USCORE @HAVE_ASM_USCORE@
/* Define it to \"addr32\" or \"addr32;\" to make GAS happy. */ /* Define it to \"addr32\" or \"addr32;\" to make GAS happy. */
+139 -13
View File
@@ -422,6 +422,26 @@ esac
# For gnulib. # For gnulib.
gl_INIT gl_INIT
WARN_FLAGS="-Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wpointer-arith -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes"
EXTRA_WARN_FLAGS="-Wold-style-definition -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign"
HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [
SAVED_CFLAGS="$CFLAGS"
grub_cv_cc_w_extra_flags=
for x in $EXTRA_WARN_FLAGS; do
CFLAGS="$HOST_CFLAGS $x -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
if test x$flag = x1 ; then
grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x"
fi
done
CFLAGS="$SAVED_CFLAGS"
])
HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
# #
# Check for target programs. # Check for target programs.
# #
@@ -472,8 +492,6 @@ LDFLAGS="$TARGET_LDFLAGS"
LIBS="" LIBS=""
# debug flags. # debug flags.
WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations" TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g" TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
@@ -481,8 +499,25 @@ if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align" TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
fi fi
AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
grub_cv_target_cc_w_extra_flags=
for x in $EXTRA_WARN_FLAGS; do
CFLAGS="$TARGET_CFLAGS $x -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
if test x$flag = x1 ; then
grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x"
fi
done
])
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang] AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang]
[AC_COMPILE_IFELSE( [
CFLAGS="$TARGET_CFLAGS"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[ [AC_LANG_PROGRAM([], [[
#ifdef __clang__ #ifdef __clang__
#error "is clang" #error "is clang"
@@ -500,6 +535,26 @@ if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as" TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
fi fi
if test "x$grub_cv_cc_target_clang" = xyes && test "x$target_cpu" = xpowerpc; then
AC_CACHE_CHECK([if clang can handle ame instruction], [grub_cv_cc_target_clang_ame]
[
CFLAGS="$TARGET_CFLAGS"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
unsigned int a = 0, b = 0;
asm volatile ("{ame|addme} %0,%1" : "=r" (a) : "r" (b));
if (a)
return 1;
]])],
[grub_cv_cc_target_clang_ame=yes], [grub_cv_cc_target_clang_ame=no])])
# clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly
# used by gcrypt
if test x$grub_cv_cc_target_clang_ame = xno ; then
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
TARGET_CFLAGS="$TARGET_CFLAGS -no-integrated-as"
fi
fi
if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
fi fi
@@ -660,6 +715,30 @@ if test x"$efiemu_excuse" = x ; then
efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib" efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
fi fi
fi fi
if test x"$efiemu_excuse" = x ; then
AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
grub_cv_target_cc_efiemu64_link_format=unknown
for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
LDFLAGS="-m64 -Wl,$format -nostdlib -static"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
asm (".globl start; start:");
asm (".globl _start; _start:");
asm (".globl __start; __start:");
void __main (void);
void __main (void) {}
]], [[]])], [flag=1], [flag=0])
if test x"$flag" = x1; then
grub_cv_target_cc_efiemu64_link_format="$format"
break;
fi
done])
if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
efiemu_excuse="no suitable link format for efiemu64 found"
else
EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
fi
fi
if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled]) AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
fi fi
@@ -669,11 +748,12 @@ else
enable_efiemu=no enable_efiemu=no
fi fi
AC_SUBST([enable_efiemu]) AC_SUBST([enable_efiemu])
AC_SUBST([EFIEMU64_LINK_FORMAT])
CFLAGS="$TARGET_CFLAGS" CFLAGS="$TARGET_CFLAGS"
if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
AC_CACHE_CHECK([for linking format], [grub_cv_target_cc_link_format], [ AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
grub_cv_target_cc_link_format=unknown grub_cv_target_cc_link_format=unknown
for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -m${target_cpu}pe -arch,${target_cpu}; do for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -m${target_cpu}pe -arch,${target_cpu}; do
if test x${target_cpu} != xi386 && test x$format = x${target_cpu}pe; then if test x${target_cpu} != xi386 && test x$format = x${target_cpu}pe; then
@@ -687,7 +767,7 @@ if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
asm (".globl __start; __start:"); asm (".globl __start; __start:");
void __main (void); void __main (void);
void __main (void) {} void __main (void) {}
]], [[]])], [flag=1], []) ]], [[]])], [flag=1], [flag=0])
if test x"$flag" = x1; then if test x"$flag" = x1; then
grub_cv_target_cc_link_format="$format" grub_cv_target_cc_link_format="$format"
break; break;
@@ -768,6 +848,18 @@ if test "$target_cpu"-"$platform" = x86_64-efi; then
TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone" TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
fi fi
if test "x$target_cpu" = xarm; then
AC_CACHE_CHECK([whether option -mlong-calls works], grub_cv_cc_mlong_calls, [
CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_mlong_calls=yes],
[grub_cv_cc_mlong_calls=no])
])
if test "x$grub_cv_cc_mlong_calls" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -mlong-calls"
fi
fi
# #
# Compiler features. # Compiler features.
# #
@@ -820,11 +912,34 @@ fi
CFLAGS="$TARGET_CFLAGS" CFLAGS="$TARGET_CFLAGS"
# -mno-unaligned-access # -mno-unaligned-access -mstrict-align
if test "$target_cpu" = arm; then if test "$target_cpu" = arm; then
grub_CHECK_NO_UNALIGNED_ACCESS AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
if test x"$nua_possible" = xyes; then grub_cv_target_cc_strict_align=
TARGET_CFLAGS="$TARGET_CFLAGS -mno-unaligned-access" for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
CFLAGS="$TARGET_CFLAGS $arg -Werror"
LDFLAGS="$TARGET_LDFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
if test x"$flag" = x1; then
grub_cv_target_cc_strict_align="$arg"
break;
fi
done])
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
fi
AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned],
[CFLAGS="$TARGET_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
#ifdef __ARM_FEATURE_UNALIGNED
#error "unaligned"
#endif
]])],
[grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])])
if test x$grub_cv_cc_target_emits_unaligned = xyes; then
AC_MSG_ERROR([compiler generates unaligned accesses])
fi fi
fi fi
@@ -1155,8 +1270,8 @@ if test x"$grub_build_mkfont_excuse" = x ; then
else else
enable_build_grub_mkfont=no enable_build_grub_mkfont=no
fi fi
if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 ); then if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports needs build-time grub-mkfont]) AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont])
fi fi
AC_SUBST([build_freetype_cflags]) AC_SUBST([build_freetype_cflags])
@@ -1209,6 +1324,11 @@ FONT_SOURCE=
for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc; do for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc; do
if test -f "$dir/unifont.$ext"; then if test -f "$dir/unifont.$ext"; then
md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
# PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
continue;
fi
FONT_SOURCE="$dir/unifont.$ext" FONT_SOURCE="$dir/unifont.$ext"
break 2 break 2
fi fi
@@ -1219,8 +1339,8 @@ if test x"$enable_build_grub_mkfont" = xno ; then
FONT_SOURCE= FONT_SOURCE=
fi fi
if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 ); then if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports need unifont]) AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont])
fi fi
AC_SUBST([FONT_SOURCE]) AC_SUBST([FONT_SOURCE])
@@ -1482,6 +1602,12 @@ AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes]) AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes]) AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x]) AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
if test x$FONT_SOURCE != x ; then
HAVE_FONT_SOURCE=1
else
HAVE_FONT_SOURCE=0
fi
AC_SUBST(HAVE_FONT_SOURCE)
AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1]) AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes]) AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1]) AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
+3 -1
View File
@@ -1812,7 +1812,9 @@ right edges of two adjacent glyphs. The @strong{device width} field determines
the effective leading value that is used to render the font. the effective leading value that is used to render the font.
@end itemize @end itemize
@image{font_char_metrics,,,,png} @ifnottex
@image{font_char_metrics,,,,.png}
@end ifnottex
An illustration of how the various font metrics apply to characters. An illustration of how the various font metrics apply to characters.
+82 -25
View File
@@ -1298,23 +1298,26 @@ a key is pressed. The default is @samp{5}. Set to @samp{0} to boot
immediately without displaying the menu, or to @samp{-1} to wait immediately without displaying the menu, or to @samp{-1} to wait
indefinitely. indefinitely.
@item GRUB_HIDDEN_TIMEOUT If @samp{GRUB_TIMEOUT_STYLE} is set to @samp{countdown} or @samp{hidden},
Wait this many seconds for @key{ESC} to be pressed before displaying the menu. the timeout is instead counted before the menu is displayed.
If no @key{ESC} is pressed during that time, display the menu for the number of
seconds specified in GRUB_TIMEOUT before booting the default entry. We expect
that most people who use GRUB_HIDDEN_TIMEOUT will want to have GRUB_TIMEOUT set
to @samp{0} so that the menu is not displayed at all unless @key{ESC} is
pressed.
Unset by default.
@item GRUB_HIDDEN_TIMEOUT_QUIET @item GRUB_TIMEOUT_STYLE
In conjunction with @samp{GRUB_HIDDEN_TIMEOUT}, set this to @samp{true} to If this option is unset or set to @samp{menu}, then GRUB will display the
suppress the verbose countdown while waiting for a key to be pressed before menu and then wait for the timeout set by @samp{GRUB_TIMEOUT} to expire
displaying the menu. Unset by default. before booting the default entry. Pressing a key interrupts the timeout.
If this option is set to @samp{countdown} or @samp{hidden}, then, before
displaying the menu, GRUB will wait for the timeout set by
@samp{GRUB_TIMEOUT} to expire. If @key{ESC} is pressed during that time, it
will display the menu and wait for input. If a hotkey associated with a
menu entry is pressed, it will boot the associated menu entry immediately.
If the timeout expires before either of these happens, it will boot the
default entry. In the @samp{countdown} case, it will show a one-line
indication of the remaining time.
@item GRUB_DEFAULT_BUTTON @item GRUB_DEFAULT_BUTTON
@itemx GRUB_TIMEOUT_BUTTON @itemx GRUB_TIMEOUT_BUTTON
@itemx GRUB_HIDDEN_TIMEOUT_BUTTON @itemx GRUB_TIMEOUT_STYLE_BUTTON
@itemx GRUB_BUTTON_CMOS_ADDRESS @itemx GRUB_BUTTON_CMOS_ADDRESS
Variants of the corresponding variables without the @samp{_BUTTON} suffix, Variants of the corresponding variables without the @samp{_BUTTON} suffix,
used to support vendor-specific power buttons. @xref{Vendor power-on keys}. used to support vendor-specific power buttons. @xref{Vendor power-on keys}.
@@ -1489,6 +1492,44 @@ Each module will be loaded as early as possible, at the start of
@end table @end table
The following options are still accepted for compatibility with existing
configurations, but have better replacements:
@table @samp
@item GRUB_HIDDEN_TIMEOUT
Wait this many seconds before displaying the menu. If @key{ESC} is pressed
during that time, display the menu and wait for input according to
@samp{GRUB_TIMEOUT}. If a hotkey associated with a menu entry is pressed,
boot the associated menu entry immediately. If the timeout expires before
either of these happens, display the menu for the number of seconds
specified in @samp{GRUB_TIMEOUT} before booting the default entry.
If you set @samp{GRUB_HIDDEN_TIMEOUT}, you should also set
@samp{GRUB_TIMEOUT=0} so that the menu is not displayed at all unless
@key{ESC} is pressed.
This option is unset by default, and is deprecated in favour of the less
confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or
@samp{GRUB_TIMEOUT_STYLE=hidden}.
@item GRUB_HIDDEN_TIMEOUT_QUIET
In conjunction with @samp{GRUB_HIDDEN_TIMEOUT}, set this to @samp{true} to
suppress the verbose countdown while waiting for a key to be pressed before
displaying the menu.
This option is unset by default, and is deprecated in favour of the less
confusing @samp{GRUB_TIMEOUT_STYLE=countdown}.
@item GRUB_HIDDEN_TIMEOUT_BUTTON
Variant of @samp{GRUB_HIDDEN_TIMEOUT}, used to support vendor-specific power
buttons. @xref{Vendor power-on keys}.
This option is unset by default, and is deprecated in favour of the less
confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or
@samp{GRUB_TIMEOUT_STYLE=hidden}.
@end table
For more detailed customisation of @command{grub-mkconfig}'s output, you may For more detailed customisation of @command{grub-mkconfig}'s output, you may
edit the scripts in @file{/etc/grub.d} directly. edit the scripts in @file{/etc/grub.d} directly.
@file{/etc/grub.d/40_custom} is particularly useful for adding entire custom @file{/etc/grub.d/40_custom} is particularly useful for adding entire custom
@@ -2477,15 +2518,16 @@ menu requires several fancy features of your terminal.
@node Vendor power-on keys @node Vendor power-on keys
@chapter Using GRUB with vendor power-on keys @chapter Using GRUB with vendor power-on keys
Some laptop vendors provide an additional power-on button which boots another Some laptop vendors provide an additional power-on button which boots
OS. GRUB supports such buttons with the @samp{GRUB_TIMEOUT_BUTTON}, another OS. GRUB supports such buttons with the @samp{GRUB_TIMEOUT_BUTTON},
@samp{GRUB_DEFAULT_BUTTON}, @samp{GRUB_HIDDEN_TIMEOUT_BUTTON} and @samp{GRUB_TIMEOUT_STYLE_BUTTON}, @samp{GRUB_DEFAULT_BUTTON}, and
@samp{GRUB_BUTTON_CMOS_ADDRESS} variables in default/grub (@pxref{Simple @samp{GRUB_BUTTON_CMOS_ADDRESS} variables in default/grub (@pxref{Simple
configuration}). @samp{GRUB_TIMEOUT_BUTTON}, @samp{GRUB_DEFAULT_BUTTON} and configuration}). @samp{GRUB_TIMEOUT_BUTTON},
@samp{GRUB_HIDDEN_TIMEOUT_BUTTON} are used instead of the corresponding @samp{GRUB_TIMEOUT_STYLE_BUTTON}, and @samp{GRUB_DEFAULT_BUTTON} are used
variables without the @samp{_BUTTON} suffix when powered on using the special instead of the corresponding variables without the @samp{_BUTTON} suffix
button. @samp{GRUB_BUTTON_CMOS_ADDRESS} is vendor-specific and partially when powered on using the special button. @samp{GRUB_BUTTON_CMOS_ADDRESS}
model-specific. Values known to the GRUB team are: is vendor-specific and partially model-specific. Values known to the GRUB
team are:
@table @key @table @key
@item Dell XPS M1330M @item Dell XPS M1330M
@@ -3030,6 +3072,7 @@ These variables have special meaning to GRUB.
* superusers:: * superusers::
* theme:: * theme::
* timeout:: * timeout::
* timeout_style::
@end menu @end menu
@@ -3462,8 +3505,21 @@ keyboard input before booting the default menu entry. A timeout of @samp{0}
means to boot the default entry immediately without displaying the menu; a means to boot the default entry immediately without displaying the menu; a
timeout of @samp{-1} (or unset) means to wait indefinitely. timeout of @samp{-1} (or unset) means to wait indefinitely.
This variable is often set by @samp{GRUB_TIMEOUT} or If @samp{timeout_style} (@pxref{timeout_style}) is set to @samp{countdown}
@samp{GRUB_HIDDEN_TIMEOUT} (@pxref{Simple configuration}). or @samp{hidden}, the timeout is instead counted before the menu is
displayed.
This variable is often set by @samp{GRUB_TIMEOUT} (@pxref{Simple
configuration}).
@node timeout_style
@subsection timeout_style
This variable may be set to @samp{menu}, @samp{countdown}, or @samp{hidden}
to control the way in which the timeout (@pxref{timeout}) interacts with
displaying the menu. See the documentation of @samp{GRUB_TIMEOUT_STYLE}
(@pxref{Simple configuration}) for details.
@node Environment block @node Environment block
@@ -4420,7 +4476,7 @@ List devices or files.
With no arguments, print all devices known to GRUB. With no arguments, print all devices known to GRUB.
If the argument is a device name enclosed in parentheses (@pxref{Device If the argument is a device name enclosed in parentheses (@pxref{Device
syntax}), then list all files at the root directory of that device. syntax}), then print the name of the filesystem of that device.
If the argument is a directory given as an absolute file name (@pxref{File If the argument is a directory given as an absolute file name (@pxref{File
name syntax}), then list the contents of that directory. name syntax}), then list the contents of that directory.
@@ -4883,7 +4939,8 @@ Alias for @code{hashsum --hash sha512 arg @dots{}}. See command @command{hashsum
@deffn Command sleep [@option{--verbose}] [@option{--interruptible}] count @deffn Command sleep [@option{--verbose}] [@option{--interruptible}] count
Sleep for @var{count} seconds. If option @option{--interruptible} is given, Sleep for @var{count} seconds. If option @option{--interruptible} is given,
allow @key{ESC} to interrupt sleep. With @option{--verbose} show countdown allow @key{ESC} to interrupt sleep. With @option{--verbose} show countdown
of remaining seconds. of remaining seconds. Exit code is set to 0 if timeout expired and to 1
if timeout was interrupted by @key{ESC}.
@end deffn @end deffn
+631 -380
View File
File diff suppressed because it is too large. Load diff
+16 -26
View File
@@ -10,10 +10,6 @@ CCAS=$(TARGET_CC)
RANLIB=$(TARGET_RANLIB) RANLIB=$(TARGET_RANLIB)
STRIP=$(TARGET_STRIP) STRIP=$(TARGET_STRIP)
if COND_HAVE_FONT_SOURCE
TARGET_CFLAGS += -DUSE_ASCII_FALLBACK=1 -DHAVE_UNIFONT_WIDTHSPEC=1
endif
MACHO2IMG=$(top_builddir)/grub-macho2img MACHO2IMG=$(top_builddir)/grub-macho2img
AM_CFLAGS = $(TARGET_CFLAGS) AM_CFLAGS = $(TARGET_CFLAGS)
@@ -393,41 +389,35 @@ CLEANFILES += $(MOD_FILES)
if COND_ENABLE_EFIEMU if COND_ENABLE_EFIEMU
efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF) efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
-rm -f $@; \ -rm -f $@
-rm -f $@.bin
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m32 -Wall -Werror -nostdlib -static -O2 -c -o $@.bin $<
if test "x$(TARGET_APPLE_LINKER)" = x1; then \ if test "x$(TARGET_APPLE_LINKER)" = x1; then \
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m32 -Wall -Werror -nostdlib -O2 -c -o $@.bin $< || exit 1; \
$(TARGET_OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \ $(TARGET_OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \
rm -f $@.bin; \ rm -f $@.bin ; \
elif test ! -z "$(TARGET_OBJ2ELF)"; then \
$(TARGET_OBJ2ELF) $@.bin || (rm -f $@.bin; exit 1); \
mv $@.bin $@ ; \
else \ else \
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m32 -Wall -Werror -nostdlib -O2 -c -o $@ $< || exit 1; \ mv $@.bin $@ ; \
if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \
fi fi
# Link format -arch,x86_64 means Apple linker
efiemu64_c.o: efiemu/runtime/efiemu.c efiemu64_c.o: efiemu/runtime/efiemu.c
if test "x$(TARGET_APPLE_LINKER)" = x1; then \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -mno-red-zone -c -o $@ $< || exit 1; \
else \
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \
fi
efiemu64_s.o: efiemu/runtime/efiemu.S efiemu64_s.o: efiemu/runtime/efiemu.S
-rm -f $@ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
if test "x$(TARGET_APPLE_LINKER)" = x1; then \
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mno-red-zone -c -o $@ $< || exit 1; \
else \
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \
fi
efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF)
-rm -f $@; \ -rm -f $@
if test "x$(TARGET_APPLE_LINKER)" = x1; then \ -rm -f $@.bin
rm -f $@.bin; \ $(TARGET_CC) -m64 $(EFIEMU64_LINK_FORMAT) -nostdlib -static -Wl,-r -o $@.bin $^
$(TARGET_CC) -m64 -Wl,-r -nostdlib -o $@.bin $^ || exit 1; \ if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \
$(TARGET_OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \ $(TARGET_OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
rm -f $@.bin; \ rm -f $@.bin; \
else \ else \
$(TARGET_CC) -m64 -Wl,-melf_x86_64 -nostdlib -Wl,-r -o $@ $^ || exit 1; \ mv $@.bin $@ ; \
if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \
fi fi
platform_DATA += efiemu32.o efiemu64.o platform_DATA += efiemu32.o efiemu64.o
+2 -10
View File
@@ -88,7 +88,6 @@ kernel = {
mips_qemu_mips_ldflags = '-Wl,-Ttext,0x80200000'; mips_qemu_mips_ldflags = '-Wl,-Ttext,0x80200000';
mips_arc_cppflags = '-DGRUB_DECOMPRESSOR_LINK_ADDR=$(TARGET_DECOMPRESSOR_LINK_ADDR)'; mips_arc_cppflags = '-DGRUB_DECOMPRESSOR_LINK_ADDR=$(TARGET_DECOMPRESSOR_LINK_ADDR)';
mips_loongson_cppflags = '-DUSE_ASCII_FALLBACK';
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)'; i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
emu_cflags = '$(CFLAGS_GNULIB)'; emu_cflags = '$(CFLAGS_GNULIB)';
emu_cppflags = '$(CPPFLAGS_GNULIB)'; emu_cppflags = '$(CPPFLAGS_GNULIB)';
@@ -620,13 +619,6 @@ module = {
common = commands/i386/nthibr.c; common = commands/i386/nthibr.c;
}; };
library = {
name = libgnulib.a;
common = gnulib/regex.c;
cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
};
module = { module = {
name = cmostest; name = cmostest;
common = commands/i386/cmostest.c; common = commands/i386/cmostest.c;
@@ -678,8 +670,7 @@ module = {
name = regexp; name = regexp;
common = commands/regexp.c; common = commands/regexp.c;
common = commands/wildcard.c; common = commands/wildcard.c;
ldadd = libgnulib.a; common = gnulib/regex.c;
dependencies = libgnulib.a;
cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)'; cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)'; cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
}; };
@@ -1579,6 +1570,7 @@ module = {
extra_dist = lib/ia64/setjmp.S; extra_dist = lib/ia64/setjmp.S;
extra_dist = lib/ia64/longjmp.S; extra_dist = lib/ia64/longjmp.S;
extra_dist = lib/arm/setjmp.S; extra_dist = lib/arm/setjmp.S;
extra_dist = lib/arm64/setjmp.S;
}; };
module = { module = {
+5 -1
View File
@@ -48,7 +48,7 @@ kernel_byte: .xword (2 << 9)
boot_path_end: boot_path_end:
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
#else #else
#define boot_path (_start + 512) #define boot_path (_start + 512 + SCRATCH_PAD_BOOT_SIZE)
#define boot_path_end (_start + 1024) #define boot_path_end (_start + 1024)
#include <grub/offsets.h> #include <grub/offsets.h>
@@ -140,7 +140,11 @@ prom_call:
boot_continue: boot_continue:
mov %o7, PIC_REG /* PIC base */ mov %o7, PIC_REG /* PIC base */
#ifndef CDBOOT
sethi %hi(SCRATCH_PAD_BOOT), %l1 /* OF argument slots */ sethi %hi(SCRATCH_PAD_BOOT), %l1 /* OF argument slots */
#else
GET_ABS(_start + 512, %l1) /* OF argument slots */
#endif
/* Find the /chosen node so we can fetch the stdout handle, /* Find the /chosen node so we can fetch the stdout handle,
* and thus perform console output. * and thus perform console output.
+10 -1
View File
@@ -534,11 +534,20 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
"EHCI grub_ehci_pci_iter: registers above 4G are not supported\n"); "EHCI grub_ehci_pci_iter: registers above 4G are not supported\n");
return 0; return 0;
} }
base &= GRUB_PCI_ADDR_MEM_MASK;
if (!base)
{
grub_dprintf ("ehci",
"EHCI: EHCI is not mapped\n");
return 0;
}
/* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */ /* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word(addr, grub_pci_write_word(addr,
GRUB_PCI_COMMAND_BUS_MASTER | grub_pci_read_word(addr)); GRUB_PCI_COMMAND_MEM_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER
| grub_pci_read_word(addr));
grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: 32-bit EHCI OK\n"); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: 32-bit EHCI OK\n");
} }
+10 -6
View File
@@ -265,16 +265,20 @@ grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0); addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
base = grub_pci_read (addr); base = grub_pci_read (addr);
#if 0 base &= GRUB_PCI_ADDR_MEM_MASK;
/* Stop if there is no IO space base address defined. */ if (!base)
if (! (base & 1)) {
return 0; grub_dprintf ("ehci",
#endif "EHCI: EHCI is not mapper\n");
return 0;
}
/* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */ /* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word(addr, grub_pci_write_word(addr,
GRUB_PCI_COMMAND_BUS_MASTER | grub_pci_read_word(addr)); GRUB_PCI_COMMAND_MEM_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER
| grub_pci_read_word(addr));
grub_dprintf ("ohci", "class=0x%02x 0x%02x interface 0x%02x\n", grub_dprintf ("ohci", "class=0x%02x 0x%02x interface 0x%02x\n",
class, subclass, interf); class, subclass, interf);
+7 -6
View File
@@ -217,12 +217,6 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
if (class != 0x0c || subclass != 0x03 || interf != 0x00) if (class != 0x0c || subclass != 0x03 || interf != 0x00)
return 0; return 0;
/* Set bus master - needed for coreboot or broken BIOSes */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word(addr, GRUB_PCI_COMMAND_IO_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER
| grub_pci_read_word (addr));
/* Determine IO base address. */ /* Determine IO base address. */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG4); addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG4);
base = grub_pci_read (addr); base = grub_pci_read (addr);
@@ -233,6 +227,13 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
if ((base & GRUB_UHCI_IOMASK) == 0) if ((base & GRUB_UHCI_IOMASK) == 0)
return 0; return 0;
/* Set bus master - needed for coreboot or broken BIOSes */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word(addr, GRUB_PCI_COMMAND_IO_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER
| GRUB_PCI_COMMAND_MEM_ENABLED
| grub_pci_read_word (addr));
grub_dprintf ("uhci", "base = %x\n", base); grub_dprintf ("uhci", "base = %x\n", base);
/* Allocate memory for the controller and register it. */ /* Allocate memory for the controller and register it. */
+51 -32
View File
@@ -31,11 +31,14 @@ static grub_ieee1275_ihandle_t last_ihandle;
struct ofdisk_hash_ent struct ofdisk_hash_ent
{ {
char *devpath; char *devpath;
char *open_path;
char *grub_devpath;
int is_boot; int is_boot;
int is_cdrom; int is_cdrom;
/* Pointer to shortest available name on nodes representing canonical names, /* Pointer to shortest available name on nodes representing canonical names,
otherwise NULL. */ otherwise NULL. */
const char *shortest; const char *shortest;
const char *grub_shortest;
struct ofdisk_hash_ent *next; struct ofdisk_hash_ent *next;
}; };
@@ -70,12 +73,50 @@ ofdisk_hash_add_real (char *devpath)
{ {
struct ofdisk_hash_ent *p; struct ofdisk_hash_ent *p;
struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)]; struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)];
const char *iptr;
char *optr;
p = grub_zalloc (sizeof (*p)); p = grub_zalloc (sizeof (*p));
if (!p) if (!p)
return NULL; return NULL;
p->devpath = devpath; p->devpath = devpath;
p->grub_devpath = grub_malloc (sizeof ("ieee1275/")
+ 2 * grub_strlen (p->devpath));
if (!p->grub_devpath)
{
grub_free (p);
return NULL;
}
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0))
{
p->open_path = grub_malloc (grub_strlen (p->devpath) + 3);
if (!p->open_path)
{
grub_free (p->grub_devpath);
grub_free (p);
return NULL;
}
optr = grub_stpcpy (p->open_path, p->devpath);
*optr++ = ':';
*optr++ = '0';
*optr = '\0';
}
else
p->open_path = p->devpath;
optr = grub_stpcpy (p->grub_devpath, "ieee1275/");
for (iptr = p->devpath; *iptr; )
{
if (*iptr == ',')
*optr++ = '\\';
*optr++ = *iptr++;
}
*optr = 0;
p->next = *head; p->next = *head;
*head = p; *head = p;
return p; return p;
@@ -104,7 +145,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
if (!curcan) if (!curcan)
{ {
p->shortest = devpath; p->shortest = p->devpath;
p->grub_shortest = p->grub_devpath;
if (check_string_cdrom (devpath)) if (check_string_cdrom (devpath))
p->is_cdrom = 1; p->is_cdrom = 1;
return p; return p;
@@ -125,7 +167,10 @@ ofdisk_hash_add (char *devpath, char *curcan)
{ {
if (!pcan->shortest if (!pcan->shortest
|| grub_strlen (pcan->shortest) > grub_strlen (devpath)) || grub_strlen (pcan->shortest) > grub_strlen (devpath))
pcan->shortest = devpath; {
pcan->shortest = p->devpath;
pcan->grub_shortest = p->grub_devpath;
}
} }
return p; return p;
@@ -288,21 +333,8 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
if (!ent->is_boot && ent->is_cdrom) if (!ent->is_boot && ent->is_cdrom)
continue; continue;
{ if (hook (ent->grub_shortest, hook_data))
char buffer[sizeof ("ieee1275/") + 2 * grub_strlen (ent->shortest)]; return 1;
const char *iptr;
char *optr;
optr = grub_stpcpy (buffer, "ieee1275/");
for (iptr = ent->shortest; *iptr; )
{
if (*iptr == ',')
*optr++ = '\\';
*optr++ = *iptr++;
}
*optr = 0;
if (hook (buffer, hook_data))
return 1;
}
} }
} }
return 0; return 0;
@@ -396,7 +428,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
if (!op) if (!op)
return grub_errno; return grub_errno;
disk->id = (unsigned long) op; disk->id = (unsigned long) op;
disk->data = op->devpath; disk->data = op->open_path;
} }
return 0; return 0;
@@ -428,20 +460,7 @@ grub_ofdisk_prepare (grub_disk_t disk, grub_disk_addr_t sector)
last_ihandle = 0; last_ihandle = 0;
last_devpath = NULL; last_devpath = NULL;
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0)) grub_ieee1275_open (disk->data, &last_ihandle);
{
char name2[grub_strlen (disk->data) + 3];
char *p;
grub_strcpy (name2, disk->data);
p = name2 + grub_strlen (name2);
*p++ = ':';
*p++ = '0';
*p = 0;
grub_ieee1275_open (name2, &last_ihandle);
}
else
grub_ieee1275_open (disk->data, &last_ihandle);
if (! last_ihandle) if (! last_ihandle)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
last_devpath = disk->data; last_devpath = disk->data;
+7 -1
View File
@@ -402,9 +402,15 @@ grub_pata_pciinit (grub_pci_device_t dev,
bar2 = grub_pci_read (addr); bar2 = grub_pci_read (addr);
/* Check if the BARs describe an IO region. */ /* Check if the BARs describe an IO region. */
if ((bar1 & 1) && (bar2 & 1)) if ((bar1 & 1) && (bar2 & 1) && (bar1 & ~3))
{ {
rega = bar1 & ~3; rega = bar1 & ~3;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word (addr, grub_pci_read_word (addr)
| GRUB_PCI_COMMAND_IO_ENABLED
| GRUB_PCI_COMMAND_MEM_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER);
} }
} }
+49 -27
View File
@@ -33,7 +33,7 @@
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
#ifdef USE_ASCII_FALLBACK #if HAVE_FONT_SOURCE
#include "ascii.h" #include "ascii.h"
#endif #endif
@@ -110,43 +110,65 @@ static struct grub_font null_font;
/* Flag to ensure module is initialized only once. */ /* Flag to ensure module is initialized only once. */
static grub_uint8_t font_loader_initialized; static grub_uint8_t font_loader_initialized;
#ifdef USE_ASCII_FALLBACK #if HAVE_FONT_SOURCE
static struct grub_font_glyph *ascii_font_glyph[0x80]; static struct grub_font_glyph *ascii_font_glyph[ASCII_NUM];
static struct grub_font_glyph *arrows_font_glyph[ARROWS_NUM];
static struct grub_font_glyph *lines_font_glyph[LINES_NUM];
static void
init_fallback (struct grub_font_glyph **glyphs, const unsigned char *stored,
grub_uint32_t len)
{
grub_uint32_t current;
for (current = 0; current < len; current++)
{
glyphs[current] =
grub_malloc (sizeof (struct grub_font_glyph) + ASCII_BITMAP_SIZE);
if (!glyphs[current])
{
grub_errno = GRUB_ERR_NONE;
continue;
}
glyphs[current]->width = 8;
glyphs[current]->height = 16;
glyphs[current]->offset_x = 0;
glyphs[current]->offset_y = -2;
glyphs[current]->device_width = 8;
glyphs[current]->font = NULL;
grub_memcpy (glyphs[current]->bitmap,
&stored[current * ASCII_BITMAP_SIZE],
ASCII_BITMAP_SIZE);
}
}
#endif #endif
static struct grub_font_glyph * static struct grub_font_glyph *
ascii_glyph_lookup (grub_uint32_t code) ascii_glyph_lookup (grub_uint32_t code)
{ {
#ifdef USE_ASCII_FALLBACK #if HAVE_FONT_SOURCE
static int ascii_failback_initialized = 0; static int ascii_fallback_initialized = 0;
struct grub_font_glyph **p;
if (code >= 0x80) if (code < ASCII_NUM)
p = &ascii_font_glyph[code];
else if (code >= ARROWS_START && code < ARROWS_START + ARROWS_NUM)
p = &arrows_font_glyph[code - ARROWS_START];
else if (code >= LINES_START && code < LINES_START + LINES_NUM)
p = &lines_font_glyph[code - LINES_START];
else
return NULL; return NULL;
if (ascii_failback_initialized == 0) if (ascii_fallback_initialized == 0)
{ {
int current; init_fallback (ascii_font_glyph, ascii_bitmaps, ASCII_NUM);
for (current = 0; current < 0x80; current++) init_fallback (arrows_font_glyph, arrows_bitmaps, ARROWS_NUM);
{ init_fallback (lines_font_glyph, lines_bitmaps, LINES_NUM);
ascii_font_glyph[current] = ascii_fallback_initialized = 1;
grub_malloc (sizeof (struct grub_font_glyph) + ASCII_BITMAP_SIZE);
ascii_font_glyph[current]->width = 8;
ascii_font_glyph[current]->height = 16;
ascii_font_glyph[current]->offset_x = 0;
ascii_font_glyph[current]->offset_y = -2;
ascii_font_glyph[current]->device_width = 8;
ascii_font_glyph[current]->font = NULL;
grub_memcpy (ascii_font_glyph[current]->bitmap,
&ascii_bitmaps[current * ASCII_BITMAP_SIZE],
ASCII_BITMAP_SIZE);
}
ascii_failback_initialized = 1;
} }
return ascii_font_glyph[code]; return *p;
#else #else
(void) code; (void) code;
return NULL; return NULL;
+166 -108
View File
@@ -25,45 +25,113 @@
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/arm/reloc.h> #include <grub/arm/reloc.h>
struct trampoline_arm
{
#define ARM_LOAD_IP 0xe59fc000
#define ARM_BX 0xe12fff1c
#define ARM_MOV_PC 0xe1a0f00c
grub_uint32_t load_ip; /* ldr ip, [pc] */
grub_uint32_t bx; /* bx ip or mov pc, ip*/
grub_uint32_t addr;
};
static grub_uint16_t thumb_template[8] =
{
0x468c, /* mov ip, r1 */
0x4903, /* ldr r1, [pc, #12] ; (10 <.text+0x10>) */
/* Exchange R1 and IP in limited Thumb instruction set.
IP gets negated but we compensate it by C code. */
/* R1 IP */
/* -A R1 */
0x4461, /* add r1, ip */ /* R1-A R1 */
0x4249, /* negs r1, r1 */ /* A-R1 R1 */
0x448c, /* add ip, r1 */ /* A-R1 A */
0x4249, /* negs r1, r1 */ /* R1-A A */
0x4461, /* add r1, ip */ /* R1 A */
0x4760 /* bx ip */
};
struct trampoline_thumb
{
grub_uint16_t template[8];
grub_uint32_t neg_addr;
};
#pragma GCC diagnostic ignored "-Wcast-align"
grub_err_t
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
grub_size_t *got)
{
const Elf_Ehdr *e = ehdr;
const Elf_Shdr *s;
unsigned i;
*tramp = 0;
*got = 0;
for (i = 0, s = (const Elf_Shdr *) ((grub_addr_t) e + e->e_shoff);
i < e->e_shnum;
i++, s = (const Elf_Shdr *) ((grub_addr_t) s + e->e_shentsize))
if (s->sh_type == SHT_REL)
{
const Elf_Rel *rel, *max;
for (rel = (const Elf_Rel *) ((grub_addr_t) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
rel < max;
rel++)
switch (ELF_R_TYPE (rel->r_info))
{
case R_ARM_CALL:
case R_ARM_JUMP24:
{
*tramp += sizeof (struct trampoline_arm);
break;
}
case R_ARM_THM_CALL:
case R_ARM_THM_JUMP24:
case R_ARM_THM_JUMP19:
{
*tramp += sizeof (struct trampoline_thumb);
break;
}
}
}
grub_dprintf ("dl", "trampoline size %x\n", *tramp);
return GRUB_ERR_NONE;
}
/************************************************* /*************************************************
* Runtime dynamic linker with helper functions. * * Runtime dynamic linker with helper functions. *
*************************************************/ *************************************************/
static grub_err_t grub_err_t
do_relocations (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod) grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{ {
grub_dl_segment_t seg; Elf_Rel *rel, *max;
Elf_Rel *rel;
Elf_Sym *sym;
int i, entnum;
entnum = relhdr->sh_size / sizeof (Elf_Rel); for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
max = (Elf_Rel *) ((char *) rel + s->sh_size);
/* Find the target segment for this relocation section. */ rel < max;
for (seg = mod->segment ; seg ; seg = seg->next) rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
if (seg->section == relhdr->sh_info)
break;
if (!seg)
return grub_error (GRUB_ERR_EOF, N_("relocation segment not found"));
rel = (Elf_Rel *) ((grub_addr_t) e + relhdr->sh_offset);
/* Step through all relocations */
for (i = 0, sym = mod->symtab; i < entnum; i++)
{ {
Elf_Addr *target, sym_addr; Elf_Addr *target, sym_addr;
int relsym, reltype;
grub_err_t retval; grub_err_t retval;
Elf_Sym *sym;
if (seg->size < rel[i].r_offset) if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE, return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment"); "reloc offset is out of the segment");
relsym = ELF_R_SYM (rel[i].r_info); target = (void *) ((char *) seg->addr + rel->r_offset);
reltype = ELF_R_TYPE (rel[i].r_info); sym = (Elf_Sym *) ((char *) mod->symtab
target = (void *) ((grub_addr_t) seg->addr + rel[i].r_offset); + mod->symsize * ELF_R_SYM (rel->r_info));
sym_addr = sym[relsym].st_value; sym_addr = sym->st_value;
switch (reltype) switch (ELF_R_TYPE (rel->r_info))
{ {
case R_ARM_ABS32: case R_ARM_ABS32:
{ {
@@ -76,16 +144,58 @@ do_relocations (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod)
case R_ARM_CALL: case R_ARM_CALL:
case R_ARM_JUMP24: case R_ARM_JUMP24:
{ {
retval = grub_arm_reloc_jump24 (target, sym_addr); grub_int32_t offset;
if (retval != GRUB_ERR_NONE)
return retval; sym_addr += grub_arm_jump24_get_offset (target);
offset = sym_addr - (grub_uint32_t) target;
if ((sym_addr & 1) || !grub_arm_jump24_check_offset (offset))
{
struct trampoline_arm *tp = mod->trampptr;
mod->trampptr = tp + 1;
tp->load_ip = ARM_LOAD_IP;
tp->bx = (sym_addr & 1) ? ARM_BX : ARM_MOV_PC;
tp->addr = sym_addr + 8;
offset = (grub_uint8_t *) tp - (grub_uint8_t *) target - 8;
}
if (!grub_arm_jump24_check_offset (offset))
return grub_error (GRUB_ERR_BAD_MODULE,
"trampoline out of range");
grub_arm_jump24_set_offset (target, offset);
} }
break; break;
case R_ARM_THM_CALL: case R_ARM_THM_CALL:
case R_ARM_THM_JUMP24: case R_ARM_THM_JUMP24:
{ {
/* Thumb instructions can be 16-bit aligned */ /* Thumb instructions can be 16-bit aligned */
retval = grub_arm_reloc_thm_call ((grub_uint16_t *) target, sym_addr); grub_int32_t offset;
sym_addr += grub_arm_thm_call_get_offset ((grub_uint16_t *) target);
grub_dprintf ("dl", " sym_addr = 0x%08x\n", sym_addr);
offset = sym_addr - (grub_uint32_t) target;
grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n",
target, sym_addr, offset);
if (!(sym_addr & 1) || (offset < -0x200000 || offset >= 0x200000))
{
struct trampoline_thumb *tp = mod->trampptr;
mod->trampptr = tp + 1;
grub_memcpy (tp->template, thumb_template, sizeof (tp->template));
tp->neg_addr = -sym_addr - 4;
offset = ((grub_uint8_t *) tp - (grub_uint8_t *) target - 4) | 1;
}
if (offset < -0x200000 || offset >= 0x200000)
return grub_error (GRUB_ERR_BAD_MODULE,
"trampoline out of range");
grub_dprintf ("dl", " relative destination = %p\n",
(char *) target + offset);
retval = grub_arm_thm_call_set_offset ((grub_uint16_t *) target, offset);
if (retval != GRUB_ERR_NONE) if (retval != GRUB_ERR_NONE)
return retval; return retval;
} }
@@ -98,15 +208,37 @@ do_relocations (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod)
case R_ARM_THM_JUMP19: case R_ARM_THM_JUMP19:
{ {
/* Thumb instructions can be 16-bit aligned */ /* Thumb instructions can be 16-bit aligned */
retval = grub_arm_reloc_thm_jump19 ((grub_uint16_t *) target, sym_addr); grub_int32_t offset;
if (retval != GRUB_ERR_NONE)
return retval; if (!(sym_addr & 1))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("Relocation targeting wrong execution state"));
sym_addr += grub_arm_thm_jump19_get_offset ((grub_uint16_t *) target);
offset = sym_addr - (grub_uint32_t) target;
if (!grub_arm_thm_jump19_check_offset (offset)
|| !(sym_addr & 1))
{
struct trampoline_thumb *tp = mod->gotptr;
mod->gotptr = tp + 1;
grub_memcpy (tp->template, thumb_template, sizeof (tp->template));
tp->neg_addr = -sym_addr - 4;
offset = ((grub_uint8_t *) tp - (grub_uint8_t *) target - 4) | 1;
}
if (!grub_arm_thm_jump19_check_offset (offset))
return grub_error (GRUB_ERR_BAD_MODULE,
"trampoline out of range");
grub_arm_thm_jump19_set_offset ((grub_uint16_t *) target, offset);
} }
break; break;
default: default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"), N_("relocation 0x%x is not implemented yet"),
reltype); ELF_R_TYPE (rel->r_info));
} }
} }
@@ -130,77 +262,3 @@ grub_arch_dl_check_header (void *ehdr)
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
/*
* Verify that provided ELF header contains reference to a symbol table
*/
static int
has_symtab (Elf_Ehdr * e)
{
int i;
Elf_Shdr *s;
for (i = 0, s = (Elf_Shdr *) ((grub_uint32_t) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((grub_uint32_t) s + e->e_shentsize))
if (s->sh_type == SHT_SYMTAB)
return 1;
return 0;
}
/*
* grub_arch_dl_relocate_symbols():
* Only externally visible function in this file.
* Locates the relocations section of the ELF object, and calls
* do_relocations() to deal with it.
*/
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
{
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
unsigned i;
if (!has_symtab (e))
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
#define FIRST_SHDR(x) ((Elf_Shdr *) ((grub_addr_t)(x) + (x)->e_shoff))
#define NEXT_SHDR(x, y) ((Elf_Shdr *) ((grub_addr_t)(y) + (x)->e_shentsize))
for (i = 0, s = FIRST_SHDR (e); i < e->e_shnum; i++, s = NEXT_SHDR (e, s))
{
grub_err_t ret;
switch (s->sh_type)
{
case SHT_REL:
{
/* Relocations, no addends */
ret = do_relocations (s, e, mod);
if (ret != GRUB_ERR_NONE)
return ret;
}
break;
case SHT_NULL:
case SHT_PROGBITS:
case SHT_SYMTAB:
case SHT_STRTAB:
case SHT_NOBITS:
case SHT_ARM_ATTRIBUTES:
break;
case SHT_RELA:
default:
{
grub_dprintf ("dl", "unhandled section_type: %d (0x%08x)\n",
s->sh_type, s->sh_type);
return GRUB_ERR_NOT_IMPLEMENTED_YET;
};
}
}
#undef FIRST_SHDR
#undef NEXT_SHDR
return GRUB_ERR_NONE;
}
+72 -78
View File
@@ -38,8 +38,6 @@ grub_arm_reloc_abs32 (Elf32_Word *target, Elf32_Addr sym_addr)
tmp = grub_le_to_cpu32 (*target); tmp = grub_le_to_cpu32 (*target);
tmp += sym_addr; tmp += sym_addr;
*target = grub_cpu_to_le32 (tmp); *target = grub_cpu_to_le32 (tmp);
grub_dprintf ("dl", " %s: reloc_abs32 0x%08x => 0x%08x", __FUNCTION__,
(unsigned int) sym_addr, (unsigned int) tmp);
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
@@ -51,37 +49,16 @@ grub_arm_reloc_abs32 (Elf32_Word *target, Elf32_Addr sym_addr)
* little-endian, requiring some additional fiddling. * * little-endian, requiring some additional fiddling. *
********************************************************************/ ********************************************************************/
/* grub_int32_t
* R_ARM_THM_CALL/THM_JUMP24 grub_arm_thm_call_get_offset (grub_uint16_t *target)
*
* Relocate Thumb (T32) instruction set relative branches:
* B.W, BL and BLX
*/
grub_err_t
grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
{ {
grub_int32_t offset, offset_low, offset_high; grub_uint32_t sign, j1, j2;
grub_uint32_t sign, j1, j2, is_blx; grub_uint32_t insword;
grub_uint32_t insword, insmask; grub_int32_t offset;
/* Extract instruction word in alignment-safe manner */ /* Extract instruction word in alignment-safe manner */
insword = (grub_le_to_cpu16 (*target) << 16) insword = (grub_le_to_cpu16 (*target) << 16)
| (grub_le_to_cpu16(*(target + 1))); | (grub_le_to_cpu16(*(target + 1)));
insmask = 0xf800d000;
/* B.W/BL or BLX? Affects range and expected target state */
if (((insword >> 12) & 0xd) == 0xc)
is_blx = 1;
else
is_blx = 0;
/* If BLX, target symbol must be ARM (target address LSB == 0) */
if (is_blx && (sym_addr & 1))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("Relocation targeting wrong execution state"));
offset_low = -16777216;
offset_high = is_blx ? 16777212 : 16777214;
/* Extract bitfields from instruction words */ /* Extract bitfields from instruction words */
sign = (insword >> 26) & 1; sign = (insword >> 26) & 1;
@@ -95,22 +72,32 @@ grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
if (offset & (1 << 24)) if (offset & (1 << 24))
offset -= (1 << 25); offset -= (1 << 25);
grub_dprintf ("dl", " sym_addr = 0x%08x", sym_addr); return offset;
}
offset += sym_addr; grub_err_t
#ifndef GRUB_UTIL grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset)
offset -= (grub_uint32_t) target; {
#endif grub_uint32_t sign, j1, j2;
const grub_uint32_t insmask = 0xf800d000;
grub_uint32_t insword;
int is_blx;
grub_dprintf("dl", " %s: target=%p, sym_addr=0x%08x, offset=%d\n", /* Extract instruction word in alignment-safe manner */
is_blx ? "BLX" : "BL", target, sym_addr, offset); insword = (grub_le_to_cpu16 (*target) << 16)
| (grub_le_to_cpu16(*(target + 1)));
if ((offset < offset_low) || (offset > offset_high)) if (((insword >> 12) & 0xd) == 0xc)
return grub_error (GRUB_ERR_BAD_MODULE, is_blx = 1;
N_("THM_CALL Relocation out of range.")); else
is_blx = 0;
grub_dprintf ("dl", " relative destination = %p", if (!is_blx && !(offset & 1))
(char *) target + offset); return grub_error (GRUB_ERR_BAD_MODULE, "bl/b.w targettting ARM");
/* Transform blx into bl if necessarry. */
if (is_blx && (offset & 1))
insword |= (1 << 12);
/* Reassemble instruction word */ /* Reassemble instruction word */
sign = (offset >> 24) & 1; sign = (offset >> 24) & 1;
@@ -130,21 +117,15 @@ grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
/* grub_int32_t
* R_ARM_THM_JUMP19 grub_arm_thm_jump19_get_offset (grub_uint16_t *target)
*
* Relocate conditional Thumb (T32) B<c>.W
*/
grub_err_t
grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
{ {
grub_int32_t offset; grub_int32_t offset;
grub_uint32_t insword, insmask; grub_uint32_t insword;
/* Extract instruction word in alignment-safe manner */ /* Extract instruction word in alignment-safe manner */
insword = grub_le_to_cpu16 ((*target)) << 16 insword = (grub_le_to_cpu16 (*target) << 16)
| grub_le_to_cpu16 (*(target + 1)); | (grub_le_to_cpu16(*(target + 1)));
insmask = 0xfbc0d000;
/* Extract and sign extend offset */ /* Extract and sign extend offset */
offset = ((insword >> 26) & 1) << 19 offset = ((insword >> 26) & 1) << 19
@@ -156,18 +137,22 @@ grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
if (offset & (1 << 20)) if (offset & (1 << 20))
offset -= (1 << 21); offset -= (1 << 21);
/* Adjust and re-truncate offset */ return offset;
offset += sym_addr; }
#ifndef GRUB_UTIL
offset -= (grub_uint32_t) target; void
#endif grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset)
if ((offset > 1048574) || (offset < -1048576)) {
return grub_error (GRUB_ERR_BAD_MODULE, grub_uint32_t insword;
N_("THM_JUMP19 Relocation out of range.")); const grub_uint32_t insmask = 0xfbc0d000;
offset >>= 1; offset >>= 1;
offset &= 0xfffff; offset &= 0xfffff;
/* Extract instruction word in alignment-safe manner */
insword = grub_le_to_cpu16 ((*target)) << 16
| grub_le_to_cpu16 (*(target + 1));
/* Reassemble instruction word and write back */ /* Reassemble instruction word and write back */
insword &= insmask; insword &= insmask;
insword |= ((offset >> 19) & 1) << 26 insword |= ((offset >> 19) & 1) << 26
@@ -177,9 +162,15 @@ grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
| (offset & 0x7ff); | (offset & 0x7ff);
*target = grub_cpu_to_le16 (insword >> 16); *target = grub_cpu_to_le16 (insword >> 16);
*(target + 1) = grub_cpu_to_le16 (insword & 0xffff); *(target + 1) = grub_cpu_to_le16 (insword & 0xffff);
return GRUB_ERR_NONE;
} }
int
grub_arm_thm_jump19_check_offset (grub_int32_t offset)
{
if ((offset > 1048574) || (offset < -1048576))
return 0;
return 1;
}
/*********************************************************** /***********************************************************
@@ -188,35 +179,38 @@ grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
* ARM instructions are 32-bit in size and 32-bit aligned. * * ARM instructions are 32-bit in size and 32-bit aligned. *
***********************************************************/ ***********************************************************/
/* grub_int32_t
* R_ARM_JUMP24 grub_arm_jump24_get_offset (grub_uint32_t *target)
*
* Relocate ARM (A32) B
*/
grub_err_t
grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr)
{ {
grub_uint32_t insword;
grub_int32_t offset; grub_int32_t offset;
grub_uint32_t insword;
if (sym_addr & 1)
return grub_error (GRUB_ERR_BAD_MODULE,
N_("Relocation targeting wrong execution state"));
insword = grub_le_to_cpu32 (*target); insword = grub_le_to_cpu32 (*target);
offset = (insword & 0x00ffffff) << 2; offset = (insword & 0x00ffffff) << 2;
if (offset & 0x02000000) if (offset & 0x02000000)
offset -= 0x04000000; offset -= 0x04000000;
offset += sym_addr; return offset;
#ifndef GRUB_UTIL }
offset -= (grub_uint32_t) target;
#endif int
grub_arm_jump24_check_offset (grub_int32_t offset)
{
if (offset >= 0x02000000 || offset < -0x02000000)
return 0;
return 1;
}
void
grub_arm_jump24_set_offset (grub_uint32_t *target,
grub_int32_t offset)
{
grub_uint32_t insword;
insword = grub_le_to_cpu32 (*target);
insword &= 0xff000000; insword &= 0xff000000;
insword |= (offset >> 2) & 0x00ffffff; insword |= (offset >> 2) & 0x00ffffff;
*target = grub_cpu_to_le32 (insword); *target = grub_cpu_to_le32 (insword);
return GRUB_ERR_NONE;
} }
+85 -119
View File
@@ -25,6 +25,15 @@
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/cpu/reloc.h> #include <grub/cpu/reloc.h>
struct trampoline
{
#define LDR 0x58000050
#define BR 0xd61f0200
grub_uint32_t ldr; /* ldr x16, 8 */
grub_uint32_t br; /* br x16 */
grub_uint64_t addr;
};
/* /*
* Check if EHDR is a valid ELF header. * Check if EHDR is a valid ELF header.
*/ */
@@ -42,59 +51,76 @@ grub_arch_dl_check_header (void *ehdr)
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
#pragma GCC diagnostic ignored "-Wcast-align"
grub_err_t
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
grub_size_t *got)
{
const Elf_Ehdr *e = ehdr;
const Elf_Shdr *s;
unsigned i;
*tramp = 0;
*got = 0;
for (i = 0, s = (const Elf_Shdr *) ((grub_addr_t) e + e->e_shoff);
i < e->e_shnum;
i++, s = (const Elf_Shdr *) ((grub_addr_t) s + e->e_shentsize))
if (s->sh_type == SHT_REL || s->sh_type == SHT_RELA)
{
const Elf_Rel *rel, *max;
for (rel = (const Elf_Rel *) ((grub_addr_t) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
rel < max;
rel = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_entsize))
switch (ELF_R_TYPE (rel->r_info))
{
case R_AARCH64_CALL26:
case R_AARCH64_JUMP26:
{
*tramp += sizeof (struct trampoline);
break;
}
}
}
return GRUB_ERR_NONE;
}
/* /*
* Unified function for both REL and RELA * Unified function for both REL and RELA
*/ */
static grub_err_t grub_err_t
do_relX (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod) grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{ {
grub_err_t retval; Elf_Rel *rel, *max;
grub_dl_segment_t segment;
Elf_Rel *rel;
Elf_Rela *rela;
Elf_Sym *symbol;
int i, entnum;
unsigned long long entsize;
/* Find the target segment for this relocation section. */ for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
for (segment = mod->segment ; segment != 0 ; segment = segment->next) max = (Elf_Rel *) ((char *) rel + s->sh_size);
if (segment->section == relhdr->sh_info) rel < max;
break; rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
if (!segment)
return grub_error (GRUB_ERR_EOF, N_("relocation segment not found"));
rel = (Elf_Rel *) ((grub_addr_t) e + relhdr->sh_offset);
rela = (Elf_Rela *) rel;
if (relhdr->sh_type == SHT_RELA)
entsize = sizeof (Elf_Rela);
else
entsize = sizeof (Elf_Rel);
entnum = relhdr->sh_size / entsize;
retval = GRUB_ERR_NONE;
grub_dprintf("dl", "Processing %d relocation entries.\n", entnum);
/* Step through all relocations */
for (i = 0, symbol = mod->symtab; i < entnum; i++)
{ {
Elf_Sym *sym;
void *place; void *place;
grub_uint64_t sym_addr, symidx, reltype; grub_uint64_t sym_addr;
if (rel->r_offset >= segment->size) if (rel->r_offset >= seg->size)
return grub_error (GRUB_ERR_BAD_MODULE, return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment"); "reloc offset is out of the segment");
symidx = ELF_R_SYM (rel->r_info); sym = (Elf_Sym *) ((char *) mod->symtab
reltype = ELF_R_TYPE (rel->r_info); + mod->symsize * ELF_R_SYM (rel->r_info));
sym_addr = symbol[symidx].st_value; sym_addr = sym->st_value;
if (relhdr->sh_type == SHT_RELA) if (s->sh_type == SHT_RELA)
sym_addr += rela->r_addend; sym_addr += ((Elf_Rela *) rel)->r_addend;
place = (void *) ((grub_addr_t) segment->addr + rel->r_offset); place = (void *) ((grub_addr_t) seg->addr + rel->r_offset);
switch (reltype) switch (ELF_R_TYPE (rel->r_info))
{ {
case R_AARCH64_ABS64: case R_AARCH64_ABS64:
{ {
@@ -108,92 +134,32 @@ do_relX (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod)
break; break;
case R_AARCH64_CALL26: case R_AARCH64_CALL26:
case R_AARCH64_JUMP26: case R_AARCH64_JUMP26:
retval = grub_arm64_reloc_xxxx26 (place, sym_addr); {
grub_int64_t offset = sym_addr - (grub_uint64_t) place;
if (!grub_arm_64_check_xxxx26_offset (offset))
{
struct trampoline *tp = mod->trampptr;
mod->trampptr = tp + 1;
tp->ldr = LDR;
tp->br = BR;
tp->addr = sym_addr;
offset = (grub_uint8_t *) tp - (grub_uint8_t *) place;
}
if (!grub_arm_64_check_xxxx26_offset (offset))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("Trampoline out of range"));
grub_arm64_set_xxxx26_offset (place, offset);
}
break; break;
default: default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"), N_("relocation 0x%x is not implemented yet"),
reltype); ELF_R_TYPE (rel->r_info));
}
if (retval != GRUB_ERR_NONE)
break;
rel = (Elf_Rel *) ((grub_addr_t) rel + entsize);
rela++;
}
return retval;
}
/*
* Verify that provided ELF header contains reference to a symbol table
*/
static int
has_symtab (Elf_Ehdr * e)
{
int i;
Elf_Shdr *s;
for (i = 0, s = (Elf_Shdr *) ((grub_addr_t) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((grub_addr_t) s + e->e_shentsize))
if (s->sh_type == SHT_SYMTAB)
return 1;
return 0;
}
/*
* grub_arch_dl_relocate_symbols():
* Locates the relocations section of the ELF object, and calls
* do_relX() to deal with it.
*/
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
{
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
unsigned i;
if (!has_symtab (e))
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
#define FIRST_SHDR(x) ((Elf_Shdr *) ((grub_addr_t)(x) + (x)->e_shoff))
#define NEXT_SHDR(x, y) ((Elf_Shdr *) ((grub_addr_t)(y) + (x)->e_shentsize))
for (i = 0, s = FIRST_SHDR (e); i < e->e_shnum; i++, s = NEXT_SHDR (e, s))
{
grub_err_t ret;
switch (s->sh_type)
{
case SHT_REL:
case SHT_RELA:
{
ret = do_relX (s, e, mod);
if (ret != GRUB_ERR_NONE)
return ret;
}
break;
case SHT_ARM_ATTRIBUTES:
case SHT_NOBITS:
case SHT_NULL:
case SHT_PROGBITS:
case SHT_SYMTAB:
case SHT_STRTAB:
break;
default:
{
grub_dprintf ("dl", "unhandled section_type: %d (0x%08x)\n",
s->sh_type, s->sh_type);
return GRUB_ERR_NOT_IMPLEMENTED_YET;
};
} }
} }
#undef FIRST_SHDR
#undef NEXT_SHDR
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
+13 -28
View File
@@ -23,13 +23,7 @@
#include <grub/err.h> #include <grub/err.h>
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/cpu/reloc.h> #include <grub/arm64/reloc.h>
static grub_ssize_t
sign_compress_offset (grub_ssize_t offset, int bitpos)
{
return offset & ((1LL << (bitpos + 1)) - 1);
}
/* /*
* grub_arm64_reloc_xxxx26(): * grub_arm64_reloc_xxxx26():
@@ -37,34 +31,25 @@ sign_compress_offset (grub_ssize_t offset, int bitpos)
* JUMP26/CALL26 relocations for B and BL instructions. * JUMP26/CALL26 relocations for B and BL instructions.
*/ */
grub_err_t int
grub_arm64_reloc_xxxx26 (grub_uint32_t *place, Elf64_Addr adjust) grub_arm_64_check_xxxx26_offset (grub_int64_t offset)
{ {
grub_uint32_t insword, insmask;
grub_ssize_t offset;
const grub_ssize_t offset_low = -(1 << 27), offset_high = (1 << 27) - 1; const grub_ssize_t offset_low = -(1 << 27), offset_high = (1 << 27) - 1;
insword = grub_le_to_cpu32 (*place);
insmask = 0xfc000000;
offset = adjust;
#ifndef GRUB_UTIL
offset -= (grub_addr_t) place;
#endif
if ((offset < offset_low) || (offset > offset_high)) if ((offset < offset_low) || (offset > offset_high))
{ return 0;
return grub_error (GRUB_ERR_BAD_MODULE, return 1;
N_("CALL26 Relocation out of range")); }
}
void
grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset)
{
const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xfc000000);
grub_dprintf ("dl", " reloc_xxxx64 %p %c= 0x%llx\n", grub_dprintf ("dl", " reloc_xxxx64 %p %c= 0x%llx\n",
place, offset > 0 ? '+' : '-', place, offset > 0 ? '+' : '-',
offset < 0 ? (long long) -(unsigned long long) offset : offset); offset < 0 ? (long long) -(unsigned long long) offset : offset);
offset = sign_compress_offset (offset, 27) >> 2; *place &= insmask;
*place |= grub_cpu_to_le32 (offset >> 2) & ~insmask;
*place = grub_cpu_to_le32 ((insword & insmask) | offset);
return GRUB_ERR_NONE;
} }
+38 -4
View File
@@ -229,7 +229,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
unsigned i; unsigned i;
Elf_Shdr *s; Elf_Shdr *s;
grub_size_t tsize = 0, talign = 1; grub_size_t tsize = 0, talign = 1;
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__) #if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__)
grub_size_t tramp; grub_size_t tramp;
grub_size_t got; grub_size_t got;
grub_err_t err; grub_err_t err;
@@ -245,7 +245,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
talign = s->sh_addralign; talign = s->sh_addralign;
} }
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__) #if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__)
err = grub_arch_dl_get_tramp_got_size (e, &tramp, &got); err = grub_arch_dl_get_tramp_got_size (e, &tramp, &got);
if (err) if (err)
return err; return err;
@@ -314,12 +314,14 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
mod->segment = seg; mod->segment = seg;
} }
} }
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__) #if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__)
ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN); ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN);
mod->tramp = ptr; mod->tramp = ptr;
mod->trampptr = ptr;
ptr += tramp; ptr += tramp;
ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_GOT_ALIGN); ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_GOT_ALIGN);
mod->got = ptr; mod->got = ptr;
mod->gotptr = ptr;
ptr += got; ptr += got;
#endif #endif
@@ -352,6 +354,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
#else #else
mod->symtab = (Elf_Sym *) ((char *) e + s->sh_offset); mod->symtab = (Elf_Sym *) ((char *) e + s->sh_offset);
#endif #endif
mod->symsize = s->sh_entsize;
sym = mod->symtab; sym = mod->symtab;
size = s->sh_size; size = s->sh_size;
entsize = s->sh_entsize; entsize = s->sh_entsize;
@@ -561,6 +564,37 @@ grub_dl_flush_cache (grub_dl_t mod)
grub_arch_sync_caches (mod->base, mod->sz); grub_arch_sync_caches (mod->base, mod->sz);
} }
static grub_err_t
grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
{
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
unsigned i;
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_REL || s->sh_type == SHT_RELA)
{
grub_dl_segment_t seg;
grub_err_t err;
/* Find the target segment. */
for (seg = mod->segment; seg; seg = seg->next)
if (seg->section == s->sh_info)
break;
if (seg)
{
err = grub_arch_dl_relocate_symbols (mod, ehdr, s, seg);
if (err)
return err;
}
}
return GRUB_ERR_NONE;
}
/* Load a module from core memory. */ /* Load a module from core memory. */
grub_dl_t grub_dl_t
grub_dl_load_core_noinit (void *addr, grub_size_t size) grub_dl_load_core_noinit (void *addr, grub_size_t size)
@@ -607,7 +641,7 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size)
|| grub_dl_resolve_dependencies (mod, e) || grub_dl_resolve_dependencies (mod, e)
|| grub_dl_load_segments (mod, e) || grub_dl_load_segments (mod, e)
|| grub_dl_resolve_symbols (mod, e) || grub_dl_resolve_symbols (mod, e)
|| grub_arch_dl_relocate_symbols (mod, e)) || grub_dl_relocate_symbols (mod, e))
{ {
mod->fini = 0; mod->fini = 0;
grub_dl_unload (mod); grub_dl_unload (mod);
+9 -4
View File
@@ -741,12 +741,17 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
case GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE: case GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE:
{ {
grub_efi_file_path_device_path_t *fp; grub_efi_file_path_device_path_t *fp;
grub_uint8_t buf[(len - 4) * 2 + 1]; grub_uint8_t *buf;
fp = (grub_efi_file_path_device_path_t *) dp; fp = (grub_efi_file_path_device_path_t *) dp;
*grub_utf16_to_utf8 (buf, fp->path_name, buf = grub_malloc ((len - 4) * 2 + 1);
(len - 4) / sizeof (grub_efi_char16_t)) if (buf)
= '\0'; *grub_utf16_to_utf8 (buf, fp->path_name,
(len - 4) / sizeof (grub_efi_char16_t))
= '\0';
else
grub_errno = GRUB_ERR_NONE;
grub_printf ("/File(%s)", buf); grub_printf ("/File(%s)", buf);
grub_free (buf);
} }
break; break;
case GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE: case GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE:
+4 -1
View File
@@ -39,10 +39,13 @@ grub_arch_dl_check_header (void *ehdr)
} }
grub_err_t grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{ {
(void) mod; (void) mod;
(void) ehdr; (void) ehdr;
(void) s;
(void) seg;
return GRUB_ERR_BAD_MODULE; return GRUB_ERR_BAD_MODULE;
} }
+5 -2
View File
@@ -39,8 +39,9 @@ is_dir (const char *path, const char *name)
{ {
int len1 = strlen(path); int len1 = strlen(path);
int len2 = strlen(name); int len2 = strlen(name);
int ret;
char pathname[len1 + 1 + len2 + 1 + 13]; char *pathname = xmalloc (len1 + 1 + len2 + 1 + 13);
strcpy (pathname, path); strcpy (pathname, path);
/* Avoid UNC-path "//name" on Cygwin. */ /* Avoid UNC-path "//name" on Cygwin. */
@@ -49,7 +50,9 @@ is_dir (const char *path, const char *name)
strcat (pathname, name); strcat (pathname, name);
return grub_util_is_directory (pathname); ret = grub_util_is_directory (pathname);
free (pathname);
return ret;
} }
struct grub_hostfs_data struct grub_hostfs_data
+2
View File
@@ -166,6 +166,8 @@ static struct argp argp = {
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
+30 -63
View File
@@ -40,75 +40,42 @@ grub_arch_dl_check_header (void *ehdr)
/* Relocate symbols. */ /* Relocate symbols. */
grub_err_t grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{ {
Elf_Ehdr *e = ehdr; Elf_Rel *rel, *max;
Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
/* Find a symbol table. */ for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); max = (Elf_Rel *) ((char *) rel + s->sh_size);
i < e->e_shnum; rel < max;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
if (s->sh_type == SHT_SYMTAB) {
break; Elf_Word *addr;
Elf_Sym *sym;
if (i == e->e_shnum) if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table")); return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
entsize = s->sh_entsize; addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
sym = (Elf_Sym *) ((char *) mod->symtab
+ mod->symsize * ELF_R_SYM (rel->r_info));
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); switch (ELF_R_TYPE (rel->r_info))
i < e->e_shnum; {
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) case R_386_32:
if (s->sh_type == SHT_REL) *addr += sym->st_value;
{ break;
grub_dl_segment_t seg;
/* Find the target segment. */ case R_386_PC32:
for (seg = mod->segment; seg; seg = seg->next) *addr += (sym->st_value - (grub_addr_t) addr);
if (seg->section == s->sh_info) break;
break; default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
if (seg) N_("relocation 0x%x is not implemented yet"),
{ ELF_R_TYPE (rel->r_info));
Elf_Rel *rel, *max; }
}
for (rel = (Elf_Rel *) ((char *) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
rel < max;
rel++)
{
Elf_Word *addr;
Elf_Sym *sym;
if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
sym = (Elf_Sym *) ((char *) mod->symtab
+ entsize * ELF_R_SYM (rel->r_info));
switch (ELF_R_TYPE (rel->r_info))
{
case R_386_32:
*addr += sym->st_value;
break;
case R_386_PC32:
*addr += (sym->st_value - (Elf_Word) seg->addr
- rel->r_offset);
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}
}
}
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
+6 -15
View File
@@ -96,17 +96,8 @@ struct iterator_ctx
grub_size_t nresources; grub_size_t nresources;
}; };
static int /* We don't support bridges, so can't have more than 32 devices. */
count_cards (grub_pci_device_t dev __attribute__ ((unused)), #define MAX_DEVICES 32
grub_pci_id_t pciid __attribute__ ((unused)),
void *data)
{
int *cnt = data;
(*cnt)++;
return 0;
}
static int static int
find_resources (grub_pci_device_t dev, find_resources (grub_pci_device_t dev,
@@ -116,6 +107,9 @@ find_resources (grub_pci_device_t dev,
struct iterator_ctx *ctx = data; struct iterator_ctx *ctx = data;
int bar; int bar;
if (ctx->nresources >= MAX_DEVICES * 6)
return 1;
for (bar = 0; bar < 6; bar++) for (bar = 0; bar < 6; bar++)
{ {
grub_pci_address_t addr; grub_pci_address_t addr;
@@ -190,13 +184,10 @@ enable_cards (grub_pci_device_t dev,
static void static void
grub_pci_assign_addresses (void) grub_pci_assign_addresses (void)
{ {
int ncards = 0;
struct iterator_ctx ctx; struct iterator_ctx ctx;
grub_pci_iterate (count_cards, &ncards);
{ {
struct resource resources[ncards * 6]; struct resource resources[MAX_DEVICES * 6];
int done; int done;
unsigned i; unsigned i;
ctx.nresources = 0; ctx.nresources = 0;
+67 -102
View File
@@ -46,117 +46,82 @@ grub_arch_dl_check_header (void *ehdr)
/* Relocate symbols. */ /* Relocate symbols. */
grub_err_t grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{ {
Elf_Ehdr *e = ehdr; Elf_Rela *rel, *max;
Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
grub_uint64_t *gp, *gpptr;
struct grub_ia64_trampoline *tr;
gp = (grub_uint64_t *) mod->base; for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset),
gpptr = (grub_uint64_t *) mod->got; max = (Elf_Rela *) ((char *) rel + s->sh_size);
tr = mod->tramp; rel < max;
rel = (Elf_Rela *) ((char *) rel + s->sh_entsize))
{
grub_addr_t addr;
Elf_Sym *sym;
grub_uint64_t value;
/* Find a symbol table. */ if (seg->size < (rel->r_offset & ~3))
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); return grub_error (GRUB_ERR_BAD_MODULE,
i < e->e_shnum; "reloc offset is out of the segment");
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_SYMTAB)
break;
if (i == e->e_shnum) addr = (grub_addr_t) seg->addr + rel->r_offset;
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table")); sym = (Elf_Sym *) ((char *) mod->symtab
+ mod->symsize * ELF_R_SYM (rel->r_info));
entsize = s->sh_entsize; /* On the PPC the value does not have an explicit
addend, add it. */
value = sym->st_value + rel->r_addend;
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); switch (ELF_R_TYPE (rel->r_info))
i < e->e_shnum; {
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) case R_IA64_PCREL21B:
if (s->sh_type == SHT_RELA)
{
grub_dl_segment_t seg;
/* Find the target segment. */
for (seg = mod->segment; seg; seg = seg->next)
if (seg->section == s->sh_info)
break;
if (seg)
{ {
Elf_Rela *rel, *max; grub_uint64_t noff;
struct grub_ia64_trampoline *tr = mod->trampptr;
grub_ia64_make_trampoline (tr, value);
noff = ((char *) tr - (char *) (addr & ~3)) >> 4;
mod->trampptr = tr + 1;
for (rel = (Elf_Rela *) ((char *) e + s->sh_offset), if (noff & ~MASK19)
max = rel + s->sh_size / s->sh_entsize; return grub_error (GRUB_ERR_BAD_OS,
rel < max; "trampoline offset too big (%lx)", noff);
rel++) grub_ia64_add_value_to_slot_20b (addr, noff);
{
grub_addr_t addr;
Elf_Sym *sym;
grub_uint64_t value;
if (seg->size < (rel->r_offset & ~3))
return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
addr = (grub_addr_t) seg->addr + rel->r_offset;
sym = (Elf_Sym *) ((char *) mod->symtab
+ entsize * ELF_R_SYM (rel->r_info));
/* On the PPC the value does not have an explicit
addend, add it. */
value = sym->st_value + rel->r_addend;
switch (ELF_R_TYPE (rel->r_info))
{
case R_IA64_PCREL21B:
{
grub_uint64_t noff;
grub_ia64_make_trampoline (tr, value);
noff = ((char *) tr - (char *) (addr & ~3)) >> 4;
tr = (struct grub_ia64_trampoline *) ((char *) tr + GRUB_IA64_DL_TRAMP_SIZE);
if (noff & ~MASK19)
return grub_error (GRUB_ERR_BAD_OS,
"trampoline offset too big (%lx)", noff);
grub_ia64_add_value_to_slot_20b (addr, noff);
}
break;
case R_IA64_SEGREL64LSB:
*(grub_uint64_t *) addr += value - (grub_addr_t) seg->addr;
break;
case R_IA64_FPTR64LSB:
case R_IA64_DIR64LSB:
*(grub_uint64_t *) addr += value;
break;
case R_IA64_PCREL64LSB:
*(grub_uint64_t *) addr += value - addr;
break;
case R_IA64_GPREL22:
grub_ia64_add_value_to_slot_21 (addr, value - (grub_addr_t) gp);
break;
case R_IA64_LTOFF22X:
case R_IA64_LTOFF22:
if (ELF_ST_TYPE (sym->st_info) == STT_FUNC)
value = *(grub_uint64_t *) sym->st_value + rel->r_addend;
case R_IA64_LTOFF_FPTR22:
*gpptr = value;
grub_ia64_add_value_to_slot_21 (addr, (grub_addr_t) gpptr - (grub_addr_t) gp);
gpptr++;
break;
/* We treat LTOFF22X as LTOFF22, so we can ignore LDXMOV. */
case R_IA64_LDXMOV:
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}
} }
} break;
case R_IA64_SEGREL64LSB:
*(grub_uint64_t *) addr += value - (grub_addr_t) seg->addr;
break;
case R_IA64_FPTR64LSB:
case R_IA64_DIR64LSB:
*(grub_uint64_t *) addr += value;
break;
case R_IA64_PCREL64LSB:
*(grub_uint64_t *) addr += value - addr;
break;
case R_IA64_GPREL22:
grub_ia64_add_value_to_slot_21 (addr, value - (grub_addr_t) mod->base);
break;
case R_IA64_LTOFF22X:
case R_IA64_LTOFF22:
if (ELF_ST_TYPE (sym->st_info) == STT_FUNC)
value = *(grub_uint64_t *) sym->st_value + rel->r_addend;
case R_IA64_LTOFF_FPTR22:
{
grub_uint64_t *gpptr = mod->gotptr;
*gpptr = value;
grub_ia64_add_value_to_slot_21 (addr, (grub_addr_t) gpptr - (grub_addr_t) mod->base);
mod->gotptr = gpptr + 1;
break;
}
/* We treat LTOFF22X as LTOFF22, so we can ignore LDXMOV. */
case R_IA64_LDXMOV:
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
-2
View File
@@ -152,8 +152,6 @@ static const grub_uint8_t jump[0x20] =
void void
grub_ia64_make_trampoline (struct grub_ia64_trampoline *tr, grub_uint64_t addr) grub_ia64_make_trampoline (struct grub_ia64_trampoline *tr, grub_uint64_t addr)
{ {
COMPILE_TIME_ASSERT (sizeof (struct grub_ia64_trampoline)
== GRUB_IA64_DL_TRAMP_SIZE);
grub_memcpy (tr->nop, nopm, sizeof (tr->nop)); grub_memcpy (tr->nop, nopm, sizeof (tr->nop));
tr->addr_hi[0] = ((addr & 0xc00000) >> 16); tr->addr_hi[0] = ((addr & 0xc00000) >> 16);
tr->addr_hi[1] = (addr >> 24) & 0xff; tr->addr_hi[1] = (addr >> 24) & 0xff;
+145 -181
View File
@@ -58,23 +58,13 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
{ {
const Elf_Ehdr *e = ehdr; const Elf_Ehdr *e = ehdr;
const Elf_Shdr *s; const Elf_Shdr *s;
unsigned i;
/* FIXME: suboptimal. */ /* FIXME: suboptimal. */
grub_size_t gp_size = 0; grub_size_t gp_size = 0;
unsigned i;
*tramp = 0; *tramp = 0;
*got = 0; *got = 0;
/* Find a symbol table. */
for (i = 0, s = (const Elf_Shdr *) ((const char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (const Elf_Shdr *) ((const char *) s + e->e_shentsize))
if (s->sh_type == SHT_SYMTAB)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
for (i = 0, s = (const Elf_Shdr *) ((const char *) e + e->e_shoff); for (i = 0, s = (const Elf_Shdr *) ((const char *) e + e->e_shoff);
i < e->e_shnum; i < e->e_shnum;
i++, s = (const Elf_Shdr *) ((const char *) s + e->e_shentsize)) i++, s = (const Elf_Shdr *) ((const char *) s + e->e_shentsize))
@@ -106,192 +96,166 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
/* Relocate symbols. */ /* Relocate symbols. */
grub_err_t grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{ {
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
/* FIXME: suboptimal. */
grub_uint32_t *gp, *gpptr;
grub_uint32_t gp0; grub_uint32_t gp0;
Elf_Ehdr *e = ehdr;
/* Find a symbol table. */ if (!mod->reginfo)
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); {
i < e->e_shnum; unsigned i;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) Elf_Shdr *ri;
if (s->sh_type == SHT_SYMTAB)
break;
if (i == e->e_shnum) /* Find reginfo. */
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table")); for (i = 0, ri = (Elf_Shdr *) ((char *) ehdr + e->e_shoff);
i < e->e_shnum;
i++, ri = (Elf_Shdr *) ((char *) ri + e->e_shentsize))
if (ri->sh_type == SHT_MIPS_REGINFO)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no reginfo found");
mod->reginfo = (grub_uint32_t *)((char *) ehdr + ri->sh_offset);
}
entsize = s->sh_entsize; gp0 = mod->reginfo[5];
Elf_Rel *rel, *max;
/* Find reginfo. */ for (rel = (Elf_Rel *) ((char *) e + s->sh_offset),
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); max = (Elf_Rel *) ((char *) rel + s->sh_size);
i < e->e_shnum; rel < max;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
if (s->sh_type == SHT_MIPS_REGINFO) {
break; grub_uint8_t *addr;
Elf_Sym *sym;
grub_uint32_t sym_value;
if (i == e->e_shnum) if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE, "no reginfo found"); return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
gp0 = ((grub_uint32_t *)((char *) e + s->sh_offset))[5]; addr = (grub_uint8_t *) ((char *) seg->addr + rel->r_offset);
sym = (Elf_Sym *) ((char *) mod->symtab
gpptr = gp = mod->got; + mod->symsize * ELF_R_SYM (rel->r_info));
sym_value = sym->st_value;
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); if (sym_value == (grub_addr_t) &__gnu_local_gp_dummy)
i < e->e_shnum; sym_value = (grub_addr_t) mod->got;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) else if (sym_value == (grub_addr_t) &_gp_disp_dummy)
if (s->sh_type == SHT_REL) {
{ sym_value = (grub_addr_t) mod->got - (grub_addr_t) addr;
grub_dl_segment_t seg; if (ELF_R_TYPE (rel->r_info) == R_MIPS_LO16)
/* ABI mandates +4 even if partner lui doesn't
/* Find the target segment. */ immediately precede addiu. */
for (seg = mod->segment; seg; seg = seg->next) sym_value += 4;
if (seg->section == s->sh_info) }
break; switch (ELF_R_TYPE (rel->r_info))
{
if (seg) case R_MIPS_HI16:
{ {
Elf_Rel *rel, *max; grub_uint32_t value;
Elf_Rel *rel2;
for (rel = (Elf_Rel *) ((char *) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
rel < max;
rel++)
{
grub_uint8_t *addr;
Elf_Sym *sym;
grub_uint32_t sym_value;
if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
addr = (grub_uint8_t *) ((char *) seg->addr + rel->r_offset);
sym = (Elf_Sym *) ((char *) mod->symtab
+ entsize * ELF_R_SYM (rel->r_info));
sym_value = sym->st_value;
if (sym_value == (grub_addr_t) &__gnu_local_gp_dummy)
sym_value = (grub_addr_t) gp;
else if (sym_value == (grub_addr_t) &_gp_disp_dummy)
{
sym_value = (grub_addr_t) gp - (grub_addr_t) addr;
if (ELF_R_TYPE (rel->r_info) == R_MIPS_LO16)
/* ABI mandates +4 even if partner lui doesn't
immediately precede addiu. */
sym_value += 4;
}
switch (ELF_R_TYPE (rel->r_info))
{
case R_MIPS_HI16:
{
grub_uint32_t value;
Elf_Rel *rel2;
#ifdef GRUB_CPU_WORDS_BIGENDIAN #ifdef GRUB_CPU_WORDS_BIGENDIAN
addr += 2; addr += 2;
#endif #endif
/* Handle partner lo16 relocation. Lower part is /* Handle partner lo16 relocation. Lower part is
treated as signed. Hence add 0x8000 to compensate. treated as signed. Hence add 0x8000 to compensate.
*/ */
value = (*(grub_uint16_t *) addr << 16) value = (*(grub_uint16_t *) addr << 16)
+ sym_value + 0x8000; + sym_value + 0x8000;
for (rel2 = rel + 1; rel2 < max; rel2++) for (rel2 = rel + 1; rel2 < max; rel2++)
if (ELF_R_SYM (rel2->r_info) if (ELF_R_SYM (rel2->r_info)
== ELF_R_SYM (rel->r_info) == ELF_R_SYM (rel->r_info)
&& ELF_R_TYPE (rel2->r_info) == R_MIPS_LO16) && ELF_R_TYPE (rel2->r_info) == R_MIPS_LO16)
{ {
value += *(grub_int16_t *) value += *(grub_int16_t *)
((char *) seg->addr + rel2->r_offset ((char *) seg->addr + rel2->r_offset
#ifdef GRUB_CPU_WORDS_BIGENDIAN #ifdef GRUB_CPU_WORDS_BIGENDIAN
+ 2 + 2
#endif #endif
); );
break; break;
} }
*(grub_uint16_t *) addr = (value >> 16) & 0xffff; *(grub_uint16_t *) addr = (value >> 16) & 0xffff;
}
break;
case R_MIPS_LO16:
#ifdef GRUB_CPU_WORDS_BIGENDIAN
addr += 2;
#endif
*(grub_uint16_t *) addr += sym_value & 0xffff;
break;
case R_MIPS_32:
*(grub_uint32_t *) addr += sym_value;
break;
case R_MIPS_GPREL32:
*(grub_uint32_t *) addr = sym_value
+ *(grub_uint32_t *) addr + gp0 - (grub_uint32_t)gp;
break;
case R_MIPS_26:
{
grub_uint32_t value;
grub_uint32_t raw;
raw = (*(grub_uint32_t *) addr) & 0x3ffffff;
value = raw << 2;
value += sym_value;
raw = (value >> 2) & 0x3ffffff;
*(grub_uint32_t *) addr =
raw | ((*(grub_uint32_t *) addr) & 0xfc000000);
}
break;
case R_MIPS_GOT16:
if (ELF_ST_BIND (sym->st_info) == STB_LOCAL)
{
Elf_Rel *rel2;
/* Handle partner lo16 relocation. Lower part is
treated as signed. Hence add 0x8000 to compensate.
*/
sym_value += (*(grub_uint16_t *) addr << 16)
+ 0x8000;
for (rel2 = rel + 1; rel2 < max; rel2++)
if (ELF_R_SYM (rel2->r_info)
== ELF_R_SYM (rel->r_info)
&& ELF_R_TYPE (rel2->r_info) == R_MIPS_LO16)
{
sym_value += *(grub_int16_t *)
((char *) seg->addr + rel2->r_offset
#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ 2
#endif
);
break;
}
sym_value &= 0xffff0000;
*(grub_uint16_t *) addr = 0;
}
case R_MIPS_CALL16:
/* FIXME: reuse*/
#ifdef GRUB_CPU_WORDS_BIGENDIAN
addr += 2;
#endif
*gpptr = sym_value + *(grub_uint16_t *) addr;
*(grub_uint16_t *) addr
= sizeof (grub_uint32_t) * (gpptr - gp);
gpptr++;
break;
case R_MIPS_JALR:
break;
default:
{
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
break;
}
}
} }
} break;
case R_MIPS_LO16:
#ifdef GRUB_CPU_WORDS_BIGENDIAN
addr += 2;
#endif
*(grub_uint16_t *) addr += sym_value & 0xffff;
break;
case R_MIPS_32:
*(grub_uint32_t *) addr += sym_value;
break;
case R_MIPS_GPREL32:
*(grub_uint32_t *) addr = sym_value
+ *(grub_uint32_t *) addr + gp0 - (grub_uint32_t)mod->got;
break;
case R_MIPS_26:
{
grub_uint32_t value;
grub_uint32_t raw;
raw = (*(grub_uint32_t *) addr) & 0x3ffffff;
value = raw << 2;
value += sym_value;
raw = (value >> 2) & 0x3ffffff;
*(grub_uint32_t *) addr =
raw | ((*(grub_uint32_t *) addr) & 0xfc000000);
}
break;
case R_MIPS_GOT16:
if (ELF_ST_BIND (sym->st_info) == STB_LOCAL)
{
Elf_Rel *rel2;
/* Handle partner lo16 relocation. Lower part is
treated as signed. Hence add 0x8000 to compensate.
*/
sym_value += (*(grub_uint16_t *) addr << 16)
+ 0x8000;
for (rel2 = rel + 1; rel2 < max; rel2++)
if (ELF_R_SYM (rel2->r_info)
== ELF_R_SYM (rel->r_info)
&& ELF_R_TYPE (rel2->r_info) == R_MIPS_LO16)
{
sym_value += *(grub_int16_t *)
((char *) seg->addr + rel2->r_offset
#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ 2
#endif
);
break;
}
sym_value &= 0xffff0000;
*(grub_uint16_t *) addr = 0;
}
case R_MIPS_CALL16:
{
grub_uint32_t *gpptr = mod->gotptr;
/* FIXME: reuse*/
#ifdef GRUB_CPU_WORDS_BIGENDIAN
addr += 2;
#endif
*gpptr = sym_value + *(grub_uint16_t *) addr;
*(grub_uint16_t *) addr
= sizeof (grub_uint32_t) * (gpptr - (grub_uint32_t *) mod->got);
mod->gotptr = gpptr + 1;
break;
}
case R_MIPS_JALR:
break;
default:
{
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
break;
}
}
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
+168 -126
View File
@@ -25,8 +25,39 @@
#include <grub/env.h> #include <grub/env.h>
#include <grub/i18n.h> #include <grub/i18n.h>
union printf_arg
{
/* Yes, type is also part of union as the moment we fill the value
we don't need to store its type anymore (when we'll need it, we'll
have format spec again. So save some space. */
enum
{
INT, LONG, LONGLONG,
UNSIGNED_INT = 3, UNSIGNED_LONG, UNSIGNED_LONGLONG
} type;
long long ll;
};
struct printf_args
{
union printf_arg prealloc[32];
union printf_arg *ptr;
grub_size_t count;
};
static void
parse_printf_args (const char *fmt0, struct printf_args *args,
va_list args_in);
static int static int
grub_vsnprintf_real (char *str, grub_size_t n, const char *fmt, va_list args); grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
struct printf_args *args);
static void
free_printf_args (struct printf_args *args)
{
if (args->ptr != args->prealloc)
grub_free (args->ptr);
}
static int static int
grub_iswordseparator (int c) grub_iswordseparator (int c)
@@ -169,15 +200,16 @@ grub_real_dprintf (const char *file, const int line, const char *condition,
#define PREALLOC_SIZE 255 #define PREALLOC_SIZE 255
int int
grub_vprintf (const char *fmt, va_list args) grub_vprintf (const char *fmt, va_list ap)
{ {
grub_size_t s; grub_size_t s;
static char buf[PREALLOC_SIZE + 1]; static char buf[PREALLOC_SIZE + 1];
char *curbuf = buf; char *curbuf = buf;
va_list ap2; struct printf_args args;
va_copy (ap2, args);
s = grub_vsnprintf_real (buf, PREALLOC_SIZE, fmt, args); parse_printf_args (fmt, &args, ap);
s = grub_vsnprintf_real (buf, PREALLOC_SIZE, fmt, &args);
if (s > PREALLOC_SIZE) if (s > PREALLOC_SIZE)
{ {
curbuf = grub_malloc (s + 1); curbuf = grub_malloc (s + 1);
@@ -191,10 +223,10 @@ grub_vprintf (const char *fmt, va_list args)
curbuf = buf; curbuf = buf;
} }
else else
s = grub_vsnprintf_real (curbuf, s, fmt, ap2); s = grub_vsnprintf_real (curbuf, s, fmt, &args);
} }
va_end (ap2); free_printf_args (&args);
grub_xputs (curbuf); grub_xputs (curbuf);
@@ -724,7 +756,7 @@ __umoddi3 (grub_uint64_t a, grub_uint64_t b)
/* Convert a long long value to a string. This function avoids 64-bit /* Convert a long long value to a string. This function avoids 64-bit
modular arithmetic or divisions. */ modular arithmetic or divisions. */
static char * static inline char *
grub_lltoa (char *str, int c, unsigned long long n) grub_lltoa (char *str, int c, unsigned long long n)
{ {
unsigned base = (c == 'x') ? 16 : 10; unsigned base = (c == 'x') ? 16 : 10;
@@ -762,39 +794,21 @@ grub_lltoa (char *str, int c, unsigned long long n)
return p; return p;
} }
static inline void static void
write_char (char *str, grub_size_t *count, grub_size_t max_len, unsigned char ch) parse_printf_args (const char *fmt0, struct printf_args *args,
{ va_list args_in)
if (*count < max_len)
str[*count] = ch;
(*count)++;
}
static inline void
write_str (char *str, grub_size_t *count, grub_size_t max_len, const char *s)
{
while (*s)
write_char (str, count, max_len, *s++);
}
static inline void
write_fill (char *str, grub_size_t *count, grub_size_t max_len, const char ch, int count_fill)
{
int i;
for (i = 0; i < count_fill; i++)
write_char (str, count, max_len, ch);
}
static int
grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list args_in)
{ {
const char *fmt;
char c; char c;
grub_size_t n = 0; grub_size_t n = 0;
grub_size_t count = 0;
grub_size_t count_args = 0; args->count = 0;
const char *fmt;
COMPILE_TIME_ASSERT (sizeof (int) == sizeof (grub_uint32_t));
COMPILE_TIME_ASSERT (sizeof (int) <= sizeof (long long));
COMPILE_TIME_ASSERT (sizeof (long) <= sizeof (long long));
COMPILE_TIME_ASSERT (sizeof (long long) == sizeof (void *)
|| sizeof (int) == sizeof (void *));
fmt = fmt0; fmt = fmt0;
while ((c = *fmt++) != 0) while ((c = *fmt++) != 0)
@@ -838,30 +852,31 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
case 'c': case 'c':
case 'C': case 'C':
case 's': case 's':
count_args++; args->count++;
break; break;
} }
} }
enum { INT, LONG, LONGLONG, POINTER } types[count_args]; if (args->count <= ARRAY_SIZE (args->prealloc))
union args->ptr = args->prealloc;
{ else
int i; {
long l; args->ptr = grub_malloc (args->count * sizeof (args->ptr[0]));
long long ll; if (!args->ptr)
void *p; {
} args[count_args]; grub_errno = GRUB_ERR_NONE;
args->ptr = args->prealloc;
args->count = ARRAY_SIZE (args->prealloc);
}
}
COMPILE_TIME_ASSERT (sizeof (int) == sizeof (grub_uint32_t)); grub_memset (args->ptr, 0, args->count * sizeof (args->ptr[0]));
grub_memset (types, 0, sizeof (types));
fmt = fmt0; fmt = fmt0;
n = 0; n = 0;
while ((c = *fmt++) != 0) while ((c = *fmt++) != 0)
{ {
int longfmt = 0; int longfmt = 0;
int longlongfmt = 0;
grub_size_t curn; grub_size_t curn;
const char *p; const char *p;
@@ -901,67 +916,85 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
{ {
c = *fmt++; c = *fmt++;
longfmt = 1; longfmt = 1;
if (c == 'l')
{
c = *fmt++;
longlongfmt = 1;
}
} }
if (curn >= count_args) if (c == 'l')
{
c = *fmt++;
longfmt = 2;
}
if (curn >= args->count)
continue; continue;
switch (c) switch (c)
{ {
case 'x': case 'x':
case 'u': case 'u':
args->ptr[curn].type = UNSIGNED_INT + longfmt;
break;
case 'd': case 'd':
if (longlongfmt) args->ptr[curn].type = INT + longfmt;
types[curn] = LONGLONG;
else if (longfmt)
types[curn] = LONG;
else
types[curn] = INT;
break; break;
case 'p': case 'p':
case 's': case 's':
types[curn] = POINTER; if (sizeof (void *) == sizeof (long long))
args->ptr[curn].type = UNSIGNED_LONGLONG;
else
args->ptr[curn].type = UNSIGNED_INT;
break; break;
case 'C': case 'C':
case 'c': case 'c':
types[curn] = INT; args->ptr[curn].type = INT;
break; break;
} }
} }
for (n = 0; n < count_args; n++) for (n = 0; n < args->count; n++)
switch (types[n]) switch (args->ptr[n].type)
{ {
case POINTER:
args[n].p = va_arg (args_in, void *);
break;
case INT: case INT:
args[n].i = va_arg (args_in, int); args->ptr[n].ll = va_arg (args_in, int);
break; break;
case LONG: case LONG:
args[n].l = va_arg (args_in, long); args->ptr[n].ll = va_arg (args_in, long);
break;
case UNSIGNED_INT:
args->ptr[n].ll = va_arg (args_in, unsigned int);
break;
case UNSIGNED_LONG:
args->ptr[n].ll = va_arg (args_in, unsigned long);
break; break;
case LONGLONG: case LONGLONG:
args[n].ll = va_arg (args_in, long long); case UNSIGNED_LONGLONG:
args->ptr[n].ll = va_arg (args_in, long long);
break; break;
} }
}
static inline void __attribute__ ((always_inline))
write_char (char *str, grub_size_t *count, grub_size_t max_len, unsigned char ch)
{
if (*count < max_len)
str[*count] = ch;
(*count)++;
}
static int
grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
struct printf_args *args)
{
char c;
grub_size_t n = 0;
grub_size_t count = 0;
const char *fmt;
fmt = fmt0; fmt = fmt0;
n = 0;
while ((c = *fmt++) != 0) while ((c = *fmt++) != 0)
{ {
char tmp[32];
unsigned int format1 = 0; unsigned int format1 = 0;
unsigned int format2 = ~ 0U; unsigned int format2 = ~ 0U;
char zerofill = ' '; char zerofill = ' ';
int rightfill = 0; char rightfill = 0;
int longfmt = 0;
int longlongfmt = 0;
int unsig = 0;
grub_size_t curn; grub_size_t curn;
if (c != '%') if (c != '%')
@@ -1008,15 +1041,9 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
c = *fmt++; c = *fmt++;
if (c == 'l') if (c == 'l')
{ c = *fmt++;
longfmt = 1; if (c == 'l')
c = *fmt++; c = *fmt++;
if (c == 'l')
{
longlongfmt = 1;
c = *fmt++;
}
}
if (c == '%') if (c == '%')
{ {
@@ -1024,45 +1051,47 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
continue; continue;
} }
if (curn >= count_args) if (curn >= args->count)
continue; continue;
long long curarg = args->ptr[curn].ll;
switch (c) switch (c)
{ {
case 'p': case 'p':
write_str (str, &count, max_len, "0x"); write_char (str, &count, max_len, '0');
write_char (str, &count, max_len, 'x');
c = 'x'; c = 'x';
longlongfmt |= (sizeof (void *) == sizeof (long long));
/* Fall through. */ /* Fall through. */
case 'x': case 'x':
case 'u': case 'u':
unsig = 1;
/* Fall through. */
case 'd': case 'd':
if (longlongfmt) {
grub_lltoa (tmp, c, args[curn].ll); char tmp[32];
else if (longfmt && unsig) const char *p = tmp;
grub_lltoa (tmp, c, (unsigned long) args[curn].l); grub_size_t len;
else if (longfmt) grub_size_t fill;
grub_lltoa (tmp, c, args[curn].l);
else if (unsig) len = grub_lltoa (tmp, c, curarg) - tmp;
grub_lltoa (tmp, c, (unsigned) args[curn].i); fill = len < format1 ? format1 - len : 0;
else if (! rightfill)
grub_lltoa (tmp, c, args[curn].i); while (fill--)
if (! rightfill && grub_strlen (tmp) < format1) write_char (str, &count, max_len, zerofill);
write_fill (str, &count, max_len, zerofill, format1 - grub_strlen (tmp)); while (*p)
write_str (str, &count, max_len, tmp); write_char (str, &count, max_len, *p++);
if (rightfill && grub_strlen (tmp) < format1) if (rightfill)
write_fill (str, &count, max_len, zerofill, format1 - grub_strlen (tmp)); while (fill--)
write_char (str, &count, max_len, zerofill);
}
break; break;
case 'c': case 'c':
write_char (str, &count, max_len,args[curn].i & 0xff); write_char (str, &count, max_len,curarg & 0xff);
break; break;
case 'C': case 'C':
{ {
grub_uint32_t code = args[curn].i; grub_uint32_t code = curarg;
int shift; int shift;
unsigned mask; unsigned mask;
@@ -1103,20 +1132,25 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
case 's': case 's':
{ {
grub_size_t len = 0; grub_size_t len = 0;
const char *p = args[curn].p ? : "(null)"; grub_size_t fill;
const char *p = ((char *) (grub_addr_t) curarg) ? : "(null)";
grub_size_t i;
while (len < format2 && p[len]) while (len < format2 && p[len])
len++; len++;
if (!rightfill && len < format1) fill = len < format1 ? format1 - len : 0;
write_fill (str, &count, max_len, zerofill, format1 - len);
if (!rightfill)
while (fill--)
write_char (str, &count, max_len, zerofill);
grub_size_t i;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
write_char (str, &count, max_len,*p++); write_char (str, &count, max_len,*p++);
if (rightfill && len < format1) if (rightfill)
write_fill (str, &count, max_len, zerofill, format1 - len); while (fill--)
write_char (str, &count, max_len, zerofill);
} }
break; break;
@@ -1131,7 +1165,6 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
str[count] = '\0'; str[count] = '\0';
else else
str[max_len] = '\0'; str[max_len] = '\0';
return count; return count;
} }
@@ -1139,13 +1172,18 @@ int
grub_vsnprintf (char *str, grub_size_t n, const char *fmt, va_list ap) grub_vsnprintf (char *str, grub_size_t n, const char *fmt, va_list ap)
{ {
grub_size_t ret; grub_size_t ret;
struct printf_args args;
if (!n) if (!n)
return 0; return 0;
n--; n--;
ret = grub_vsnprintf_real (str, n, fmt, ap); parse_printf_args (fmt, &args, ap);
ret = grub_vsnprintf_real (str, n, fmt, &args);
free_printf_args (&args);
return ret < n ? ret : n; return ret < n ? ret : n;
} }
@@ -1168,22 +1206,26 @@ grub_xvasprintf (const char *fmt, va_list ap)
{ {
grub_size_t s, as = PREALLOC_SIZE; grub_size_t s, as = PREALLOC_SIZE;
char *ret; char *ret;
struct printf_args args;
parse_printf_args (fmt, &args, ap);
while (1) while (1)
{ {
va_list ap2;
ret = grub_malloc (as + 1); ret = grub_malloc (as + 1);
if (!ret) if (!ret)
return NULL; {
free_printf_args (&args);
return NULL;
}
va_copy (ap2, ap); s = grub_vsnprintf_real (ret, as, fmt, &args);
s = grub_vsnprintf_real (ret, as, fmt, ap2);
va_end (ap2);
if (s <= as) if (s <= as)
return ret; {
free_printf_args (&args);
return ret;
}
grub_free (ret); grub_free (ret);
as = s; as = s;
+60 -92
View File
@@ -101,109 +101,77 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
/* Relocate symbols. */ /* Relocate symbols. */
grub_err_t grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{ {
Elf_Ehdr *e = ehdr; Elf_Rela *rel, *max;
Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
struct trampoline *tptr = mod->tramp;
/* Find a symbol table. */ for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset),
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); max = (Elf_Rela *) ((char *) rel + s->sh_size);
i < e->e_shnum; rel < max;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) rel = (Elf_Rela *) ((char *) rel + s->sh_entsize))
if (s->sh_type == SHT_SYMTAB) {
break; Elf_Word *addr;
Elf_Sym *sym;
grub_uint32_t value;
if (i == e->e_shnum) if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table")); return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
entsize = s->sh_entsize; addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
sym = (Elf_Sym *) ((char *) mod->symtab
+ mod->symsize * ELF_R_SYM (rel->r_info));
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); /* On the PPC the value does not have an explicit
i < e->e_shnum; addend, add it. */
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) value = sym->st_value + rel->r_addend;
if (s->sh_type == SHT_RELA) switch (ELF_R_TYPE (rel->r_info))
{ {
grub_dl_segment_t seg; case GRUB_ELF_R_PPC_ADDR16_LO:
*(Elf_Half *) addr = value;
break;
/* Find the target segment. */ case GRUB_ELF_R_PPC_REL24:
for (seg = mod->segment; seg; seg = seg->next)
if (seg->section == s->sh_info)
break;
if (seg)
{ {
Elf_Rela *rel, *max; Elf_Sword delta = value - (Elf_Word) addr;
for (rel = (Elf_Rela *) ((char *) e + s->sh_offset), if (delta << 6 >> 6 != delta)
max = rel + s->sh_size / s->sh_entsize;
rel < max;
rel++)
{ {
Elf_Word *addr; struct trampoline *tptr = mod->trampptr;
Elf_Sym *sym; grub_memcpy (tptr, &trampoline_template,
grub_uint32_t value; sizeof (*tptr));
delta = (grub_uint8_t *) tptr - (grub_uint8_t *) addr;
if (seg->size < rel->r_offset) tptr->lis |= (((value) >> 16) & 0xffff);
return grub_error (GRUB_ERR_BAD_MODULE, tptr->ori |= ((value) & 0xffff);
"reloc offset is out of the segment"); mod->trampptr = tptr + 1;
addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
sym = (Elf_Sym *) ((char *) mod->symtab
+ entsize * ELF_R_SYM (rel->r_info));
/* On the PPC the value does not have an explicit
addend, add it. */
value = sym->st_value + rel->r_addend;
switch (ELF_R_TYPE (rel->r_info))
{
case GRUB_ELF_R_PPC_ADDR16_LO:
*(Elf_Half *) addr = value;
break;
case GRUB_ELF_R_PPC_REL24:
{
Elf_Sword delta = value - (Elf_Word) addr;
if (delta << 6 >> 6 != delta)
{
grub_memcpy (tptr, &trampoline_template,
sizeof (*tptr));
delta = (grub_uint8_t *) tptr - (grub_uint8_t *) addr;
tptr->lis |= (((value) >> 16) & 0xffff);
tptr->ori |= ((value) & 0xffff);
tptr++;
}
if (delta << 6 >> 6 != delta)
return grub_error (GRUB_ERR_BAD_MODULE,
"relocation overflow");
*addr = (*addr & 0xfc000003) | (delta & 0x3fffffc);
break;
}
case GRUB_ELF_R_PPC_ADDR16_HA:
*(Elf_Half *) addr = (value + 0x8000) >> 16;
break;
case GRUB_ELF_R_PPC_ADDR32:
*addr = value;
break;
case GRUB_ELF_R_PPC_REL32:
*addr = value - (Elf_Word) addr;
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
} }
if (delta << 6 >> 6 != delta)
return grub_error (GRUB_ERR_BAD_MODULE,
"relocation overflow");
*addr = (*addr & 0xfc000003) | (delta & 0x3fffffc);
break;
} }
}
case GRUB_ELF_R_PPC_ADDR16_HA:
*(Elf_Half *) addr = (value + 0x8000) >> 16;
break;
case GRUB_ELF_R_PPC_ADDR32:
*addr = value;
break;
case GRUB_ELF_R_PPC_REL32:
*addr = value - (Elf_Word) addr;
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
+63 -95
View File
@@ -42,106 +42,74 @@ grub_arch_dl_check_header (void *ehdr)
/* Relocate symbols. */ /* Relocate symbols. */
grub_err_t grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{ {
Elf_Ehdr *e = ehdr; Elf_Rela *rel, *max;
Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
/* Find a symbol table. */ for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset),
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); max = (Elf_Rela *) ((char *) rel + s->sh_size);
i < e->e_shnum; rel < max;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) rel = (Elf_Rela *) ((char *) rel + s->sh_entsize))
if (s->sh_type == SHT_SYMTAB) {
break; Elf_Word *addr;
Elf_Sym *sym;
Elf_Addr value;
if (i == e->e_shnum) if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table")); return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
entsize = s->sh_entsize; addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
sym = (Elf_Sym *) ((char *) mod->symtab
+ mod->symsize * ELF_R_SYM (rel->r_info));
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); value = sym->st_value + rel->r_addend;
i < e->e_shnum; switch (ELF_R_TYPE (rel->r_info) & 0xff)
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) {
if (s->sh_type == SHT_RELA) case R_SPARC_32: /* 3 V-word32 */
{ if (value & 0xFFFFFFFF00000000)
grub_dl_segment_t seg; return grub_error (GRUB_ERR_BAD_MODULE,
"address out of 32 bits range");
/* Find the target segment. */ *addr = value;
for (seg = mod->segment; seg; seg = seg->next) break;
if (seg->section == s->sh_info) case R_SPARC_WDISP30: /* 7 V-disp30 */
break; if (((value - (Elf_Addr) addr) & 0xFFFFFFFF00000000) &&
(((value - (Elf_Addr) addr) & 0xFFFFFFFF00000000)
if (seg) != 0xFFFFFFFF00000000))
{ return grub_error (GRUB_ERR_BAD_MODULE,
Elf_Rela *rel, *max; "displacement out of 30 bits range");
*addr = (*addr & 0xC0000000) |
for (rel = (Elf_Rela *) ((char *) e + s->sh_offset), (((grub_int32_t) ((value - (Elf_Addr) addr) >> 2)) &
max = rel + s->sh_size / s->sh_entsize; 0x3FFFFFFF);
rel < max; break;
rel++) case R_SPARC_HH22: /* 9 V-imm22 */
{ *addr = (*addr & 0xFFC00000) | ((value >> 42) & 0x3FFFFF);
Elf_Word *addr; break;
Elf_Sym *sym; case R_SPARC_HM10: /* 12 T-simm13 */
Elf_Addr value; *addr = (*addr & 0xFFFFFC00) | ((value >> 32) & 0x3FF);
break;
if (seg->size < rel->r_offset) case R_SPARC_HI22: /* 9 V-imm22 */
return grub_error (GRUB_ERR_BAD_MODULE, *addr = (*addr & 0xFFC00000) | ((value >> 10) & 0x3FFFFF);
"reloc offset is out of the segment"); break;
case R_SPARC_LO10: /* 12 T-simm13 */
addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset); *addr = (*addr & 0xFFFFFC00) | (value & 0x3FF);
sym = (Elf_Sym *) ((char *) mod->symtab break;
+ entsize * ELF_R_SYM (rel->r_info)); case R_SPARC_64: /* 32 V-xwords64 */
*(Elf_Xword *) addr = value;
value = sym->st_value + rel->r_addend; break;
switch (ELF_R_TYPE (rel->r_info) & 0xff) case R_SPARC_OLO10:
{ *addr = (*addr & ~0x1fff)
case R_SPARC_32: /* 3 V-word32 */ | (((value & 0x3ff) +
if (value & 0xFFFFFFFF00000000) (ELF_R_TYPE (rel->r_info) >> 8))
return grub_error (GRUB_ERR_BAD_MODULE, & 0x1fff);
"address out of 32 bits range"); break;
*addr = value; default:
break; return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
case R_SPARC_WDISP30: /* 7 V-disp30 */ N_("relocation 0x%x is not implemented yet"),
if (((value - (Elf_Addr) addr) & 0xFFFFFFFF00000000) && ELF_R_TYPE (rel->r_info));
(((value - (Elf_Addr) addr) & 0xFFFFFFFF00000000) }
!= 0xFFFFFFFF00000000)) }
return grub_error (GRUB_ERR_BAD_MODULE,
"displacement out of 30 bits range");
*addr = (*addr & 0xC0000000) |
(((grub_int32_t) ((value - (Elf_Addr) addr) >> 2)) &
0x3FFFFFFF);
break;
case R_SPARC_HH22: /* 9 V-imm22 */
*addr = (*addr & 0xFFC00000) | ((value >> 42) & 0x3FFFFF);
break;
case R_SPARC_HM10: /* 12 T-simm13 */
*addr = (*addr & 0xFFFFFC00) | ((value >> 32) & 0x3FF);
break;
case R_SPARC_HI22: /* 9 V-imm22 */
*addr = (*addr & 0xFFC00000) | ((value >> 10) & 0x3FFFFF);
break;
case R_SPARC_LO10: /* 12 T-simm13 */
*addr = (*addr & 0xFFFFFC00) | (value & 0x3FF);
break;
case R_SPARC_64: /* 32 V-xwords64 */
*(Elf_Xword *) addr = value;
break;
case R_SPARC_OLO10:
*addr = (*addr & ~0x1fff)
| (((value & 0x3ff) +
(ELF_R_TYPE (rel->r_info) >> 8))
& 0x1fff);
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}
}
}
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
+28 -6
View File
@@ -36,10 +36,14 @@ codestart:
/* Copy the modules past the end of the kernel image. /* Copy the modules past the end of the kernel image.
* They are currently sitting in the BSS. * They are currently sitting in the BSS.
*/ */
sethi %hi(__bss_start), %o2 sethi %hi(__bss_start + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o2
or %o2, %lo(__bss_start), %o2 or %o2, %lo(__bss_start + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o2
sethi %hi(_end), %o3 srl %o2, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o2
or %o3, %lo(_end), %o3 sll %o2, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o2
sethi %hi(_end + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o3
or %o3, %lo(_end + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o3
srl %o3, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o3
sll %o3, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o3
sethi %hi(grub_total_module_size), %o4 sethi %hi(grub_total_module_size), %o4
lduw [%o4 + %lo(grub_total_module_size)], %o4 lduw [%o4 + %lo(grub_total_module_size)], %o4
@@ -67,16 +71,34 @@ codestart:
/* Now it's safe to clear out the BSS. */ /* Now it's safe to clear out the BSS. */
sethi %hi(__bss_start), %o2 sethi %hi(__bss_start), %o2
or %o2, %lo(__bss_start), %o2 or %o2, %lo(__bss_start), %o2
sethi %hi(_end), %o3 1: stb %g0, [%o2]
or %o3, %lo(_end), %o3 add %o2, 1, %o2
and %o2, 7, %o3
brnz %o3, 1b
nop
sethi %hi(_end - 1), %o3
or %o3, %lo(_end - 1), %o3
srl %o3, 3, %o3
sll %o3, 3, %o3
1: stx %g0, [%o2] 1: stx %g0, [%o2]
add %o2, 8, %o2 add %o2, 8, %o2
cmp %o2, %o3 cmp %o2, %o3
blt,pt %xcc, 1b blt,pt %xcc, 1b
nop nop
sethi %hi(_end), %o3
or %o3, %lo(_end), %o3
1: stb %g0, [%o2]
add %o2, 1, %o2
cmp %o2, %o3
blt,pt %xcc, 1b
nop
sethi %hi(grub_ieee1275_original_stack), %o2 sethi %hi(grub_ieee1275_original_stack), %o2
stx %o1, [%o2 + %lo(grub_ieee1275_original_stack)] stx %o1, [%o2 + %lo(grub_ieee1275_original_stack)]
sethi %hi(grub_ieee1275_entry_fn), %o2 sethi %hi(grub_ieee1275_entry_fn), %o2
call grub_main call grub_main
stx %o0, [%o2 + %lo(grub_ieee1275_entry_fn)] stx %o0, [%o2 + %lo(grub_ieee1275_entry_fn)]
1: ba,a 1b 1: ba,a 1b
nop
+7 -1
View File
@@ -61,7 +61,13 @@ grub_uboot_get_boot_data (void)
static grub_uint64_t static grub_uint64_t
uboot_timer_ms (void) uboot_timer_ms (void)
{ {
return (grub_uint64_t) grub_uboot_get_timer (timer_start) / 1000; static grub_uint32_t last = 0, high = 0;
grub_uint32_t cur = grub_uboot_get_timer (timer_start);
if (cur < last)
high++;
last = cur;
return grub_divmod64 ((((grub_uint64_t) high) << 32) | cur,
1000, 0);
} }
void void
+55 -87
View File
@@ -40,101 +40,69 @@ grub_arch_dl_check_header (void *ehdr)
/* Relocate symbols. */ /* Relocate symbols. */
grub_err_t grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{ {
Elf64_Ehdr *e = ehdr; Elf64_Rela *rel, *max;
Elf64_Shdr *s;
Elf64_Word entsize;
unsigned i;
/* Find a symbol table. */ for (rel = (Elf64_Rela *) ((char *) ehdr + s->sh_offset),
for (i = 0, s = (Elf64_Shdr *) ((char *) e + e->e_shoff); max = (Elf64_Rela *) ((char *) rel + s->sh_size);
i < e->e_shnum; rel < max;
i++, s = (Elf64_Shdr *) ((char *) s + e->e_shentsize)) rel = (Elf64_Rela *) ((char *) rel + s->sh_entsize))
if (s->sh_type == SHT_SYMTAB) {
break; Elf64_Word *addr32;
Elf64_Xword *addr64;
Elf64_Sym *sym;
if (i == e->e_shnum) if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table")); return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
entsize = s->sh_entsize; addr32 = (Elf64_Word *) ((char *) seg->addr + rel->r_offset);
addr64 = (Elf64_Xword *) addr32;
sym = (Elf64_Sym *) ((char *) mod->symtab
+ mod->symsize * ELF_R_SYM (rel->r_info));
for (i = 0, s = (Elf64_Shdr *) ((char *) e + e->e_shoff); switch (ELF_R_TYPE (rel->r_info))
i < e->e_shnum; {
i++, s = (Elf64_Shdr *) ((char *) s + e->e_shentsize)) case R_X86_64_64:
if (s->sh_type == SHT_RELA) *addr64 += rel->r_addend + sym->st_value;
{ break;
grub_dl_segment_t seg;
/* Find the target segment. */ case R_X86_64_PC32:
for (seg = mod->segment; seg; seg = seg->next)
if (seg->section == s->sh_info)
break;
if (seg)
{ {
Elf64_Rela *rel, *max; grub_int64_t value;
value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value -
for (rel = (Elf64_Rela *) ((char *) e + s->sh_offset), (Elf64_Xword) seg->addr - rel->r_offset;
max = rel + s->sh_size / s->sh_entsize; if (value != (grub_int32_t) value)
rel < max; return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
rel++) *addr32 = value;
{
Elf64_Word *addr32;
Elf64_Xword *addr64;
Elf64_Sym *sym;
if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
addr32 = (Elf64_Word *) ((char *) seg->addr + rel->r_offset);
addr64 = (Elf64_Xword *) addr32;
sym = (Elf64_Sym *) ((char *) mod->symtab
+ entsize * ELF_R_SYM (rel->r_info));
switch (ELF_R_TYPE (rel->r_info))
{
case R_X86_64_64:
*addr64 += rel->r_addend + sym->st_value;
break;
case R_X86_64_PC32:
{
grub_int64_t value;
value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value -
(Elf64_Xword) seg->addr - rel->r_offset;
if (value != (grub_int32_t) value)
return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
*addr32 = value;
}
break;
case R_X86_64_32:
{
grub_uint64_t value = *addr32 + rel->r_addend + sym->st_value;
if (value != (grub_uint32_t) value)
return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
*addr32 = value;
}
break;
case R_X86_64_32S:
{
grub_int64_t value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value;
if (value != (grub_int32_t) value)
return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
*addr32 = value;
}
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}
} }
} break;
case R_X86_64_32:
{
grub_uint64_t value = *addr32 + rel->r_addend + sym->st_value;
if (value != (grub_uint32_t) value)
return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
*addr32 = value;
}
break;
case R_X86_64_32S:
{
grub_int64_t value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value;
if (value != (grub_int32_t) value)
return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
*addr32 = value;
}
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
+2
View File
@@ -132,6 +132,7 @@ static int add_subnode (void *fdt, int parentoffset, const char *name)
+ parentoffset); + parentoffset);
grub_uint32_t *end = (void *) struct_end (fdt); grub_uint32_t *end = (void *) struct_end (fdt);
unsigned int entry_size = node_entry_size (name); unsigned int entry_size = node_entry_size (name);
unsigned int struct_size = grub_fdt_get_size_dt_struct(fdt);
char *node_name; char *node_name;
SKIP_NODE_NAME(node_name, token, end); SKIP_NODE_NAME(node_name, token, end);
@@ -167,6 +168,7 @@ insert:
token[entry_size / sizeof(*token) - 2] = 0; /* padding bytes */ token[entry_size / sizeof(*token) - 2] = 0; /* padding bytes */
grub_strcpy((char *) (token + 1), name); grub_strcpy((char *) (token + 1), name);
token[entry_size / sizeof(*token) - 1] = grub_cpu_to_be32(FDT_END_NODE); token[entry_size / sizeof(*token) - 1] = grub_cpu_to_be32(FDT_END_NODE);
grub_fdt_set_size_dt_struct (fdt, struct_size + entry_size);
return ((grub_addr_t) token - (grub_addr_t) fdt return ((grub_addr_t) token - (grub_addr_t) fdt
- grub_fdt_get_off_dt_struct(fdt)); - grub_fdt_get_off_dt_struct(fdt));
} }
+1 -1
View File
@@ -247,7 +247,7 @@ extern UDItype __udiv_qrnnd ();
"=r" ((xl)) \ "=r" ((xl)) \
: "r" ((USItype)(a)), \ : "r" ((USItype)(a)), \
"r" ((USItype)(b)) \ "r" ((USItype)(b)) \
: "r0", "r1", "r2" __CLOBBER_CC) : "r0", "r1", "r2" __AND_CLOBBER_CC)
#else /* __ARM_ARCH >= 4 */ #else /* __ARM_ARCH >= 4 */
#define umul_ppmm(xh, xl, a, b) \ #define umul_ppmm(xh, xl, a, b) \
__asm__ ("@ Inlined umul_ppmm\n" \ __asm__ ("@ Inlined umul_ppmm\n" \
+25 -16
View File
@@ -28,6 +28,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
struct grub_ofnetcard_data struct grub_ofnetcard_data
{ {
char *path; char *path;
char *suffix;
grub_ieee1275_ihandle_t handle; grub_ieee1275_ihandle_t handle;
}; };
@@ -37,18 +38,7 @@ card_open (struct grub_net_card *dev)
int status; int status;
struct grub_ofnetcard_data *data = dev->data; struct grub_ofnetcard_data *data = dev->data;
if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX)) status = grub_ieee1275_open (data->path, &(data->handle));
{
char path[grub_strlen (data->path) +
sizeof (":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512")];
/* The full string will prevent a bootp packet to be sent. Just put some valid ip in there. */
grub_snprintf (path, sizeof (path), "%s%s", data->path,
":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512");
status = grub_ieee1275_open (path, &(data->handle));
}
else
status = grub_ieee1275_open (data->path, &(data->handle));
if (status) if (status)
return grub_error (GRUB_ERR_IO, "Couldn't open network card."); return grub_error (GRUB_ERR_IO, "Couldn't open network card.");
@@ -146,8 +136,9 @@ grub_ieee1275_net_config_real (const char *devpath, char **device, char **path)
FOR_NET_CARDS (card) FOR_NET_CARDS (card)
{ {
char *bootp_response; char *bootp_response;
char *cardpath;
char *canon; char *canon;
char c;
struct grub_ofnetcard_data *data;
grub_ssize_t size = -1; grub_ssize_t size = -1;
unsigned int i; unsigned int i;
@@ -155,8 +146,11 @@ grub_ieee1275_net_config_real (const char *devpath, char **device, char **path)
if (card->driver != &ofdriver) if (card->driver != &ofdriver)
continue; continue;
cardpath = ((struct grub_ofnetcard_data *) card->data)->path; data = card->data;
canon = grub_ieee1275_canonicalise_devname (cardpath); c = *data->suffix;
*data->suffix = '\0';
canon = grub_ieee1275_canonicalise_devname (data->path);
*data->suffix = c;
if (grub_strcmp (devpath, canon) != 0) if (grub_strcmp (devpath, canon) != 0)
{ {
grub_free (canon); grub_free (canon);
@@ -224,7 +218,22 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
return 1; return 1;
} }
ofdata->path = grub_strdup (alias->path); #define SUFFIX ":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512"
if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof (SUFFIX));
else
ofdata->path = grub_malloc (grub_strlen (alias->path) + 1);
if (!ofdata->path)
{
grub_print_error ();
return 0;
}
ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
else
*ofdata->suffix = '\0';
grub_ieee1275_finddevice (ofdata->path, &devhandle); grub_ieee1275_finddevice (ofdata->path, &devhandle);
+2 -2
View File
@@ -49,7 +49,7 @@
#include <grub/term.h> #include <grub/term.h>
#include <grub/normal.h> #include <grub/normal.h>
#ifdef HAVE_UNIFONT_WIDTHSPEC #if HAVE_FONT_SOURCE
#include "widthspec.h" #include "widthspec.h"
#endif #endif
@@ -387,7 +387,7 @@ grub_unicode_get_comb_type (grub_uint32_t c)
return GRUB_UNICODE_COMB_NONE; return GRUB_UNICODE_COMB_NONE;
} }
#ifdef HAVE_UNIFONT_WIDTHSPEC #if HAVE_FONT_SOURCE
grub_size_t grub_size_t
grub_unicode_estimate_width (const struct grub_unicode_glyph *c) grub_unicode_estimate_width (const struct grub_unicode_glyph *c)
+1 -1
View File
@@ -523,7 +523,7 @@ static const char *features[] = {
"feature_chainloader_bpb", "feature_ntldr", "feature_platform_search_hint", "feature_chainloader_bpb", "feature_ntldr", "feature_platform_search_hint",
"feature_default_font_path", "feature_all_video_module", "feature_default_font_path", "feature_all_video_module",
"feature_menuentry_id", "feature_menuentry_options", "feature_200_final", "feature_menuentry_id", "feature_menuentry_options", "feature_200_final",
"feature_nativedisk_cmd" "feature_nativedisk_cmd", "feature_timeout_style"
}; };
GRUB_MOD_INIT(normal) GRUB_MOD_INIT(normal)
+155 -22
View File
@@ -40,6 +40,22 @@
grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu, grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu,
int nested) = NULL; int nested) = NULL;
enum timeout_style {
TIMEOUT_STYLE_MENU,
TIMEOUT_STYLE_COUNTDOWN,
TIMEOUT_STYLE_HIDDEN
};
struct timeout_style_name {
const char *name;
enum timeout_style style;
} timeout_style_names[] = {
{"menu", TIMEOUT_STYLE_MENU},
{"countdown", TIMEOUT_STYLE_COUNTDOWN},
{"hidden", TIMEOUT_STYLE_HIDDEN},
{NULL, 0}
};
/* Wait until the user pushes any key so that the user /* Wait until the user pushes any key so that the user
can see what happened. */ can see what happened. */
void void
@@ -70,6 +86,40 @@ grub_menu_get_entry (grub_menu_t menu, int no)
return e; return e;
} }
/* Get the index of a menu entry associated with a given hotkey, or -1. */
static int
get_entry_index_by_hotkey (grub_menu_t menu, int hotkey)
{
grub_menu_entry_t entry;
int i;
for (i = 0, entry = menu->entry_list; i < menu->size;
i++, entry = entry->next)
if (entry->hotkey == hotkey)
return i;
return -1;
}
/* Return the timeout style. If the variable "timeout_style" is not set or
invalid, default to TIMEOUT_STYLE_MENU. */
static enum timeout_style
get_timeout_style (void)
{
const char *val;
struct timeout_style_name *style_name;
val = grub_env_get ("timeout_style");
if (!val)
return TIMEOUT_STYLE_MENU;
for (style_name = timeout_style_names; style_name->name; style_name++)
if (grub_strcmp (style_name->name, val) == 0)
return style_name->style;
return TIMEOUT_STYLE_MENU;
}
/* Return the current timeout. If the variable "timeout" is not set or /* Return the current timeout. If the variable "timeout" is not set or
invalid, return -1. */ invalid, return -1. */
int int
@@ -488,6 +538,33 @@ get_entry_number (grub_menu_t menu, const char *name)
return entry; return entry;
} }
/* Check whether a second has elapsed since the last tick. If so, adjust
the timer and return 1; otherwise, return 0. */
static int
has_second_elapsed (grub_uint64_t *saved_time)
{
grub_uint64_t current_time;
current_time = grub_get_time_ms ();
if (current_time - *saved_time >= 1000)
{
*saved_time = current_time;
return 1;
}
else
return 0;
}
static void
print_countdown (struct grub_term_coordinate *pos, int n)
{
grub_term_restore_pos (pos);
/* NOTE: Do not remove the trailing space characters.
They are required to clear the line. */
grub_printf ("%d ", n);
grub_refresh ();
}
#define GRUB_MENU_PAGE_SIZE 10 #define GRUB_MENU_PAGE_SIZE 10
/* Show the menu and handle menu entry selection. Returns the menu entry /* Show the menu and handle menu entry selection. Returns the menu entry
@@ -502,6 +579,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
grub_uint64_t saved_time; grub_uint64_t saved_time;
int default_entry, current_entry; int default_entry, current_entry;
int timeout; int timeout;
enum timeout_style timeout_style;
default_entry = get_entry_number (menu, "default"); default_entry = get_entry_number (menu, "default");
@@ -510,8 +588,71 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
if (default_entry < 0 || default_entry >= menu->size) if (default_entry < 0 || default_entry >= menu->size)
default_entry = 0; default_entry = 0;
timeout = grub_menu_get_timeout ();
if (timeout < 0)
/* If there is no timeout, the "countdown" and "hidden" styles result in
the system doing nothing and providing no or very little indication
why. Technically this is what the user asked for, but it's not very
useful and likely to be a source of confusion, so we disallow this. */
grub_env_unset ("timeout_style");
timeout_style = get_timeout_style ();
if (timeout_style == TIMEOUT_STYLE_COUNTDOWN
|| timeout_style == TIMEOUT_STYLE_HIDDEN)
{
static struct grub_term_coordinate *pos;
int entry = -1;
if (timeout_style == TIMEOUT_STYLE_COUNTDOWN && timeout)
{
pos = grub_term_save_pos ();
print_countdown (pos, timeout);
}
/* Enter interruptible sleep until Escape or a menu hotkey is pressed,
or the timeout expires. */
saved_time = grub_get_time_ms ();
while (1)
{
int key;
key = grub_getkey_noblock ();
if (key != GRUB_TERM_NO_KEY)
{
entry = get_entry_index_by_hotkey (menu, key);
if (entry >= 0)
break;
}
if (key == GRUB_TERM_ESC)
{
timeout = -1;
break;
}
if (timeout > 0 && has_second_elapsed (&saved_time))
{
timeout--;
if (timeout_style == TIMEOUT_STYLE_COUNTDOWN)
print_countdown (pos, timeout);
}
if (timeout == 0)
/* We will fall through to auto-booting the default entry. */
break;
}
grub_env_unset ("timeout");
grub_env_unset ("timeout_style");
if (entry >= 0)
{
*auto_boot = 0;
return entry;
}
}
/* If timeout is 0, drawing is pointless (and ugly). */ /* If timeout is 0, drawing is pointless (and ugly). */
if (grub_menu_get_timeout () == 0) if (timeout == 0)
{ {
*auto_boot = 1; *auto_boot = 1;
return default_entry; return default_entry;
@@ -540,18 +681,11 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
if (grub_normal_exit_level) if (grub_normal_exit_level)
return -1; return -1;
if (timeout > 0) if (timeout > 0 && has_second_elapsed (&saved_time))
{ {
grub_uint64_t current_time; timeout--;
grub_menu_set_timeout (timeout);
current_time = grub_get_time_ms (); menu_print_timeout (timeout);
if (current_time - saved_time >= 1000)
{
timeout--;
grub_menu_set_timeout (timeout);
saved_time = current_time;
menu_print_timeout (timeout);
}
} }
if (timeout == 0) if (timeout == 0)
@@ -653,16 +787,15 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
default: default:
{ {
grub_menu_entry_t entry; int entry;
int i;
for (i = 0, entry = menu->entry_list; i < menu->size; entry = get_entry_index_by_hotkey (menu, c);
i++, entry = entry->next) if (entry >= 0)
if (entry->hotkey == c) {
{ menu_fini ();
menu_fini (); *auto_boot = 0;
*auto_boot = 0; return entry;
return i; }
}
} }
break; break;
} }
+27 -7
View File
@@ -455,6 +455,8 @@ grub_util_fd_close (grub_util_fd_t fd)
} }
} }
static int allow_fd_syncs = 1;
static void static void
grub_util_fd_sync_volume (grub_util_fd_t fd) grub_util_fd_sync_volume (grub_util_fd_t fd)
{ {
@@ -469,17 +471,35 @@ grub_util_fd_sync_volume (grub_util_fd_t fd)
void void
grub_util_fd_sync (grub_util_fd_t fd) grub_util_fd_sync (grub_util_fd_t fd)
{ {
switch (fd->type) if (allow_fd_syncs)
{ {
case GRUB_UTIL_FD_FILE: switch (fd->type)
fsync (fd->fd); {
return; case GRUB_UTIL_FD_FILE:
case GRUB_UTIL_FD_DISK: fsync (fd->fd);
grub_util_fd_sync_volume (fd); return;
return; case GRUB_UTIL_FD_DISK:
grub_util_fd_sync_volume (fd);
return;
}
} }
} }
void
grub_util_file_sync (FILE *f)
{
fflush (f);
if (!allow_fd_syncs)
return;
fsync (fileno (f));
}
void
grub_util_disable_fd_syncs (void)
{
allow_fd_syncs = 0;
}
void void
grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused))) grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
{ {
+89
View File
@@ -27,6 +27,7 @@
#include <grub/emu/misc.h> #include <grub/emu/misc.h>
#include <grub/emu/hostdisk.h> #include <grub/emu/hostdisk.h>
#include <grub/emu/getroot.h> #include <grub/emu/getroot.h>
#include <grub/emu/exec.h>
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/list.h> #include <grub/list.h>
@@ -39,6 +40,7 @@
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
@@ -93,12 +95,99 @@ grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_sec
return nr; return nr;
} }
static char *
sysfs_partition_path (const char *dev, const char *entry)
{
const char *argv[7];
int fd;
pid_t pid;
FILE *udevadm;
char *buf = NULL;
size_t len = 0;
char *path = NULL;
argv[0] = "udevadm";
argv[1] = "info";
argv[2] = "--query";
argv[3] = "path";
argv[4] = "--name";
argv[5] = dev;
argv[6] = NULL;
pid = grub_util_exec_pipe (argv, &fd);
if (!pid)
return NULL;
/* Parent. Read udevadm's output. */
udevadm = fdopen (fd, "r");
if (!udevadm)
{
grub_util_warn (_("Unable to open stream from %s: %s"),
"udevadm", strerror (errno));
close (fd);
goto out;
}
if (getline (&buf, &len, udevadm) > 0)
{
char *newline;
newline = strchr (buf, '\n');
if (newline)
*newline = '\0';
path = xasprintf ("/sys%s/%s", buf, entry);
}
out:
if (udevadm)
fclose (udevadm);
waitpid (pid, NULL, 0);
free (buf);
return path;
}
static int
sysfs_partition_start (const char *dev, grub_disk_addr_t *start)
{
char *path;
FILE *fp;
unsigned long long val;
int ret = 0;
path = sysfs_partition_path (dev, "start");
if (!path)
return 0;
fp = grub_util_fopen (path, "r");
if (!fp)
goto out;
if (fscanf (fp, "%llu", &val) == 1)
{
*start = (grub_disk_addr_t) val;
ret = 1;
}
out:
free (path);
if (fp)
fclose (fp);
return ret;
}
grub_disk_addr_t grub_disk_addr_t
grub_util_find_partition_start_os (const char *dev) grub_util_find_partition_start_os (const char *dev)
{ {
grub_disk_addr_t start = 0;
grub_util_fd_t fd; grub_util_fd_t fd;
struct hd_geometry hdg; struct hd_geometry hdg;
if (sysfs_partition_start (dev, &start))
return start;
fd = open (dev, O_RDONLY); fd = open (dev, O_RDONLY);
if (fd == -1) if (fd == -1)
{ {
+12 -4
View File
@@ -143,7 +143,12 @@ find_obppath (const char *sysfs_path_orig)
size = st.st_size; size = st.st_size;
of_path = xmalloc (size + MAX_DISK_CAT + 1); of_path = xmalloc (size + MAX_DISK_CAT + 1);
memset(of_path, 0, size + MAX_DISK_CAT + 1); memset(of_path, 0, size + MAX_DISK_CAT + 1);
read(fd, of_path, size); if (read(fd, of_path, size) < 0)
{
grub_util_info (_("cannot read `%s': %s"), path, strerror (errno));
close(fd);
return NULL;
}
close(fd); close(fd);
trim_newline(of_path); trim_newline(of_path);
@@ -353,7 +358,9 @@ check_sas (char *sysfs_path, int *tgt, unsigned long int *sas_address)
grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
memset (phy, 0, sizeof (phy)); memset (phy, 0, sizeof (phy));
read (fd, phy, sizeof (phy) - 1); if (read (fd, phy, sizeof (phy) - 1) < 0)
grub_util_error (_("cannot read `%s': %s"), path, strerror (errno));
close (fd); close (fd);
sscanf (phy, "%d", tgt); sscanf (phy, "%d", tgt);
@@ -361,10 +368,11 @@ check_sas (char *sysfs_path, int *tgt, unsigned long int *sas_address)
snprintf (path, path_size, "%s/sas_device/%s/sas_address", p, ed); snprintf (path, path_size, "%s/sas_device/%s/sas_address", p, ed);
fd = open (path, O_RDONLY); fd = open (path, O_RDONLY);
if (fd < 0) if (fd < 0)
grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
memset (phy, 0, sizeof (phy)); memset (phy, 0, sizeof (phy));
read (fd, phy, sizeof (phy) - 1); if (read (fd, phy, sizeof (phy) - 1) < 0)
grub_util_error (_("cannot read `%s': %s"), path, strerror (errno));
sscanf (phy, "%lx", sas_address); sscanf (phy, "%lx", sas_address);
free (path); free (path);
+30 -30
View File
@@ -86,7 +86,7 @@ int
grub_util_exec_redirect (const char *const *argv, const char *stdin_file, grub_util_exec_redirect (const char *const *argv, const char *stdin_file,
const char *stdout_file) const char *stdout_file)
{ {
pid_t mdadm_pid; pid_t pid;
int status = -1; int status = -1;
char *str, *pstr; char *str, *pstr;
const char *const *ptr; const char *const *ptr;
@@ -112,10 +112,10 @@ grub_util_exec_redirect (const char *const *argv, const char *stdin_file,
grub_util_info ("executing %s", str); grub_util_info ("executing %s", str);
grub_free (str); grub_free (str);
mdadm_pid = fork (); pid = fork ();
if (mdadm_pid < 0) if (pid < 0)
grub_util_error (_("Unable to fork: %s"), strerror (errno)); grub_util_error (_("Unable to fork: %s"), strerror (errno));
else if (mdadm_pid == 0) else if (pid == 0)
{ {
int in, out; int in, out;
/* Child. */ /* Child. */
@@ -145,7 +145,7 @@ grub_util_exec_redirect (const char *const *argv, const char *stdin_file,
execvp ((char *) argv[0], (char **) argv); execvp ((char *) argv[0], (char **) argv);
exit (127); exit (127);
} }
waitpid (mdadm_pid, &status, 0); waitpid (pid, &status, 0);
if (!WIFEXITED (status)) if (!WIFEXITED (status))
return -1; return -1;
return WEXITSTATUS (status); return WEXITSTATUS (status);
@@ -160,21 +160,21 @@ grub_util_exec_redirect_null (const char *const *argv)
pid_t pid_t
grub_util_exec_pipe (const char *const *argv, int *fd) grub_util_exec_pipe (const char *const *argv, int *fd)
{ {
int mdadm_pipe[2]; int pipe_fd[2];
pid_t mdadm_pid; pid_t pid;
*fd = 0; *fd = 0;
if (pipe (mdadm_pipe) < 0) if (pipe (pipe_fd) < 0)
{ {
grub_util_warn (_("Unable to create pipe: %s"), grub_util_warn (_("Unable to create pipe: %s"),
strerror (errno)); strerror (errno));
return 0; return 0;
} }
mdadm_pid = fork (); pid = fork ();
if (mdadm_pid < 0) if (pid < 0)
grub_util_error (_("Unable to fork: %s"), strerror (errno)); grub_util_error (_("Unable to fork: %s"), strerror (errno));
else if (mdadm_pid == 0) else if (pid == 0)
{ {
/* Child. */ /* Child. */
@@ -187,39 +187,39 @@ grub_util_exec_pipe (const char *const *argv, int *fd)
/* Ensure child is not localised. */ /* Ensure child is not localised. */
setenv ("LC_ALL", "C", 1); setenv ("LC_ALL", "C", 1);
close (mdadm_pipe[0]); close (pipe_fd[0]);
dup2 (mdadm_pipe[1], STDOUT_FILENO); dup2 (pipe_fd[1], STDOUT_FILENO);
close (mdadm_pipe[1]); close (pipe_fd[1]);
execvp ((char *) argv[0], (char **) argv); execvp ((char *) argv[0], (char **) argv);
exit (127); exit (127);
} }
else else
{ {
close (mdadm_pipe[1]); close (pipe_fd[1]);
*fd = mdadm_pipe[0]; *fd = pipe_fd[0];
return mdadm_pid; return pid;
} }
} }
pid_t pid_t
grub_util_exec_pipe_stderr (const char *const *argv, int *fd) grub_util_exec_pipe_stderr (const char *const *argv, int *fd)
{ {
int mdadm_pipe[2]; int pipe_fd[2];
pid_t mdadm_pid; pid_t pid;
*fd = 0; *fd = 0;
if (pipe (mdadm_pipe) < 0) if (pipe (pipe_fd) < 0)
{ {
grub_util_warn (_("Unable to create pipe: %s"), grub_util_warn (_("Unable to create pipe: %s"),
strerror (errno)); strerror (errno));
return 0; return 0;
} }
mdadm_pid = fork (); pid = fork ();
if (mdadm_pid < 0) if (pid < 0)
grub_util_error (_("Unable to fork: %s"), strerror (errno)); grub_util_error (_("Unable to fork: %s"), strerror (errno));
else if (mdadm_pid == 0) else if (pid == 0)
{ {
/* Child. */ /* Child. */
@@ -232,18 +232,18 @@ grub_util_exec_pipe_stderr (const char *const *argv, int *fd)
/* Ensure child is not localised. */ /* Ensure child is not localised. */
setenv ("LC_ALL", "C", 1); setenv ("LC_ALL", "C", 1);
close (mdadm_pipe[0]); close (pipe_fd[0]);
dup2 (mdadm_pipe[1], STDOUT_FILENO); dup2 (pipe_fd[1], STDOUT_FILENO);
dup2 (mdadm_pipe[1], STDERR_FILENO); dup2 (pipe_fd[1], STDERR_FILENO);
close (mdadm_pipe[1]); close (pipe_fd[1]);
execvp ((char *) argv[0], (char **) argv); execvp ((char *) argv[0], (char **) argv);
exit (127); exit (127);
} }
else else
{ {
close (mdadm_pipe[1]); close (pipe_fd[1]);
*fd = mdadm_pipe[0]; *fd = pipe_fd[0];
return mdadm_pid; return pid;
} }
} }
+5 -5
View File
@@ -567,7 +567,7 @@ grub_util_pull_lvm_by_command (const char *os_dev)
const char *argv[8]; const char *argv[8];
int fd; int fd;
pid_t pid; pid_t pid;
FILE *mdadm; FILE *vgs;
char *buf = NULL; char *buf = NULL;
size_t len = 0; size_t len = 0;
char *vgname = NULL; char *vgname = NULL;
@@ -622,16 +622,16 @@ grub_util_pull_lvm_by_command (const char *os_dev)
if (!pid) if (!pid)
return; return;
/* Parent. Read mdadm's output. */ /* Parent. Read vgs' output. */
mdadm = fdopen (fd, "r"); vgs = fdopen (fd, "r");
if (! mdadm) if (! vgs)
{ {
grub_util_warn (_("Unable to open stream from %s: %s"), grub_util_warn (_("Unable to open stream from %s: %s"),
"vgs", strerror (errno)); "vgs", strerror (errno));
goto out; goto out;
} }
while (getline (&buf, &len, mdadm) > 0) while (getline (&buf, &len, vgs) > 0)
{ {
char *ptr; char *ptr;
/* LVM adds two spaces as standard prefix */ /* LVM adds two spaces as standard prefix */
+19 -1
View File
@@ -191,10 +191,28 @@ grub_util_fd_strerror (void)
return strerror (errno); return strerror (errno);
} }
static int allow_fd_syncs = 1;
void void
grub_util_fd_sync (grub_util_fd_t fd) grub_util_fd_sync (grub_util_fd_t fd)
{ {
fsync (fd); if (allow_fd_syncs)
fsync (fd);
}
void
grub_util_file_sync (FILE *f)
{
fflush (f);
if (!allow_fd_syncs)
return;
fsync (fileno (f));
}
void
grub_util_disable_fd_syncs (void)
{
allow_fd_syncs = 0;
} }
void void
+3 -1
View File
@@ -51,7 +51,9 @@ grub_password_get (char buf[], unsigned buf_size)
} }
else else
tty_changed = 0; tty_changed = 0;
fgets (buf, buf_size, stdin); grub_memset (buf, 0, buf_size);
if (!fgets (buf, buf_size, stdin))
return 0;
ptr = buf + strlen (buf) - 1; ptr = buf + strlen (buf) - 1;
while (buf <= ptr && (*ptr == '\n' || *ptr == '\r')) while (buf <= ptr && (*ptr == '\n' || *ptr == '\r'))
*ptr-- = 0; *ptr-- = 0;
+2 -2
View File
@@ -37,7 +37,7 @@ static void
grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)), grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
const struct grub_unicode_glyph *c) const struct grub_unicode_glyph *c)
{ {
TCHAR str[2 + c->ncomb]; TCHAR str[2 + 30];
unsigned i, j; unsigned i, j;
DWORD written; DWORD written;
@@ -47,7 +47,7 @@ grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
else else
str[0] = (c->base & 0xffff); str[0] = (c->base & 0xffff);
j = 1; j = 1;
for (i = 0; i < c->ncomb; i++) for (i = 0; i < c->ncomb && j+1 < ARRAY_SIZE (str); i++)
if (c->base < 0xffff) if (c->base < 0xffff)
str[j++] = grub_unicode_get_comb (c)[i].code; str[j++] = grub_unicode_get_comb (c)[i].code;
str[j] = 0; str[j] = 0;
+17 -4
View File
@@ -240,10 +240,19 @@ grub_util_fd_write (grub_util_fd_t fd, const char *buf, size_t len)
return real_read; return real_read;
} }
static int allow_fd_syncs = 1;
void void
grub_util_fd_sync (grub_util_fd_t fd) grub_util_fd_sync (grub_util_fd_t fd)
{ {
FlushFileBuffers (fd); if (allow_fd_syncs)
FlushFileBuffers (fd);
}
void
grub_util_disable_fd_syncs (void)
{
allow_fd_syncs = 0;
} }
void void
@@ -575,12 +584,16 @@ grub_util_fopen (const char *path, const char *mode)
return ret; return ret;
} }
int fsync (int fno) void
grub_util_file_sync (FILE *f)
{ {
HANDLE hnd; HANDLE hnd;
hnd = (HANDLE) _get_osfhandle (fno);
fflush (f);
if (!allow_fd_syncs)
return;
hnd = (HANDLE) _get_osfhandle (fileno (f));
FlushFileBuffers (hnd); FlushFileBuffers (hnd);
return 0;
} }
int int
+2 -2
View File
@@ -69,7 +69,7 @@ static void
grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)), grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
const struct grub_unicode_glyph *c) const struct grub_unicode_glyph *c)
{ {
grub_efi_char16_t str[2 + c->ncomb]; grub_efi_char16_t str[2 + 30];
grub_efi_simple_text_output_interface_t *o; grub_efi_simple_text_output_interface_t *o;
unsigned i, j; unsigned i, j;
@@ -84,7 +84,7 @@ grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
else else
str[0] = (grub_efi_char16_t) map_char (c->base & 0xffff); str[0] = (grub_efi_char16_t) map_char (c->base & 0xffff);
j = 1; j = 1;
for (i = 0; i < c->ncomb; i++) for (i = 0; i < c->ncomb && j + 1 < ARRAY_SIZE (str); i++)
if (c->base < 0xffff) if (c->base < 0xffff)
str[j++] = grub_unicode_get_comb (c)[i].code; str[j++] = grub_unicode_get_comb (c)[i].code;
str[j] = 0; str[j] = 0;
+7 -2
View File
@@ -213,12 +213,17 @@ find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x11111234) if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x11111234)
return 0; return 0;
*found = 1;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0); addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK; framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
if (!framebuffer.base)
return 0;
*found = 1;
framebuffer.dev = dev; framebuffer.dev = dev;
/* Enable address spaces. */
addr = grub_pci_make_address (framebuffer.dev, GRUB_PCI_REG_COMMAND);
grub_pci_write (addr, 0x7);
return 1; return 1;
} }
+9 -2
View File
@@ -249,10 +249,17 @@ find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x00b81013) if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x00b81013)
return 0; return 0;
*found = 1;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0); addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK; framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
if (!framebuffer.base)
return 0;
*found = 1;
/* Enable address spaces. */
addr = grub_pci_make_address (framebuffer.dev, GRUB_PCI_REG_COMMAND);
grub_pci_write (addr, 0x7);
framebuffer.dev = dev; framebuffer.dev = dev;
return 1; return 1;
+22 -3
View File
@@ -20,8 +20,27 @@
#define GRUB_ARM_RELOC_H 1 #define GRUB_ARM_RELOC_H 1
grub_err_t grub_arm_reloc_abs32 (grub_uint32_t *addr, Elf32_Addr sym_addr); grub_err_t grub_arm_reloc_abs32 (grub_uint32_t *addr, Elf32_Addr sym_addr);
grub_err_t grub_arm_reloc_jump24 (grub_uint32_t *addr, Elf32_Addr sym_addr);
grub_err_t grub_arm_reloc_thm_call (grub_uint16_t *addr, Elf32_Addr sym_addr); int
grub_err_t grub_arm_reloc_thm_jump19 (grub_uint16_t *addr, Elf32_Addr sym_addr); grub_arm_thm_call_check_offset (grub_int32_t offset, int is_thumb);
grub_int32_t
grub_arm_thm_call_get_offset (grub_uint16_t *target);
grub_err_t
grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset);
grub_int32_t
grub_arm_thm_jump19_get_offset (grub_uint16_t *target);
void
grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset);
int
grub_arm_thm_jump19_check_offset (grub_int32_t offset);
grub_int32_t
grub_arm_jump24_get_offset (grub_uint32_t *target);
int
grub_arm_jump24_check_offset (grub_int32_t offset);
void
grub_arm_jump24_set_offset (grub_uint32_t *target,
grub_int32_t offset);
#endif #endif
+3 -1
View File
@@ -19,6 +19,8 @@
#ifndef GRUB_ARM64_RELOC_H #ifndef GRUB_ARM64_RELOC_H
#define GRUB_ARM64_RELOC_H 1 #define GRUB_ARM64_RELOC_H 1
grub_err_t grub_arm64_reloc_xxxx26 (grub_uint32_t *target, Elf64_Addr sym_addr); int grub_arm_64_check_xxxx26_offset (grub_int64_t offset);
void
grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset);
#endif #endif
+18 -4
View File
@@ -177,11 +177,17 @@ struct grub_dl
grub_dl_dep_t dep; grub_dl_dep_t dep;
grub_dl_segment_t segment; grub_dl_segment_t segment;
Elf_Sym *symtab; Elf_Sym *symtab;
grub_size_t symsize;
void (*init) (struct grub_dl *mod); void (*init) (struct grub_dl *mod);
void (*fini) (void); void (*fini) (void);
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__) #if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__)
void *got; void *got;
void *gotptr;
void *tramp; void *tramp;
void *trampptr;
#endif
#ifdef __mips__
grub_uint32_t *reginfo;
#endif #endif
void *base; void *base;
grub_size_t sz; grub_size_t sz;
@@ -232,7 +238,11 @@ grub_err_t grub_dl_register_symbol (const char *name, void *addr,
int isfunc, grub_dl_t mod); int isfunc, grub_dl_t mod);
grub_err_t grub_arch_dl_check_header (void *ehdr); grub_err_t grub_arch_dl_check_header (void *ehdr);
grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr); #ifndef GRUB_UTIL
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg);
#endif
#if defined (_mips) #if defined (_mips)
#define GRUB_LINKER_HAVE_INIT 1 #define GRUB_LINKER_HAVE_INIT 1
@@ -240,7 +250,6 @@ void grub_arch_dl_init_linker (void);
#endif #endif
#define GRUB_IA64_DL_TRAMP_ALIGN 16 #define GRUB_IA64_DL_TRAMP_ALIGN 16
#define GRUB_IA64_DL_TRAMP_SIZE 48
#define GRUB_IA64_DL_GOT_ALIGN 16 #define GRUB_IA64_DL_GOT_ALIGN 16
grub_err_t grub_err_t
@@ -257,11 +266,16 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
grub_size_t *got); grub_size_t *got);
#endif #endif
#if defined (__powerpc__) || defined (__mips__) #if defined (__powerpc__) || defined (__mips__) || defined (__arm__)
#define GRUB_ARCH_DL_TRAMP_ALIGN 4 #define GRUB_ARCH_DL_TRAMP_ALIGN 4
#define GRUB_ARCH_DL_GOT_ALIGN 4 #define GRUB_ARCH_DL_GOT_ALIGN 4
#endif #endif
#if defined (__aarch64__)
#define GRUB_ARCH_DL_TRAMP_ALIGN 8
#define GRUB_ARCH_DL_GOT_ALIGN 8
#endif
#endif #endif
#endif /* ! GRUB_DL_H */ #endif /* ! GRUB_DL_H */
+2
View File
@@ -50,6 +50,8 @@ EXPORT_FUNC(grub_util_fd_strerror) (void);
void void
grub_util_fd_sync (grub_util_fd_t fd); grub_util_fd_sync (grub_util_fd_t fd);
void void
grub_util_disable_fd_syncs (void);
void
EXPORT_FUNC(grub_util_fd_close) (grub_util_fd_t fd); EXPORT_FUNC(grub_util_fd_close) (grub_util_fd_t fd);
grub_uint64_t grub_uint64_t
+2
View File
@@ -66,4 +66,6 @@ FILE *
grub_util_fopen (const char *path, const char *mode); grub_util_fopen (const char *path, const char *mode);
#endif #endif
void grub_util_file_sync (FILE *f);
#endif /* GRUB_EMU_MISC_H */ #endif /* GRUB_EMU_MISC_H */
+2 -1
View File
@@ -111,7 +111,8 @@
#define GRUB_KERNEL_ARM_UBOOT_MOD_GAP 0x0 #define GRUB_KERNEL_ARM_UBOOT_MOD_GAP 0x0
#define GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN 0x1000 #define GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN 0x1000
#define GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN 0x1 #define GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN 3
#define GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN (1 << GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN)
#define GRUB_KERNEL_MIPS_LOONGSON_MOD_ALIGN 0x1 #define GRUB_KERNEL_MIPS_LOONGSON_MOD_ALIGN 0x1
#define GRUB_KERNEL_MIPS_ARC_MOD_ALIGN 0x1 #define GRUB_KERNEL_MIPS_ARC_MOD_ALIGN 0x1
-6
View File
@@ -79,10 +79,4 @@ grub_util_utf8_to_tchar (const char *in);
char * char *
grub_util_tchar_to_utf8 (LPCTSTR in); grub_util_tchar_to_utf8 (LPCTSTR in);
#ifdef __MINGW32__
int fsync (int fno);
#endif
#endif #endif
+1
View File
@@ -27,6 +27,7 @@
#define SCRATCH_PAD_BOOT 0x5000 #define SCRATCH_PAD_BOOT 0x5000
#define SCRATCH_PAD_DISKBOOT 0x4000 #define SCRATCH_PAD_DISKBOOT 0x4000
#define SCRATCH_PAD_BOOT_SIZE 0x110
#define GET_ABS(symbol, reg) \ #define GET_ABS(symbol, reg) \
add PIC_REG, (symbol - pic_base), reg add PIC_REG, (symbol - pic_base), reg
+1 -1
View File
@@ -398,7 +398,7 @@ grub_term_cls (struct grub_term_output *term)
} }
} }
#ifdef HAVE_UNIFONT_WIDTHSPEC #if HAVE_FONT_SOURCE
grub_size_t grub_size_t
grub_unicode_estimate_width (const struct grub_unicode_glyph *c); grub_unicode_estimate_width (const struct grub_unicode_glyph *c);
+22 -25
View File
@@ -153,11 +153,10 @@ typedef grub_uint64_t grub_off_t;
typedef grub_uint64_t grub_disk_addr_t; typedef grub_uint64_t grub_disk_addr_t;
/* Byte-orders. */ /* Byte-orders. */
#define grub_swap_bytes16(x) \ static inline grub_uint16_t grub_swap_bytes16(grub_uint16_t _x)
({ \ {
grub_uint16_t _x = (x); \ return (grub_uint16_t) ((_x << 8) | (_x >> 8));
(grub_uint16_t) ((_x << 8) | (_x >> 8)); \ }
})
#define grub_swap_bytes16_compile_time(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8)) #define grub_swap_bytes16_compile_time(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
#define grub_swap_bytes32_compile_time(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000UL) >> 24)) #define grub_swap_bytes32_compile_time(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000UL) >> 24))
@@ -185,27 +184,25 @@ static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t x)
return __builtin_bswap64(x); return __builtin_bswap64(x);
} }
#else /* not gcc 4.3 or newer */ #else /* not gcc 4.3 or newer */
#define grub_swap_bytes32(x) \ static inline grub_uint32_t grub_swap_bytes32(grub_uint32_t _x)
({ \ {
grub_uint32_t _x = (x); \ return ((_x << 24)
(grub_uint32_t) ((_x << 24) \ | ((_x & (grub_uint32_t) 0xFF00UL) << 8)
| ((_x & (grub_uint32_t) 0xFF00UL) << 8) \ | ((_x & (grub_uint32_t) 0xFF0000UL) >> 8)
| ((_x & (grub_uint32_t) 0xFF0000UL) >> 8) \ | (_x >> 24));
| (_x >> 24)); \ }
})
#define grub_swap_bytes64(x) \ static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t _x)
({ \ {
grub_uint64_t _x = (x); \ return ((_x << 56)
(grub_uint64_t) ((_x << 56) \ | ((_x & (grub_uint64_t) 0xFF00ULL) << 40)
| ((_x & (grub_uint64_t) 0xFF00ULL) << 40) \ | ((_x & (grub_uint64_t) 0xFF0000ULL) << 24)
| ((_x & (grub_uint64_t) 0xFF0000ULL) << 24) \ | ((_x & (grub_uint64_t) 0xFF000000ULL) << 8)
| ((_x & (grub_uint64_t) 0xFF000000ULL) << 8) \ | ((_x & (grub_uint64_t) 0xFF00000000ULL) >> 8)
| ((_x & (grub_uint64_t) 0xFF00000000ULL) >> 8) \ | ((_x & (grub_uint64_t) 0xFF0000000000ULL) >> 24)
| ((_x & (grub_uint64_t) 0xFF0000000000ULL) >> 24) \ | ((_x & (grub_uint64_t) 0xFF000000000000ULL) >> 40)
| ((_x & (grub_uint64_t) 0xFF000000000000ULL) >> 40) \ | (_x >> 56));
| (_x >> 56)); \ }
})
#endif /* not gcc 4.3 or newer */ #endif /* not gcc 4.3 or newer */
#ifdef GRUB_CPU_WORDS_BIGENDIAN #ifdef GRUB_CPU_WORDS_BIGENDIAN
+8
View File
@@ -47,6 +47,12 @@
{ "override-directory", GRUB_INSTALL_OPTIONS_DIRECTORY2, \ { "override-directory", GRUB_INSTALL_OPTIONS_DIRECTORY2, \
N_("DIR"), OPTION_HIDDEN, \ N_("DIR"), OPTION_HIDDEN, \
N_("use images and modules under DIR [default=%s/<platform>]"), 1 }, \ N_("use images and modules under DIR [default=%s/<platform>]"), 1 }, \
{ "locale-directory", GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY, \
N_("DIR"), 0, \
N_("use translations under DIR [default=%s]"), 1 }, \
{ "themes-directory", GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY, \
N_("DIR"), OPTION_HIDDEN, \
N_("use themes under DIR [default=%s]"), 1 }, \
{ "grub-mkimage", GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE, \ { "grub-mkimage", GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE, \
"FILE", OPTION_HIDDEN, 0, 1 }, \ "FILE", OPTION_HIDDEN, 0, 1 }, \
/* TRANSLATORS: "embed" is a verb (command description). "*/ \ /* TRANSLATORS: "embed" is a verb (command description). "*/ \
@@ -103,6 +109,8 @@ enum grub_install_options {
GRUB_INSTALL_OPTIONS_INSTALL_LOCALES, GRUB_INSTALL_OPTIONS_INSTALL_LOCALES,
GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS, GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS,
GRUB_INSTALL_OPTIONS_DIRECTORY2, GRUB_INSTALL_OPTIONS_DIRECTORY2,
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY,
GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY,
GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE
}; };
+2
View File
@@ -47,4 +47,6 @@ void grub_util_init_nls (void);
void grub_util_host_init (int *argc, char ***argv); void grub_util_host_init (int *argc, char ***argv);
int grub_qsort_strcmp (const void *, const void *);
#endif /* ! GRUB_UTIL_MISC_HEADER */ #endif /* ! GRUB_UTIL_MISC_HEADER */
+8 -8
View File
@@ -950,28 +950,28 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
xorriso -compliance rec_mtime -set_filter_r --zisofs -- -zisofs default -as mkisofs -iso-level 3 -graft-points -R -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" -- -set_filter_r --zisofs -- -zisofs default -add /="$MASTER" ;; xorriso -compliance rec_mtime -set_filter_r --zisofs -- -zisofs default -as mkisofs -iso-level 3 -graft-points -R -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" -- -set_filter_r --zisofs -- -zisofs default -add /="$MASTER" ;;
x"iso9660") x"iso9660")
FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00);
/usr/local/bin/xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;;
x"joliet") x"joliet")
FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00);
/usr/local/bin/xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;;
x"rockridge") x"rockridge")
FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00);
/usr/local/bin/xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;;
x"rockridge_joliet") x"rockridge_joliet")
FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00);
/usr/local/bin/xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;;
x"iso9660_1999") x"iso9660_1999")
FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00);
/usr/local/bin/xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;;
x"joliet_1999") x"joliet_1999")
FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00);
/usr/local/bin/xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;;
x"rockridge_1999") x"rockridge_1999")
FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00);
/usr/local/bin/xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;;
x"rockridge_joliet_1999") x"rockridge_joliet_1999")
FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00);
/usr/local/bin/xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;;
x"romfs") x"romfs")
genromfs -V "$FSLABEL" -f "${FSIMAGES[0]}" -d "$MASTER" ;; genromfs -V "$FSLABEL" -f "${FSIMAGES[0]}" -d "$MASTER" ;;
xsquash4_*) xsquash4_*)
+3 -2
View File
@@ -347,9 +347,10 @@ if test -z "$debug"; then
fi fi
if [ x$boot != xnet ] && [ x$boot != xemu ]; then if [ x$boot != xnet ] && [ x$boot != xemu ]; then
cp -R "@srcdir@/themes" "@builddir@"
pkgdatadir="@builddir@" "@builddir@/grub-mkrescue" "--output=${isofile}" "--override-directory=${builddir}/grub-core" \ pkgdatadir="@builddir@" "@builddir@/grub-mkrescue" "--output=${isofile}" "--override-directory=${builddir}/grub-core" \
--rom-directory="${rom_directory}" $mkimage_extra_arg ${mkrescue_args} \ --rom-directory="${rom_directory}" \
--themes-directory="@srcdir@/themes" \
$mkimage_extra_arg ${mkrescue_args} \
"/boot/grub/grub.cfg=${cfgfile}" "/boot/grub/testcase.cfg=${source}" \ "/boot/grub/grub.cfg=${cfgfile}" "/boot/grub/testcase.cfg=${source}" \
${files} >/dev/null 2>&1 ${files} >/dev/null 2>&1
fi fi
+3
View File
@@ -47,6 +47,9 @@ grub_util_parse_config (FILE *f, struct grub_util_config *cfg, int simple)
{ {
char *optr; char *optr;
enum { NONE, SNGLQUOT, DBLQUOT } state; enum { NONE, SNGLQUOT, DBLQUOT } state;
ptr += sizeof ("GRUB_DISTRIBUTOR=") - 1;
if (simple) if (simple)
{ {
free (cfg->grub_distributor); free (cfg->grub_distributor);
+2 -1
View File
@@ -53,7 +53,8 @@ grub_util_create_envblk_file (const char *name)
grub_util_error (_("cannot write to `%s': %s"), namenew, grub_util_error (_("cannot write to `%s': %s"), namenew,
strerror (errno)); strerror (errno));
fsync (fileno (fp));
grub_util_file_sync (fp);
free (buf); free (buf);
fclose (fp); fclose (fp);
+1 -1
View File
@@ -188,7 +188,7 @@ write_envblk (const char *name, grub_envblk_t envblk)
grub_util_error (_("cannot write to `%s': %s"), name, grub_util_error (_("cannot write to `%s': %s"), name,
strerror (errno)); strerror (errno));
fsync (fileno (fp)); grub_util_file_sync (fp);
fclose (fp); fclose (fp);
} }
+2 -1
View File
@@ -344,13 +344,14 @@ crc_hook (grub_off_t ofs, char *buf, int len, void *crc_ctx)
static void static void
cmd_crc (char *pathname) cmd_crc (char *pathname)
{ {
grub_uint8_t crc32_context[GRUB_MD_CRC32->contextsize]; grub_uint8_t *crc32_context = xmalloc (GRUB_MD_CRC32->contextsize);
GRUB_MD_CRC32->init(crc32_context); GRUB_MD_CRC32->init(crc32_context);
read_file (pathname, crc_hook, crc32_context); read_file (pathname, crc_hook, crc32_context);
GRUB_MD_CRC32->final(crc32_context); GRUB_MD_CRC32->final(crc32_context);
printf ("%08x\n", printf ("%08x\n",
grub_be_to_cpu32 (grub_get_unaligned32 (GRUB_MD_CRC32->read (crc32_context)))); grub_be_to_cpu32 (grub_get_unaligned32 (GRUB_MD_CRC32->read (crc32_context))));
free (crc32_context);
} }
static const char *root = NULL; static const char *root = NULL;
+75 -46
View File
@@ -26,7 +26,7 @@
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include FT_TRUETYPE_TAGS_H #include FT_TRUETYPE_TAGS_H
#include FT_TRUETYPE_TABLES_H #include FT_TRUETYPE_TABLES_H
#include <freetype/ftsynth.h> #include FT_SYNTHESIS_H
#undef __FTERRORS_H__ #undef __FTERRORS_H__
#define FT_ERROR_START_LIST const char *ft_errmsgs[] = { #define FT_ERROR_START_LIST const char *ft_errmsgs[] = {
@@ -125,62 +125,91 @@ add_glyph (FT_UInt glyph_idx, FT_Face face,
(1 << (7 - (i & 7)))); (1 << (7 - (i & 7))));
} }
static void
write_code (FILE *file, FT_Face face, unsigned int char_code)
{
FT_UInt glyph_idx;
struct grub_glyph_info glyph;
glyph_idx = FT_Get_Char_Index (face, char_code);
if (!glyph_idx)
{
fprintf (stderr, "grub-gen-asciih: error: couldn't retrieve code %x",
(unsigned) char_code);
exit (1);
}
add_glyph (glyph_idx, face, char_code, &glyph);
if (glyph.width == 8 && glyph.height == 16
&& glyph.x_ofs == 0 && glyph.y_ofs == 0)
{
int row;
for (row = 0; row < 16; row++)
fprintf (file, "0x%02x, ", glyph.bitmap[row]);
}
else
{
unsigned char glph[16];
int p = 0, mask = 0x80;
int row, col;
int dy = 12 - glyph.height - glyph.y_ofs;
for (row = 0; row < 16; row++)
glph[row] = 0;
for (row = 0; row < glyph.height; row++)
for (col = 0; col < glyph.width; col++)
{
int val = glyph.bitmap[p] & mask;
mask >>= 1;
if (mask == 0)
{
mask = 0x80;
p++;
}
if (val && dy + row >= 0
&& dy + row < 16
&& glyph.x_ofs + col >= 0
&& glyph.x_ofs + col < 8)
glph[dy + row] |= 1 << (7 - (glyph.x_ofs + col));
}
for (row = 0; row < 16; row++)
fprintf (file, "0x%02x, ", glph[row]);
}
fprintf (file, "\n");
free (glyph.bitmap);
}
static void static void
write_font_ascii_bitmap (FILE *file, FT_Face face) write_font_ascii_bitmap (FILE *file, FT_Face face)
{ {
struct grub_glyph_info glyph;
int char_code; int char_code;
fprintf (file, "/* THIS CHUNK OF BYTES IS AUTOMATICALLY GENERATED */\n"); fprintf (file, "/* THIS CHUNK OF BYTES IS AUTOMATICALLY GENERATED */\n");
fprintf (file, "unsigned char ascii_bitmaps[] =\n"); fprintf (file, "#define ASCII_START 0\n");
fprintf (file, "#define ASCII_NUM 128\n");
fprintf (file, "static unsigned char ascii_bitmaps[] =\n");
fprintf (file, "{\n"); fprintf (file, "{\n");
for (char_code = 0; char_code <= 0x7f; char_code++) for (char_code = 0; char_code <= 0x7f; char_code++)
{ write_code (file, face, char_code);
FT_UInt glyph_idx; fprintf (file, "};\n");
glyph_idx = FT_Get_Char_Index (face, char_code); fprintf (file, "#define ARROWS_START 0x2190\n");
if (!glyph_idx) fprintf (file, "#define ARROWS_NUM 4\n");
return; fprintf (file, "static unsigned char arrows_bitmaps[] =\n");
add_glyph (glyph_idx, face, char_code, &glyph); fprintf (file, "{\n");
if (glyph.width == 8 && glyph.height == 16 for (char_code = 0x2190; char_code <= 0x2193; char_code++)
&& glyph.x_ofs == 0 && glyph.y_ofs == 0) write_code (file, face, char_code);
{ fprintf (file, "};\n");
int row;
for (row = 0; row < 16; row++) fprintf (file, "#define LINES_START 0x2501\n");
fprintf (file, "0x%02x, ", glyph.bitmap[row]); fprintf (file, "#define LINES_NUM 0x1b\n");
} fprintf (file, "static unsigned char lines_bitmaps[] =\n");
else fprintf (file, "{\n");
{
unsigned char glph[16]; for (char_code = 0x2501; char_code <= 0x251b; char_code++)
int p = 0, mask = 0x80; write_code (file, face, char_code);
int row, col;
int dy = 12 - glyph.height - glyph.y_ofs;
for (row = 0; row < 16; row++)
glph[row] = 0;
for (row = 0; row < glyph.height; row++)
for (col = 0; col < glyph.width; col++)
{
int val = glyph.bitmap[p] & mask;
mask >>= 1;
if (mask == 0)
{
mask = 0x80;
p++;
}
if (val && dy + row >= 0
&& dy + row < 16
&& glyph.x_ofs + col >= 0
&& glyph.x_ofs + col < 8)
glph[dy + row] |= 1 << (7 - (glyph.x_ofs + col));
}
for (row = 0; row < 16; row++)
fprintf (file, "0x%02x, ", glph[row]);
}
fprintf (file, "\n");
free (glyph.bitmap);
}
fprintf (file, "};\n"); fprintf (file, "};\n");
} }
+1 -1
View File
@@ -26,7 +26,7 @@
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include FT_TRUETYPE_TAGS_H #include FT_TRUETYPE_TAGS_H
#include FT_TRUETYPE_TABLES_H #include FT_TRUETYPE_TABLES_H
#include <freetype/ftsynth.h> #include FT_SYNTHESIS_H
#undef __FTERRORS_H__ #undef __FTERRORS_H__
#define FT_ERROR_START_LIST const char *ft_errmsgs[] = { #define FT_ERROR_START_LIST const char *ft_errmsgs[] = {
+53 -9
View File
@@ -58,6 +58,10 @@ grub_install_help_filter (int key, const char *text,
case GRUB_INSTALL_OPTIONS_DIRECTORY: case GRUB_INSTALL_OPTIONS_DIRECTORY:
case GRUB_INSTALL_OPTIONS_DIRECTORY2: case GRUB_INSTALL_OPTIONS_DIRECTORY2:
return xasprintf(text, grub_util_get_pkglibdir ()); return xasprintf(text, grub_util_get_pkglibdir ());
case GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY:
return xasprintf(text, grub_util_get_localedir ());
case GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY:
return grub_util_path_concat (2, grub_util_get_pkgdatadir (), "themes");
default: default:
return (char *) text; return (char *) text;
} }
@@ -217,6 +221,8 @@ struct install_list install_locales = { 1, 0, 0, 0 };
struct install_list install_fonts = { 1, 0, 0, 0 }; struct install_list install_fonts = { 1, 0, 0, 0 };
struct install_list install_themes = { 1, 0, 0, 0 }; struct install_list install_themes = { 1, 0, 0, 0 };
char *grub_install_source_directory = NULL; char *grub_install_source_directory = NULL;
char *grub_install_locale_directory = NULL;
char *grub_install_themes_directory = NULL;
void void
grub_install_push_module (const char *val) grub_install_push_module (const char *val)
@@ -313,6 +319,14 @@ grub_install_parse (int key, char *arg)
free (grub_install_source_directory); free (grub_install_source_directory);
grub_install_source_directory = xstrdup (arg); grub_install_source_directory = xstrdup (arg);
return 1; return 1;
case GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY:
free (grub_install_locale_directory);
grub_install_locale_directory = xstrdup (arg);
return 1;
case GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY:
free (grub_install_themes_directory);
grub_install_themes_directory = xstrdup (arg);
return 1;
case GRUB_INSTALL_OPTIONS_INSTALL_MODULES: case GRUB_INSTALL_OPTIONS_INSTALL_MODULES:
handle_install_list (&install_modules, arg, 0); handle_install_list (&install_modules, arg, 0);
return 1; return 1;
@@ -484,8 +498,7 @@ grub_install_make_image_wrap (const char *dir, const char *prefix,
grub_install_make_image_wrap_file (dir, prefix, fp, outname, grub_install_make_image_wrap_file (dir, prefix, fp, outname,
memdisk_path, config_path, memdisk_path, config_path,
mkimage_target, note, comp); mkimage_target, note, comp);
fflush (fp); grub_util_file_sync (fp);
fsync (fileno (fp));
fclose (fp); fclose (fp);
} }
@@ -551,12 +564,21 @@ copy_all (const char *srcd,
grub_util_fd_closedir (d); grub_util_fd_closedir (d);
} }
static const char *
get_localedir (void)
{
if (grub_install_locale_directory)
return grub_install_locale_directory;
else
return grub_util_get_localedir ();
}
static void static void
copy_locales (const char *dstd) copy_locales (const char *dstd)
{ {
grub_util_fd_dir_t d; grub_util_fd_dir_t d;
grub_util_fd_dirent_t de; grub_util_fd_dirent_t de;
const char *locale_dir = grub_util_get_localedir (); const char *locale_dir = get_localedir ();
d = grub_util_fd_opendir (locale_dir); d = grub_util_fd_opendir (locale_dir);
if (!d) if (!d)
@@ -570,13 +592,26 @@ copy_locales (const char *dstd)
{ {
char *srcf; char *srcf;
char *dstf; char *dstf;
char *ext;
if (strcmp (de->d_name, ".") == 0) if (strcmp (de->d_name, ".") == 0)
continue; continue;
if (strcmp (de->d_name, "..") == 0) if (strcmp (de->d_name, "..") == 0)
continue; continue;
srcf = grub_util_path_concat_ext (4, locale_dir, de->d_name, ext = grub_strrchr (de->d_name, '.');
"LC_MESSAGES", PACKAGE, ".mo"); if (ext && (grub_strcmp (ext, ".mo") == 0
dstf = grub_util_path_concat_ext (2, dstd, de->d_name, ".mo"); || grub_strcmp (ext, ".gmo") == 0))
{
srcf = grub_util_path_concat (2, locale_dir, de->d_name);
dstf = grub_util_path_concat (2, dstd, de->d_name);
ext = grub_strrchr (dstf, '.');
grub_strcpy (ext, ".mo");
}
else
{
srcf = grub_util_path_concat_ext (4, locale_dir, de->d_name,
"LC_MESSAGES", PACKAGE, ".mo");
dstf = grub_util_path_concat_ext (2, dstd, de->d_name, ".mo");
}
grub_install_compress_file (srcf, dstf, 0); grub_install_compress_file (srcf, dstf, 0);
free (srcf); free (srcf);
free (dstf); free (dstf);
@@ -639,6 +674,7 @@ grub_install_copy_files (const char *src,
{ {
char *dst_platform, *dst_locale, *dst_fonts; char *dst_platform, *dst_locale, *dst_fonts;
const char *pkgdatadir = grub_util_get_pkgdatadir (); const char *pkgdatadir = grub_util_get_pkgdatadir ();
char *themes_dir;
{ {
char *platform; char *platform;
@@ -709,7 +745,7 @@ grub_install_copy_files (const char *src,
} }
else else
{ {
const char *locale_dir = grub_util_get_localedir (); const char *locale_dir = get_localedir ();
for (i = 0; i < install_locales.n_entries; i++) for (i = 0; i < install_locales.n_entries; i++)
{ {
@@ -753,14 +789,20 @@ grub_install_copy_files (const char *src,
install_themes.entries[1] = NULL; install_themes.entries[1] = NULL;
} }
if (grub_install_themes_directory)
themes_dir = xstrdup (grub_install_themes_directory);
else
themes_dir = grub_util_path_concat (2, grub_util_get_pkgdatadir (),
"themes");
for (i = 0; i < install_themes.n_entries; i++) for (i = 0; i < install_themes.n_entries; i++)
{ {
char *srcf = grub_util_path_concat (4, pkgdatadir, "themes", char *srcf = grub_util_path_concat (3, themes_dir,
install_themes.entries[i], install_themes.entries[i],
"theme.txt"); "theme.txt");
if (grub_util_is_regular (srcf)) if (grub_util_is_regular (srcf))
{ {
char *srcd = grub_util_path_concat (3, pkgdatadir, "themes", char *srcd = grub_util_path_concat (2, themes_dir,
install_themes.entries[i]); install_themes.entries[i]);
char *dstd = grub_util_path_concat (3, dst, "themes", char *dstd = grub_util_path_concat (3, dst, "themes",
install_themes.entries[i]); install_themes.entries[i]);
@@ -772,6 +814,8 @@ grub_install_copy_files (const char *src,
free (srcf); free (srcf);
} }
free (themes_dir);
if (install_fonts.is_default) if (install_fonts.is_default)
{ {
install_fonts.is_default = 0; install_fonts.is_default = 0;
+2 -2
View File
@@ -232,7 +232,7 @@ static struct argp_option options[] = {
N_("disk module to use (biosdisk or native). " N_("disk module to use (biosdisk or native). "
"This option is only available on BIOS target."), 2}, "This option is only available on BIOS target."), 2},
{"no-nvram", OPTION_NO_NVRAM, 0, 0, {"no-nvram", OPTION_NO_NVRAM, 0, 0,
N_("don't update the `boot-device' NVRAM variable. " N_("don't update the `boot-device'/`Boot*' NVRAM variables. "
"This option is only available on EFI and IEEE1275 targets."), 2}, "This option is only available on EFI and IEEE1275 targets."), 2},
{"skip-fs-probe",'s',0, 0, {"skip-fs-probe",'s',0, 0,
N_("do not probe for filesystems in DEVICE"), 0}, N_("do not probe for filesystems in DEVICE"), 0},
@@ -586,7 +586,7 @@ device_map_check_duplicates (const char *dev_map)
fclose (fp); fclose (fp);
qsort (d, filled, sizeof (d[0]), (int (*) (const void *, const void *))strcmp); qsort (d, filled, sizeof (d[0]), grub_qsort_strcmp);
for (i = 0; i + 1 < filled; i++) for (i = 0; i + 1 < filled; i++)
if (strcmp (d[i], d[i+1]) == 0) if (strcmp (d[i], d[i+1]) == 0)
+2
View File
@@ -186,9 +186,11 @@ export GRUB_DEFAULT \
GRUB_HIDDEN_TIMEOUT \ GRUB_HIDDEN_TIMEOUT \
GRUB_HIDDEN_TIMEOUT_QUIET \ GRUB_HIDDEN_TIMEOUT_QUIET \
GRUB_TIMEOUT \ GRUB_TIMEOUT \
GRUB_TIMEOUT_STYLE \
GRUB_DEFAULT_BUTTON \ GRUB_DEFAULT_BUTTON \
GRUB_HIDDEN_TIMEOUT_BUTTON \ GRUB_HIDDEN_TIMEOUT_BUTTON \
GRUB_TIMEOUT_BUTTON \ GRUB_TIMEOUT_BUTTON \
GRUB_TIMEOUT_STYLE_BUTTON \
GRUB_BUTTON_CMOS_ADDRESS \ GRUB_BUTTON_CMOS_ADDRESS \
GRUB_BUTTON_CMOS_CLEAN \ GRUB_BUTTON_CMOS_CLEAN \
GRUB_DISTRIBUTOR \ GRUB_DISTRIBUTOR \
+1 -1
View File
@@ -43,7 +43,7 @@
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include FT_TRUETYPE_TAGS_H #include FT_TRUETYPE_TAGS_H
#include FT_TRUETYPE_TABLES_H #include FT_TRUETYPE_TABLES_H
#include <freetype/ftsynth.h> #include FT_SYNTHESIS_H
#undef __FTERRORS_H__ #undef __FTERRORS_H__
#define FT_ERROR_START_LIST const char *ft_errmsgs[] = { #define FT_ERROR_START_LIST const char *ft_errmsgs[] = {
+1 -2
View File
@@ -285,8 +285,7 @@ main (int argc, char *argv[])
arguments.image_target, arguments.note, arguments.image_target, arguments.note,
arguments.comp); arguments.comp);
fflush (fp); grub_util_file_sync (fp);
fsync (fileno (fp));
fclose (fp); fclose (fp);
if (arguments.dir) if (arguments.dir)
+168 -23
View File
@@ -493,6 +493,85 @@ SUFFIX (count_funcs) (Elf_Ehdr *e, Elf_Shdr *symtab_section,
} }
#endif #endif
#ifdef MKIMAGE_ELF32
/* Deal with relocation information. This function relocates addresses
within the virtual address space starting from 0. So only relative
addresses can be fully resolved. Absolute addresses must be relocated
again by a PE32 relocator when loaded. */
static grub_size_t
arm_get_trampoline_size (Elf_Ehdr *e,
Elf_Shdr *sections,
Elf_Half section_entsize,
Elf_Half num_sections,
const struct grub_install_image_target_desc *image_target)
{
Elf_Half i;
Elf_Shdr *s;
grub_size_t ret = 0;
for (i = 0, s = sections;
i < num_sections;
i++, s = (Elf_Shdr *) ((char *) s + section_entsize))
if ((s->sh_type == grub_host_to_target32 (SHT_REL)) ||
(s->sh_type == grub_host_to_target32 (SHT_RELA)))
{
Elf_Rela *r;
Elf_Word rtab_size, r_size, num_rs;
Elf_Off rtab_offset;
Elf_Shdr *symtab_section;
Elf_Word j;
symtab_section = (Elf_Shdr *) ((char *) sections
+ (grub_target_to_host32 (s->sh_link)
* section_entsize));
rtab_size = grub_target_to_host (s->sh_size);
r_size = grub_target_to_host (s->sh_entsize);
rtab_offset = grub_target_to_host (s->sh_offset);
num_rs = rtab_size / r_size;
for (j = 0, r = (Elf_Rela *) ((char *) e + rtab_offset);
j < num_rs;
j++, r = (Elf_Rela *) ((char *) r + r_size))
{
Elf_Addr info;
Elf_Addr sym_addr;
info = grub_target_to_host (r->r_info);
sym_addr = SUFFIX (get_symbol_address) (e, symtab_section,
ELF_R_SYM (info), image_target);
sym_addr += (s->sh_type == grub_target_to_host32 (SHT_RELA)) ?
grub_target_to_host (r->r_addend) : 0;
switch (ELF_R_TYPE (info))
{
case R_ARM_ABS32:
case R_ARM_V4BX:
break;
case R_ARM_THM_CALL:
case R_ARM_THM_JUMP24:
case R_ARM_THM_JUMP19:
if (!(sym_addr & 1))
ret += 8;
break;
case R_ARM_CALL:
case R_ARM_JUMP24:
if (sym_addr & 1)
ret += 16;
break;
default:
grub_util_error (_("relocation 0x%x is not implemented yet!"), ELF_R_TYPE (info));
break;
}
}
}
return ret;
}
#endif
/* Deal with relocation information. This function relocates addresses /* Deal with relocation information. This function relocates addresses
within the virtual address space starting from 0. So only relative within the virtual address space starting from 0. So only relative
addresses can be fully resolved. Absolute addresses must be relocated addresses can be fully resolved. Absolute addresses must be relocated
@@ -512,6 +591,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
struct grub_ia64_trampoline *tr = (void *) (pe_target + tramp_off); struct grub_ia64_trampoline *tr = (void *) (pe_target + tramp_off);
grub_uint64_t *gpptr = (void *) (pe_target + got_off); grub_uint64_t *gpptr = (void *) (pe_target + got_off);
#define MASK19 ((1 << 19) - 1) #define MASK19 ((1 << 19) - 1)
#else
grub_uint32_t *tr = (void *) (pe_target + tramp_off);
#endif #endif
for (i = 0, s = sections; for (i = 0, s = sections;
@@ -731,13 +812,13 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
case R_AARCH64_JUMP26: case R_AARCH64_JUMP26:
case R_AARCH64_CALL26: case R_AARCH64_CALL26:
{ {
grub_err_t err;
sym_addr -= offset; sym_addr -= offset;
sym_addr -= SUFFIX (entry_point); sym_addr -= SUFFIX (entry_point);
err = grub_arm64_reloc_xxxx26((grub_uint32_t *)target, if (!grub_arm_64_check_xxxx26_offset (sym_addr))
grub_util_error ("%s", _("CALL26 Relocation out of range"));
grub_arm64_set_xxxx26_offset((grub_uint32_t *)target,
sym_addr); sym_addr);
if (err)
grub_util_error ("%s", grub_errmsg);
} }
break; break;
default: default:
@@ -764,32 +845,74 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
*target = grub_host_to_target32 (grub_target_to_host32 (*target) + sym_addr); *target = grub_host_to_target32 (grub_target_to_host32 (*target) + sym_addr);
} }
break; break;
/* Happens when compiled with -march=armv4.
Since currently we need at least armv5, keep bx as-is.
*/
case R_ARM_V4BX:
break;
case R_ARM_THM_CALL: case R_ARM_THM_CALL:
case R_ARM_THM_JUMP24: case R_ARM_THM_JUMP24:
{
grub_err_t err;
grub_util_info (" THM_JUMP24:\ttarget=0x%08lx\toffset=(0x%08x)", (unsigned long) target, sym_addr);
sym_addr -= offset;
/* Thumb instructions can be 16-bit aligned */
err = grub_arm_reloc_thm_call ((grub_uint16_t *) target,
sym_addr);
if (err)
grub_util_error ("%s", grub_errmsg);
}
break;
case R_ARM_THM_JUMP19: case R_ARM_THM_JUMP19:
{ {
grub_err_t err; grub_err_t err;
grub_util_info (" THM_JUMP19:\toffset=%d\t(0x%08x)", grub_util_info (" THM_JUMP24:\ttarget=0x%08lx\toffset=(0x%08x)", (unsigned long) target, sym_addr);
sym_addr, sym_addr); if (!(sym_addr & 1))
sym_addr -= offset; {
grub_uint32_t tr_addr;
grub_int32_t new_offset;
tr_addr = (char *) tr - (char *) pe_target
- target_section_addr;
new_offset = sym_addr - tr_addr - 12;
if (!grub_arm_jump24_check_offset (new_offset))
return grub_util_error ("jump24 relocation out of range");
tr[0] = grub_host_to_target32 (0x46c04778); /* bx pc; nop */
tr[1] = grub_host_to_target32 (((new_offset >> 2) & 0xffffff) | 0xea000000); /* b new_offset */
tr += 2;
sym_addr = tr_addr | 1;
}
sym_addr -= offset;
/* Thumb instructions can be 16-bit aligned */ /* Thumb instructions can be 16-bit aligned */
err = grub_arm_reloc_thm_jump19 ((grub_uint16_t *) target, sym_addr); if (ELF_R_TYPE (info) == R_ARM_THM_JUMP19)
err = grub_arm_reloc_thm_jump19 ((grub_uint16_t *) target, sym_addr);
else
err = grub_arm_reloc_thm_call ((grub_uint16_t *) target,
sym_addr);
if (err) if (err)
grub_util_error ("%s", grub_errmsg); grub_util_error ("%s", grub_errmsg);
} }
break; break;
case R_ARM_CALL:
case R_ARM_JUMP24:
{
grub_err_t err;
grub_util_info (" JUMP24:\ttarget=0x%08lx\toffset=(0x%08x)", (unsigned long) target, sym_addr);
if (sym_addr & 1)
{
grub_uint32_t tr_addr;
grub_int32_t new_offset;
tr_addr = (char *) tr - (char *) pe_target
- target_section_addr;
new_offset = sym_addr - tr_addr - 12;
/* There is no immediate version of bx, only register one... */
tr[0] = grub_host_to_target32 (0xe59fc004); /* ldr ip, [pc, #4] */
tr[1] = grub_host_to_target32 (0xe08cc00f); /* add ip, ip, pc */
tr[2] = grub_host_to_target32 (0xe12fff1c); /* bx ip */
tr[3] = grub_host_to_target32 (new_offset | 1);
tr += 4;
sym_addr = tr_addr;
}
sym_addr -= offset;
err = grub_arm_reloc_jump24 (target,
sym_addr);
if (err)
grub_util_error ("%s", grub_errmsg);
}
break;
default: default:
grub_util_error (_("relocation 0x%x is not implemented yet!"), ELF_R_TYPE (info)); grub_util_error (_("relocation 0x%x is not implemented yet!"), ELF_R_TYPE (info));
break; break;
@@ -1054,11 +1177,13 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
case EM_ARM: case EM_ARM:
switch (ELF_R_TYPE (info)) switch (ELF_R_TYPE (info))
{ {
case R_ARM_V4BX:
/* Relative relocations do not require fixup entries. */ /* Relative relocations do not require fixup entries. */
case R_ARM_JUMP24: case R_ARM_JUMP24:
case R_ARM_THM_CALL: case R_ARM_THM_CALL:
case R_ARM_THM_JUMP19: case R_ARM_THM_JUMP19:
case R_ARM_THM_JUMP24: case R_ARM_THM_JUMP24:
case R_ARM_CALL:
{ {
Elf_Addr addr; Elf_Addr addr;
@@ -1280,7 +1405,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
Elf_Off section_offset; Elf_Off section_offset;
Elf_Half section_entsize; Elf_Half section_entsize;
grub_size_t kernel_size; grub_size_t kernel_size;
grub_size_t ia64jmp_off = 0, ia64_toff = 0, ia64_got_off = 0; grub_size_t ia64jmp_off = 0, tramp_off = 0, ia64_got_off = 0;
unsigned ia64jmpnum = 0; unsigned ia64jmpnum = 0;
Elf_Shdr *symtab_section = 0; Elf_Shdr *symtab_section = 0;
grub_size_t got = 0; grub_size_t got = 0;
@@ -1356,6 +1481,11 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
else else
*bss_size = 0; *bss_size = 0;
if (image_target->id == IMAGE_SPARC64_AOUT
|| image_target->id == IMAGE_SPARC64_RAW
|| image_target->id == IMAGE_SPARC64_CDCORE)
*kernel_sz = ALIGN_UP (*kernel_sz, image_target->mod_align);
if (image_target->id == IMAGE_EFI) if (image_target->id == IMAGE_EFI)
{ {
symtab_section = NULL; symtab_section = NULL;
@@ -1368,6 +1498,21 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
break; break;
} }
#ifdef MKIMAGE_ELF32
if (image_target->elf_target == EM_ARM)
{
grub_size_t tramp;
*kernel_sz = ALIGN_UP (*kernel_sz, 16);
tramp = arm_get_trampoline_size (e, sections, section_entsize,
num_sections, image_target);
tramp_off = *kernel_sz;
*kernel_sz += ALIGN_UP (tramp, 16);
}
#endif
#ifdef MKIMAGE_ELF64 #ifdef MKIMAGE_ELF64
if (image_target->elf_target == EM_IA_64) if (image_target->elf_target == EM_IA_64)
{ {
@@ -1377,7 +1522,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
grub_ia64_dl_get_tramp_got_size (e, &tramp, &got); grub_ia64_dl_get_tramp_got_size (e, &tramp, &got);
ia64_toff = *kernel_sz; tramp_off = *kernel_sz;
*kernel_sz += ALIGN_UP (tramp, 16); *kernel_sz += ALIGN_UP (tramp, 16);
ia64jmp_off = *kernel_sz; ia64jmp_off = *kernel_sz;
@@ -1419,7 +1564,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
SUFFIX (relocate_addresses) (e, sections, section_addresses, SUFFIX (relocate_addresses) (e, sections, section_addresses,
section_entsize, section_entsize,
num_sections, strtab, num_sections, strtab,
out_img, ia64_toff, ia64_got_off, out_img, tramp_off, ia64_got_off,
image_target); image_target);
*reloc_size = SUFFIX (make_reloc_section) (e, reloc_section, *reloc_size = SUFFIX (make_reloc_section) (e, reloc_section,
@@ -1427,7 +1572,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
section_entsize, num_sections, section_entsize, num_sections,
strtab, ia64jmp_off strtab, ia64jmp_off
+ image_target->vaddr_offset, + image_target->vaddr_offset,
2 * ia64jmpnum + got, 2 * ia64jmpnum + (got / 8),
image_target); image_target);
} }
+6 -2
View File
@@ -168,10 +168,12 @@ process_input_dir (const char *input_dir, enum grub_install_plat platform)
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
const char *pkgdatadir = grub_util_get_pkgdatadir (); const char *pkglibdir;
grub_util_host_init (&argc, &argv); grub_util_host_init (&argc, &argv);
grub_util_disable_fd_syncs ();
rootdir = xstrdup ("/srv/tftp"); rootdir = xstrdup ("/srv/tftp");
pkglibdir = grub_util_get_pkglibdir ();
subdir = grub_util_path_concat (2, GRUB_BOOT_DIR_NAME, GRUB_DIR_NAME); subdir = grub_util_path_concat (2, GRUB_BOOT_DIR_NAME, GRUB_DIR_NAME);
@@ -191,9 +193,11 @@ main (int argc, char *argv[])
for (plat = 0; plat < GRUB_INSTALL_PLATFORM_MAX; plat++) for (plat = 0; plat < GRUB_INSTALL_PLATFORM_MAX; plat++)
if (targets[plat].mkimage_target) if (targets[plat].mkimage_target)
{ {
char *platdir = grub_util_path_concat (2, pkgdatadir, char *platdir = grub_util_path_concat (2, pkglibdir,
grub_install_get_platform_name (plat)); grub_install_get_platform_name (plat));
grub_util_info ("Looking for `%s'", platdir);
if (!grub_util_is_directory (platdir)) if (!grub_util_is_directory (platdir))
{ {
free (platdir); free (platdir);
+14 -3
View File
@@ -369,6 +369,7 @@ main (int argc, char *argv[])
const char *pkgdatadir; const char *pkgdatadir;
grub_util_host_init (&argc, &argv); grub_util_host_init (&argc, &argv);
grub_util_disable_fd_syncs ();
pkgdatadir = grub_util_get_pkgdatadir (); pkgdatadir = grub_util_get_pkgdatadir ();
@@ -518,7 +519,9 @@ main (int argc, char *argv[])
if (!bi) if (!bi)
grub_util_error (_("cannot open `%s': %s"), bin, grub_util_error (_("cannot open `%s': %s"), bin,
strerror (errno)); strerror (errno));
fread (buf, 1, 512, bi); if (fread (buf, 1, 512, bi) != 512)
grub_util_error (_("cannot read `%s': %s"), bin,
strerror (errno));
fclose (bi); fclose (bi);
fwrite (buf, 1, 512, sa); fwrite (buf, 1, 512, sa);
@@ -529,7 +532,7 @@ main (int argc, char *argv[])
GRUB_COMPRESSION_AUTO); GRUB_COMPRESSION_AUTO);
sz = ftello (sa); sz = ftello (sa);
fflush (sa); fflush (sa);
fsync (fileno (sa)); grub_util_fd_sync (fileno (sa));
fclose (sa); fclose (sa);
if (sz > 32768) if (sz > 32768)
@@ -728,10 +731,18 @@ main (int argc, char *argv[])
cdboot = grub_util_path_concat (2, source_dirs[GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275], cdboot = grub_util_path_concat (2, source_dirs[GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275],
"cdboot.img"); "cdboot.img");
in = grub_util_fopen (cdboot, "rb"); in = grub_util_fopen (cdboot, "rb");
if (!in)
grub_util_error (_("cannot open `%s': %s"), cdboot,
strerror (errno));
out = grub_util_fopen (sysarea_img, "wb"); out = grub_util_fopen (sysarea_img, "wb");
if (!out)
grub_util_error (_("cannot open `%s': %s"), sysarea_img,
strerror (errno));
memset (buf, 0, 512); memset (buf, 0, 512);
fwrite (buf, 1, 512, out); fwrite (buf, 1, 512, out);
fread (buf, 1, 512, in); if (fread (buf, 1, 512, in) != 512)
grub_util_error (_("cannot read `%s': %s"), cdboot,
strerror (errno));
fwrite (buf, 1, 512, out); fwrite (buf, 1, 512, out);
fclose (in); fclose (in);
fclose (out); fclose (out);
+1
View File
@@ -305,6 +305,7 @@ main (int argc, char *argv[])
int i; int i;
grub_util_host_init (&argc, &argv); grub_util_host_init (&argc, &argv);
grub_util_disable_fd_syncs ();
files = xmalloc ((argc + 1) * sizeof (files[0])); files = xmalloc ((argc + 1) * sizeof (files[0]));
+1 -40
View File
@@ -209,23 +209,9 @@ DEVICE must be an OS device (e.g. /dev/sda)."),
NULL, help_filter, NULL NULL, help_filter, NULL
}; };
static char *
get_device_name (char *dev)
{
size_t len = strlen (dev);
if (dev[0] != '(' || dev[len - 1] != ')')
return 0;
dev[len - 1] = '\0';
return dev + 1;
}
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
char *root_dev = NULL;
char *dest_dev = NULL;
struct arguments arguments; struct arguments arguments;
grub_util_host_init (&argc, &argv); grub_util_host_init (&argc, &argv);
@@ -264,34 +250,11 @@ main (int argc, char *argv[])
grub_mdraid1x_init (); grub_mdraid1x_init ();
grub_lvm_init (); grub_lvm_init ();
dest_dev = get_device_name (arguments.device);
if (! dest_dev)
{
/* Possibly, the user specified an OS device file. */
dest_dev = grub_util_get_grub_dev (arguments.device);
if (! dest_dev)
{
char *program = xstrdup(program_name);
fprintf (stderr, _("Invalid device `%s'.\n"), arguments.device);
argp_help (&argp, stderr, ARGP_HELP_STD_USAGE, program);
free(program);
exit(1);
}
grub_util_info ("transformed OS device `%s' into GRUB device `%s'",
arguments.device, dest_dev);
}
else
{
/* For simplicity. */
dest_dev = xstrdup (dest_dev);
grub_util_info ("Using `%s' as GRUB device", dest_dev);
}
/* Do the real work. */ /* Do the real work. */
GRUB_SETUP_FUNC (arguments.dir ? : DEFAULT_DIRECTORY, GRUB_SETUP_FUNC (arguments.dir ? : DEFAULT_DIRECTORY,
arguments.boot_file ? : DEFAULT_BOOT_FILE, arguments.boot_file ? : DEFAULT_BOOT_FILE,
arguments.core_file ? : DEFAULT_CORE_FILE, arguments.core_file ? : DEFAULT_CORE_FILE,
dest_dev, arguments.force, arguments.device, arguments.force,
arguments.fs_probe, arguments.allow_floppy); arguments.fs_probe, arguments.allow_floppy);
/* Free resources. */ /* Free resources. */
@@ -303,8 +266,6 @@ main (int argc, char *argv[])
free (arguments.dir); free (arguments.dir);
free (arguments.dev_map); free (arguments.dev_map);
free (arguments.device); free (arguments.device);
free (root_dev);
free (dest_dev);
return 0; return 0;
} }
+34 -8
View File
@@ -282,15 +282,41 @@ fi
make_timeout () make_timeout ()
{ {
if [ "x${1}" != "x" ] ; then if [ "x${1}${3}" != "x" ] ; then
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then if [ "x${3}" != "x" ] ; then
verbose= timeout="${2}"
style="${3}"
else else
# Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
timeout="${1}"
if [ "x${2}" != "x0" ] ; then
grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
fi
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
style="hidden"
else
style="countdown"
fi
fi
if [ "x${style}" = "xcountdown" ] ; then
verbose=" --verbose" verbose=" --verbose"
else
verbose=
fi
cat << EOF
if [ x\$feature_timeout_style = xy ] ; then
set timeout_style=${style}
set timeout=${timeout}
EOF
if [ "x${style}" != "xmenu" ] ; then
cat << EOF
# Fallback hidden-timeout code in case the timeout_style feature is
# unavailable.
elif sleep${verbose} --interruptible ${timeout} ; then
set timeout=0
EOF
fi fi
cat << EOF cat << EOF
if sleep$verbose --interruptible ${1} ; then
set timeout=${2}
fi fi
EOF EOF
else else
@@ -304,12 +330,12 @@ if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
cat <<EOF cat <<EOF
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
EOF EOF
make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}" make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_STYLE_BUTTON}"
echo else echo else
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" "${GRUB_TIMEOUT_STYLE}"
echo fi echo fi
else else
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" "${GRUB_TIMEOUT_STYLE}"
fi fi
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ] && [ "x$GRUB_BUTTON_CMOS_CLEAN" = "xyes" ]; then if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ] && [ "x$GRUB_BUTTON_CMOS_CLEAN" = "xyes" ]; then
+1 -1
View File
@@ -112,7 +112,7 @@ for OS in ${OSPROBED} ; do
LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`" LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`" LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
BOOT="`echo ${OS} | cut -d ':' -f 4`" BOOT="`echo ${OS} | cut -d ':' -f 4`"
UUID="`grub-probe --target=fs_uuid --device ${DEVICE%@*}`" UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"
EXPUUID="$UUID" EXPUUID="$UUID"
if [ x"${DEVICE#*@}" != x ] ; then if [ x"${DEVICE#*@}" != x ] ; then
+8
View File
@@ -256,3 +256,11 @@ void
grub_register_exported_symbols (void) grub_register_exported_symbols (void)
{ {
} }
/* Used in comparison of arrays of strings with qsort */
int
grub_qsort_strcmp (const void *p1, const void *p2)
{
return strcmp(*(char **)p1, *(char **)p2);
}
+100 -19
View File
@@ -383,7 +383,8 @@ static const struct grub_install_image_target_desc image_targets[] =
.decompressor_uncompressed_addr = TARGET_NO_FIELD, .decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1, .section_align = 1,
.vaddr_offset = 0, .vaddr_offset = 0,
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR .link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR,
.mod_align = GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN,
}, },
{ {
.dirname = "sparc64-ieee1275", .dirname = "sparc64-ieee1275",
@@ -398,7 +399,8 @@ static const struct grub_install_image_target_desc image_targets[] =
.decompressor_uncompressed_addr = TARGET_NO_FIELD, .decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1, .section_align = 1,
.vaddr_offset = 0, .vaddr_offset = 0,
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR .link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR,
.mod_align = GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN,
}, },
{ {
.dirname = "sparc64-ieee1275", .dirname = "sparc64-ieee1275",
@@ -413,7 +415,8 @@ static const struct grub_install_image_target_desc image_targets[] =
.decompressor_uncompressed_addr = TARGET_NO_FIELD, .decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1, .section_align = 1,
.vaddr_offset = 0, .vaddr_offset = 0,
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR .link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR,
.mod_align = GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN,
}, },
{ {
.dirname = "ia64-efi", .dirname = "ia64-efi",
@@ -831,6 +834,94 @@ struct fixup_block_list
struct grub_pe32_fixup_block b; struct grub_pe32_fixup_block b;
}; };
/*
* R_ARM_THM_CALL/THM_JUMP24
*
* Relocate Thumb (T32) instruction set relative branches:
* B.W, BL and BLX
*/
static grub_err_t
grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
{
grub_int32_t offset;
offset = grub_arm_thm_call_get_offset (target);
grub_dprintf ("dl", " sym_addr = 0x%08x", sym_addr);
offset += sym_addr;
grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n",
target, sym_addr, offset);
/* Keep traditional (pre-Thumb2) limits on blx. In any case if the kernel
is bigger than 2M (currently under 150K) then we probably have a problem
somewhere else. */
if (offset < -0x200000 || offset >= 0x200000)
return grub_error (GRUB_ERR_BAD_MODULE,
N_("THM_CALL Relocation out of range."));
grub_dprintf ("dl", " relative destination = %p",
(char *) target + offset);
return grub_arm_thm_call_set_offset (target, offset);
}
/*
* R_ARM_THM_JUMP19
*
* Relocate conditional Thumb (T32) B<c>.W
*/
static grub_err_t
grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
{
grub_int32_t offset;
if (!(sym_addr & 1))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("Relocation targeting wrong execution state"));
offset = grub_arm_thm_jump19_get_offset (target);
/* Adjust and re-truncate offset */
offset += sym_addr;
if (!grub_arm_thm_jump19_check_offset (offset))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("THM_JUMP19 Relocation out of range."));
grub_arm_thm_jump19_set_offset (target, offset);
return GRUB_ERR_NONE;
}
/*
* R_ARM_JUMP24
*
* Relocate ARM (A32) B
*/
static grub_err_t
grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr)
{
grub_int32_t offset;
if (sym_addr & 1)
return grub_error (GRUB_ERR_BAD_MODULE,
N_("Relocation targeting wrong execution state"));
offset = grub_arm_jump24_get_offset (target);
offset += sym_addr;
if (!grub_arm_jump24_check_offset (offset))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("JUMP24 Relocation out of range."));
grub_arm_jump24_set_offset (target, offset);
return GRUB_ERR_NONE;
}
#pragma GCC diagnostic ignored "-Wcast-align" #pragma GCC diagnostic ignored "-Wcast-align"
#define MKIMAGE_ELF32 1 #define MKIMAGE_ELF32 1
@@ -1582,7 +1673,6 @@ grub_install_generate_image (const char *dir, const char *prefix,
size_t rom_size; size_t rom_size;
char *boot_path, *boot_img; char *boot_path, *boot_img;
size_t boot_size; size_t boot_size;
grub_uint8_t context[GRUB_MD_SHA512->contextsize];
/* fwstart.img is the only part which can't be tested by using *-elf /* fwstart.img is the only part which can't be tested by using *-elf
target. Check it against the checksum. */ target. Check it against the checksum. */
const grub_uint8_t yeeloong_fwstart_good_hash[512 / 8] = const grub_uint8_t yeeloong_fwstart_good_hash[512 / 8] =
@@ -1608,6 +1698,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
0x46, 0x50, 0xd6, 0x21, 0xce, 0x8e, 0x24, 0xa7 0x46, 0x50, 0xd6, 0x21, 0xce, 0x8e, 0x24, 0xa7
}; };
const grub_uint8_t *fwstart_good_hash; const grub_uint8_t *fwstart_good_hash;
grub_uint8_t fwstart_hash[512 / 8];
if (image_target->id == IMAGE_FULOONG2F_FLASH) if (image_target->id == IMAGE_FULOONG2F_FLASH)
{ {
@@ -1623,11 +1714,9 @@ grub_install_generate_image (const char *dir, const char *prefix,
boot_size = grub_util_get_image_size (boot_path); boot_size = grub_util_get_image_size (boot_path);
boot_img = grub_util_read_image (boot_path); boot_img = grub_util_read_image (boot_path);
grub_memset (context, 0, sizeof (context)); grub_crypto_hash (GRUB_MD_SHA512, fwstart_hash, boot_img, boot_size);
GRUB_MD_SHA512->init (context);
GRUB_MD_SHA512->write (context, boot_img, boot_size); if (grub_memcmp (fwstart_hash, fwstart_good_hash,
GRUB_MD_SHA512->final (context);
if (grub_memcmp (GRUB_MD_SHA512->read (context), fwstart_good_hash,
GRUB_MD_SHA512->mdlen) != 0) GRUB_MD_SHA512->mdlen) != 0)
/* TRANSLATORS: fwstart.img may still be good, just it wasn't checked. */ /* TRANSLATORS: fwstart.img may still be good, just it wasn't checked. */
grub_util_warn ("%s", grub_util_warn ("%s",
@@ -1679,7 +1768,6 @@ grub_install_generate_image (const char *dir, const char *prefix,
case IMAGE_UBOOT: case IMAGE_UBOOT:
{ {
struct grub_uboot_image_header *hdr; struct grub_uboot_image_header *hdr;
GRUB_PROPERLY_ALIGNED_ARRAY (crc32_context, GRUB_MD_CRC32->contextsize);
hdr = xmalloc (core_size + sizeof (struct grub_uboot_image_header)); hdr = xmalloc (core_size + sizeof (struct grub_uboot_image_header));
memcpy (hdr + 1, core_img, core_size); memcpy (hdr + 1, core_img, core_size);
@@ -1695,15 +1783,8 @@ grub_install_generate_image (const char *dir, const char *prefix,
hdr->ih_arch = GRUB_UBOOT_IH_ARCH_ARM; hdr->ih_arch = GRUB_UBOOT_IH_ARCH_ARM;
hdr->ih_comp = GRUB_UBOOT_IH_COMP_NONE; hdr->ih_comp = GRUB_UBOOT_IH_COMP_NONE;
GRUB_MD_CRC32->init(crc32_context); grub_crypto_hash (GRUB_MD_CRC32, &hdr->ih_dcrc, hdr + 1, core_size);
GRUB_MD_CRC32->write(crc32_context, hdr + 1, core_size); grub_crypto_hash (GRUB_MD_CRC32, &hdr->ih_hcrc, hdr, sizeof (*hdr));
GRUB_MD_CRC32->final(crc32_context);
hdr->ih_dcrc = grub_get_unaligned32 (GRUB_MD_CRC32->read (crc32_context));
GRUB_MD_CRC32->init(crc32_context);
GRUB_MD_CRC32->write(crc32_context, hdr, sizeof (*hdr));
GRUB_MD_CRC32->final(crc32_context);
hdr->ih_hcrc = grub_get_unaligned32 (GRUB_MD_CRC32->read (crc32_context));
free (core_img); free (core_img);
core_img = (char *) hdr; core_img = (char *) hdr;
+25 -1
View File
@@ -247,12 +247,13 @@ identify_partmap (grub_disk_t disk __attribute__ ((unused)),
void void
SETUP (const char *dir, SETUP (const char *dir,
const char *boot_file, const char *core_file, const char *boot_file, const char *core_file,
const char *dest, int force, const char *dev, int force,
int fs_probe, int allow_floppy) int fs_probe, int allow_floppy)
{ {
char *core_path; char *core_path;
char *boot_img, *core_img, *boot_path; char *boot_img, *core_img, *boot_path;
char *root = 0; char *root = 0;
char *dest = 0;
size_t boot_size, core_size; size_t boot_size, core_size;
#ifdef GRUB_SETUP_BIOS #ifdef GRUB_SETUP_BIOS
grub_uint16_t core_sectors; grub_uint16_t core_sectors;
@@ -269,6 +270,28 @@ SETUP (const char *dir,
#endif #endif
bl.last_length = 0; bl.last_length = 0;
{
size_t len = strlen (dev);
if (len > 2 && dev[0] == '(' && dev[len - 1] == ')')
{
dest = xmalloc (len - 1);
strncpy (dest, dev + 1, len - 2);
dest[len - 2] = '\0';
}
}
if (! dest)
{
/* Possibly, the user specified an OS device file. */
dest = grub_util_get_grub_dev (dev);
if (! dest)
grub_util_error (_("Invalid device `%s'.\n"), dev);
grub_util_info ("transformed OS device `%s' into GRUB device `%s'",
dev, dest);
}
/* Read the boot image by the OS service. */ /* Read the boot image by the OS service. */
boot_path = grub_util_get_path (dir, boot_file); boot_path = grub_util_get_path (dir, boot_file);
boot_size = grub_util_get_image_size (boot_path); boot_size = grub_util_get_image_size (boot_path);
@@ -303,6 +326,7 @@ SETUP (const char *dir,
dest_dev = grub_device_open (dest); dest_dev = grub_device_open (dest);
if (! dest_dev) if (! dest_dev)
grub_util_error ("%s", grub_errmsg); grub_util_error ("%s", grub_errmsg);
free (dest);
core_dev = dest_dev; core_dev = dest_dev;