Merge upstream changes as of April 29th
This commit is contained in:
commit
c7c750ecc2
267 changed files with 5728 additions and 1943 deletions
|
@ -1,3 +1,259 @@
|
|||
2015-01-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* tests/file_filter/file: Really add missing file.
|
||||
|
||||
2015-01-23 Andrei Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* grub-core/disk/xen/xendisk.c: Accept hdX as disk names on Xen to
|
||||
allow legacy menu.lst processing.
|
||||
|
||||
2015-01-22 Felix Janda <felix.janda@posteo.de>
|
||||
|
||||
Remove direct _llseek code and require long filesystem libc.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Remove potential division by 0 in gfxmenu.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/normal/menu_text.c (grub_menu_init_page): Avoid
|
||||
returning 0 geometry to avoid divisions by 0.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/osdep/unix/cputime.c (grub_util_get_cpu_time_ms): Cache
|
||||
sc_clk_tck and check it for sanity.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/efi/mm.c (grub_efi_get_memory_map): Never return a
|
||||
descriptor_size==0 to avoid potential divisions by zero.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/osdep/haiku/getroot.c (grub_util_find_partition_start_os):
|
||||
Avoid division by zero.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/generic/rtc_get_time_ms.c (grub_rtc_get_time_ms): Avoid
|
||||
division by zero.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/loader/i386/xnu.c (guessfsb): Avoid division by 0.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that
|
||||
no division by 0 occurs.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* include/grub/misc.h (grub_div_roundup): Remove as it's unused.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/term/gfxterm.c: Avoid division by zero.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Avoid division by zero in serial.
|
||||
|
||||
* grub-core/term/serial.c (grub_cmd_serial): Ensure speed is not 0.
|
||||
* grub-core/term/ns8250.c (serial_get_divisor): Exit if speed is 0.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/video/readers/jpeg.c: Avoid sivision by zero.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/diskfilter.c: Validate volumes to avoid division
|
||||
by zero.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* include/grub/term.h: Avoid returining 0-sized terminal
|
||||
as it may lead to division by zero.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/fs/zfs.c: Avoid divisions by zero.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/fs/btrfs.c: Avoid divisions by zero.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/lib/pbkdf2.c (grub_crypto_pbkdf2): Check that hash len is not 0.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/osdep/linux/blocklist.c (grub_install_get_blocklist): Check
|
||||
blocksize validity.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/i386/pc/biosdisk.c: Check disk size sanity.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/ieee1275/nand.c (grub_nand_open): Check block size
|
||||
validity.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/dmraid_nvidia.c (grub_dmraid_nv_detect): Do not
|
||||
divide by zero.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/fs/hfs.c (grub_hfs_mount): Additional filesystem
|
||||
sanity checks.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/fs/minix.c: Additional filesystem
|
||||
sanity checks.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/fs/ext2.c (grub_ext2_mount): Additional
|
||||
checks for superblock validity.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/fs/ufs.c (grub_ufs_mount): Check
|
||||
that sblock.ino_per_group is not 0.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Reject NILFS2 superblocks with over 1GiB blocks.
|
||||
|
||||
* grub-core/fs/nilfs2.c (grub_nilfs2_valid_sb): Check that
|
||||
block size is <= 1GiB.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/ata.c (grub_ata_setaddress): Check that geometry
|
||||
is sane when using CHS addressing.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/AFSplitter.c (AF_merge): Check that mdlen is not 0.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/commands/i386/pc/play.c (grub_cmd_play): Avoid
|
||||
division by zero.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/bus/usb/usbtrans.c (grub_usb_bulk_maxpacket): Avoid
|
||||
potentially returning 0.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/fs/minix.c (grub_minix_read_file): Avoid reading past
|
||||
the end of file.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/fs/fshelp.c (grub_fshelp_read_file): Don't attempt to read
|
||||
past the end of file.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/script/lexer.c (grub_script_lexer_yywrap): Update len
|
||||
synchronously with line.
|
||||
|
||||
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Replace explicit sizeof divisions by ARRAY_SIZE.
|
||||
|
||||
2015-01-19 Kris Moore <kris@pcbsd.org>
|
||||
|
||||
* grub-core/disk/geli.c: Support GELI v6 and v7.
|
||||
|
||||
2014-12-09 Andrei Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* grub-core/term/serial.c (grub_cmd_serial): Fix --rtscts
|
||||
option processing.
|
||||
|
||||
2014-12-07 David Kozub <zub.272@gmail.com>
|
||||
|
||||
* grub-core/kern/arm/misc.S: fix unaligned 64bit local variable
|
||||
in __aeabi_uidivmod
|
||||
Fixes Savannah bug #43632.
|
||||
|
||||
2014-12-07 Peter Nelson <peterdn>
|
||||
|
||||
* grub-core/fs/ext2.c (grub_ext2_read_block): Support large sparse
|
||||
chunks.
|
||||
|
||||
2014-12-07 Andrei Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* util/grub-mkconfig_lib.in (version_test_gt): Remove redundant
|
||||
non-portable '-n' echo option.
|
||||
* util/grub.d/10_kfreebsd.in: Change how list is built to avoid
|
||||
non-portable 'echo -n.
|
||||
* util/grub.d/10_linux.in: Likewise (closes 43668).
|
||||
* util/grub.d/20_linux_xen.in: Likewise.
|
||||
* util/grub.d/30_os-prober.in: Print spaces directly to avoid
|
||||
non-portable 'echo -n'.
|
||||
|
||||
2014-12-07 Curtis Larsen <larsen@dixie.edu>
|
||||
|
||||
* grub-core/net/tcp.c (grub_net_recv_tcp_packet): Fix double
|
||||
free when multiple empty segments were received (closes 42765).
|
||||
|
||||
2014-12-05 Andrei Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* tests/util/grub-shell.in: Support --files also for netboot.
|
||||
* tests/file_filter_test.in: New file with file filters tests.
|
||||
* Makefile.util.def: Add file_filter_test.
|
||||
* conf/Makefile.extra-dist: ... and here.
|
||||
* tests/file_filter/file.gz: Test file for file_filter_test.
|
||||
* tests/file_filter/file.gz.sig: Likewise.
|
||||
* tests/file_filter/file.lzop: Likewise.
|
||||
* tests/file_filter/file.lzop.sig: Likewise.
|
||||
* tests/file_filter/file.xz: Likewise.
|
||||
* tests/file_filter/file.xz.sig: Likewise.
|
||||
* tests/file_filter/keys: Likewise.
|
||||
* tests/file_filter/keys.pub: Likewise.
|
||||
* tests/file_filter/test.cfg: Likewise.
|
||||
* grub-core/commands/verify.c: Fix memory corruption doing
|
||||
signature check for network files (closes 43601).
|
||||
|
||||
2014-12-01 Andrei Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* grub-core/loader/i386/xen_fileXX.c (grub_xen_get_infoXX): Fix
|
||||
memory leak (CID 73645, 73782).
|
||||
* grub-core/fs/zfs/zfsinfo.c (print_vdev_info): Fix memory leak
|
||||
(CID 73635).
|
||||
|
||||
2014-11-30 Andrei Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* grub-core/lib/syslinux_parse.c (free_menu): Do not free
|
||||
inline array (CID 73610).
|
||||
|
||||
2014-11-28 Andrei Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* grub-core/io/lzopio.c (test_header): Fix double free (CID 73665)
|
||||
* grub-core/disk/geli.c (configure_ciphers): Fix memory leaks
|
||||
(Coverity CID 73813, 73710)
|
||||
* grub-core/disk/luks.c (configure_ciphers): Fix memory leaks
|
||||
and use after free (Coverity CID 73813, 73710, 73730)
|
||||
* grub-core/disk/luks.c (luks_recover_key): Fix memory leak (Coverity
|
||||
CID 73854)
|
||||
* util/grub-install-common.c (grub_install_get_target): Check return
|
||||
value of grub_util_fd_read (Coverity CID 73819).
|
||||
* util/grub-mkstandalone.c (add_tar_file): Fix out of bound access
|
||||
to hd.magic (Coverity CID 73587, 73888, bug 43690).
|
||||
|
||||
2014-11-20 Andrei Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* tests/util/grub-fs-tester.in: Consistently print output
|
16
INSTALL
16
INSTALL
|
@ -13,6 +13,9 @@ configuring the GRUB.
|
|||
|
||||
* GCC 4.1.3 or later
|
||||
Note: older versions may work but support is limited
|
||||
|
||||
Experimental support for clang 3.3 or later (results in much bigger binaries)
|
||||
for i386, x86_64, arm (except thumb), arm64, mips(el), powerpc, sparc64
|
||||
Note: clang 3.2 or later works for i386 and x86_64 targets but results in
|
||||
much bigger binaries.
|
||||
earlier versions not tested
|
||||
|
@ -26,7 +29,8 @@ configuring the GRUB.
|
|||
fail.
|
||||
Note: clang 3.2 or later works for powerpc
|
||||
earlier versions not tested
|
||||
Note: clang doesn't support -mno-app-regs and so can't be used for sparc64
|
||||
Note: clang 3.5 or later works for sparc64
|
||||
earlier versions return "error: unable to interface with target machine"
|
||||
Note: clang has no support for ia64 and hence you can't compile GRUB
|
||||
for ia64 with clang
|
||||
* GNU Make
|
||||
|
@ -35,6 +39,7 @@ configuring the GRUB.
|
|||
* GNU binutils 2.9.1.0.23 or later
|
||||
* Flex 2.5.35 or later
|
||||
* Other standard GNU/Unix tools
|
||||
* a libc with large file support (e.g. glibc 2.1 or later)
|
||||
|
||||
On GNU/Linux, you also need:
|
||||
|
||||
|
@ -99,6 +104,9 @@ The simplest way to compile this package is:
|
|||
|
||||
3. Type `./autogen.sh'.
|
||||
|
||||
* autogen.sh uses python. By default invocation is "python" but can be
|
||||
overriden by setting variable $PYTHON.
|
||||
|
||||
4. Type `./configure' to configure the package for your system.
|
||||
If you're using `csh' on an old version of System V, you might
|
||||
need to type `sh ./configure' instead to prevent `csh' from trying
|
||||
|
@ -174,9 +182,9 @@ corresponding platform are not needed for the platform in question.
|
|||
- For host
|
||||
1. --host= to autoconf name of host.
|
||||
2. CC= for gcc able to compile for host
|
||||
3. CFLAGS= for C options for host.
|
||||
4. CPPFLAGS= for C preprocessor options for host.
|
||||
5. LDFLAGS= for linker options for host.
|
||||
3. HOST_CFLAGS= for C options for host.
|
||||
4. HOST_CPPFLAGS= for C preprocessor options for host.
|
||||
5. HOST_LDFLAGS= for linker options for host.
|
||||
6. FREETYPE= for freetype-config for host (optional).
|
||||
7. Libdevmapper if any must be in standard linker folders (-ldevmapper) (optional).
|
||||
8. Libfuse if any must be in standard linker folders (-lfuse) (optional).
|
||||
|
|
21
Makefile.am
21
Makefile.am
|
@ -392,7 +392,7 @@ endif
|
|||
.PHONY: bootcheck-linux-i386 bootcheck-linux-x86_64 \
|
||||
bootcheck-kfreebsd-i386 bootcheck-kfreebsd-x86_64 \
|
||||
bootcheck-knetbsd-i386 bootcheck-knetbsd-x86_64 \
|
||||
bootcheck-linux-mips
|
||||
bootcheck-linux-mips FORCE
|
||||
|
||||
# Randomly generated
|
||||
SUCCESSFUL_BOOT_STRING=3e49994fd5d82b7c9298d672d774080d
|
||||
|
@ -439,3 +439,22 @@ windowszip: windowsdir
|
|||
rm -rf $(windowsdir)
|
||||
|
||||
EXTRA_DIST += linguas.sh
|
||||
|
||||
changelog_start_date = 2015-01-23
|
||||
gitlog_to_changelog = $(top_srcdir)/build-aux/gitlog-to-changelog
|
||||
|
||||
ChangeLog: FORCE
|
||||
if test -d $(top_srcdir)/.git; then \
|
||||
$(gitlog_to_changelog) --srcdir=$(top_srcdir) --since=$(changelog_start_date) > '$@.tmp'; \
|
||||
rm -f '$@'; mv '$@.tmp' '$@'; \
|
||||
else \
|
||||
touch $@; \
|
||||
fi
|
||||
|
||||
EXTRA_DIST += ChangeLog ChangeLog-2015
|
||||
|
||||
syslinux_test: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg
|
||||
|
||||
tests/syslinux/ubuntu10.04_grub.cfg: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg.in
|
||||
(for x in tests/syslinux/ubuntu10.04_grub.cfg.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
|
||||
CLEANFILES += tests/syslinux/ubuntu10.04_grub.cfg
|
||||
|
|
|
@ -613,7 +613,6 @@ program = {
|
|||
common = grub-core/disk/host.c;
|
||||
|
||||
common = util/resolve.c;
|
||||
enable = noemu;
|
||||
common = grub-core/kern/emu/argp_common.c;
|
||||
common = grub-core/osdep/init.c;
|
||||
|
||||
|
@ -1162,6 +1161,24 @@ script = {
|
|||
common = tests/gptprio_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = file_filter_test;
|
||||
common = tests/file_filter_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = grub_cmd_test;
|
||||
common = tests/grub_cmd_test.in;
|
||||
};
|
||||
|
||||
script = {
|
||||
testcase;
|
||||
name = syslinux_test;
|
||||
common = tests/syslinux_test.in;
|
||||
};
|
||||
|
||||
program = {
|
||||
testcase;
|
||||
name = example_unit_test;
|
||||
|
|
2
NEWS
2
NEWS
|
@ -85,6 +85,8 @@ New in 2.02:
|
|||
* Support for USB debug dongles.
|
||||
* Support for *-emu on all platforms (previously only i386/x86_64 worked).
|
||||
* Support *-emu on Windows.
|
||||
* New platform `none' which builds only user level utilities. This is now
|
||||
default if target CPU is not supported.
|
||||
|
||||
* Security:
|
||||
* Add optional facility to enforce that all files read by the core image
|
||||
|
|
74
acinclude.m4
74
acinclude.m4
|
@ -210,80 +210,6 @@ fi
|
|||
])
|
||||
|
||||
|
||||
dnl Mass confusion!
|
||||
dnl Older versions of GAS interpret `.code16' to mean ``generate 32-bit
|
||||
dnl instructions, but implicitly insert addr32 and data32 bytes so
|
||||
dnl that the code works in real mode''.
|
||||
dnl
|
||||
dnl Newer versions of GAS interpret `.code16' to mean ``generate 16-bit
|
||||
dnl instructions,'' which seems right. This requires the programmer
|
||||
dnl to explicitly insert addr32 and data32 instructions when they want
|
||||
dnl them.
|
||||
dnl
|
||||
dnl We only support the newer versions, because the old versions cause
|
||||
dnl major pain, by requiring manual assembly to get 16-bit instructions into
|
||||
dnl asm files.
|
||||
AC_DEFUN([grub_I386_ASM_ADDR32],
|
||||
[AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([grub_I386_ASM_PREFIX_REQUIREMENT])
|
||||
AC_MSG_CHECKING([for .code16 addr32 assembler support])
|
||||
AC_CACHE_VAL(grub_cv_i386_asm_addr32,
|
||||
[cat > conftest.s.in <<\EOF
|
||||
.code16
|
||||
l1: @ADDR32@ movb %al, l1
|
||||
EOF
|
||||
|
||||
if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then
|
||||
sed -e s/@ADDR32@/addr32/ < conftest.s.in > conftest.s
|
||||
else
|
||||
sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s
|
||||
fi
|
||||
|
||||
if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
|
||||
grub_cv_i386_asm_addr32=yes
|
||||
else
|
||||
grub_cv_i386_asm_addr32=no
|
||||
fi
|
||||
|
||||
rm -f conftest*])
|
||||
|
||||
AC_MSG_RESULT([$grub_cv_i386_asm_addr32])])
|
||||
|
||||
dnl Later versions of GAS requires that addr32 and data32 prefixes
|
||||
dnl appear in the same lines as the instructions they modify, while
|
||||
dnl earlier versions requires that they appear in separate lines.
|
||||
AC_DEFUN([grub_I386_ASM_PREFIX_REQUIREMENT],
|
||||
[AC_REQUIRE([AC_PROG_CC])
|
||||
AC_MSG_CHECKING(dnl
|
||||
[whether addr32 must be in the same line as the instruction])
|
||||
AC_CACHE_VAL(grub_cv_i386_asm_prefix_requirement,
|
||||
[cat > conftest.s <<\EOF
|
||||
.code16
|
||||
l1: addr32 movb %al, l1
|
||||
EOF
|
||||
|
||||
if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
|
||||
grub_cv_i386_asm_prefix_requirement=yes
|
||||
else
|
||||
grub_cv_i386_asm_prefix_requirement=no
|
||||
fi
|
||||
|
||||
rm -f conftest*])
|
||||
|
||||
if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then
|
||||
grub_tmp_addr32="addr32"
|
||||
grub_tmp_data32="data32"
|
||||
else
|
||||
grub_tmp_addr32="addr32;"
|
||||
grub_tmp_data32="data32;"
|
||||
fi
|
||||
|
||||
ADDR32=$grub_tmp_addr32
|
||||
DATA32=$grub_tmp_data32
|
||||
|
||||
AC_MSG_RESULT([$grub_cv_i386_asm_prefix_requirement])])
|
||||
|
||||
|
||||
dnl Check what symbol is defined as a bss start symbol.
|
||||
dnl Written by Michael Hohmoth and Yoshinori K. Okuji.
|
||||
AC_DEFUN([grub_CHECK_BSS_START_SYMBOL],
|
||||
|
|
20
asm-tests/arm.S
Normal file
20
asm-tests/arm.S
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* on arm clang doesn't support .arch directive */
|
||||
|
||||
.text
|
||||
.syntax unified
|
||||
|
||||
#if !defined (__thumb2__)
|
||||
.arch armv7a
|
||||
.arm
|
||||
#else
|
||||
.arch armv7
|
||||
.thumb
|
||||
#endif
|
||||
mcr p15, 0, r11, c7, c14, 2
|
||||
|
||||
/* clang restricts access to dsb/isb despite .arch */
|
||||
dsb
|
||||
isb
|
||||
|
||||
|
||||
|
10
asm-tests/i386-pc.S
Normal file
10
asm-tests/i386-pc.S
Normal file
|
@ -0,0 +1,10 @@
|
|||
/* on x86 old clang doesn't support .code16
|
||||
newer clang supports it but creates 6-byte jumps instead of 3-byte ones
|
||||
which makes us go over boot sector size. */
|
||||
|
||||
.code16
|
||||
jmp far
|
||||
.org 4
|
||||
.space 300
|
||||
far:
|
||||
.byte 0
|
4
asm-tests/i386.S
Normal file
4
asm-tests/i386.S
Normal file
|
@ -0,0 +1,4 @@
|
|||
/* on x86 old clang doesn't support .code16 */
|
||||
|
||||
.code16
|
||||
movb %al, %bl
|
11
asm-tests/mips.S
Normal file
11
asm-tests/mips.S
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* on mips clang doesn't support privilegied instructions, doubleword store/load
|
||||
and crashes with hand-written assembly
|
||||
*/
|
||||
|
||||
.set mips3
|
||||
sync
|
||||
ld $t2, 0($t6)
|
||||
|
||||
a:
|
||||
addiu $t7, $s0, (b - a)
|
||||
b: nop
|
8
asm-tests/powerpc.S
Normal file
8
asm-tests/powerpc.S
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly
|
||||
used by gcrypt */
|
||||
/* Cache invalidation loop is a fair test. */
|
||||
li 5, 0
|
||||
1: icbi 5, 3
|
||||
addi 5, 5, 32
|
||||
cmpw 5, 4
|
||||
blt 1b
|
9
asm-tests/sparc64.S
Normal file
9
asm-tests/sparc64.S
Normal file
|
@ -0,0 +1,9 @@
|
|||
.text
|
||||
1:
|
||||
/* A small list of examples of what clang doesn't support. */
|
||||
clr %o0
|
||||
lduw [%o4 + 4], %o4
|
||||
and %o6, ~0xff, %o6
|
||||
stw %o5, [%o3]
|
||||
bne,pt %icc, 1b
|
||||
nop
|
11
autogen.sh
11
autogen.sh
|
@ -2,6 +2,9 @@
|
|||
|
||||
set -e
|
||||
|
||||
# Set ${PYTHON} to plain 'python' if not set already
|
||||
: ${PYTHON:=python}
|
||||
|
||||
export LC_COLLATE=C
|
||||
unset LC_ALL
|
||||
|
||||
|
@ -9,10 +12,10 @@ find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './b
|
|||
find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in
|
||||
|
||||
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
|
||||
|
||||
echo "Importing libgcrypt..."
|
||||
python util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
|
||||
${PYTHON} util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
|
||||
sed -n -f util/import_gcrypth.sed < grub-core/lib/libgcrypt/src/gcrypt.h.in > include/grub/gcrypt/gcrypt.h
|
||||
if [ -f include/grub/gcrypt/g10lib.h ]; then
|
||||
rm include/grub/gcrypt/g10lib.h
|
||||
|
@ -54,8 +57,8 @@ for extra in contrib/*/Makefile.core.def; do
|
|||
fi
|
||||
done
|
||||
|
||||
python gentpl.py $UTIL_DEFS > Makefile.util.am
|
||||
python gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
|
||||
${PYTHON} gentpl.py $UTIL_DEFS > Makefile.util.am
|
||||
${PYTHON} gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
|
||||
|
||||
for extra in contrib/*/Makefile.common; do
|
||||
if test -e "$extra"; then
|
||||
|
|
432
build-aux/gitlog-to-changelog
Executable file
432
build-aux/gitlog-to-changelog
Executable file
|
@ -0,0 +1,432 @@
|
|||
eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
|
||||
& eval 'exec perl -wS "$0" $argv:q'
|
||||
if 0;
|
||||
# Convert git log output to ChangeLog format.
|
||||
|
||||
my $VERSION = '2012-07-29 06:11'; # UTC
|
||||
# The definition above must lie within the first 8 lines in order
|
||||
# for the Emacs time-stamp write hook (at end) to update it.
|
||||
# If you change this file with Emacs, please let the write hook
|
||||
# do its job. Otherwise, update this string manually.
|
||||
|
||||
# Copyright (C) 2008-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Written by Jim Meyering
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long;
|
||||
use POSIX qw(strftime);
|
||||
|
||||
(my $ME = $0) =~ s|.*/||;
|
||||
|
||||
# use File::Coda; # http://meyering.net/code/Coda/
|
||||
END {
|
||||
defined fileno STDOUT or return;
|
||||
close STDOUT and return;
|
||||
warn "$ME: failed to close standard output: $!\n";
|
||||
$? ||= 1;
|
||||
}
|
||||
|
||||
sub usage ($)
|
||||
{
|
||||
my ($exit_code) = @_;
|
||||
my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
|
||||
if ($exit_code != 0)
|
||||
{
|
||||
print $STREAM "Try '$ME --help' for more information.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print $STREAM <<EOF;
|
||||
Usage: $ME [OPTIONS] [ARGS]
|
||||
|
||||
Convert git log output to ChangeLog format. If present, any ARGS
|
||||
are passed to "git log". To avoid ARGS being parsed as options to
|
||||
$ME, they may be preceded by '--'.
|
||||
|
||||
OPTIONS:
|
||||
|
||||
--amend=FILE FILE maps from an SHA1 to perl code (i.e., s/old/new/) that
|
||||
makes a change to SHA1's commit log text or metadata.
|
||||
--append-dot append a dot to the first line of each commit message if
|
||||
there is no other punctuation or blank at the end.
|
||||
--no-cluster never cluster commit messages under the same date/author
|
||||
header; the default is to cluster adjacent commit messages
|
||||
if their headers are the same and neither commit message
|
||||
contains multiple paragraphs.
|
||||
--srcdir=DIR the root of the source tree, from which the .git/
|
||||
directory can be derived.
|
||||
--since=DATE convert only the logs since DATE;
|
||||
the default is to convert all log entries.
|
||||
--format=FMT set format string for commit subject and body;
|
||||
see 'man git-log' for the list of format metacharacters;
|
||||
the default is '%s%n%b%n'
|
||||
--strip-tab remove one additional leading TAB from commit message lines.
|
||||
--strip-cherry-pick remove data inserted by "git cherry-pick";
|
||||
this includes the "cherry picked from commit ..." line,
|
||||
and the possible final "Conflicts:" paragraph.
|
||||
--help display this help and exit
|
||||
--version output version information and exit
|
||||
|
||||
EXAMPLE:
|
||||
|
||||
$ME --since=2008-01-01 > ChangeLog
|
||||
$ME -- -n 5 foo > last-5-commits-to-branch-foo
|
||||
|
||||
SPECIAL SYNTAX:
|
||||
|
||||
The following types of strings are interpreted specially when they appear
|
||||
at the beginning of a log message line. They are not copied to the output.
|
||||
|
||||
Copyright-paperwork-exempt: Yes
|
||||
Append the "(tiny change)" notation to the usual "date name email"
|
||||
ChangeLog header to mark a change that does not require a copyright
|
||||
assignment.
|
||||
Co-authored-by: Joe User <user\@example.com>
|
||||
List the specified name and email address on a second
|
||||
ChangeLog header, denoting a co-author.
|
||||
Signed-off-by: Joe User <user\@example.com>
|
||||
These lines are simply elided.
|
||||
|
||||
In a FILE specified via --amend, comment lines (starting with "#") are ignored.
|
||||
FILE must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1 (alone on
|
||||
a line) referring to a commit in the current project, and CODE refers to one
|
||||
or more consecutive lines of Perl code. Pairs must be separated by one or
|
||||
more blank line.
|
||||
|
||||
Here is sample input for use with --amend=FILE, from coreutils:
|
||||
|
||||
3a169f4c5d9159283548178668d2fae6fced3030
|
||||
# fix typo in title:
|
||||
s/all tile types/all file types/
|
||||
|
||||
1379ed974f1fa39b12e2ffab18b3f7a607082202
|
||||
# Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself.
|
||||
# Change the author to be Paul. Note the escaped "@":
|
||||
s,Jim .*>,Paul Eggert <eggert\\\@cs.ucla.edu>,
|
||||
|
||||
EOF
|
||||
}
|
||||
exit $exit_code;
|
||||
}
|
||||
|
||||
# If the string $S is a well-behaved file name, simply return it.
|
||||
# If it contains white space, quotes, etc., quote it, and return the new string.
|
||||
sub shell_quote($)
|
||||
{
|
||||
my ($s) = @_;
|
||||
if ($s =~ m![^\w+/.,-]!)
|
||||
{
|
||||
# Convert each single quote to '\''
|
||||
$s =~ s/\'/\'\\\'\'/g;
|
||||
# Then single quote the string.
|
||||
$s = "'$s'";
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
sub quoted_cmd(@)
|
||||
{
|
||||
return join (' ', map {shell_quote $_} @_);
|
||||
}
|
||||
|
||||
# Parse file F.
|
||||
# Comment lines (starting with "#") are ignored.
|
||||
# F must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1
|
||||
# (alone on a line) referring to a commit in the current project, and
|
||||
# CODE refers to one or more consecutive lines of Perl code.
|
||||
# Pairs must be separated by one or more blank line.
|
||||
sub parse_amend_file($)
|
||||
{
|
||||
my ($f) = @_;
|
||||
|
||||
open F, '<', $f
|
||||
or die "$ME: $f: failed to open for reading: $!\n";
|
||||
|
||||
my $fail;
|
||||
my $h = {};
|
||||
my $in_code = 0;
|
||||
my $sha;
|
||||
while (defined (my $line = <F>))
|
||||
{
|
||||
$line =~ /^\#/
|
||||
and next;
|
||||
chomp $line;
|
||||
$line eq ''
|
||||
and $in_code = 0, next;
|
||||
|
||||
if (!$in_code)
|
||||
{
|
||||
$line =~ /^([0-9a-fA-F]{40})$/
|
||||
or (warn "$ME: $f:$.: invalid line; expected an SHA1\n"),
|
||||
$fail = 1, next;
|
||||
$sha = lc $1;
|
||||
$in_code = 1;
|
||||
exists $h->{$sha}
|
||||
and (warn "$ME: $f:$.: duplicate SHA1\n"),
|
||||
$fail = 1, next;
|
||||
}
|
||||
else
|
||||
{
|
||||
$h->{$sha} ||= '';
|
||||
$h->{$sha} .= "$line\n";
|
||||
}
|
||||
}
|
||||
close F;
|
||||
|
||||
$fail
|
||||
and exit 1;
|
||||
|
||||
return $h;
|
||||
}
|
||||
|
||||
# git_dir_option $SRCDIR
|
||||
#
|
||||
# From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR
|
||||
# is undef). Return as a list (0 or 1 element).
|
||||
sub git_dir_option($)
|
||||
{
|
||||
my ($srcdir) = @_;
|
||||
my @res = ();
|
||||
if (defined $srcdir)
|
||||
{
|
||||
my $qdir = shell_quote $srcdir;
|
||||
my $cmd = "cd $qdir && git rev-parse --show-toplevel";
|
||||
my $qcmd = shell_quote $cmd;
|
||||
my $git_dir = qx($cmd);
|
||||
defined $git_dir
|
||||
or die "$ME: cannot run $qcmd: $!\n";
|
||||
$? == 0
|
||||
or die "$ME: $qcmd had unexpected exit code or signal ($?)\n";
|
||||
chomp $git_dir;
|
||||
push @res, "--git-dir=$git_dir/.git";
|
||||
}
|
||||
@res;
|
||||
}
|
||||
|
||||
{
|
||||
my $since_date;
|
||||
my $format_string = '%s%n%b%n';
|
||||
my $amend_file;
|
||||
my $append_dot = 0;
|
||||
my $cluster = 1;
|
||||
my $strip_tab = 0;
|
||||
my $strip_cherry_pick = 0;
|
||||
my $srcdir;
|
||||
GetOptions
|
||||
(
|
||||
help => sub { usage 0 },
|
||||
version => sub { print "$ME version $VERSION\n"; exit },
|
||||
'since=s' => \$since_date,
|
||||
'format=s' => \$format_string,
|
||||
'amend=s' => \$amend_file,
|
||||
'append-dot' => \$append_dot,
|
||||
'cluster!' => \$cluster,
|
||||
'strip-tab' => \$strip_tab,
|
||||
'strip-cherry-pick' => \$strip_cherry_pick,
|
||||
'srcdir=s' => \$srcdir,
|
||||
) or usage 1;
|
||||
|
||||
defined $since_date
|
||||
and unshift @ARGV, "--since=$since_date";
|
||||
|
||||
# This is a hash that maps an SHA1 to perl code (i.e., s/old/new/)
|
||||
# that makes a correction in the log or attribution of that commit.
|
||||
my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {};
|
||||
|
||||
my @cmd = ('git',
|
||||
git_dir_option $srcdir,
|
||||
qw(log --log-size),
|
||||
'--pretty=format:%H:%ct %an <%ae>%n%n'.$format_string, @ARGV);
|
||||
open PIPE, '-|', @cmd
|
||||
or die ("$ME: failed to run '". quoted_cmd (@cmd) ."': $!\n"
|
||||
. "(Is your Git too old? Version 1.5.1 or later is required.)\n");
|
||||
|
||||
my $prev_multi_paragraph;
|
||||
my $prev_date_line = '';
|
||||
my @prev_coauthors = ();
|
||||
while (1)
|
||||
{
|
||||
defined (my $in = <PIPE>)
|
||||
or last;
|
||||
$in =~ /^log size (\d+)$/
|
||||
or die "$ME:$.: Invalid line (expected log size):\n$in";
|
||||
my $log_nbytes = $1;
|
||||
|
||||
my $log;
|
||||
my $n_read = read PIPE, $log, $log_nbytes;
|
||||
$n_read == $log_nbytes
|
||||
or die "$ME:$.: unexpected EOF\n";
|
||||
|
||||
# Extract leading hash.
|
||||
my ($sha, $rest) = split ':', $log, 2;
|
||||
defined $sha
|
||||
or die "$ME:$.: malformed log entry\n";
|
||||
$sha =~ /^[0-9a-fA-F]{40}$/
|
||||
or die "$ME:$.: invalid SHA1: $sha\n";
|
||||
|
||||
# If this commit's log requires any transformation, do it now.
|
||||
my $code = $amend_code->{$sha};
|
||||
if (defined $code)
|
||||
{
|
||||
eval 'use Safe';
|
||||
my $s = new Safe;
|
||||
# Put the unpreprocessed entry into "$_".
|
||||
$_ = $rest;
|
||||
|
||||
# Let $code operate on it, safely.
|
||||
my $r = $s->reval("$code")
|
||||
or die "$ME:$.:$sha: failed to eval \"$code\":\n$@\n";
|
||||
|
||||
# Note that we've used this entry.
|
||||
delete $amend_code->{$sha};
|
||||
|
||||
# Update $rest upon success.
|
||||
$rest = $_;
|
||||
}
|
||||
|
||||
# Remove lines inserted by "git cherry-pick".
|
||||
if ($strip_cherry_pick)
|
||||
{
|
||||
$rest =~ s/^\s*Conflicts:\n.*//sm;
|
||||
$rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m;
|
||||
}
|
||||
|
||||
my @line = split "\n", $rest;
|
||||
my $author_line = shift @line;
|
||||
defined $author_line
|
||||
or die "$ME:$.: unexpected EOF\n";
|
||||
$author_line =~ /^(\d+) (.*>)$/
|
||||
or die "$ME:$.: Invalid line "
|
||||
. "(expected date/author/email):\n$author_line\n";
|
||||
|
||||
# Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog
|
||||
# `(tiny change)' annotation.
|
||||
my $tiny = (grep (/^Copyright-paperwork-exempt:\s+[Yy]es$/, @line)
|
||||
? ' (tiny change)' : '');
|
||||
|
||||
my $date_line = sprintf "%s %s$tiny\n",
|
||||
strftime ("%F", localtime ($1)), $2;
|
||||
|
||||
my @coauthors = grep /^Co-authored-by:.*$/, @line;
|
||||
# Omit meta-data lines we've already interpreted.
|
||||
@line = grep !/^(?:Signed-off-by:[ ].*>$
|
||||
|Co-authored-by:[ ]
|
||||
|Copyright-paperwork-exempt:[ ]
|
||||
)/x, @line;
|
||||
|
||||
# Remove leading and trailing blank lines.
|
||||
if (@line)
|
||||
{
|
||||
while ($line[0] =~ /^\s*$/) { shift @line; }
|
||||
while ($line[$#line] =~ /^\s*$/) { pop @line; }
|
||||
}
|
||||
|
||||
# Record whether there are two or more paragraphs.
|
||||
my $multi_paragraph = grep /^\s*$/, @line;
|
||||
|
||||
# Format 'Co-authored-by: A U Thor <email@example.com>' lines in
|
||||
# standard multi-author ChangeLog format.
|
||||
for (@coauthors)
|
||||
{
|
||||
s/^Co-authored-by:\s*/\t /;
|
||||
s/\s*</ </;
|
||||
|
||||
/<.*?@.*\..*>/
|
||||
or warn "$ME: warning: missing email address for "
|
||||
. substr ($_, 5) . "\n";
|
||||
}
|
||||
|
||||
# If clustering of commit messages has been disabled, if this header
|
||||
# would be different from the previous date/name/email/coauthors header,
|
||||
# or if this or the previous entry consists of two or more paragraphs,
|
||||
# then print the header.
|
||||
if ( ! $cluster
|
||||
|| $date_line ne $prev_date_line
|
||||
|| "@coauthors" ne "@prev_coauthors"
|
||||
|| $multi_paragraph
|
||||
|| $prev_multi_paragraph)
|
||||
{
|
||||
$prev_date_line eq ''
|
||||
or print "\n";
|
||||
print $date_line;
|
||||
@coauthors
|
||||
and print join ("\n", @coauthors), "\n";
|
||||
}
|
||||
$prev_date_line = $date_line;
|
||||
@prev_coauthors = @coauthors;
|
||||
$prev_multi_paragraph = $multi_paragraph;
|
||||
|
||||
# If there were any lines
|
||||
if (@line == 0)
|
||||
{
|
||||
warn "$ME: warning: empty commit message:\n $date_line\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($append_dot)
|
||||
{
|
||||
# If the first line of the message has enough room, then
|
||||
if (length $line[0] < 72)
|
||||
{
|
||||
# append a dot if there is no other punctuation or blank
|
||||
# at the end.
|
||||
$line[0] =~ /[[:punct:]\s]$/
|
||||
or $line[0] .= '.';
|
||||
}
|
||||
}
|
||||
|
||||
# Remove one additional leading TAB from each line.
|
||||
$strip_tab
|
||||
and map { s/^\t// } @line;
|
||||
|
||||
# Prefix each non-empty line with a TAB.
|
||||
@line = map { length $_ ? "\t$_" : '' } @line;
|
||||
|
||||
print "\n", join ("\n", @line), "\n";
|
||||
}
|
||||
|
||||
defined ($in = <PIPE>)
|
||||
or last;
|
||||
$in ne "\n"
|
||||
and die "$ME:$.: unexpected line:\n$in";
|
||||
}
|
||||
|
||||
close PIPE
|
||||
or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n";
|
||||
# FIXME-someday: include $PROCESS_STATUS in the diagnostic
|
||||
|
||||
# Complain about any unused entry in the --amend=F specified file.
|
||||
my $fail = 0;
|
||||
foreach my $sha (keys %$amend_code)
|
||||
{
|
||||
warn "$ME:$amend_file: unused entry: $sha\n";
|
||||
$fail = 1;
|
||||
}
|
||||
|
||||
exit $fail;
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# mode: perl
|
||||
# indent-tabs-mode: nil
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "my $VERSION = '"
|
||||
# time-stamp-format: "%:y-%02m-%02d %02H:%02M"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "'; # UTC"
|
||||
# End:
|
|
@ -7,12 +7,7 @@ unexport LC_ALL
|
|||
|
||||
# Platform specific options
|
||||
if COND_sparc64_ieee1275
|
||||
CFLAGS_PLATFORM += -mno-app-regs
|
||||
LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax
|
||||
endif
|
||||
if COND_sparc64_emu
|
||||
CFLAGS_PLATFORM += -mno-app-regs
|
||||
LDFLAGS_PLATFORM = -Wl,--no-relax
|
||||
LDFLAGS_PLATFORM = -Wl,-melf64_sparc
|
||||
endif
|
||||
if COND_arm
|
||||
if !COND_emu
|
||||
|
@ -39,21 +34,19 @@ CPPFLAGS_DEFAULT += -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/src/
|
|||
CCASFLAGS_DEFAULT = $(CPPFLAGS_DEFAULT) -DASM_FILE=1
|
||||
BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT)
|
||||
|
||||
LDADD_KERNEL = $(TARGET_LIBGCC)
|
||||
|
||||
CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
|
||||
LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC)
|
||||
CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
|
||||
LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC)
|
||||
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
|
||||
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
|
||||
STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version
|
||||
STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags
|
||||
|
||||
CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
|
||||
LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
|
||||
CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
|
||||
LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
|
||||
CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
|
||||
CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
|
||||
|
||||
CFLAGS_IMAGE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -fno-builtin
|
||||
LDFLAGS_IMAGE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S
|
||||
CFLAGS_IMAGE = $(CFLAGS_PLATFORM) -fno-builtin
|
||||
LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S
|
||||
CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
|
||||
CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
|
||||
|
||||
|
|
|
@ -110,3 +110,26 @@ EXTRA_DIST += tests/dfly-mbr-mbexample.mbr.img.gz
|
|||
EXTRA_DIST += tests/dfly-mbr-mbexample.dfly.img.gz
|
||||
|
||||
EXTRA_DIST += coreboot.cfg
|
||||
|
||||
EXTRA_DIST += tests/file_filter/file
|
||||
EXTRA_DIST += tests/file_filter/file.gz
|
||||
EXTRA_DIST += tests/file_filter/file.gz.sig
|
||||
EXTRA_DIST += tests/file_filter/file.lzop
|
||||
EXTRA_DIST += tests/file_filter/file.lzop.sig
|
||||
EXTRA_DIST += tests/file_filter/file.xz
|
||||
EXTRA_DIST += tests/file_filter/file.xz.sig
|
||||
EXTRA_DIST += tests/file_filter/keys
|
||||
EXTRA_DIST += tests/file_filter/keys.pub
|
||||
EXTRA_DIST += tests/file_filter/test.cfg
|
||||
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/prompt.cfg
|
||||
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg
|
||||
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg
|
||||
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg
|
||||
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg
|
||||
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/txt.cfg
|
||||
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/menu.cfg
|
||||
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg
|
||||
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg
|
||||
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/po4a.cfg
|
||||
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg
|
||||
EXTRA_DIST += tests/syslinux/ubuntu10.04_grub.cfg.in
|
||||
|
|
13
config.h.in
13
config.h.in
|
@ -7,11 +7,20 @@
|
|||
#endif
|
||||
|
||||
#define GCRYPT_NO_DEPRECATED 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
||||
/* Define to 1 to enable disk cache statistics. */
|
||||
#define DISK_CACHE_STATS @DISK_CACHE_STATS@
|
||||
#define BOOT_TIME_STATS @BOOT_TIME_STATS@
|
||||
|
||||
/* We don't need those. */
|
||||
#define MINILZO_CFG_SKIP_LZO_PTR 1
|
||||
#define MINILZO_CFG_SKIP_LZO_UTIL 1
|
||||
#define MINILZO_CFG_SKIP_LZO_STRING 1
|
||||
#define MINILZO_CFG_SKIP_LZO_INIT 1
|
||||
#define MINILZO_CFG_SKIP_LZO1X_1_COMPRESS 1
|
||||
#define MINILZO_CFG_SKIP_LZO1X_DECOMPRESS 1
|
||||
|
||||
#if defined (GRUB_BUILD)
|
||||
#undef ENABLE_NLS
|
||||
#define BUILD_SIZEOF_LONG @BUILD_SIZEOF_LONG@
|
||||
|
@ -31,10 +40,6 @@
|
|||
#define HAVE_FONT_SOURCE @HAVE_FONT_SOURCE@
|
||||
/* Define if C symbols get an underscore after compilation. */
|
||||
#define HAVE_ASM_USCORE @HAVE_ASM_USCORE@
|
||||
/* Define it to \"addr32\" or \"addr32;\" to make GAS happy. */
|
||||
#define ADDR32 @ADDR32@
|
||||
/* Define it to \"data32\" or \"data32;\" to make GAS happy. */
|
||||
#define DATA32 @DATA32@
|
||||
/* Define it to one of __bss_start, edata and _edata. */
|
||||
#define BSS_START_SYMBOL @BSS_START_SYMBOL@
|
||||
/* Define it to either end or _end. */
|
||||
|
|
282
configure.ac
282
configure.ac
|
@ -78,12 +78,9 @@ fi
|
|||
|
||||
# Default HOST_CPPFLAGS
|
||||
HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
|
||||
HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
|
||||
HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
|
||||
|
||||
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
|
||||
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
|
||||
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
|
||||
|
||||
case "$target_cpu" in
|
||||
i[[3456]]86) target_cpu=i386 ;;
|
||||
|
@ -354,6 +351,9 @@ if test x"$target_cpu-$platform" = xsparc64-emu ; then
|
|||
HOST_CFLAGS="$HOST_CFLAGS -m64"
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
|
||||
HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64"
|
||||
|
||||
AC_C_BIGENDIAN
|
||||
AC_CHECK_SIZEOF(void *)
|
||||
AC_CHECK_SIZEOF(long)
|
||||
|
@ -366,6 +366,14 @@ case "$host_os" in
|
|||
;;
|
||||
esac
|
||||
|
||||
case "$host_os" in
|
||||
cygwin | windows* | mingw32* | aros*)
|
||||
;;
|
||||
*)
|
||||
AC_CHECK_SIZEOF(off_t)
|
||||
test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required]);;
|
||||
esac
|
||||
|
||||
if test x$USE_NLS = xno; then
|
||||
HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
|
||||
fi
|
||||
|
@ -541,7 +549,7 @@ int main (void);
|
|||
|
||||
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],
|
||||
[
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
AC_COMPILE_IFELSE(
|
||||
|
@ -552,35 +560,42 @@ AC_COMPILE_IFELSE(
|
|||
]])],
|
||||
[grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
|
||||
|
||||
# on x86 clang doesn't support .code16
|
||||
# on arm clang doesn't support .arch directive
|
||||
# on mips clang doesn't support privilegied instructions, doubleword store/load
|
||||
# and crashes with hand-written assembly
|
||||
if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \
|
||||
|| test "x$target_cpu" = xx86_64 || test "x$target_cpu" = xarm \
|
||||
|| test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ); then
|
||||
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
|
||||
AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
|
||||
test_program=
|
||||
case "x$target_cpu-$platform" in
|
||||
xmips-* | xmipsel-*)
|
||||
test_program=mips
|
||||
;;
|
||||
xi386-pc)
|
||||
test_program=i386-pc
|
||||
;;
|
||||
xi386-* | xx86_64-*)
|
||||
test_program=i386
|
||||
;;
|
||||
xpowerpc-* | xsparc64-* | xarm-*)
|
||||
test_program=$target_cpu
|
||||
;;
|
||||
esac
|
||||
if test x"$test_program" = x ; then
|
||||
grub_cv_cc_target_asm_compile=
|
||||
else
|
||||
found=no
|
||||
for arg in "" "-no-integrated-as"; do
|
||||
cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
|
||||
echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
|
||||
if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
|
||||
grub_cv_cc_target_asm_compile="$arg"
|
||||
found=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test x"$found" = xno ; then
|
||||
AC_MSG_ERROR([could not compile assembly])
|
||||
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
|
||||
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
|
||||
|
||||
if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
|
||||
|
@ -663,6 +678,110 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p
|
|||
TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
|
||||
fi
|
||||
|
||||
# GRUB doesn't use float or doubles at all. Yet some toolchains may decide
|
||||
# that floats are a good fit to run instead of what's written in the code.
|
||||
# Given that floating point unit is disabled (if present to begin with)
|
||||
# when GRUB is running which may result in various hard crashes.
|
||||
if test x"$platform" != xemu ; then
|
||||
AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
|
||||
grub_cv_target_cc_soft_float=no
|
||||
if test "x$target_cpu" = xarm64; then
|
||||
CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], [])
|
||||
fi
|
||||
if test "x$target_cpu" = xia64; then
|
||||
CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], [])
|
||||
fi
|
||||
for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \
|
||||
"-Xclang -msoft-float -Xclang -no-implicit-float" \
|
||||
"-Xclang -msoft-float" "-msoft-float"; do
|
||||
if test x"$grub_cv_target_cc_soft_float" != xno ; then
|
||||
break
|
||||
fi
|
||||
CFLAGS="$TARGET_CFLAGS $cand -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_target_cc_soft_float="$cand"], [])
|
||||
done
|
||||
])
|
||||
|
||||
if test x"$grub_cv_target_cc_soft_float" = xno ; then
|
||||
AC_MSG_ERROR([could not force soft-float])
|
||||
fi
|
||||
|
||||
case x"$grub_cv_target_cc_soft_float" in
|
||||
x*"-Xclang"*)
|
||||
# A trick so that clang doesn't see it on link stаge
|
||||
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float"
|
||||
;;
|
||||
*)
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
|
||||
;;
|
||||
esac
|
||||
case x"$grub_cv_target_cc_soft_float" in
|
||||
x"-march=armv8-a+nofp+nosimd")
|
||||
# +nosimd disables also the cache opcodes that we need in asm.
|
||||
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -march=armv8-a+nofp"
|
||||
;;
|
||||
*)
|
||||
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
if test x"$target_cpu" = xsparc64 ; then
|
||||
AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [
|
||||
grub_cv_target_cc_mno_app_regs=no
|
||||
for cand in "-mllvm -sparc-reserve-app-registers" \
|
||||
"-mno-app-regs"; do
|
||||
if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then
|
||||
break
|
||||
fi
|
||||
CFLAGS="$TARGET_CFLAGS $cand -Werror"
|
||||
CPPFLAGS="$TARGET_CPPFLAGS"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_target_cc_mno_app_regs="$cand"], [])
|
||||
done
|
||||
])
|
||||
|
||||
if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then
|
||||
AC_MSG_ERROR([could not reserve application registers])
|
||||
fi
|
||||
if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then
|
||||
# A trick so that clang doesn't see it on link stаge
|
||||
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs"
|
||||
else
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs"
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
|
||||
grub_cv_target_cc_mno_relax=no
|
||||
for cand in "-mno-relax" "-Wl,--no-relax"; do
|
||||
if test x"$grub_cv_target_cc_mno_relax" != xno ; then
|
||||
break
|
||||
fi
|
||||
LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static"
|
||||
CFLAGS="$TARGET_CFLAGS -Werror"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
asm (".globl start; start:");
|
||||
void __main (void);
|
||||
void __main (void) {}
|
||||
int main (void);
|
||||
]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
|
||||
done
|
||||
])
|
||||
LDFLAGS="$TARGET_LDFLAGS"
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
|
||||
if test x"$grub_cv_target_cc_mno_relax" = xno ; then
|
||||
AC_MSG_ERROR([could not find no-relax options])
|
||||
fi
|
||||
TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax"
|
||||
fi
|
||||
|
||||
# By default, GCC 4.4 generates .eh_frame sections containing unwind
|
||||
# information in some cases where it previously did not. GRUB doesn't need
|
||||
# these and they just use up vital space. Restore the old compiler
|
||||
|
@ -864,7 +983,7 @@ AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
|
|||
|
||||
LDFLAGS="$TARGET_LDFLAGS"
|
||||
|
||||
if test "$target_cpu" = x86_64 || test "$target_cpu-$platform" = sparc64-emu ; then
|
||||
if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then
|
||||
# Use large model to support 4G memory
|
||||
AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
|
||||
CFLAGS="$TARGET_CFLAGS -mcmodel=large"
|
||||
|
@ -874,7 +993,7 @@ if test "$target_cpu" = x86_64 || test "$target_cpu-$platform" = sparc64-emu ; t
|
|||
])
|
||||
if test "x$grub_cv_cc_mcmodel" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
|
||||
elif test "$target_cpu-$platform" = sparc64-emu; then
|
||||
elif test "$target_cpu" = sparc64; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
|
||||
fi
|
||||
fi
|
||||
|
@ -912,20 +1031,9 @@ if test "x$target_cpu" = xarm; then
|
|||
])
|
||||
if test "x$grub_cv_cc_mthumb_interwork" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork"
|
||||
# Clang defaults to thumb interworking
|
||||
elif test "x$grub_cv_cc_target_clang" = xno ; then
|
||||
AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork])
|
||||
else
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
|
||||
#if defined (__thumb__) && !defined (__thumb2__)
|
||||
#error thumb without interworking
|
||||
#endif
|
||||
]])],
|
||||
[no_interwork_ok=yes],
|
||||
[no_interwork_ok=no])
|
||||
if test x$no_interwork_ok = xno ; then
|
||||
AC_MSG_ERROR([attempt to compile to thumb with no thumb interwork])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -1023,22 +1131,17 @@ fi
|
|||
|
||||
# Set them to their new values for the tests below.
|
||||
CC="$TARGET_CC"
|
||||
if test "x$TARGET_APPLE_LINKER" = x1 ; then
|
||||
if test x"$platform" = xemu ; then
|
||||
CFLAGS="$TARGET_CFLAGS -Wno-error"
|
||||
elif test "x$TARGET_APPLE_LINKER" = x1 ; then
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
|
||||
else
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
|
||||
fi
|
||||
CPPFLAGS="$TARGET_CPPFLAGS"
|
||||
if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then
|
||||
TARGET_LIBGCC=
|
||||
else
|
||||
TARGET_LIBGCC=-lgcc
|
||||
fi
|
||||
|
||||
LIBS="$TARGET_LIBGCC"
|
||||
|
||||
grub_ASM_USCORE
|
||||
if test "x$TARGET_APPLE_LINKER" = x0 ; then
|
||||
if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then
|
||||
if test x$grub_cv_asm_uscore = xyes; then
|
||||
DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main"
|
||||
else
|
||||
|
@ -1048,7 +1151,9 @@ CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM"
|
|||
fi
|
||||
|
||||
# Check for libgcc symbols
|
||||
AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x)
|
||||
if test x"$platform" = xemu; then
|
||||
AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms)
|
||||
fi
|
||||
|
||||
if test "x$TARGET_APPLE_LINKER" = x1 ; then
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -static"
|
||||
|
@ -1073,8 +1178,6 @@ if test "x$target_cpu" = xi386; then
|
|||
grub_CHECK_END_SYMBOL
|
||||
fi
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
grub_I386_ASM_PREFIX_REQUIREMENT
|
||||
grub_I386_ASM_ADDR32
|
||||
fi
|
||||
|
||||
grub_PROG_NM_WORKS
|
||||
|
@ -1152,10 +1255,6 @@ else
|
|||
fi
|
||||
AC_SUBST([BOOT_TIME_STATS])
|
||||
|
||||
AC_ARG_ENABLE([grub-emu-usb],
|
||||
[AS_HELP_STRING([--enable-grub-emu-usb],
|
||||
[build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
|
||||
|
||||
AC_ARG_ENABLE([grub-emu-sdl],
|
||||
[AS_HELP_STRING([--enable-grub-emu-sdl],
|
||||
[build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
|
||||
|
@ -1166,34 +1265,6 @@ AC_ARG_ENABLE([grub-emu-pci],
|
|||
|
||||
if test "$platform" = emu; then
|
||||
|
||||
if test x"$enable_grub_emu_usb" != xyes ; then
|
||||
grub_emu_usb_excuse="not enabled"
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_emu_pci" = xyes ; then
|
||||
grub_emu_usb_excuse="conflicts with PCI support"
|
||||
fi
|
||||
|
||||
[if [ x"$grub_emu_usb_excuse" = x ]; then
|
||||
# Check for libusb libraries.]
|
||||
AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
|
||||
[grub_emu_usb_excuse=["need libusb library"]])
|
||||
AC_SUBST([LIBUSB])
|
||||
[fi]
|
||||
[if [ x"$grub_emu_usb_excuse" = x ]; then
|
||||
# Check for headers.]
|
||||
AC_CHECK_HEADERS([usb.h], [],
|
||||
[grub_emu_usb_excuse=["need libusb headers"]])
|
||||
[fi]
|
||||
if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
|
||||
AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled ($grub_emu_usb_excuse)])
|
||||
fi
|
||||
if test x"$grub_emu_usb_excuse" = x ; then
|
||||
enable_grub_emu_usb=yes
|
||||
else
|
||||
enable_grub_emu_usb=no
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_emu_sdl" = xno ; then
|
||||
grub_emu_sdl_excuse="explicitly disabled"
|
||||
fi
|
||||
|
@ -1223,10 +1294,6 @@ if test x"$enable_grub_emu_pci" != xyes ; then
|
|||
grub_emu_pci_excuse="not enabled"
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_emu_usb" = xyes ; then
|
||||
grub_emu_pci_excuse="conflicts with USB support"
|
||||
fi
|
||||
|
||||
[if [ x"$grub_emu_pci_excuse" = x ]; then
|
||||
# Check for libpci libraries.]
|
||||
AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
|
||||
|
@ -1235,7 +1302,7 @@ fi
|
|||
[fi]
|
||||
[if [ x"$grub_emu_pci_excuse" = x ]; then
|
||||
# Check for headers.]
|
||||
AC_CHECK_HEADERS([pci/pci.h], [],
|
||||
AC_CHECK_HEADERS([pciaccess.h], [],
|
||||
[grub_emu_pci_excuse=["need libpciaccess headers"]])
|
||||
[fi]
|
||||
|
||||
|
@ -1247,14 +1314,12 @@ enable_grub_emu_pci=no
|
|||
fi
|
||||
|
||||
AC_SUBST([enable_grub_emu_sdl])
|
||||
AC_SUBST([enable_grub_emu_usb])
|
||||
AC_SUBST([enable_grub_emu_pci])
|
||||
|
||||
else
|
||||
|
||||
# Ignore --enable-emu-* if platform is not emu
|
||||
enable_grub_emu_sdl=no
|
||||
enable_grub_emu_usb=no
|
||||
enable_grub_emu_pci=no
|
||||
fi
|
||||
|
||||
|
@ -1463,7 +1528,7 @@ fi
|
|||
if test x"$grub_mount_excuse" = x ; then
|
||||
# Check for fuse headers.
|
||||
SAVED_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
|
||||
CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26"
|
||||
AC_CHECK_HEADERS([fuse/fuse.h], [],
|
||||
[grub_mount_excuse=["need FUSE headers"]])
|
||||
CPPFLAGS="$SAVED_CPPFLAGS"
|
||||
|
@ -1598,8 +1663,6 @@ AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
|
|||
[AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
|
||||
|
||||
AC_SUBST(HAVE_ASM_USCORE)
|
||||
AC_SUBST(ADDR32)
|
||||
AC_SUBST(DATA32)
|
||||
AC_SUBST(BSS_START_SYMBOL)
|
||||
AC_SUBST(END_SYMBOL)
|
||||
AC_SUBST(PACKAGE)
|
||||
|
@ -1613,15 +1676,15 @@ if test x"$enable_werror" != xno ; then
|
|||
HOST_CFLAGS="$HOST_CFLAGS -Werror"
|
||||
fi
|
||||
|
||||
if test "x$grub_cv_cc_target_clang" = xno; then
|
||||
TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc"
|
||||
else
|
||||
TARGET_LDFLAGS_STATIC_LIBGCC=
|
||||
fi
|
||||
|
||||
TARGET_CPP="$TARGET_CC -E"
|
||||
TARGET_CCAS=$TARGET_CC
|
||||
|
||||
# Includes which include make-time substitutions. They must come last
|
||||
# as to avoid executing top_builddir in shell.
|
||||
HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
|
||||
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
|
||||
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
|
||||
|
||||
GRUB_TARGET_CPU="${target_cpu}"
|
||||
GRUB_PLATFORM="${platform}"
|
||||
|
||||
|
@ -1629,8 +1692,6 @@ AC_SUBST(GRUB_TARGET_CPU)
|
|||
AC_SUBST(GRUB_PLATFORM)
|
||||
|
||||
AC_SUBST(TARGET_OBJCONV)
|
||||
AC_SUBST(TARGET_LIBGCC)
|
||||
AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC)
|
||||
AC_SUBST(TARGET_CPP)
|
||||
AC_SUBST(TARGET_CCAS)
|
||||
AC_SUBST(TARGET_OBJ2ELF)
|
||||
|
@ -1660,7 +1721,6 @@ AC_SUBST(BUILD_LIBM)
|
|||
|
||||
AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
|
||||
AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
|
||||
AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes])
|
||||
AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
|
||||
AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
|
||||
AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
|
||||
|
@ -1695,7 +1755,6 @@ AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
|
|||
AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
|
||||
|
||||
AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
|
||||
AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
|
||||
AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
|
||||
AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
|
||||
AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
|
||||
|
@ -1773,11 +1832,6 @@ echo "*******************************************************"
|
|||
echo GRUB2 will be compiled with following components:
|
||||
echo Platform: "$target_cpu"-"$platform"
|
||||
if [ x"$platform" = xemu ]; then
|
||||
if [ x"$grub_emu_usb_excuse" = x ]; then
|
||||
echo USB support for grub-emu: Yes
|
||||
else
|
||||
echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
|
||||
fi
|
||||
if [ x"$grub_emu_sdl_excuse" = x ]; then
|
||||
echo SDL support for grub-emu: Yes
|
||||
else
|
||||
|
|
|
@ -5848,7 +5848,7 @@ Following variables must be defined:
|
|||
|
||||
@multitable @columnfractions .30 .65
|
||||
@item GRUB_PAYLOADS_DIR @tab directory containing the required kernels
|
||||
@item GRUB_CBFSTOOL @tab cbfstoll from Coreboot package (for coreboot platform only)
|
||||
@item GRUB_CBFSTOOL @tab cbfstool from Coreboot package (for coreboot platform only)
|
||||
@item GRUB_COREBOOT_ROM @tab empty Coreboot ROM
|
||||
@item GRUB_QEMU_OPTS @tab additional options to be supplied to QEMU
|
||||
@end multitable
|
||||
|
|
10
gentpl.py
10
gentpl.py
|
@ -76,6 +76,12 @@ for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i)
|
|||
# Flattened Device Trees (FDT)
|
||||
GROUPS["fdt"] = [ "arm64_efi", "arm_uboot", "arm_efi" ]
|
||||
|
||||
# Needs software helpers for division
|
||||
# Must match GRUB_DIVISION_IN_SOFTWARE in misc.h
|
||||
GROUPS["softdiv"] = GROUPS["arm"] + ["ia64_efi"]
|
||||
GROUPS["no_softdiv"] = GRUB_PLATFORMS[:]
|
||||
for i in GROUPS["softdiv"]: GROUPS["no_softdiv"].remove(i)
|
||||
|
||||
# Miscelaneous groups schedulded to disappear in future
|
||||
GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"]
|
||||
GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc")
|
||||
|
@ -600,7 +606,7 @@ def foreach_enabled_platform(defn, closure):
|
|||
# enable = emu;
|
||||
# enable = i386;
|
||||
# enable = mips_loongson;
|
||||
# emu_condition = COND_GRUB_EMU_USB;
|
||||
# emu_condition = COND_GRUB_EMU_SDL;
|
||||
# };
|
||||
#
|
||||
def under_platform_specific_conditionals(defn, platform, closure):
|
||||
|
@ -753,7 +759,7 @@ def image(defn, platform):
|
|||
if test x$(TARGET_APPLE_LINKER) = x1; then \
|
||||
$(MACHO2IMG) $< $@; \
|
||||
else \
|
||||
$(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \
|
||||
$(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \
|
||||
fi
|
||||
""")
|
||||
|
||||
|
|
|
@ -76,6 +76,11 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h
|
|||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h
|
||||
if COND_emu
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt-emu.h
|
||||
else
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt.h
|
||||
endif
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h
|
||||
|
@ -83,9 +88,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
|
|||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h
|
||||
if !COND_clang
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
|
||||
endif
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h
|
||||
|
||||
if COND_i386_pc
|
||||
|
@ -248,9 +250,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
|
|||
if COND_GRUB_EMU_SDL
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h
|
||||
endif
|
||||
if COND_GRUB_EMU_USB
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libusb.h
|
||||
endif
|
||||
if COND_GRUB_EMU_PCI
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libpciaccess.h
|
||||
endif
|
||||
|
|
|
@ -83,8 +83,6 @@ kernel = {
|
|||
x86_64_xen_ldflags = '$(TARGET_IMG_LDFLAGS)';
|
||||
x86_64_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0';
|
||||
|
||||
ldadd = '$(LDADD_KERNEL)';
|
||||
|
||||
mips_loongson_ldflags = '-Wl,-Ttext,0x80200000';
|
||||
powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
|
||||
sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
|
||||
|
@ -132,6 +130,7 @@ kernel = {
|
|||
common = kern/rescue_reader.c;
|
||||
common = kern/term.c;
|
||||
|
||||
noemu = kern/compiler-rt.c;
|
||||
noemu = kern/mm.c;
|
||||
noemu = kern/time.c;
|
||||
noemu = kern/generic/millisleep.c;
|
||||
|
@ -159,6 +158,8 @@ kernel = {
|
|||
terminfoinkernel = commands/extcmd.c;
|
||||
terminfoinkernel = lib/arg.c;
|
||||
|
||||
softdiv = lib/division.c;
|
||||
|
||||
i386 = kern/i386/dl.c;
|
||||
i386_xen = kern/i386/dl.c;
|
||||
|
||||
|
@ -252,6 +253,7 @@ kernel = {
|
|||
|
||||
powerpc_ieee1275 = kern/powerpc/cache.S;
|
||||
powerpc_ieee1275 = kern/powerpc/dl.c;
|
||||
powerpc_ieee1275 = kern/powerpc/compiler-rt.S;
|
||||
|
||||
sparc64_ieee1275 = kern/sparc64/cache.S;
|
||||
sparc64_ieee1275 = kern/sparc64/dl.c;
|
||||
|
@ -263,7 +265,7 @@ kernel = {
|
|||
arm = kern/arm/cache_armv7.S;
|
||||
extra_dist = kern/arm/cache.S;
|
||||
arm = kern/arm/cache.c;
|
||||
arm = kern/arm/misc.S;
|
||||
arm = kern/arm/compiler-rt.S;
|
||||
|
||||
arm64 = kern/arm64/cache.c;
|
||||
arm64 = kern/arm64/cache_flush.S;
|
||||
|
@ -441,13 +443,13 @@ image = {
|
|||
common = lib/xzembed/xz_dec_bcj.c;
|
||||
common = lib/xzembed/xz_dec_lzma2.c;
|
||||
common = lib/xzembed/xz_dec_stream.c;
|
||||
common = kern/compiler-rt.c;
|
||||
|
||||
cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1';
|
||||
|
||||
objcopyflags = '-O binary';
|
||||
mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
|
||||
ldadd = '$(TARGET_LIBGCC)';
|
||||
cflags = '-Wno-unreachable-code $(TARGET_LDFLAGS_STATIC_LIBGCC)';
|
||||
mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
|
||||
cflags = '-Wno-unreachable-code';
|
||||
enable = mips;
|
||||
};
|
||||
|
||||
|
@ -459,9 +461,7 @@ image = {
|
|||
cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1';
|
||||
|
||||
objcopyflags = '-O binary';
|
||||
mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
|
||||
ldadd = '$(TARGET_LIBGCC)';
|
||||
cflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC)';
|
||||
mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
|
||||
enable = mips;
|
||||
};
|
||||
|
||||
|
@ -479,7 +479,7 @@ image = {
|
|||
name = fwstart;
|
||||
mips_loongson = boot/mips/loongson/fwstart.S;
|
||||
objcopyflags = '-O binary';
|
||||
ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
|
||||
ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
|
||||
enable = mips_loongson;
|
||||
};
|
||||
|
||||
|
@ -487,7 +487,7 @@ image = {
|
|||
name = fwstart_fuloong2f;
|
||||
mips_loongson = boot/mips/loongson/fuloong2f.S;
|
||||
objcopyflags = '-O binary';
|
||||
ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
|
||||
ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
|
||||
enable = mips_loongson;
|
||||
};
|
||||
|
||||
|
@ -509,13 +509,6 @@ module = {
|
|||
enable = x86;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = libusb;
|
||||
emu = bus/usb/emu/usb.c;
|
||||
enable = emu;
|
||||
condition = COND_GRUB_EMU_USB;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = lsspd;
|
||||
mips_loongson = commands/mips/loongson/lsspd.c;
|
||||
|
@ -530,13 +523,6 @@ module = {
|
|||
enable = usb;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = emuusb;
|
||||
common = bus/usb/usb.c;
|
||||
enable = emu;
|
||||
condition = COND_GRUB_EMU_USB;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = usbserial_common;
|
||||
common = bus/usb/serial/common.c;
|
||||
|
@ -2009,11 +1995,42 @@ module = {
|
|||
enable = xen;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = div;
|
||||
common = lib/division.c;
|
||||
enable = no_softdiv;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = div_test;
|
||||
common = tests/div_test.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = mul_test;
|
||||
common = tests/mul_test.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = shift_test;
|
||||
common = tests/shift_test.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = cmp_test;
|
||||
common = tests/cmp_test.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = ctz_test;
|
||||
common = tests/ctz_test.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = bswap_test;
|
||||
common = tests/bswap_test.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = videotest_checksum;
|
||||
common = tests/videotest_checksum.c;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <grub/decompressor.h>
|
||||
|
||||
void *
|
||||
memset (void *s, int c, grub_size_t len)
|
||||
grub_memset (void *s, int c, grub_size_t len)
|
||||
{
|
||||
grub_uint8_t *ptr;
|
||||
for (ptr = s; len; ptr++, len--)
|
||||
|
@ -68,15 +68,6 @@ grub_memcmp (const void *s1, const void *s2, grub_size_t n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int memcmp (const void *s1, const void *s2, grub_size_t n)
|
||||
__attribute__ ((alias ("grub_memcmp")));
|
||||
|
||||
void *memmove (void *dest, const void *src, grub_size_t n)
|
||||
__attribute__ ((alias ("grub_memmove")));
|
||||
|
||||
void *memcpy (void *dest, const void *src, grub_size_t n)
|
||||
__attribute__ ((alias ("grub_memmove")));
|
||||
|
||||
void *grub_decompressor_scratch;
|
||||
|
||||
void
|
||||
|
|
|
@ -165,8 +165,8 @@ start:
|
|||
* this area.
|
||||
*/
|
||||
|
||||
. = _start + GRUB_BOOT_MACHINE_BPB_START
|
||||
. = _start + 4
|
||||
.org GRUB_BOOT_MACHINE_BPB_START
|
||||
.org 4
|
||||
#endif
|
||||
#ifdef HYBRID_BOOT
|
||||
floppy
|
||||
|
@ -174,23 +174,23 @@ start:
|
|||
scratch
|
||||
#endif
|
||||
|
||||
. = _start + GRUB_BOOT_MACHINE_BPB_END
|
||||
.org GRUB_BOOT_MACHINE_BPB_END
|
||||
/*
|
||||
* End of BIOS parameter block.
|
||||
*/
|
||||
|
||||
kernel_address:
|
||||
LOCAL(kernel_address):
|
||||
.word GRUB_BOOT_MACHINE_KERNEL_ADDR
|
||||
|
||||
#ifndef HYBRID_BOOT
|
||||
. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
|
||||
kernel_sector:
|
||||
.org GRUB_BOOT_MACHINE_KERNEL_SECTOR
|
||||
LOCAL(kernel_sector):
|
||||
.long 1
|
||||
kernel_sector_high:
|
||||
LOCAL(kernel_sector_high):
|
||||
.long 0
|
||||
#endif
|
||||
|
||||
. = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE
|
||||
.org GRUB_BOOT_MACHINE_BOOT_DRIVE
|
||||
boot_drive:
|
||||
.byte 0xff /* the disk to load kernel from */
|
||||
/* 0xff means use the boot drive */
|
||||
|
@ -208,7 +208,7 @@ LOCAL(after_BPB):
|
|||
* possible boot drive. If GRUB is installed into a floppy,
|
||||
* this does nothing (only jump).
|
||||
*/
|
||||
. = _start + GRUB_BOOT_MACHINE_DRIVE_CHECK
|
||||
.org GRUB_BOOT_MACHINE_DRIVE_CHECK
|
||||
boot_drive_check:
|
||||
jmp 3f /* grub-setup may overwrite this jump */
|
||||
testb $0x80, %dl
|
||||
|
@ -275,7 +275,7 @@ real_start:
|
|||
andw $1, %cx
|
||||
jz LOCAL(chs_mode)
|
||||
|
||||
lba_mode:
|
||||
LOCAL(lba_mode):
|
||||
xorw %ax, %ax
|
||||
movw %ax, 4(%si)
|
||||
|
||||
|
@ -290,9 +290,9 @@ lba_mode:
|
|||
movw $0x0010, (%si)
|
||||
|
||||
/* the absolute address */
|
||||
movl kernel_sector, %ebx
|
||||
movl LOCAL(kernel_sector), %ebx
|
||||
movl %ebx, 8(%si)
|
||||
movl kernel_sector_high, %ebx
|
||||
movl LOCAL(kernel_sector_high), %ebx
|
||||
movl %ebx, 12(%si)
|
||||
|
||||
/* the segment of buffer address */
|
||||
|
@ -361,13 +361,13 @@ LOCAL(final_init):
|
|||
|
||||
setup_sectors:
|
||||
/* load logical sector start (top half) */
|
||||
movl kernel_sector_high, %eax
|
||||
movl LOCAL(kernel_sector_high), %eax
|
||||
|
||||
orl %eax, %eax
|
||||
jnz LOCAL(geometry_error)
|
||||
|
||||
/* load logical sector start (bottom half) */
|
||||
movl kernel_sector, %eax
|
||||
movl LOCAL(kernel_sector), %eax
|
||||
|
||||
/* zero %edx */
|
||||
xorl %edx, %edx
|
||||
|
@ -452,7 +452,7 @@ LOCAL(copy_buffer):
|
|||
popa
|
||||
|
||||
/* boot kernel */
|
||||
jmp *(kernel_address)
|
||||
jmp *(LOCAL(kernel_address))
|
||||
|
||||
/* END OF MAIN LOOP */
|
||||
|
||||
|
@ -511,13 +511,13 @@ LOCAL(message):
|
|||
*/
|
||||
|
||||
#ifdef HYBRID_BOOT
|
||||
. = _start + 0x1b0
|
||||
kernel_sector:
|
||||
.org 0x1b0
|
||||
LOCAL(kernel_sector):
|
||||
.long 1
|
||||
kernel_sector_high:
|
||||
LOCAL(kernel_sector_high):
|
||||
.long 0
|
||||
#endif
|
||||
. = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
|
||||
.org GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
|
||||
nt_magic:
|
||||
.long 0
|
||||
.word 0
|
||||
|
@ -528,7 +528,7 @@ nt_magic:
|
|||
* sneaky, huh?
|
||||
*/
|
||||
|
||||
. = _start + GRUB_BOOT_MACHINE_PART_START
|
||||
.org GRUB_BOOT_MACHINE_PART_START
|
||||
|
||||
#ifndef HYBRID_BOOT
|
||||
floppy
|
||||
|
@ -536,7 +536,7 @@ nt_magic:
|
|||
scratch
|
||||
#endif
|
||||
|
||||
. = _start + GRUB_BOOT_MACHINE_PART_END
|
||||
.org GRUB_BOOT_MACHINE_PART_END
|
||||
|
||||
/* the last 2 bytes in the sector 0 contain the signature */
|
||||
.word GRUB_BOOT_MACHINE_SIGNATURE
|
||||
|
|
|
@ -43,7 +43,7 @@ _start:
|
|||
LOCAL(next):
|
||||
jmp 1f
|
||||
|
||||
. = start + 8
|
||||
.org 8
|
||||
|
||||
bi_pvd:
|
||||
.long 0 /* LBA of primary volume descriptor. */
|
||||
|
@ -168,6 +168,6 @@ err_noboot_msg:
|
|||
err_cdfail_msg:
|
||||
.ascii "cdrom read fails\0"
|
||||
|
||||
. = start + 0x7FF
|
||||
.org 0x7FF
|
||||
|
||||
.byte 0
|
||||
|
|
|
@ -362,7 +362,7 @@ LOCAL(message):
|
|||
.word 0
|
||||
.word 0
|
||||
|
||||
. = _start + 0x200 - GRUB_BOOT_MACHINE_LIST_SIZE
|
||||
.org 0x200 - GRUB_BOOT_MACHINE_LIST_SIZE
|
||||
LOCAL(firstlist): /* this label has to be before the first list entry!!! */
|
||||
/* fill the first data listing with the default */
|
||||
blocklist_default_start:
|
||||
|
|
|
@ -41,7 +41,7 @@ data_start:
|
|||
xorl %ebp, %ebp
|
||||
jmp LOCAL(linux_next)
|
||||
|
||||
. = data_start + 0x1F1
|
||||
.org 0x1F1
|
||||
|
||||
setup_sects:
|
||||
.byte CODE_SECTORS
|
||||
|
@ -292,4 +292,4 @@ LOCAL(fail):
|
|||
err_int15_msg:
|
||||
.ascii "move memory fails\0"
|
||||
|
||||
. = _start + CODE_SECTORS * 512
|
||||
.org (CODE_SECTORS * 512 + 512)
|
||||
|
|
|
@ -38,5 +38,5 @@ start:
|
|||
/* This region is a junk. Do you say that this is wasteful?
|
||||
But I like that the memory layout of the body is consistent
|
||||
among different kernels rather than scamping just for 1.5KB. */
|
||||
. = _start + 0x8200 - 0x7C00 - 0x200 - 1
|
||||
.org 0x8200 - 0x7C00 - 0x200 - 1
|
||||
.byte 0
|
||||
|
|
|
@ -50,23 +50,23 @@ LOCAL (base):
|
|||
* This is a special data area.
|
||||
*/
|
||||
|
||||
. = _start + GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
|
||||
.org GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
|
||||
LOCAL(compressed_size):
|
||||
.long 0
|
||||
. = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
|
||||
.org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
|
||||
LOCAL(uncompressed_size):
|
||||
.long 0
|
||||
|
||||
. = _start + GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY
|
||||
.org GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY
|
||||
reed_solomon_redundancy:
|
||||
.long 0
|
||||
. = _start + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH
|
||||
.org GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH
|
||||
.short (LOCAL(reed_solomon_part) - _start)
|
||||
|
||||
/*
|
||||
* This is the area for all of the special variables.
|
||||
*/
|
||||
. = _start + GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE
|
||||
.org GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE
|
||||
LOCAL(boot_dev):
|
||||
.byte 0xFF, 0xFF, 0xFF
|
||||
LOCAL(boot_drive):
|
||||
|
@ -89,13 +89,13 @@ LOCAL (codestart):
|
|||
sti /* we're safe again */
|
||||
|
||||
/* save the boot drive */
|
||||
ADDR32 movb %dl, LOCAL(boot_drive)
|
||||
movb %dl, LOCAL(boot_drive)
|
||||
|
||||
/* reset disk system (%ah = 0) */
|
||||
int $0x13
|
||||
|
||||
/* transition to protected mode */
|
||||
DATA32 call real_to_prot
|
||||
calll real_to_prot
|
||||
|
||||
/* The ".code32" directive takes GAS out of 16-bit mode. */
|
||||
.code32
|
||||
|
@ -149,7 +149,7 @@ gate_a20_try_bios:
|
|||
movw $0x2401, %ax
|
||||
int $0x15
|
||||
|
||||
DATA32 call real_to_prot
|
||||
calll real_to_prot
|
||||
.code32
|
||||
|
||||
popl %ebp
|
||||
|
|
|
@ -31,7 +31,7 @@ _start:
|
|||
|
||||
jmp 1f
|
||||
|
||||
. = _start + GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR
|
||||
.org GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR
|
||||
VARIABLE(grub_core_entry_addr)
|
||||
.long 0
|
||||
1:
|
||||
|
@ -48,8 +48,9 @@ VARIABLE(grub_core_entry_addr)
|
|||
/* Transition to protected mode. We use pushl to force generation
|
||||
of a flat return address. */
|
||||
pushl $1f
|
||||
DATA32 jmp real_to_prot
|
||||
jmp real_to_prot
|
||||
.code32
|
||||
1:
|
||||
/* Ensure A20 is enabled. We're in qemu, so control port A works
|
||||
and there is no need to wait since there is no real logic, it's
|
||||
all emulated. */
|
||||
|
@ -57,7 +58,6 @@ VARIABLE(grub_core_entry_addr)
|
|||
andb $(~0x03), %al
|
||||
orb $0x02, %al
|
||||
outb $0x92
|
||||
1:
|
||||
movl EXT_C(grub_core_entry_addr), %edx
|
||||
jmp *%edx
|
||||
|
||||
|
@ -66,9 +66,9 @@ VARIABLE(grub_core_entry_addr)
|
|||
/* Intel, in its infinite wisdom, decided to put the i8086 entry point
|
||||
*right here* and this is why we need this kludge. */
|
||||
|
||||
. = GRUB_BOOT_MACHINE_SIZE - 16
|
||||
.org GRUB_BOOT_MACHINE_SIZE - 16
|
||||
|
||||
.code16
|
||||
|
||||
jmp _start
|
||||
. = GRUB_BOOT_MACHINE_SIZE
|
||||
.org GRUB_BOOT_MACHINE_SIZE
|
||||
|
|
|
@ -162,7 +162,7 @@ retry_cs5536:
|
|||
|
||||
b continue
|
||||
|
||||
. = start + GRUB_CPU_LOONGSON_FLASH_TLB_REFILL - GRUB_CPU_LOONGSON_FLASH_START
|
||||
.org GRUB_CPU_LOONGSON_FLASH_TLB_REFILL - GRUB_CPU_LOONGSON_FLASH_START
|
||||
tlb_refill:
|
||||
mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC
|
||||
mfc0 $s2, GRUB_CPU_LOONGSON_COP0_BADVADDR
|
||||
|
@ -196,13 +196,13 @@ tlb_refill:
|
|||
b fatal
|
||||
addiu $a0, $a0, %lo(unhandled_tlb_refill)
|
||||
|
||||
. = start + GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR - GRUB_CPU_LOONGSON_FLASH_START
|
||||
.org GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR - GRUB_CPU_LOONGSON_FLASH_START
|
||||
cache_error:
|
||||
lui $a0, %hi(unhandled_cache_error)
|
||||
b fatal
|
||||
addiu $a0, $a0, %lo(unhandled_cache_error)
|
||||
|
||||
. = start + GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - GRUB_CPU_LOONGSON_FLASH_START
|
||||
.org GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - GRUB_CPU_LOONGSON_FLASH_START
|
||||
other_exception:
|
||||
mfc0 $s0, GRUB_CPU_LOONGSON_COP0_CAUSE
|
||||
mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <grub/offsets.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/cpu/kernel.h>
|
||||
#include <grub/offsets.h>
|
||||
|
||||
#define BASE_ADDR 8
|
||||
|
@ -32,6 +33,7 @@
|
|||
.globl __start, _start, start
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
mips_attributes
|
||||
__start:
|
||||
_start:
|
||||
start:
|
||||
|
@ -39,13 +41,13 @@ start:
|
|||
bal codestart
|
||||
nop
|
||||
base:
|
||||
. = _start + GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
|
||||
.org GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
|
||||
compressed_size:
|
||||
.long 0
|
||||
. = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
|
||||
.org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
|
||||
uncompressed_size:
|
||||
.long 0
|
||||
. = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR
|
||||
.org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR
|
||||
uncompressed_addr:
|
||||
.long 0
|
||||
codestart:
|
||||
|
@ -150,18 +152,18 @@ digcont:
|
|||
1:
|
||||
jr $ra
|
||||
nop
|
||||
busclockstr: .asciiz "busclock="
|
||||
cpuclockstr: .asciiz "cpuclock="
|
||||
memsizestr: .asciiz "memsize="
|
||||
highmemsizestr: .asciiz "highmemsize="
|
||||
machtype_yeeloong_str1: .asciiz "machtype=8.9"
|
||||
machtype_yeeloong_str2: .asciiz "machtype=lemote-yeeloong-"
|
||||
machtype_fuloong2f_str: .asciiz "machtype=lemote-fuloong-2f"
|
||||
machtype_fuloong2e_str: .asciiz "machtype=lemote-fuloong-2e"
|
||||
pmon_yeeloong_str: .asciiz "PMON_VER=LM8"
|
||||
pmon_fuloong2f_str: .asciiz "PMON_VER=LM6"
|
||||
pmon_yeeloong_verstr: .asciiz "Version=LM8"
|
||||
pmon_fuloong2f_verstr: .asciiz "Version=LM6"
|
||||
busclockstr: .asciz "busclock="
|
||||
cpuclockstr: .asciz "cpuclock="
|
||||
memsizestr: .asciz "memsize="
|
||||
highmemsizestr: .asciz "highmemsize="
|
||||
machtype_yeeloong_str1: .asciz "machtype=8.9"
|
||||
machtype_yeeloong_str2: .asciz "machtype=lemote-yeeloong-"
|
||||
machtype_fuloong2f_str: .asciz "machtype=lemote-fuloong-2f"
|
||||
machtype_fuloong2e_str: .asciz "machtype=lemote-fuloong-2e"
|
||||
pmon_yeeloong_str: .asciz "PMON_VER=LM8"
|
||||
pmon_fuloong2f_str: .asciz "PMON_VER=LM6"
|
||||
pmon_yeeloong_verstr: .asciz "Version=LM8"
|
||||
pmon_fuloong2f_verstr: .asciz "Version=LM6"
|
||||
.p2align 2
|
||||
|
||||
argdone:
|
||||
|
|
|
@ -41,9 +41,9 @@ pic_base:
|
|||
* After loading in that block we will execute it by jumping to the
|
||||
* load address plus the size of the prepended A.OUT header (32 bytes).
|
||||
*/
|
||||
. = _start + GRUB_BOOT_MACHINE_BOOT_DEVPATH
|
||||
.org GRUB_BOOT_MACHINE_BOOT_DEVPATH
|
||||
boot_path:
|
||||
. = _start + GRUB_BOOT_MACHINE_KERNEL_BYTE
|
||||
.org GRUB_BOOT_MACHINE_KERNEL_BYTE
|
||||
boot_path_end:
|
||||
kernel_byte: .xword (2 << 9)
|
||||
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
|
||||
|
@ -52,7 +52,7 @@ kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
|
|||
#define boot_path_end (_start + 1024)
|
||||
#include <grub/offsets.h>
|
||||
|
||||
. = _start + 8
|
||||
.org 8
|
||||
kernel_byte: .xword (2 << 9)
|
||||
kernel_size: .word 512
|
||||
kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS
|
||||
|
@ -224,7 +224,7 @@ bootpath_known:
|
|||
#else
|
||||
nop
|
||||
#endif
|
||||
. = _start + GRUB_BOOT_MACHINE_CODE_END
|
||||
.org GRUB_BOOT_MACHINE_CODE_END
|
||||
|
||||
/* the last 4 bytes in the sector 0 contain the signature */
|
||||
.word GRUB_BOOT_MACHINE_SIGNATURE
|
||||
|
|
|
@ -136,7 +136,7 @@ lastlist:
|
|||
.word 0
|
||||
.word 0
|
||||
|
||||
. = _start + (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE)
|
||||
.org (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE)
|
||||
blocklist_default_start:
|
||||
.word 0
|
||||
.word 2
|
||||
|
|
|
@ -55,7 +55,8 @@ grub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base,
|
|||
int err;
|
||||
err = pci_device_map_range (dev, base, size, PCI_DEV_MAP_FLAG_WRITABLE, &addr);
|
||||
if (err)
|
||||
grub_util_error ("mapping 0x%x failed (error %d)\n", base, err);
|
||||
grub_util_error ("mapping 0x%llx failed (error %d)\n",
|
||||
(unsigned long long) base, err);
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
@ -66,12 +67,12 @@ grub_pci_device_unmap_range (grub_pci_device_t dev, void *mem,
|
|||
pci_device_unmap_range (dev, mem, size);
|
||||
}
|
||||
|
||||
GRUB_MOD_INIT (pci)
|
||||
GRUB_MOD_INIT (emupci)
|
||||
{
|
||||
pci_system_init ();
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (pci)
|
||||
GRUB_MOD_FINI (emupci)
|
||||
{
|
||||
pci_system_cleanup ();
|
||||
}
|
||||
|
|
|
@ -1,203 +0,0 @@
|
|||
/* usb.c -- libusb USB support for GRUB. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <usb.h>
|
||||
#include <grub/usb.h>
|
||||
#include <grub/dl.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
|
||||
static struct grub_usb_controller_dev usb_controller =
|
||||
{
|
||||
.name = "libusb"
|
||||
};
|
||||
|
||||
static struct grub_usb_device *grub_usb_devs[128];
|
||||
|
||||
struct usb_bus *busses;
|
||||
|
||||
static grub_err_t
|
||||
grub_libusb_devices (void)
|
||||
|
||||
{
|
||||
struct usb_bus *bus;
|
||||
int last = 0;
|
||||
|
||||
busses = usb_get_busses();
|
||||
|
||||
for (bus = busses; bus; bus = bus->next)
|
||||
{
|
||||
struct usb_device *usbdev;
|
||||
struct grub_usb_device *dev;
|
||||
|
||||
for (usbdev = bus->devices; usbdev; usbdev = usbdev->next)
|
||||
{
|
||||
struct usb_device_descriptor *desc = &usbdev->descriptor;
|
||||
grub_err_t err;
|
||||
|
||||
if (! desc->bcdUSB)
|
||||
continue;
|
||||
|
||||
dev = grub_malloc (sizeof (*dev));
|
||||
if (! dev)
|
||||
return grub_errno;
|
||||
|
||||
dev->data = usbdev;
|
||||
|
||||
/* Fill in all descriptors. */
|
||||
err = grub_usb_device_initialize (dev);
|
||||
if (err)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Register the device. */
|
||||
grub_usb_devs[last++] = dev;
|
||||
}
|
||||
}
|
||||
|
||||
return GRUB_USB_ERR_NONE;
|
||||
}
|
||||
|
||||
void
|
||||
grub_usb_poll_devices (void)
|
||||
{
|
||||
/* TODO: recheck grub_usb_devs */
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
grub_usb_iterate (grub_usb_iterate_hook_t hook, void *hook_data)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
if (grub_usb_devs[i])
|
||||
{
|
||||
if (hook (grub_usb_devs[i], hook_data))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_usb_err_t
|
||||
grub_usb_root_hub (grub_usb_controller_t controller __attribute__((unused)))
|
||||
{
|
||||
return GRUB_USB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_usb_err_t
|
||||
grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype,
|
||||
grub_uint8_t request, grub_uint16_t value,
|
||||
grub_uint16_t idx, grub_size_t size, char *data)
|
||||
{
|
||||
usb_dev_handle *devh;
|
||||
struct usb_device *d = dev->data;
|
||||
|
||||
devh = usb_open (d);
|
||||
if (usb_control_msg (devh, reqtype, request,
|
||||
value, idx, data, size, 20) < 0)
|
||||
{
|
||||
usb_close (devh);
|
||||
return GRUB_USB_ERR_STALL;
|
||||
}
|
||||
|
||||
usb_close (devh);
|
||||
|
||||
return GRUB_USB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_usb_err_t
|
||||
grub_usb_bulk_read (grub_usb_device_t dev,
|
||||
int endpoint, grub_size_t size, char *data)
|
||||
{
|
||||
usb_dev_handle *devh;
|
||||
struct usb_device *d = dev->data;
|
||||
|
||||
devh = usb_open (d);
|
||||
if (usb_claim_interface (devh, 0) < 1)
|
||||
{
|
||||
usb_close (devh);
|
||||
return GRUB_USB_ERR_STALL;
|
||||
}
|
||||
|
||||
if (usb_bulk_read (devh, endpoint, data, size, 20) < 1)
|
||||
{
|
||||
usb_close (devh);
|
||||
return GRUB_USB_ERR_STALL;
|
||||
}
|
||||
|
||||
usb_release_interface (devh, 0);
|
||||
usb_close (devh);
|
||||
|
||||
return GRUB_USB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_usb_err_t
|
||||
grub_usb_bulk_write (grub_usb_device_t dev,
|
||||
int endpoint, grub_size_t size, char *data)
|
||||
{
|
||||
usb_dev_handle *devh;
|
||||
struct usb_device *d = dev->data;
|
||||
|
||||
devh = usb_open (d);
|
||||
if (usb_claim_interface (devh, 0) < 0)
|
||||
goto fail;
|
||||
|
||||
if (usb_bulk_write (devh, endpoint, data, size, 20) < 0)
|
||||
goto fail;
|
||||
|
||||
if (usb_release_interface (devh, 0) < 0)
|
||||
goto fail;
|
||||
|
||||
usb_close (devh);
|
||||
|
||||
return GRUB_USB_ERR_NONE;
|
||||
|
||||
fail:
|
||||
usb_close (devh);
|
||||
return GRUB_USB_ERR_STALL;
|
||||
}
|
||||
|
||||
GRUB_MOD_INIT (libusb)
|
||||
{
|
||||
usb_init();
|
||||
usb_find_busses();
|
||||
usb_find_devices();
|
||||
|
||||
if (grub_libusb_devices ())
|
||||
return;
|
||||
|
||||
grub_usb_controller_dev_register (&usb_controller);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (libusb)
|
||||
{
|
||||
return;
|
||||
}
|
|
@ -625,9 +625,7 @@ grub_uhci_check_transfer (grub_usb_controller_t dev,
|
|||
return GRUB_USB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_dprintf ("uhci", "t status=0x%02x\n", errtd->ctrl_status);
|
||||
|
||||
if (!(errtd->ctrl_status & (1 << 23)))
|
||||
if (errtd && !(errtd->ctrl_status & (1 << 23)))
|
||||
{
|
||||
grub_usb_err_t err = GRUB_USB_ERR_NONE;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ grub_usb_bulk_maxpacket (grub_usb_device_t dev,
|
|||
struct grub_usb_desc_endp *endpoint)
|
||||
{
|
||||
/* Use the maximum packet size given in the endpoint descriptor. */
|
||||
if (dev->initialized && endpoint)
|
||||
if (dev->initialized && endpoint && (unsigned int) endpoint->maxpacket)
|
||||
return endpoint->maxpacket;
|
||||
|
||||
return 64;
|
||||
|
|
|
@ -131,6 +131,8 @@ grub_acpi_get_rsdpv1 (void)
|
|||
return grub_machine_acpi_get_rsdpv1 ();
|
||||
}
|
||||
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
|
||||
static inline int
|
||||
iszero (grub_uint8_t *reg, int size)
|
||||
{
|
||||
|
@ -141,7 +143,6 @@ iszero (grub_uint8_t *reg, int size)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
/* Context for grub_acpi_create_ebda. */
|
||||
struct grub_acpi_create_ebda_ctx {
|
||||
int ebda_len;
|
||||
|
@ -227,7 +228,7 @@ grub_acpi_create_ebda (void)
|
|||
grub_dprintf ("acpi", "Copying rsdpv2 to %p\n", target);
|
||||
v2inebda = target;
|
||||
target += v2->length;
|
||||
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
|
||||
target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
|
||||
v2 = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -246,7 +247,7 @@ grub_acpi_create_ebda (void)
|
|||
grub_dprintf ("acpi", "Copying rsdpv1 to %p\n", target);
|
||||
v1inebda = target;
|
||||
target += sizeof (struct grub_acpi_rsdp_v10);
|
||||
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
|
||||
target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
|
||||
v1 = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -265,7 +266,7 @@ grub_acpi_create_ebda (void)
|
|||
grub_memcpy (target, v2, v2->length);
|
||||
v2inebda = target;
|
||||
target += v2->length;
|
||||
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
|
||||
target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
|
||||
v2 = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -282,7 +283,7 @@ grub_acpi_create_ebda (void)
|
|||
grub_memcpy (target, v1, sizeof (struct grub_acpi_rsdp_v10));
|
||||
v1inebda = target;
|
||||
target += sizeof (struct grub_acpi_rsdp_v10);
|
||||
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
|
||||
target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
|
||||
v1 = 0;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include <grub/i18n.h>
|
||||
#include <grub/disk.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static grub_err_t
|
||||
grub_rescue_cmd_info (struct grub_command *cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
|
|
|
@ -476,8 +476,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
be at least 12 bytes and aligned on a 4-byte boundary. */
|
||||
for (header = buffer;
|
||||
((char *) header <=
|
||||
(char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12))
|
||||
|| (header = 0); header += step)
|
||||
(char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12));
|
||||
header += step)
|
||||
{
|
||||
if (header[0] == magic
|
||||
&& !(grub_le_to_cpu32 (header[0])
|
||||
|
@ -485,11 +485,12 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
+ grub_le_to_cpu32 (header[2])
|
||||
+ (type == IS_MULTIBOOT2
|
||||
? grub_le_to_cpu32 (header[3]) : 0)))
|
||||
break;
|
||||
{
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (header != 0)
|
||||
ret = 1;
|
||||
grub_free (buffer);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -40,10 +40,10 @@ grub_file_check_netbsdXX (grub_elf_t elf)
|
|||
return 0;
|
||||
|
||||
if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1)
|
||||
return 0;
|
||||
goto fail;
|
||||
|
||||
if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize)
|
||||
return 0;
|
||||
goto fail;
|
||||
|
||||
s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize);
|
||||
stroff = s->sh_offset;
|
||||
|
@ -54,18 +54,21 @@ grub_file_check_netbsdXX (grub_elf_t elf)
|
|||
char name[sizeof(".note.netbsd.ident")];
|
||||
grub_memset (name, 0, sizeof (name));
|
||||
if (grub_file_seek (elf->file, stroff + s->sh_name) == (grub_off_t) -1)
|
||||
return grub_errno;
|
||||
goto fail;
|
||||
|
||||
if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name))
|
||||
{
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
goto fail;
|
||||
continue;
|
||||
}
|
||||
if (grub_memcmp (name, ".note.netbsd.ident",
|
||||
sizeof(".note.netbsd.ident")) != 0)
|
||||
continue;
|
||||
grub_free (s0);
|
||||
return 1;
|
||||
}
|
||||
fail:
|
||||
grub_free (s0);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -235,6 +235,8 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
grub_device_close (dev);
|
||||
|
||||
grub_printf_ (N_("New MBR is written to `%s'\n"), args[0]);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
|
|
@ -329,6 +329,7 @@ grub_cmd_hdparm (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
grub_disk_close (disk);
|
||||
return grub_error (GRUB_ERR_IO, "not an ATA device");
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,14 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
if (!tempo)
|
||||
{
|
||||
grub_file_close (file);
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid tempo in %s"),
|
||||
args[0]);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
tempo = grub_le_to_cpu32 (tempo);
|
||||
grub_dprintf ("play","tempo = %d\n", tempo);
|
||||
|
||||
|
@ -131,6 +139,13 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
tempo = grub_strtoul (args[0], &end, 0);
|
||||
|
||||
if (!tempo)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid tempo in %s"),
|
||||
args[0]);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
if (*end)
|
||||
/* Was not a number either, assume it was supposed to be a file name. */
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), args[0]);
|
||||
|
|
|
@ -292,7 +292,7 @@ find_key_code (char *key)
|
|||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(keysym_table); i++)
|
||||
{
|
||||
if (keysym_table[i].unshifted_name
|
||||
&& grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
|
||||
|
@ -311,7 +311,7 @@ find_ascii_code (char *key)
|
|||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(keysym_table); i++)
|
||||
{
|
||||
if (keysym_table[i].unshifted_name
|
||||
&& grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
|
||||
|
@ -352,15 +352,13 @@ grub_cmd_sendkey (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < sizeof (simple_flag_offsets)
|
||||
/ sizeof (simple_flag_offsets[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(simple_flag_offsets); i++)
|
||||
grub_sendkey_set_simple_flag (simple_flag_offsets[i],
|
||||
grub_sendkey_parse_op(state[i]));
|
||||
}
|
||||
|
||||
/* Set noled. */
|
||||
noled = (state[sizeof (simple_flag_offsets)
|
||||
/ sizeof (simple_flag_offsets[0])].set);
|
||||
noled = (state[ARRAY_SIZE(simple_flag_offsets)].set);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
|
|
@ -57,14 +57,20 @@ legacy_file (const char *filename)
|
|||
|
||||
file = grub_file_open (filename);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
{
|
||||
grub_free (suffix);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
menu = grub_env_get_menu ();
|
||||
if (! menu)
|
||||
{
|
||||
menu = grub_zalloc (sizeof (*menu));
|
||||
if (! menu)
|
||||
return grub_errno;
|
||||
{
|
||||
grub_free (suffix);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
grub_env_set_menu (menu);
|
||||
}
|
||||
|
@ -77,6 +83,7 @@ legacy_file (const char *filename)
|
|||
if (!buf && grub_errno)
|
||||
{
|
||||
grub_file_close (file);
|
||||
grub_free (suffix);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
@ -173,6 +180,8 @@ legacy_file (const char *filename)
|
|||
if (!args)
|
||||
{
|
||||
grub_file_close (file);
|
||||
grub_free (suffix);
|
||||
grub_free (entrysrc);
|
||||
return grub_errno;
|
||||
}
|
||||
args[0] = entryname;
|
||||
|
@ -376,6 +385,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
|
|||
if (part && grub_strcmp (part->partmap->name, "msdos") == 0)
|
||||
bsd_slice = part->number;
|
||||
}
|
||||
if (dev)
|
||||
grub_device_close (dev);
|
||||
}
|
||||
|
||||
/* k*BSD didn't really work well with grub-legacy. */
|
||||
|
|
|
@ -106,7 +106,7 @@ grub_mac_bless_inode (grub_device_t dev, grub_uint32_t inode, int is_dir,
|
|||
ablk_size = grub_be_to_cpu32 (volheader.hfs.blksz);
|
||||
ablk_start = grub_be_to_cpu16 (volheader.hfs.first_block);
|
||||
embedded_offset = (ablk_start
|
||||
+ extent_start
|
||||
+ ((grub_uint64_t) extent_start)
|
||||
* (ablk_size >> GRUB_DISK_SECTOR_BITS));
|
||||
|
||||
err =
|
||||
|
@ -183,7 +183,7 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args)
|
|||
{
|
||||
char *device_name;
|
||||
char *path = 0;
|
||||
grub_device_t dev;
|
||||
grub_device_t dev = 0;
|
||||
grub_err_t err;
|
||||
|
||||
if (argc != 1)
|
||||
|
@ -197,13 +197,12 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args)
|
|||
else
|
||||
path = path + 1;
|
||||
|
||||
if (!path || *path == 0 || !device_name)
|
||||
if (!path || *path == 0 || !dev)
|
||||
{
|
||||
if (dev)
|
||||
grub_device_close (dev);
|
||||
|
||||
grub_free (device_name);
|
||||
grub_free (path);
|
||||
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ get_uuid (const char *name, char **uuid, int getnative)
|
|||
if (!dev->disk)
|
||||
{
|
||||
grub_dprintf ("nativedisk", "Skipping non-disk\n");
|
||||
grub_device_close (dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -90,6 +91,7 @@ get_uuid (const char *name, char **uuid, int getnative)
|
|||
case GRUB_DISK_DEVICE_MEMDISK_ID:
|
||||
grub_dprintf ("nativedisk", "Skipping native disk %s\n",
|
||||
dev->disk->name);
|
||||
grub_device_close (dev);
|
||||
return 0;
|
||||
|
||||
/* FIXME: those probably need special handling. */
|
||||
|
|
|
@ -243,11 +243,19 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
|
||||
if (argc == 1)
|
||||
return show_help (dev);
|
||||
{
|
||||
err = show_help (dev);
|
||||
grub_device_close (dev);
|
||||
return err;
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if (grub_strcmp (args[i], "help") == 0)
|
||||
return show_help (dev);
|
||||
{
|
||||
err = show_help (dev);
|
||||
grub_device_close (dev);
|
||||
return err;
|
||||
}
|
||||
|
||||
parsed = (int *) grub_zalloc (argc * sizeof (int));
|
||||
|
||||
|
@ -274,8 +282,11 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
|||
break;
|
||||
}
|
||||
if (! cur)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"),
|
||||
{
|
||||
grub_device_close (dev);
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"),
|
||||
args[i]);
|
||||
}
|
||||
ptool = cur;
|
||||
pargs = (struct grub_parttool_args *)
|
||||
grub_zalloc (ptool->nargs * sizeof (struct grub_parttool_args));
|
||||
|
|
|
@ -119,7 +119,10 @@ syslinux_file (grub_extcmd_context_t ctxt, const char *filename)
|
|||
{
|
||||
menu = grub_zalloc (sizeof (*menu));
|
||||
if (! menu)
|
||||
return grub_errno;
|
||||
{
|
||||
grub_free (result);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
grub_env_set_menu (menu);
|
||||
}
|
||||
|
|
|
@ -332,7 +332,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
get_fileinfo (args[*argn + 1], &ctx);
|
||||
update_val (ctx.file_exists && ctx.file_info.dir, &ctx);
|
||||
(*argn) += 2;
|
||||
return ctx.or || ctx.and;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (grub_strcmp (args[*argn], "-e") == 0)
|
||||
|
@ -340,7 +340,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
get_fileinfo (args[*argn + 1], &ctx);
|
||||
update_val (ctx.file_exists, &ctx);
|
||||
(*argn) += 2;
|
||||
return ctx.or || ctx.and;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (grub_strcmp (args[*argn], "-f") == 0)
|
||||
|
@ -349,7 +349,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
/* FIXME: check for other types. */
|
||||
update_val (ctx.file_exists && ! ctx.file_info.dir, &ctx);
|
||||
(*argn) += 2;
|
||||
return ctx.or || ctx.and;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (grub_strcmp (args[*argn], "-s") == 0)
|
||||
|
@ -362,7 +362,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
grub_file_close (file);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
(*argn) += 2;
|
||||
return ctx.or || ctx.and;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* String tests. */
|
||||
|
|
|
@ -80,7 +80,7 @@ grub_cmd_tr (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
} else if (argc > 3)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many parameters");
|
||||
|
||||
if (argc <= 0 && (!s1 || !s2 || !input))
|
||||
if (!s1 || !s2 || !input)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing parameters");
|
||||
|
||||
if (grub_strlen (s1) != grub_strlen (s2))
|
||||
|
|
|
@ -33,6 +33,13 @@
|
|||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
struct grub_verified
|
||||
{
|
||||
grub_file_t file;
|
||||
void *buf;
|
||||
};
|
||||
typedef struct grub_verified *grub_verified_t;
|
||||
|
||||
enum
|
||||
{
|
||||
OPTION_SKIP_SIG = 0
|
||||
|
@ -301,7 +308,7 @@ grub_load_public_key (grub_file_t f)
|
|||
if (!sk)
|
||||
goto fail;
|
||||
|
||||
grub_memset (fingerprint_context, 0, sizeof (fingerprint_context));
|
||||
grub_memset (fingerprint_context, 0, GRUB_MD_SHA1->contextsize);
|
||||
GRUB_MD_SHA1->init (fingerprint_context);
|
||||
GRUB_MD_SHA1->write (fingerprint_context, "\x99", 1);
|
||||
len_be = grub_cpu_to_be16 (len);
|
||||
|
@ -447,7 +454,7 @@ grub_verify_signature_real (char *buf, grub_size_t size,
|
|||
grub_err_t err;
|
||||
grub_size_t i;
|
||||
gcry_mpi_t mpis[10];
|
||||
grub_uint8_t type;
|
||||
grub_uint8_t type = 0;
|
||||
|
||||
err = read_packet_header (sig, &type, &len);
|
||||
if (err)
|
||||
|
@ -802,19 +809,39 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
|
|||
|
||||
static int sec = 0;
|
||||
|
||||
static void
|
||||
verified_free (grub_verified_t verified)
|
||||
{
|
||||
if (verified)
|
||||
{
|
||||
grub_free (verified->buf);
|
||||
grub_free (verified);
|
||||
}
|
||||
}
|
||||
|
||||
static grub_ssize_t
|
||||
verified_read (struct grub_file *file, char *buf, grub_size_t len)
|
||||
{
|
||||
grub_memcpy (buf, (char *) file->data + file->offset, len);
|
||||
grub_verified_t verified = file->data;
|
||||
|
||||
grub_memcpy (buf, (char *) verified->buf + file->offset, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
verified_close (struct grub_file *file)
|
||||
{
|
||||
grub_free (file->data);
|
||||
grub_verified_t verified = file->data;
|
||||
|
||||
grub_file_close (verified->file);
|
||||
verified_free (verified);
|
||||
file->data = 0;
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
/* device and name are freed by parent */
|
||||
file->device = 0;
|
||||
file->name = 0;
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
struct grub_fs verified_fs =
|
||||
|
@ -832,6 +859,7 @@ grub_pubkey_open (grub_file_t io, const char *filename)
|
|||
grub_err_t err;
|
||||
grub_file_filter_t curfilt[GRUB_FILE_FILTER_MAX];
|
||||
grub_file_t ret;
|
||||
grub_verified_t verified;
|
||||
|
||||
if (!sec)
|
||||
return io;
|
||||
|
@ -857,7 +885,10 @@ grub_pubkey_open (grub_file_t io, const char *filename)
|
|||
|
||||
ret = grub_malloc (sizeof (*ret));
|
||||
if (!ret)
|
||||
return NULL;
|
||||
{
|
||||
grub_file_close (sig);
|
||||
return NULL;
|
||||
}
|
||||
*ret = *io;
|
||||
|
||||
ret->fs = &verified_fs;
|
||||
|
@ -866,29 +897,46 @@ grub_pubkey_open (grub_file_t io, const char *filename)
|
|||
{
|
||||
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"big file signature isn't implemented yet");
|
||||
return NULL;
|
||||
}
|
||||
ret->data = grub_malloc (ret->size);
|
||||
if (!ret->data)
|
||||
{
|
||||
grub_file_close (sig);
|
||||
grub_free (ret);
|
||||
return NULL;
|
||||
}
|
||||
if (grub_file_read (io, ret->data, ret->size) != (grub_ssize_t) ret->size)
|
||||
verified = grub_malloc (sizeof (*verified));
|
||||
if (!verified)
|
||||
{
|
||||
grub_file_close (sig);
|
||||
grub_free (ret);
|
||||
return NULL;
|
||||
}
|
||||
verified->buf = grub_malloc (ret->size);
|
||||
if (!verified->buf)
|
||||
{
|
||||
grub_file_close (sig);
|
||||
grub_free (verified);
|
||||
grub_free (ret);
|
||||
return NULL;
|
||||
}
|
||||
if (grub_file_read (io, verified->buf, ret->size) != (grub_ssize_t) ret->size)
|
||||
{
|
||||
if (!grub_errno)
|
||||
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
|
||||
filename);
|
||||
grub_file_close (sig);
|
||||
verified_free (verified);
|
||||
grub_free (ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = grub_verify_signature_real (ret->data, ret->size, 0, sig, NULL);
|
||||
err = grub_verify_signature_real (verified->buf, ret->size, 0, sig, NULL);
|
||||
grub_file_close (sig);
|
||||
if (err)
|
||||
return NULL;
|
||||
io->device = 0;
|
||||
io->name = 0;
|
||||
grub_file_close (io);
|
||||
{
|
||||
verified_free (verified);
|
||||
grub_free (ret);
|
||||
return NULL;
|
||||
}
|
||||
verified->file = io;
|
||||
ret->data = verified;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -245,7 +245,10 @@ match_devices_iter (const char *name, void *data)
|
|||
|
||||
t = grub_realloc (ctx->devs, sizeof (char*) * (ctx->ndev + 2));
|
||||
if (! t)
|
||||
return 1;
|
||||
{
|
||||
grub_free (buffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ctx->devs = t;
|
||||
ctx->devs[ctx->ndev++] = buffer;
|
||||
|
@ -290,7 +293,8 @@ struct match_files_ctx
|
|||
|
||||
/* Helper for match_files. */
|
||||
static int
|
||||
match_files_iter (const char *name, const struct grub_dirhook_info *info,
|
||||
match_files_iter (const char *name,
|
||||
const struct grub_dirhook_info *info __attribute__((unused)),
|
||||
void *data)
|
||||
{
|
||||
struct match_files_ctx *ctx = data;
|
||||
|
|
|
@ -72,13 +72,13 @@ AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst,
|
|||
grub_size_t i;
|
||||
grub_uint8_t *bufblock;
|
||||
|
||||
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0)
|
||||
return GPG_ERR_INV_ARG;
|
||||
|
||||
bufblock = grub_zalloc (blocksize);
|
||||
if (bufblock == NULL)
|
||||
return GPG_ERR_OUT_OF_MEMORY;
|
||||
|
||||
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return GPG_ERR_INV_ARG;
|
||||
|
||||
grub_memset (bufblock, 0, blocksize);
|
||||
for (i = 0; i < blocknumbers - 1; i++)
|
||||
{
|
||||
|
|
|
@ -198,7 +198,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
|
|||
| GRUB_PCI_COMMAND_MEM_ENABLED);
|
||||
|
||||
hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK,
|
||||
sizeof (hba));
|
||||
sizeof (*hba));
|
||||
grub_dprintf ("ahci", "dev: %x:%x.%x\n", dev.bus, dev.device, dev.function);
|
||||
|
||||
grub_dprintf ("ahci", "tfd[0]: %x\n",
|
||||
|
|
|
@ -216,6 +216,12 @@ grub_ata_setaddress (struct grub_ata *dev,
|
|||
unsigned int head;
|
||||
unsigned int sect;
|
||||
|
||||
if (dev->sectors_per_track == 0
|
||||
|| dev->heads == 0)
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
"sector %d cannot be addressed "
|
||||
"using CHS addressing", sector);
|
||||
|
||||
/* Calculate the sector, cylinder and head to use. */
|
||||
sect = ((grub_uint32_t) sector % dev->sectors_per_track) + 1;
|
||||
cylinder = (((grub_uint32_t) sector / dev->sectors_per_track)
|
||||
|
|
|
@ -110,20 +110,23 @@ grub_crypto_pcbc_decrypt (grub_crypto_cipher_handle_t cipher,
|
|||
{
|
||||
grub_uint8_t *inptr, *outptr, *end;
|
||||
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
|
||||
if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
|
||||
return GPG_ERR_INV_ARG;
|
||||
grub_size_t blocksize;
|
||||
if (!cipher->cipher->decrypt)
|
||||
return GPG_ERR_NOT_SUPPORTED;
|
||||
if (size % cipher->cipher->blocksize != 0)
|
||||
blocksize = cipher->cipher->blocksize;
|
||||
if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
|
||||
|| ((size & (blocksize - 1)) != 0))
|
||||
return GPG_ERR_INV_ARG;
|
||||
if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
|
||||
return GPG_ERR_INV_ARG;
|
||||
end = (grub_uint8_t *) in + size;
|
||||
for (inptr = in, outptr = out; inptr < end;
|
||||
inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize)
|
||||
inptr += blocksize, outptr += blocksize)
|
||||
{
|
||||
grub_memcpy (ivt, inptr, cipher->cipher->blocksize);
|
||||
grub_memcpy (ivt, inptr, blocksize);
|
||||
cipher->cipher->decrypt (cipher->ctx, outptr, inptr);
|
||||
grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize);
|
||||
grub_crypto_xor (iv, ivt, outptr, cipher->cipher->blocksize);
|
||||
grub_crypto_xor (outptr, outptr, iv, blocksize);
|
||||
grub_crypto_xor (iv, ivt, outptr, blocksize);
|
||||
}
|
||||
return GPG_ERR_NO_ERROR;
|
||||
}
|
||||
|
@ -135,20 +138,23 @@ grub_crypto_pcbc_encrypt (grub_crypto_cipher_handle_t cipher,
|
|||
{
|
||||
grub_uint8_t *inptr, *outptr, *end;
|
||||
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
|
||||
if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
|
||||
return GPG_ERR_INV_ARG;
|
||||
if (!cipher->cipher->decrypt)
|
||||
grub_size_t blocksize;
|
||||
if (!cipher->cipher->encrypt)
|
||||
return GPG_ERR_NOT_SUPPORTED;
|
||||
if (size % cipher->cipher->blocksize != 0)
|
||||
blocksize = cipher->cipher->blocksize;
|
||||
if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
|
||||
return GPG_ERR_INV_ARG;
|
||||
if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
|
||||
|| ((size & (blocksize - 1)) != 0))
|
||||
return GPG_ERR_INV_ARG;
|
||||
end = (grub_uint8_t *) in + size;
|
||||
for (inptr = in, outptr = out; inptr < end;
|
||||
inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize)
|
||||
inptr += blocksize, outptr += blocksize)
|
||||
{
|
||||
grub_memcpy (ivt, inptr, cipher->cipher->blocksize);
|
||||
grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize);
|
||||
grub_memcpy (ivt, inptr, blocksize);
|
||||
grub_crypto_xor (outptr, outptr, iv, blocksize);
|
||||
cipher->cipher->encrypt (cipher->ctx, outptr, inptr);
|
||||
grub_crypto_xor (iv, ivt, outptr, cipher->cipher->blocksize);
|
||||
grub_crypto_xor (iv, ivt, outptr, blocksize);
|
||||
}
|
||||
return GPG_ERR_NO_ERROR;
|
||||
}
|
||||
|
@ -372,11 +378,13 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
|
|||
break;
|
||||
case GRUB_CRYPTODISK_MODE_ECB:
|
||||
if (do_encrypt)
|
||||
grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i,
|
||||
(1U << dev->log_sector_size));
|
||||
err = grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i,
|
||||
(1U << dev->log_sector_size));
|
||||
else
|
||||
grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i,
|
||||
(1U << dev->log_sector_size));
|
||||
err = grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i,
|
||||
(1U << dev->log_sector_size));
|
||||
if (err)
|
||||
return err;
|
||||
break;
|
||||
default:
|
||||
return GPG_ERR_NOT_IMPLEMENTED;
|
||||
|
|
|
@ -71,10 +71,12 @@ is_lv_readable (struct grub_diskfilter_lv *lv, int easily)
|
|||
case GRUB_DISKFILTER_RAID6:
|
||||
if (!easily)
|
||||
need--;
|
||||
/* Fallthrough. */
|
||||
case GRUB_DISKFILTER_RAID4:
|
||||
case GRUB_DISKFILTER_RAID5:
|
||||
if (!easily)
|
||||
need--;
|
||||
/* Fallthrough. */
|
||||
case GRUB_DISKFILTER_STRIPED:
|
||||
break;
|
||||
|
||||
|
@ -483,6 +485,96 @@ grub_diskfilter_read_node (const struct grub_diskfilter_node *node,
|
|||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown node '%s'", node->name);
|
||||
}
|
||||
|
||||
|
||||
static grub_err_t
|
||||
validate_segment (struct grub_diskfilter_segment *seg);
|
||||
|
||||
static grub_err_t
|
||||
validate_lv (struct grub_diskfilter_lv *lv)
|
||||
{
|
||||
unsigned int i;
|
||||
if (!lv)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown volume");
|
||||
|
||||
if (!lv->vg || lv->vg->extent_size == 0)
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "invalid volume");
|
||||
|
||||
for (i = 0; i < lv->segment_count; i++)
|
||||
{
|
||||
grub_err_t err;
|
||||
err = validate_segment (&lv->segments[i]);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
static grub_err_t
|
||||
validate_node (const struct grub_diskfilter_node *node)
|
||||
{
|
||||
/* Check whether we actually know the physical volume we want to
|
||||
read from. */
|
||||
if (node->pv)
|
||||
return GRUB_ERR_NONE;
|
||||
if (node->lv)
|
||||
return validate_lv (node->lv);
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown node '%s'", node->name);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
validate_segment (struct grub_diskfilter_segment *seg)
|
||||
{
|
||||
grub_err_t err;
|
||||
|
||||
if (seg->stripe_size == 0 || seg->node_count == 0)
|
||||
return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
|
||||
|
||||
switch (seg->type)
|
||||
{
|
||||
case GRUB_DISKFILTER_RAID10:
|
||||
{
|
||||
grub_uint8_t near, far;
|
||||
near = seg->layout & 0xFF;
|
||||
far = (seg->layout >> 8) & 0xFF;
|
||||
if ((seg->layout >> 16) == 0 && far == 0)
|
||||
return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
|
||||
if (near > seg->node_count)
|
||||
return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
|
||||
break;
|
||||
}
|
||||
|
||||
case GRUB_DISKFILTER_STRIPED:
|
||||
case GRUB_DISKFILTER_MIRROR:
|
||||
break;
|
||||
|
||||
case GRUB_DISKFILTER_RAID4:
|
||||
case GRUB_DISKFILTER_RAID5:
|
||||
if (seg->node_count <= 1)
|
||||
return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
|
||||
break;
|
||||
|
||||
case GRUB_DISKFILTER_RAID6:
|
||||
if (seg->node_count <= 2)
|
||||
return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
|
||||
break;
|
||||
|
||||
default:
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"unsupported RAID level %d", seg->type);
|
||||
}
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < seg->node_count; i++)
|
||||
{
|
||||
err = validate_node (&seg->nodes[i]);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector,
|
||||
grub_size_t size, char *buf)
|
||||
|
@ -494,6 +586,7 @@ read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector,
|
|||
if (seg->node_count == 1)
|
||||
return grub_diskfilter_read_node (&seg->nodes[0],
|
||||
sector, size, buf);
|
||||
/* Fallthrough. */
|
||||
case GRUB_DISKFILTER_MIRROR:
|
||||
case GRUB_DISKFILTER_RAID10:
|
||||
{
|
||||
|
@ -848,6 +941,23 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
|
|||
|
||||
for (lv = vg->lvs; lv; lv = lv->next)
|
||||
{
|
||||
grub_err_t err;
|
||||
|
||||
/* RAID 1 and single-disk RAID 0 don't use a chunksize but code
|
||||
assumes one so set one. */
|
||||
for (i = 0; i < lv->segment_count; i++)
|
||||
{
|
||||
if (lv->segments[i].type == 1)
|
||||
lv->segments[i].stripe_size = 64;
|
||||
if (lv->segments[i].type == GRUB_DISKFILTER_STRIPED
|
||||
&& lv->segments[i].node_count == 1
|
||||
&& lv->segments[i].stripe_size == 0)
|
||||
lv->segments[i].stripe_size = 64;
|
||||
}
|
||||
|
||||
err = validate_lv(lv);
|
||||
if (err)
|
||||
return err;
|
||||
lv->number = lv_num++;
|
||||
|
||||
if (lv->fullname)
|
||||
|
@ -888,12 +998,6 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
|
|||
lv->fullname = tmp;
|
||||
}
|
||||
}
|
||||
/* RAID 1 doesn't use a chunksize but code assumes one so set
|
||||
one. */
|
||||
for (i = 0; i < lv->segment_count; i++)
|
||||
if (lv->segments[i].type == 1)
|
||||
lv->segments[i].stripe_size = 64;
|
||||
lv->vg = vg;
|
||||
}
|
||||
/* Add our new array to the list. */
|
||||
vg->next = array_list;
|
||||
|
@ -926,6 +1030,11 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
|
|||
n = layout & 0xFF;
|
||||
if (n == 1)
|
||||
n = (layout >> 8) & 0xFF;
|
||||
if (n == 0)
|
||||
{
|
||||
grub_free (uuid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
totsize = grub_divmod64 (nmemb * disk_size, n, 0);
|
||||
}
|
||||
|
@ -939,6 +1048,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
|
|||
break;
|
||||
|
||||
default:
|
||||
grub_free (uuid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -952,7 +1062,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
|
|||
array->lvs->segments->extent_count = totsize;
|
||||
}
|
||||
|
||||
if (array->lvs->segments
|
||||
if (array->lvs && array->lvs->segments
|
||||
&& array->lvs->segments->raid_member_size > disk_size)
|
||||
array->lvs->segments->raid_member_size = disk_size;
|
||||
|
||||
|
@ -961,7 +1071,10 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
|
|||
}
|
||||
array = grub_zalloc (sizeof (*array));
|
||||
if (!array)
|
||||
return NULL;
|
||||
{
|
||||
grub_free (uuid);
|
||||
return NULL;
|
||||
}
|
||||
array->uuid = uuid;
|
||||
array->uuid_len = uuidlen;
|
||||
if (name)
|
||||
|
@ -983,8 +1096,16 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
|
|||
goto fail;
|
||||
array->lvs->segment_count = 1;
|
||||
array->lvs->visible = 1;
|
||||
array->lvs->name = array->name;
|
||||
array->lvs->fullname = array->name;
|
||||
if (array->name)
|
||||
{
|
||||
array->lvs->name = grub_strdup (array->name);
|
||||
if (!array->lvs->name)
|
||||
goto fail;
|
||||
array->lvs->fullname = grub_strdup (array->name);
|
||||
if (!array->lvs->fullname)
|
||||
goto fail;
|
||||
}
|
||||
array->lvs->vg = array;
|
||||
|
||||
array->lvs->idname = grub_malloc (sizeof ("mduuid/") + 2 * uuidlen);
|
||||
if (!array->lvs->idname)
|
||||
|
@ -1034,13 +1155,26 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
|
|||
return array;
|
||||
|
||||
fail:
|
||||
grub_free (array->lvs);
|
||||
if (array->lvs)
|
||||
{
|
||||
grub_free (array->lvs->name);
|
||||
grub_free (array->lvs->fullname);
|
||||
grub_free (array->lvs->idname);
|
||||
if (array->lvs->segments)
|
||||
{
|
||||
grub_free (array->lvs->segments->nodes);
|
||||
grub_free (array->lvs->segments);
|
||||
}
|
||||
grub_free (array->lvs);
|
||||
}
|
||||
while (array->pvs)
|
||||
{
|
||||
pv = array->pvs->next;
|
||||
grub_free (array->pvs);
|
||||
array->pvs = pv;
|
||||
}
|
||||
grub_free (array->name);
|
||||
grub_free (array->uuid);
|
||||
grub_free (array);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1143,10 +1277,9 @@ free_array (void)
|
|||
{
|
||||
unsigned i;
|
||||
vg->lvs = lv->next;
|
||||
if (lv->name != lv->fullname)
|
||||
grub_free (lv->fullname);
|
||||
if (lv->name != vg->name)
|
||||
grub_free (lv->name);
|
||||
grub_free (lv->fullname);
|
||||
grub_free (lv->name);
|
||||
grub_free (lv->idname);
|
||||
for (i = 0; i < lv->segment_count; i++)
|
||||
grub_free (lv->segments[i].nodes);
|
||||
grub_free (lv->segments);
|
||||
|
|
|
@ -99,6 +99,8 @@ grub_dmraid_nv_detect (grub_disk_t disk,
|
|||
struct grub_nv_super sb;
|
||||
int level;
|
||||
grub_uint64_t disk_size;
|
||||
grub_uint32_t capacity;
|
||||
grub_uint8_t total_volumes;
|
||||
char *uuid;
|
||||
|
||||
if (disk->partition)
|
||||
|
@ -124,11 +126,17 @@ grub_dmraid_nv_detect (grub_disk_t disk,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
capacity = grub_le_to_cpu32 (sb.capacity);
|
||||
total_volumes = sb.array.total_volumes;
|
||||
|
||||
switch (sb.array.raid_level)
|
||||
{
|
||||
case NV_LEVEL_0:
|
||||
level = 0;
|
||||
disk_size = sb.capacity / sb.array.total_volumes;
|
||||
if (total_volumes == 0)
|
||||
/* Not RAID. */
|
||||
return NULL;
|
||||
disk_size = capacity / total_volumes;
|
||||
break;
|
||||
|
||||
case NV_LEVEL_1:
|
||||
|
@ -138,7 +146,10 @@ grub_dmraid_nv_detect (grub_disk_t disk,
|
|||
|
||||
case NV_LEVEL_5:
|
||||
level = 5;
|
||||
disk_size = sb.capacity / (sb.array.total_volumes - 1);
|
||||
if (total_volumes == 0 || total_volumes == 1)
|
||||
/* Not RAID. */
|
||||
return NULL;
|
||||
disk_size = capacity / (total_volumes - 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -803,7 +803,6 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
|||
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE
|
||||
|| GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))
|
||||
{
|
||||
int is_cdrom = 0;
|
||||
struct grub_efidisk_get_device_name_ctx ctx;
|
||||
char *dev_name;
|
||||
grub_efi_device_path_t *dup_dp;
|
||||
|
@ -824,9 +823,6 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
|||
|| GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)))
|
||||
break;
|
||||
|
||||
if (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE)
|
||||
is_cdrom = 1;
|
||||
|
||||
dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
|
||||
dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
|
||||
dup_ldp->length = sizeof (*dup_ldp);
|
||||
|
@ -861,10 +857,13 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
|||
|
||||
if (! ctx.partition_name)
|
||||
{
|
||||
/* No partition found. In most cases partition is embed in
|
||||
the root path anyway, so this is not critical.
|
||||
This happens only if partition is on partmap that GRUB
|
||||
doesn't need to access root.
|
||||
*/
|
||||
grub_disk_close (parent);
|
||||
if (is_cdrom)
|
||||
return grub_strdup (device_name);
|
||||
return 0;
|
||||
return grub_strdup (device_name);
|
||||
}
|
||||
|
||||
dev_name = grub_xasprintf ("%s,%s", parent->name,
|
||||
|
|
|
@ -212,7 +212,8 @@ grub_util_get_geli_uuid (const char *dev)
|
|||
|
||||
s = grub_util_get_fd_size (fd, dev, &log_secsize);
|
||||
s >>= log_secsize;
|
||||
grub_util_fd_seek (fd, (s << log_secsize) - 512);
|
||||
if (grub_util_fd_seek (fd, (s << log_secsize) - 512) < 0)
|
||||
grub_util_error ("%s", _("couldn't read ELI metadata"));
|
||||
|
||||
uuid = xmalloc (GRUB_MD_SHA256->mdlen * 2 + 1);
|
||||
if (grub_util_fd_read (fd, (void *) &hdr, 512) < 0)
|
||||
|
@ -225,13 +226,16 @@ grub_util_get_geli_uuid (const char *dev)
|
|||
|
||||
/* Look for GELI magic sequence. */
|
||||
if (grub_memcmp (header->magic, GELI_MAGIC, sizeof (GELI_MAGIC))
|
||||
|| grub_le_to_cpu32 (header->version) > 5
|
||||
|| grub_le_to_cpu32 (header->version) > 7
|
||||
|| grub_le_to_cpu32 (header->version) < 1)
|
||||
grub_util_error ("%s", _("wrong ELI magic or version"));
|
||||
|
||||
err = make_uuid ((void *) &hdr, uuid);
|
||||
if (err)
|
||||
return NULL;
|
||||
{
|
||||
grub_free (uuid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return uuid;
|
||||
}
|
||||
|
@ -265,7 +269,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|
|||
|
||||
/* Look for GELI magic sequence. */
|
||||
if (grub_memcmp (header.magic, GELI_MAGIC, sizeof (GELI_MAGIC))
|
||||
|| grub_le_to_cpu32 (header.version) > 5
|
||||
|| grub_le_to_cpu32 (header.version) > 7
|
||||
|| grub_le_to_cpu32 (header.version) < 1)
|
||||
{
|
||||
grub_dprintf ("geli", "wrong magic %02x\n", header.magic[0]);
|
||||
|
@ -332,19 +336,29 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|
|||
{
|
||||
secondary_cipher = grub_crypto_cipher_open (ciph);
|
||||
if (!secondary_cipher)
|
||||
return NULL;
|
||||
{
|
||||
grub_crypto_cipher_close (cipher);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (grub_le_to_cpu16 (header.keylen) > 1024)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid keysize %d",
|
||||
grub_le_to_cpu16 (header.keylen));
|
||||
grub_crypto_cipher_close (cipher);
|
||||
grub_crypto_cipher_close (secondary_cipher);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
newdev = grub_zalloc (sizeof (struct grub_cryptodisk));
|
||||
if (!newdev)
|
||||
return NULL;
|
||||
{
|
||||
grub_crypto_cipher_close (cipher);
|
||||
grub_crypto_cipher_close (secondary_cipher);
|
||||
return NULL;
|
||||
}
|
||||
newdev->cipher = cipher;
|
||||
newdev->secondary_cipher = secondary_cipher;
|
||||
newdev->offset = 0;
|
||||
|
@ -391,6 +405,7 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
|
|||
grub_uint8_t geomkey[GRUB_CRYPTO_MAX_MDLEN];
|
||||
grub_uint8_t verify_key[GRUB_CRYPTO_MAX_MDLEN];
|
||||
grub_uint8_t zero[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
|
||||
grub_uint8_t geli_cipher_key[64];
|
||||
char passphrase[MAX_PASSPHRASE] = "";
|
||||
unsigned i;
|
||||
gcry_err_code_t gcry_err;
|
||||
|
@ -514,6 +529,19 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
|
|||
continue;
|
||||
grub_printf_ (N_("Slot %d opened\n"), i);
|
||||
|
||||
if (grub_le_to_cpu32 (header.version) >= 7)
|
||||
{
|
||||
/* GELI >=7 uses the cipher_key */
|
||||
grub_memcpy (geli_cipher_key, candidate_key.cipher_key,
|
||||
sizeof (candidate_key.cipher_key));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* GELI <=6 uses the iv_key */
|
||||
grub_memcpy (geli_cipher_key, candidate_key.iv_key,
|
||||
sizeof (candidate_key.iv_key));
|
||||
}
|
||||
|
||||
/* Set the master key. */
|
||||
if (!dev->rekey)
|
||||
{
|
||||
|
@ -530,13 +558,13 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
|
|||
grub_size_t real_keysize = keysize;
|
||||
if (grub_le_to_cpu16 (header.alg) == 0x16)
|
||||
real_keysize *= 2;
|
||||
/* For a reason I don't know, the IV key is used in rekeying. */
|
||||
grub_memcpy (dev->rekey_key, candidate_key.iv_key,
|
||||
sizeof (candidate_key.iv_key));
|
||||
|
||||
grub_memcpy (dev->rekey_key, geli_cipher_key,
|
||||
sizeof (geli_cipher_key));
|
||||
dev->rekey_derived_size = real_keysize;
|
||||
dev->last_rekey = -1;
|
||||
COMPILE_TIME_ASSERT (sizeof (dev->rekey_key)
|
||||
>= sizeof (candidate_key.iv_key));
|
||||
>= sizeof (geli_cipher_key));
|
||||
}
|
||||
|
||||
dev->iv_prefix_len = sizeof (candidate_key.iv_key);
|
||||
|
|
|
@ -382,7 +382,8 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
/* Some buggy BIOSes doesn't return the total sectors
|
||||
correctly but returns zero. So if it is zero, compute
|
||||
it by C/H/S returned by the LBA BIOS call. */
|
||||
total_sectors = drp->cylinders * drp->heads * drp->sectors;
|
||||
total_sectors = ((grub_uint64_t) drp->cylinders)
|
||||
* drp->heads * drp->sectors;
|
||||
if (drp->bytes_per_sector
|
||||
&& !(drp->bytes_per_sector & (drp->bytes_per_sector - 1))
|
||||
&& drp->bytes_per_sector >= 512
|
||||
|
@ -419,8 +420,14 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
}
|
||||
}
|
||||
|
||||
if (data->sectors == 0)
|
||||
data->sectors = 63;
|
||||
if (data->heads == 0)
|
||||
data->heads = 255;
|
||||
|
||||
if (! total_sectors)
|
||||
total_sectors = data->cylinders * data->heads * data->sectors;
|
||||
total_sectors = ((grub_uint64_t) data->cylinders)
|
||||
* data->heads * data->sectors;
|
||||
}
|
||||
|
||||
disk->total_sectors = total_sectors;
|
||||
|
|
|
@ -113,6 +113,11 @@ grub_nand_open (const char *name, grub_disk_t disk)
|
|||
}
|
||||
|
||||
data->block_size = (args.size1 >> GRUB_DISK_SECTOR_BITS);
|
||||
if (!data->block_size)
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "invalid block size");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
|
||||
args.method = (grub_ieee1275_cell_t) "size";
|
||||
|
|
|
@ -34,7 +34,8 @@ struct ofdisk_hash_ent
|
|||
char *open_path;
|
||||
char *grub_devpath;
|
||||
int is_boot;
|
||||
int is_cdrom;
|
||||
int is_removable;
|
||||
int block_size_fails;
|
||||
/* Pointer to shortest available name on nodes representing canonical names,
|
||||
otherwise NULL. */
|
||||
const char *shortest;
|
||||
|
@ -42,6 +43,10 @@ struct ofdisk_hash_ent
|
|||
struct ofdisk_hash_ent *next;
|
||||
};
|
||||
|
||||
static grub_err_t
|
||||
grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size,
|
||||
struct ofdisk_hash_ent *op);
|
||||
|
||||
#define OFDISK_HASH_SZ 8
|
||||
static struct ofdisk_hash_ent *ofdisk_hash[OFDISK_HASH_SZ];
|
||||
|
||||
|
@ -123,7 +128,7 @@ ofdisk_hash_add_real (char *devpath)
|
|||
}
|
||||
|
||||
static int
|
||||
check_string_cdrom (const char *str)
|
||||
check_string_removable (const char *str)
|
||||
{
|
||||
const char *ptr = grub_strrchr (str, '/');
|
||||
|
||||
|
@ -131,7 +136,7 @@ check_string_cdrom (const char *str)
|
|||
ptr++;
|
||||
else
|
||||
ptr = str;
|
||||
return (grub_strncmp (ptr, "cdrom", 5) == 0);
|
||||
return (grub_strncmp (ptr, "cdrom", 5) == 0 || grub_strncmp (ptr, "fd", 2) == 0);
|
||||
}
|
||||
|
||||
static struct ofdisk_hash_ent *
|
||||
|
@ -147,8 +152,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
|
|||
{
|
||||
p->shortest = p->devpath;
|
||||
p->grub_shortest = p->grub_devpath;
|
||||
if (check_string_cdrom (devpath))
|
||||
p->is_cdrom = 1;
|
||||
if (check_string_removable (devpath))
|
||||
p->is_removable = 1;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -158,8 +163,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
|
|||
else
|
||||
grub_free (curcan);
|
||||
|
||||
if (check_string_cdrom (devpath) || check_string_cdrom (curcan))
|
||||
pcan->is_cdrom = 1;
|
||||
if (check_string_removable (devpath) || check_string_removable (curcan))
|
||||
pcan->is_removable = 1;
|
||||
|
||||
if (!pcan)
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
@ -330,7 +335,7 @@ 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_removable)
|
||||
continue;
|
||||
|
||||
if (hook (ent->grub_shortest, hook_data))
|
||||
|
@ -375,6 +380,8 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
|||
/* XXX: This should be large enough for any possible case. */
|
||||
char prop[64];
|
||||
grub_ssize_t actual;
|
||||
grub_uint32_t block_size = 0;
|
||||
grub_err_t err;
|
||||
|
||||
if (grub_strncmp (name, "ieee1275/", sizeof ("ieee1275/") - 1) != 0)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||
|
@ -405,14 +412,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
|||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a block device");
|
||||
}
|
||||
|
||||
grub_uint32_t block_size = 0;
|
||||
if (grub_ofdisk_get_block_size (devpath, &block_size) == 0)
|
||||
{
|
||||
for (disk->log_sector_size = 0;
|
||||
(1U << disk->log_sector_size) < block_size;
|
||||
disk->log_sector_size++);
|
||||
}
|
||||
|
||||
/* XXX: There is no property to read the number of blocks. There
|
||||
should be a property `#blocks', but it is not there. Perhaps it
|
||||
is possible to use seek for this. */
|
||||
|
@ -429,6 +428,18 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
|||
return grub_errno;
|
||||
disk->id = (unsigned long) op;
|
||||
disk->data = op->open_path;
|
||||
|
||||
err = grub_ofdisk_get_block_size (devpath, &block_size, op);
|
||||
if (err)
|
||||
return err;
|
||||
if (block_size != 0)
|
||||
{
|
||||
for (disk->log_sector_size = 0;
|
||||
(1U << disk->log_sector_size) < block_size;
|
||||
disk->log_sector_size++);
|
||||
}
|
||||
else
|
||||
disk->log_sector_size = 9;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -589,8 +600,9 @@ grub_ofdisk_init (void)
|
|||
grub_disk_dev_register (&grub_ofdisk_dev);
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size)
|
||||
static grub_err_t
|
||||
grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size,
|
||||
struct ofdisk_hash_ent *op)
|
||||
{
|
||||
struct size_args_ieee1275
|
||||
{
|
||||
|
@ -612,20 +624,34 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size)
|
|||
if (! last_ihandle)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
||||
|
||||
*block_size = 0;
|
||||
|
||||
if (op->block_size_fails >= 2)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2);
|
||||
args_ieee1275.method = (grub_ieee1275_cell_t) "block-size";
|
||||
args_ieee1275.ihandle = last_ihandle;
|
||||
args_ieee1275.result = 1;
|
||||
|
||||
*block_size = GRUB_DISK_SECTOR_SIZE;
|
||||
|
||||
if ((IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) || (args_ieee1275.result))
|
||||
grub_dprintf ("disk", "can't get block size\n");
|
||||
else
|
||||
if (args_ieee1275.size1
|
||||
&& !(args_ieee1275.size1 & (args_ieee1275.size1 - 1))
|
||||
&& args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384)
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1)
|
||||
{
|
||||
grub_dprintf ("disk", "can't get block size: failed call-method\n");
|
||||
op->block_size_fails++;
|
||||
}
|
||||
else if (args_ieee1275.result)
|
||||
{
|
||||
grub_dprintf ("disk", "can't get block size: %lld\n",
|
||||
(long long) args_ieee1275.result);
|
||||
op->block_size_fails++;
|
||||
}
|
||||
else if (args_ieee1275.size1
|
||||
&& !(args_ieee1275.size1 & (args_ieee1275.size1 - 1))
|
||||
&& args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384)
|
||||
{
|
||||
op->block_size_fails = 0;
|
||||
*block_size = args_ieee1275.size1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -143,6 +143,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|
|||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid keysize %d",
|
||||
grub_be_to_cpu32 (header.keyBytes));
|
||||
grub_crypto_cipher_close (cipher);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -181,9 +182,10 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|
|||
}
|
||||
if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES)
|
||||
{
|
||||
grub_crypto_cipher_close (cipher);
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported XTS block size: %d",
|
||||
cipher->cipher->blocksize);
|
||||
grub_crypto_cipher_close (cipher);
|
||||
grub_crypto_cipher_close (secondary_cipher);
|
||||
return NULL;
|
||||
}
|
||||
if (secondary_cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES)
|
||||
|
@ -191,6 +193,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|
|||
grub_crypto_cipher_close (cipher);
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported XTS block size: %d",
|
||||
secondary_cipher->cipher->blocksize);
|
||||
grub_crypto_cipher_close (secondary_cipher);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -200,9 +203,9 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|
|||
cipheriv = ciphermode + sizeof ("lrw-") - 1;
|
||||
if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES)
|
||||
{
|
||||
grub_crypto_cipher_close (cipher);
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported LRW block size: %d",
|
||||
cipher->cipher->blocksize);
|
||||
grub_crypto_cipher_close (cipher);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -225,6 +228,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|
|||
|| cipher->cipher->blocksize == 0)
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported benbi blocksize: %d",
|
||||
cipher->cipher->blocksize);
|
||||
/* FIXME should we return an error here? */
|
||||
for (benbi_log = 0;
|
||||
(cipher->cipher->blocksize << benbi_log) < GRUB_DISK_SECTOR_SIZE;
|
||||
benbi_log++);
|
||||
|
@ -243,6 +247,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|
|||
if (!essiv_hash)
|
||||
{
|
||||
grub_crypto_cipher_close (cipher);
|
||||
grub_crypto_cipher_close (secondary_cipher);
|
||||
grub_error (GRUB_ERR_FILE_NOT_FOUND,
|
||||
"Couldn't load %s hash", hash_str);
|
||||
return NULL;
|
||||
|
@ -251,12 +256,14 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|
|||
if (!essiv_cipher)
|
||||
{
|
||||
grub_crypto_cipher_close (cipher);
|
||||
grub_crypto_cipher_close (secondary_cipher);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_crypto_cipher_close (cipher);
|
||||
grub_crypto_cipher_close (secondary_cipher);
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown IV mode: %s",
|
||||
cipheriv);
|
||||
return NULL;
|
||||
|
@ -276,7 +283,12 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|
|||
|
||||
newdev = grub_zalloc (sizeof (struct grub_cryptodisk));
|
||||
if (!newdev)
|
||||
return NULL;
|
||||
{
|
||||
grub_crypto_cipher_close (cipher);
|
||||
grub_crypto_cipher_close (essiv_cipher);
|
||||
grub_crypto_cipher_close (secondary_cipher);
|
||||
return NULL;
|
||||
}
|
||||
newdev->cipher = cipher;
|
||||
newdev->offset = grub_be_to_cpu32 (header.payloadOffset);
|
||||
newdev->source_disk = NULL;
|
||||
|
@ -451,6 +463,7 @@ luks_recover_key (grub_disk_t source,
|
|||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_free (split_key);
|
||||
return GRUB_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
|
|
|
@ -426,7 +426,7 @@ grub_lvm_detect (grub_disk_t disk,
|
|||
#endif
|
||||
goto lvs_fail;
|
||||
}
|
||||
lv->segments = grub_malloc (sizeof (*seg) * lv->segment_count);
|
||||
lv->segments = grub_zalloc (sizeof (*seg) * lv->segment_count);
|
||||
seg = lv->segments;
|
||||
|
||||
for (i = 0; i < lv->segment_count; i++)
|
||||
|
@ -577,13 +577,17 @@ grub_lvm_detect (grub_disk_t disk,
|
|||
if (is_pvmove)
|
||||
seg->node_count = 1;
|
||||
}
|
||||
else if (grub_memcmp (p, "raid", sizeof ("raid") - 1)
|
||||
== 0 && (p[sizeof ("raid") - 1] >= '4'
|
||||
&& p[sizeof ("raid") - 1] <= '6')
|
||||
else if (grub_memcmp (p, "raid", sizeof ("raid") - 1) == 0
|
||||
&& ((p[sizeof ("raid") - 1] >= '4'
|
||||
&& p[sizeof ("raid") - 1] <= '6')
|
||||
|| p[sizeof ("raid") - 1] == '1')
|
||||
&& p[sizeof ("raidX") - 1] == '"')
|
||||
{
|
||||
switch (p[sizeof ("raid") - 1])
|
||||
{
|
||||
case '1':
|
||||
seg->type = GRUB_DISKFILTER_MIRROR;
|
||||
break;
|
||||
case '4':
|
||||
seg->type = GRUB_DISKFILTER_RAID4;
|
||||
seg->layout = GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC;
|
||||
|
@ -608,16 +612,18 @@ grub_lvm_detect (grub_disk_t disk,
|
|||
goto lvs_segment_fail;
|
||||
}
|
||||
|
||||
seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
|
||||
if (p == NULL)
|
||||
if (seg->type != GRUB_DISKFILTER_MIRROR)
|
||||
{
|
||||
seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
|
||||
if (p == NULL)
|
||||
{
|
||||
#ifdef GRUB_UTIL
|
||||
grub_util_info ("unknown stripe_size\n");
|
||||
grub_util_info ("unknown stripe_size\n");
|
||||
#endif
|
||||
goto lvs_segment_fail;
|
||||
goto lvs_segment_fail;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
seg->nodes = grub_zalloc (sizeof (seg->nodes[0])
|
||||
* seg->node_count);
|
||||
|
||||
|
@ -625,7 +631,7 @@ grub_lvm_detect (grub_disk_t disk,
|
|||
if (p == NULL)
|
||||
{
|
||||
#ifdef GRUB_UTIL
|
||||
grub_util_info ("unknown mirrors\n");
|
||||
grub_util_info ("unknown raids\n");
|
||||
#endif
|
||||
goto lvs_segment_fail2;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,16 @@ grub_raid6_init_table (void)
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned
|
||||
mod_255 (unsigned x)
|
||||
{
|
||||
while (x > 0xff)
|
||||
x = (x >> 8) + (x & 0xff);
|
||||
if (x == 0xff)
|
||||
return 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p,
|
||||
char *buf, grub_disk_addr_t sector, grub_size_t size)
|
||||
|
@ -162,11 +172,11 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p,
|
|||
|
||||
grub_crypto_xor (qbuf, qbuf, buf, size);
|
||||
|
||||
c = ((255 ^ bad1)
|
||||
+ (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)])) % 255;
|
||||
c = mod_255((255 ^ bad1)
|
||||
+ (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)]));
|
||||
grub_raid_block_mulx (c, qbuf, size);
|
||||
|
||||
c = ((unsigned) bad2 + c) % 255;
|
||||
c = mod_255((unsigned) bad2 + c);
|
||||
grub_raid_block_mulx (c, pbuf, size);
|
||||
|
||||
grub_crypto_xor (pbuf, pbuf, qbuf, size);
|
||||
|
|
|
@ -40,6 +40,7 @@ struct virtdisk
|
|||
grub_xen_evtchn_t evtchn;
|
||||
void *dma_page;
|
||||
grub_xen_grant_t dma_grant;
|
||||
struct virtdisk *compat_next;
|
||||
};
|
||||
|
||||
#define xen_wmb() mb()
|
||||
|
@ -47,6 +48,7 @@ struct virtdisk
|
|||
|
||||
static struct virtdisk *virtdisks;
|
||||
static grub_size_t vdiskcnt;
|
||||
struct virtdisk *compat_head;
|
||||
|
||||
static int
|
||||
grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
||||
|
@ -66,20 +68,32 @@ grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
|||
static grub_err_t
|
||||
grub_virtdisk_open (const char *name, grub_disk_t disk)
|
||||
{
|
||||
grub_size_t i;
|
||||
int i;
|
||||
grub_uint32_t secsize;
|
||||
char fdir[200];
|
||||
char *buf;
|
||||
int num = -1;
|
||||
struct virtdisk *vd;
|
||||
|
||||
for (i = 0; i < vdiskcnt; i++)
|
||||
if (grub_strcmp (name, virtdisks[i].fullname) == 0)
|
||||
/* For compatibility with pv-grub legacy menu.lst accept hdX as disk name */
|
||||
if (name[0] == 'h' && name[1] == 'd' && name[2])
|
||||
{
|
||||
num = grub_strtoul (name + 2, 0, 10);
|
||||
if (grub_errno)
|
||||
{
|
||||
grub_errno = 0;
|
||||
num = -1;
|
||||
}
|
||||
}
|
||||
for (i = 0, vd = compat_head; vd; vd = vd->compat_next, i++)
|
||||
if (i == num || grub_strcmp (name, vd->fullname) == 0)
|
||||
break;
|
||||
if (i == vdiskcnt)
|
||||
if (!vd)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a virtdisk");
|
||||
disk->data = &virtdisks[i];
|
||||
disk->id = i;
|
||||
disk->data = vd;
|
||||
disk->id = vd - virtdisks;
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/sectors", virtdisks[i].backend_dir);
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/sectors", vd->backend_dir);
|
||||
buf = grub_xenstore_get_file (fdir, NULL);
|
||||
if (!buf)
|
||||
return grub_errno;
|
||||
|
@ -87,8 +101,7 @@ grub_virtdisk_open (const char *name, grub_disk_t disk)
|
|||
if (grub_errno)
|
||||
return grub_errno;
|
||||
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/sector-size",
|
||||
virtdisks[i].backend_dir);
|
||||
grub_snprintf (fdir, sizeof (fdir), "%s/sector-size", vd->backend_dir);
|
||||
buf = grub_xenstore_get_file (fdir, NULL);
|
||||
if (!buf)
|
||||
return grub_errno;
|
||||
|
@ -264,6 +277,7 @@ fill (const char *dir, void *data)
|
|||
grub_err_t err;
|
||||
void *buf;
|
||||
struct evtchn_alloc_unbound alloc_unbound;
|
||||
struct virtdisk **prev = &compat_head, *vd = compat_head;
|
||||
|
||||
/* Shouldn't happen unles some hotplug happened. */
|
||||
if (vdiskcnt >= *ctr)
|
||||
|
@ -374,6 +388,19 @@ fill (const char *dir, void *data)
|
|||
|
||||
virtdisks[vdiskcnt].frontend_dir = grub_strdup (fdir);
|
||||
|
||||
/* For compatibility with pv-grub maintain linked list sorted by handle
|
||||
value in increasing order. This allows mapping of (hdX) disk names
|
||||
from legacy menu.lst */
|
||||
while (vd)
|
||||
{
|
||||
if (vd->handle > virtdisks[vdiskcnt].handle)
|
||||
break;
|
||||
prev = &vd->compat_next;
|
||||
vd = vd->compat_next;
|
||||
}
|
||||
virtdisks[vdiskcnt].compat_next = vd;
|
||||
*prev = &virtdisks[vdiskcnt];
|
||||
|
||||
vdiskcnt++;
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -777,6 +777,7 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
|
|||
if (grub_file_read (font->file, glyph->bitmap, len) != len)
|
||||
{
|
||||
remove_font (font);
|
||||
grub_free (glyph);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1285,7 +1286,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
|
|||
- grub_font_get_xheight (combining_glyphs[i]->font) - 1;
|
||||
if (space <= 0)
|
||||
space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8;
|
||||
|
||||
/* Fallthrough. */
|
||||
case GRUB_UNICODE_STACK_ATTACHED_ABOVE:
|
||||
do_blit (combining_glyphs[i], targetx,
|
||||
-(ctx.bounds.height + ctx.bounds.y + space
|
||||
|
@ -1326,6 +1327,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
|
|||
+ combining_glyphs[i]->height);
|
||||
if (space <= 0)
|
||||
space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8;
|
||||
/* Fallthrough. */
|
||||
|
||||
case GRUB_UNICODE_STACK_ATTACHED_BELOW:
|
||||
do_blit (combining_glyphs[i], targetx, -(ctx.bounds.y - space),
|
||||
|
|
|
@ -680,6 +680,8 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
|
|||
grub_uint64_t stripen;
|
||||
grub_uint64_t stripe_offset;
|
||||
grub_uint64_t off = addr - grub_le_to_cpu64 (key->offset);
|
||||
grub_uint64_t chunk_stripe_length;
|
||||
grub_uint16_t nstripes;
|
||||
unsigned redundancy = 1;
|
||||
unsigned i, j;
|
||||
|
||||
|
@ -690,15 +692,17 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
|
|||
"couldn't find the chunk descriptor");
|
||||
}
|
||||
|
||||
nstripes = grub_le_to_cpu16 (chunk->nstripes) ? : 1;
|
||||
chunk_stripe_length = grub_le_to_cpu64 (chunk->stripe_length) ? : 512;
|
||||
grub_dprintf ("btrfs", "chunk 0x%" PRIxGRUB_UINT64_T
|
||||
"+0x%" PRIxGRUB_UINT64_T
|
||||
" (%d stripes (%d substripes) of %"
|
||||
PRIxGRUB_UINT64_T ")\n",
|
||||
grub_le_to_cpu64 (key->offset),
|
||||
grub_le_to_cpu64 (chunk->size),
|
||||
grub_le_to_cpu16 (chunk->nstripes),
|
||||
nstripes,
|
||||
grub_le_to_cpu16 (chunk->nsubstripes),
|
||||
grub_le_to_cpu64 (chunk->stripe_length));
|
||||
chunk_stripe_length);
|
||||
|
||||
switch (grub_le_to_cpu64 (chunk->type)
|
||||
& ~GRUB_BTRFS_CHUNK_TYPE_BITS_DONTCARE)
|
||||
|
@ -708,8 +712,10 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
|
|||
grub_uint64_t stripe_length;
|
||||
grub_dprintf ("btrfs", "single\n");
|
||||
stripe_length = grub_divmod64 (grub_le_to_cpu64 (chunk->size),
|
||||
grub_le_to_cpu16 (chunk->nstripes),
|
||||
nstripes,
|
||||
NULL);
|
||||
if (stripe_length == 0)
|
||||
stripe_length = 512;
|
||||
stripen = grub_divmod64 (off, stripe_length, &stripe_offset);
|
||||
csize = (stripen + 1) * stripe_length - off;
|
||||
break;
|
||||
|
@ -730,33 +736,34 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
|
|||
grub_uint64_t low;
|
||||
grub_dprintf ("btrfs", "RAID0\n");
|
||||
middle = grub_divmod64 (off,
|
||||
grub_le_to_cpu64 (chunk->stripe_length),
|
||||
chunk_stripe_length,
|
||||
&low);
|
||||
|
||||
high = grub_divmod64 (middle, grub_le_to_cpu16 (chunk->nstripes),
|
||||
high = grub_divmod64 (middle, nstripes,
|
||||
&stripen);
|
||||
stripe_offset =
|
||||
low + grub_le_to_cpu64 (chunk->stripe_length) * high;
|
||||
csize = grub_le_to_cpu64 (chunk->stripe_length) - low;
|
||||
low + chunk_stripe_length * high;
|
||||
csize = chunk_stripe_length - low;
|
||||
break;
|
||||
}
|
||||
case GRUB_BTRFS_CHUNK_TYPE_RAID10:
|
||||
{
|
||||
grub_uint64_t middle, high;
|
||||
grub_uint64_t low;
|
||||
grub_uint16_t nsubstripes;
|
||||
nsubstripes = grub_le_to_cpu16 (chunk->nsubstripes) ? : 1;
|
||||
middle = grub_divmod64 (off,
|
||||
grub_le_to_cpu64 (chunk->stripe_length),
|
||||
chunk_stripe_length,
|
||||
&low);
|
||||
|
||||
high = grub_divmod64 (middle,
|
||||
grub_le_to_cpu16 (chunk->nstripes)
|
||||
/ grub_le_to_cpu16 (chunk->nsubstripes),
|
||||
nstripes / nsubstripes ? : 1,
|
||||
&stripen);
|
||||
stripen *= grub_le_to_cpu16 (chunk->nsubstripes);
|
||||
redundancy = grub_le_to_cpu16 (chunk->nsubstripes);
|
||||
stripe_offset = low + grub_le_to_cpu64 (chunk->stripe_length)
|
||||
stripen *= nsubstripes;
|
||||
redundancy = nsubstripes;
|
||||
stripe_offset = low + chunk_stripe_length
|
||||
* high;
|
||||
csize = grub_le_to_cpu64 (chunk->stripe_length) - low;
|
||||
csize = chunk_stripe_length - low;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -74,8 +74,7 @@ grub_cbfs_find_file (struct grub_archelp_data *data, char **name,
|
|||
(void) mtime;
|
||||
offset = grub_be_to_cpu32 (hd.offset);
|
||||
|
||||
if (mode)
|
||||
*mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME;
|
||||
*mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME;
|
||||
|
||||
namesize = offset;
|
||||
if (namesize >= sizeof (hd))
|
||||
|
@ -144,7 +143,7 @@ static struct grub_archelp_data *
|
|||
grub_cbfs_mount (grub_disk_t disk)
|
||||
{
|
||||
struct cbfs_file hd;
|
||||
struct grub_archelp_data *data;
|
||||
struct grub_archelp_data *data = NULL;
|
||||
grub_uint32_t ptr;
|
||||
grub_off_t header_off;
|
||||
struct cbfs_header head;
|
||||
|
@ -196,6 +195,7 @@ grub_cbfs_mount (grub_disk_t disk)
|
|||
return data;
|
||||
|
||||
fail:
|
||||
grub_free (data);
|
||||
grub_error (GRUB_ERR_BAD_FS, "not a cbfs filesystem");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -61,8 +61,15 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name,
|
|||
modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode));
|
||||
namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize));
|
||||
|
||||
if (mode)
|
||||
*mode = modeval;
|
||||
/* Don't allow negative numbers. */
|
||||
if (namesize >= 0x80000000)
|
||||
{
|
||||
/* Probably a corruption, don't attempt to recover. */
|
||||
*mode = GRUB_ARCHELP_ATTR_END;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
*mode = modeval;
|
||||
|
||||
*name = grub_malloc (namesize + 1);
|
||||
if (*name == NULL)
|
||||
|
|
|
@ -100,6 +100,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
|||
#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
|
||||
#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* Extents used */
|
||||
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
|
||||
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
|
||||
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
|
||||
|
||||
/* The set of back-incompatible features this driver DOES support. Add (OR)
|
||||
|
@ -107,6 +108,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
|||
#define EXT2_DRIVER_SUPPORTED_INCOMPAT ( EXT2_FEATURE_INCOMPAT_FILETYPE \
|
||||
| EXT4_FEATURE_INCOMPAT_EXTENTS \
|
||||
| EXT4_FEATURE_INCOMPAT_FLEX_BG \
|
||||
| EXT2_FEATURE_INCOMPAT_META_BG \
|
||||
| EXT4_FEATURE_INCOMPAT_64BIT)
|
||||
/* List of rationales for the ignored "incompatible" features:
|
||||
* needs_recovery: Not really back-incompatible - was added as such to forbid
|
||||
|
@ -114,8 +116,13 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
|||
* journal because they will ignore the journal, but the next
|
||||
* ext3 driver to mount the volume will find the journal and
|
||||
* replay it, potentially corrupting the metadata written by
|
||||
* the ext2 drivers. Safe to ignore for this RO driver. */
|
||||
#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER )
|
||||
* the ext2 drivers. Safe to ignore for this RO driver.
|
||||
* mmp: Not really back-incompatible - was added as such to
|
||||
* avoid multiple read-write mounts. Safe to ignore for this
|
||||
* RO driver.
|
||||
*/
|
||||
#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \
|
||||
| EXT4_FEATURE_INCOMPAT_MMP)
|
||||
|
||||
|
||||
#define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U
|
||||
|
@ -331,16 +338,68 @@ static grub_dl_t my_mod;
|
|||
|
||||
|
||||
|
||||
/* Check is a = b^x for some x. */
|
||||
static inline int
|
||||
is_power_of (grub_uint64_t a, grub_uint32_t b)
|
||||
{
|
||||
grub_uint64_t c;
|
||||
/* Prevent overflow assuming b < 8. */
|
||||
if (a >= (1LL << 60))
|
||||
return 0;
|
||||
for (c = 1; c <= a; c *= b);
|
||||
return (c == a);
|
||||
}
|
||||
|
||||
|
||||
static inline int
|
||||
group_has_super_block (struct grub_ext2_data *data, grub_uint64_t group)
|
||||
{
|
||||
if (!(data->sblock.feature_ro_compat
|
||||
& grub_cpu_to_le32_compile_time(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)))
|
||||
return 1;
|
||||
/* Algorithm looked up in Linux source. */
|
||||
if (group <= 1)
|
||||
return 1;
|
||||
/* Even number is never a power of odd number. */
|
||||
if (!(group & 1))
|
||||
return 0;
|
||||
return (is_power_of(group, 7) || is_power_of(group, 5) ||
|
||||
is_power_of(group, 3));
|
||||
}
|
||||
|
||||
/* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of
|
||||
the mounted filesystem DATA. */
|
||||
inline static grub_err_t
|
||||
grub_ext2_blockgroup (struct grub_ext2_data *data, int group,
|
||||
grub_ext2_blockgroup (struct grub_ext2_data *data, grub_uint64_t group,
|
||||
struct grub_ext2_block_group *blkgrp)
|
||||
{
|
||||
grub_uint64_t full_offset = (group << data->log_group_desc_size);
|
||||
grub_uint64_t block, offset;
|
||||
block = (full_offset >> LOG2_BLOCK_SIZE (data));
|
||||
offset = (full_offset & ((1 << LOG2_BLOCK_SIZE (data)) - 1));
|
||||
if ((data->sblock.feature_incompat
|
||||
& grub_cpu_to_le32_compile_time (EXT2_FEATURE_INCOMPAT_META_BG))
|
||||
&& block >= grub_le_to_cpu32(data->sblock.first_meta_bg))
|
||||
{
|
||||
grub_uint64_t first_block_group;
|
||||
/* Find the first block group for which a descriptor
|
||||
is stored in given block. */
|
||||
first_block_group = (block << (LOG2_BLOCK_SIZE (data)
|
||||
- data->log_group_desc_size));
|
||||
|
||||
block = (first_block_group
|
||||
* grub_le_to_cpu32(data->sblock.blocks_per_group));
|
||||
|
||||
if (group_has_super_block (data, first_block_group))
|
||||
block++;
|
||||
}
|
||||
else
|
||||
/* Superblock. */
|
||||
block++;
|
||||
return grub_disk_read (data->disk,
|
||||
((grub_le_to_cpu32 (data->sblock.first_data_block) + 1)
|
||||
<< LOG2_EXT2_BLOCK_SIZE (data)),
|
||||
group << data->log_group_desc_size,
|
||||
((grub_le_to_cpu32 (data->sblock.first_data_block)
|
||||
+ block)
|
||||
<< LOG2_EXT2_BLOCK_SIZE (data)), offset,
|
||||
sizeof (struct grub_ext2_block_group), blkgrp);
|
||||
}
|
||||
|
||||
|
@ -484,6 +543,10 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
|||
|
||||
indirect:
|
||||
do {
|
||||
/* If the indirect block is zero, all child blocks are absent
|
||||
(i.e. filled with zeros.) */
|
||||
if (indir == 0)
|
||||
return 0;
|
||||
if (grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t) grub_le_to_cpu32 (indir))
|
||||
<< log2_blksz,
|
||||
|
@ -573,7 +636,12 @@ grub_ext2_mount (grub_disk_t disk)
|
|||
|
||||
/* Make sure this is an ext2 filesystem. */
|
||||
if (data->sblock.magic != grub_cpu_to_le16_compile_time (EXT2_MAGIC)
|
||||
|| grub_le_to_cpu32 (data->sblock.log2_block_size) >= 16)
|
||||
|| grub_le_to_cpu32 (data->sblock.log2_block_size) >= 16
|
||||
|| data->sblock.inodes_per_group == 0
|
||||
/* 20 already means 1GiB blocks. We don't want to deal with blocks overflowing int32. */
|
||||
|| grub_le_to_cpu32 (data->sblock.log2_block_size) > 20
|
||||
|| EXT2_INODE_SIZE (data) == 0
|
||||
|| EXT2_BLOCK_SIZE (data) / EXT2_INODE_SIZE (data) == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "not an ext2 filesystem");
|
||||
goto fail;
|
||||
|
|
|
@ -1136,7 +1136,7 @@ grub_fat_label (grub_device_t device, char **label)
|
|||
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
|
||||
return 0;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
err = grub_fat_iterate_init (&ctxt);
|
||||
|
|
|
@ -252,6 +252,13 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
|
|||
grub_disk_addr_t i, blockcnt;
|
||||
int blocksize = 1 << (log2blocksize + GRUB_DISK_SECTOR_BITS);
|
||||
|
||||
if (pos > filesize)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
N_("attempt to read past the end of file"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Adjust LEN so it we can't read past the end of the file. */
|
||||
if (pos + len > filesize)
|
||||
len = filesize - pos;
|
||||
|
|
|
@ -330,6 +330,7 @@ grub_hfs_mount (grub_disk_t disk)
|
|||
|
||||
/* Check if this is a HFS filesystem. */
|
||||
if (grub_be_to_cpu16 (data->sblock.magic) != GRUB_HFS_MAGIC
|
||||
|| data->sblock.blksz == 0
|
||||
|| (data->sblock.blksz & grub_cpu_to_be32_compile_time (0xc00001ff)))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "not an HFS filesystem");
|
||||
|
@ -367,6 +368,11 @@ grub_hfs_mount (grub_disk_t disk)
|
|||
data->cat_root = grub_be_to_cpu32 (treehead.head.root_node);
|
||||
data->cat_size = grub_be_to_cpu16 (treehead.head.node_size);
|
||||
|
||||
if (data->cat_size == 0
|
||||
|| data->blksz < data->cat_size
|
||||
|| data->blksz < data->ext_size)
|
||||
goto fail;
|
||||
|
||||
/* Lookup the root directory node in the catalog tree using the
|
||||
volume name. */
|
||||
key.parent_dir = grub_cpu_to_be32_compile_time (1);
|
||||
|
@ -686,6 +692,7 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
|
|||
int i;
|
||||
struct grub_hfs_extent *dat;
|
||||
int blk;
|
||||
grub_uint16_t reccnt;
|
||||
|
||||
dat = (struct grub_hfs_extent *) (type == 0
|
||||
? (&data->sblock.catalog_recs)
|
||||
|
@ -704,8 +711,12 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
reccnt = grub_be_to_cpu16 (node->node.reccnt);
|
||||
if (reccnt > (nodesize >> 1))
|
||||
reccnt = (nodesize >> 1);
|
||||
|
||||
/* Iterate over all records in this node. */
|
||||
for (i = 0; i < grub_be_to_cpu16 (node->node.reccnt); i++)
|
||||
for (i = 0; i < reccnt; i++)
|
||||
{
|
||||
int pos = (nodesize >> 1) - 1 - i;
|
||||
struct pointer
|
||||
|
@ -713,16 +724,19 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
|
|||
grub_uint8_t keylen;
|
||||
grub_uint8_t key;
|
||||
} GRUB_PACKED *pnt;
|
||||
pnt = (struct pointer *) (grub_be_to_cpu16 (node->offsets[pos])
|
||||
+ node->rawnode);
|
||||
grub_uint16_t off = grub_be_to_cpu16 (node->offsets[pos]);
|
||||
if (off > nodesize - sizeof(*pnt))
|
||||
continue;
|
||||
pnt = (struct pointer *) (off + node->rawnode);
|
||||
if (nodesize < (grub_size_t) off + pnt->keylen + 1)
|
||||
continue;
|
||||
|
||||
struct grub_hfs_record rec =
|
||||
{
|
||||
&pnt->key,
|
||||
pnt->keylen,
|
||||
&pnt->key + pnt->keylen +(pnt->keylen + 1) % 2,
|
||||
nodesize - grub_be_to_cpu16 (node->offsets[pos])
|
||||
- pnt->keylen - 1
|
||||
nodesize - off - pnt->keylen - 1
|
||||
};
|
||||
|
||||
if (node_hook (&node->node, &rec, hook_arg))
|
||||
|
@ -1300,6 +1314,12 @@ grub_hfs_open (struct grub_file *file, const char *name)
|
|||
|
||||
data = grub_hfs_mount (file->device->disk);
|
||||
|
||||
if (!data)
|
||||
{
|
||||
grub_dl_unref (my_mod);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
if (grub_hfs_find_dir (data, name, &frec, 0))
|
||||
{
|
||||
grub_free (data);
|
||||
|
|
|
@ -336,6 +336,9 @@ grub_hfsplus_mount (grub_disk_t disk)
|
|||
data->case_sensitive = ((magic == GRUB_HFSPLUSX_MAGIC) &&
|
||||
(header.key_compare == GRUB_HFSPLUSX_BINARYCOMPARE));
|
||||
|
||||
if (data->catalog_tree.nodesize < 2)
|
||||
goto fail;
|
||||
|
||||
if (grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, 0,
|
||||
sizeof (struct grub_hfsplus_btnode),
|
||||
sizeof (header), (char *) &header) <= 0)
|
||||
|
@ -350,6 +353,9 @@ grub_hfsplus_mount (grub_disk_t disk)
|
|||
data->extoverflow_tree.root = grub_be_to_cpu32 (header.root);
|
||||
data->extoverflow_tree.nodesize = grub_be_to_cpu16 (header.nodesize);
|
||||
|
||||
if (data->extoverflow_tree.nodesize < 2)
|
||||
goto fail;
|
||||
|
||||
if (grub_hfsplus_read_file (&data->attr_tree.file, 0, 0,
|
||||
sizeof (struct grub_hfsplus_btnode),
|
||||
sizeof (header), (char *) &header) <= 0)
|
||||
|
@ -723,7 +729,10 @@ list_nodes (void *record, void *hook_arg)
|
|||
|
||||
/* If the name is obviously invalid, skip this node. */
|
||||
if (catkey->name[i] == 0)
|
||||
return 0;
|
||||
{
|
||||
grub_free (filename);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
*grub_utf16_to_utf8 ((grub_uint8_t *) filename, catkey->name,
|
||||
|
@ -745,7 +754,10 @@ list_nodes (void *record, void *hook_arg)
|
|||
callback function. */
|
||||
node = grub_malloc (sizeof (*node));
|
||||
if (!node)
|
||||
return 1;
|
||||
{
|
||||
grub_free (filename);
|
||||
return 1;
|
||||
}
|
||||
node->data = ctx->dir->data;
|
||||
node->compressed = 0;
|
||||
node->cbuf = 0;
|
||||
|
@ -780,8 +792,8 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
|
|||
};
|
||||
|
||||
struct grub_hfsplus_key_internal intern;
|
||||
struct grub_hfsplus_btnode *node;
|
||||
grub_disk_addr_t ptr;
|
||||
struct grub_hfsplus_btnode *node = NULL;
|
||||
grub_disk_addr_t ptr = 0;
|
||||
|
||||
{
|
||||
struct grub_fshelp_node *fsnode;
|
||||
|
@ -964,8 +976,8 @@ grub_hfsplus_label (grub_device_t device, char **label)
|
|||
struct grub_hfsplus_catkey *catkey;
|
||||
int i, label_len;
|
||||
struct grub_hfsplus_key_internal intern;
|
||||
struct grub_hfsplus_btnode *node;
|
||||
grub_disk_addr_t ptr;
|
||||
struct grub_hfsplus_btnode *node = NULL;
|
||||
grub_disk_addr_t ptr = 0;
|
||||
|
||||
*label = 0;
|
||||
|
||||
|
|
|
@ -959,14 +959,15 @@ grub_iso9660_read (grub_file_t file, char *buf, grub_size_t len)
|
|||
{
|
||||
struct grub_iso9660_data *data =
|
||||
(struct grub_iso9660_data *) file->data;
|
||||
grub_err_t err;
|
||||
|
||||
/* XXX: The file is stored in as a single extent. */
|
||||
data->disk->read_hook = file->read_hook;
|
||||
data->disk->read_hook_data = file->read_hook_data;
|
||||
read_node (data->node, file->offset, len, buf);
|
||||
err = read_node (data->node, file->offset, len, buf);
|
||||
data->disk->read_hook = NULL;
|
||||
|
||||
if (grub_errno)
|
||||
if (err || grub_errno)
|
||||
return -1;
|
||||
|
||||
return len;
|
||||
|
|
|
@ -65,7 +65,6 @@ typedef grub_uint16_t grub_minix_uintn_t;
|
|||
#define grub_minix_to_cpu_n grub_minix_to_cpu16
|
||||
#endif
|
||||
|
||||
#define GRUB_MINIX_INODE_BLKSZ(data) sizeof (grub_minix_uintn_t)
|
||||
#ifdef MODE_MINIX3
|
||||
typedef grub_uint32_t grub_minix_ino_t;
|
||||
#define grub_minix_to_cpu_ino grub_minix_to_cpu32
|
||||
|
@ -83,19 +82,6 @@ typedef grub_uint16_t grub_minix_ino_t;
|
|||
#define GRUB_MINIX_INODE_DINDIR_ZONE(data) (grub_minix_to_cpu_n \
|
||||
(data->inode.double_indir_zone))
|
||||
|
||||
#ifndef MODE_MINIX3
|
||||
#define GRUB_MINIX_LOG2_ZONESZ (GRUB_MINIX_LOG2_BSIZE \
|
||||
+ grub_minix_to_cpu16 (data->sblock.log2_zone_size))
|
||||
#endif
|
||||
#define GRUB_MINIX_ZONESZ ((grub_uint64_t) data->block_size << \
|
||||
(GRUB_DISK_SECTOR_BITS + grub_minix_to_cpu16 (data->sblock.log2_zone_size)))
|
||||
|
||||
#ifdef MODE_MINIX3
|
||||
#define GRUB_MINIX_ZONE2SECT(zone) ((zone) * data->block_size)
|
||||
#else
|
||||
#define GRUB_MINIX_ZONE2SECT(zone) ((zone) << GRUB_MINIX_LOG2_ZONESZ)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MODE_MINIX3
|
||||
struct grub_minix_sblock
|
||||
|
@ -172,6 +158,7 @@ struct grub_minix_data
|
|||
{
|
||||
struct grub_minix_sblock sblock;
|
||||
struct grub_minix_inode inode;
|
||||
grub_uint32_t block_per_zone;
|
||||
grub_minix_ino_t ino;
|
||||
int linknest;
|
||||
grub_disk_t disk;
|
||||
|
@ -184,6 +171,23 @@ static grub_dl_t my_mod;
|
|||
static grub_err_t grub_minix_find_file (struct grub_minix_data *data,
|
||||
const char *path);
|
||||
|
||||
#ifdef MODE_MINIX3
|
||||
static inline grub_disk_addr_t
|
||||
grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone)
|
||||
{
|
||||
return ((grub_disk_addr_t) zone) * data->block_size;
|
||||
}
|
||||
#else
|
||||
static inline grub_disk_addr_t
|
||||
grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone)
|
||||
{
|
||||
int log2_zonesz = (GRUB_MINIX_LOG2_BSIZE
|
||||
+ grub_minix_to_cpu16 (data->sblock.log2_zone_size));
|
||||
return (((grub_disk_addr_t) zone) << log2_zonesz);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Read the block pointer in ZONE, on the offset NUM. */
|
||||
static grub_minix_uintn_t
|
||||
grub_get_indir (struct grub_minix_data *data,
|
||||
|
@ -192,7 +196,7 @@ grub_get_indir (struct grub_minix_data *data,
|
|||
{
|
||||
grub_minix_uintn_t indirn;
|
||||
grub_disk_read (data->disk,
|
||||
GRUB_MINIX_ZONE2SECT(zone),
|
||||
grub_minix_zone2sect(data, zone),
|
||||
sizeof (grub_minix_uintn_t) * num,
|
||||
sizeof (grub_minix_uintn_t), (char *) &indirn);
|
||||
return grub_minix_to_cpu_n (indirn);
|
||||
|
@ -202,8 +206,6 @@ static grub_minix_uintn_t
|
|||
grub_minix_get_file_block (struct grub_minix_data *data, unsigned int blk)
|
||||
{
|
||||
grub_minix_uintn_t indir;
|
||||
const grub_uint32_t block_per_zone = (GRUB_MINIX_ZONESZ
|
||||
/ GRUB_MINIX_INODE_BLKSZ (data));
|
||||
|
||||
/* Direct block. */
|
||||
if (blk < GRUB_MINIX_INODE_DIR_BLOCKS)
|
||||
|
@ -211,33 +213,33 @@ grub_minix_get_file_block (struct grub_minix_data *data, unsigned int blk)
|
|||
|
||||
/* Indirect block. */
|
||||
blk -= GRUB_MINIX_INODE_DIR_BLOCKS;
|
||||
if (blk < block_per_zone)
|
||||
if (blk < data->block_per_zone)
|
||||
{
|
||||
indir = grub_get_indir (data, GRUB_MINIX_INODE_INDIR_ZONE (data), blk);
|
||||
return indir;
|
||||
}
|
||||
|
||||
/* Double indirect block. */
|
||||
blk -= block_per_zone;
|
||||
if (blk < block_per_zone * block_per_zone)
|
||||
blk -= data->block_per_zone;
|
||||
if (blk < (grub_uint64_t) data->block_per_zone * (grub_uint64_t) data->block_per_zone)
|
||||
{
|
||||
indir = grub_get_indir (data, GRUB_MINIX_INODE_DINDIR_ZONE (data),
|
||||
blk / block_per_zone);
|
||||
blk / data->block_per_zone);
|
||||
|
||||
indir = grub_get_indir (data, indir, blk % block_per_zone);
|
||||
indir = grub_get_indir (data, indir, blk % data->block_per_zone);
|
||||
|
||||
return indir;
|
||||
}
|
||||
|
||||
#if defined (MODE_MINIX3) || defined (MODE_MINIX2)
|
||||
blk -= block_per_zone * block_per_zone;
|
||||
if (blk < ((grub_uint64_t) block_per_zone * (grub_uint64_t) block_per_zone
|
||||
* (grub_uint64_t) block_per_zone))
|
||||
blk -= data->block_per_zone * data->block_per_zone;
|
||||
if (blk < ((grub_uint64_t) data->block_per_zone * (grub_uint64_t) data->block_per_zone
|
||||
* (grub_uint64_t) data->block_per_zone))
|
||||
{
|
||||
indir = grub_get_indir (data, grub_minix_to_cpu_n (data->inode.triple_indir_zone),
|
||||
(blk / block_per_zone) / block_per_zone);
|
||||
indir = grub_get_indir (data, indir, (blk / block_per_zone) % block_per_zone);
|
||||
indir = grub_get_indir (data, indir, blk % block_per_zone);
|
||||
(blk / data->block_per_zone) / data->block_per_zone);
|
||||
indir = grub_get_indir (data, indir, (blk / data->block_per_zone) % data->block_per_zone);
|
||||
indir = grub_get_indir (data, indir, blk % data->block_per_zone);
|
||||
|
||||
return indir;
|
||||
}
|
||||
|
@ -262,6 +264,13 @@ grub_minix_read_file (struct grub_minix_data *data,
|
|||
grub_uint32_t posblock;
|
||||
grub_uint32_t blockoff;
|
||||
|
||||
if (pos > GRUB_MINIX_INODE_SIZE (data))
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
N_("attempt to read past the end of file"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Adjust len so it we can't read past the end of the file. */
|
||||
if (len + pos > GRUB_MINIX_INODE_SIZE (data))
|
||||
len = GRUB_MINIX_INODE_SIZE (data) - pos;
|
||||
|
@ -278,7 +287,7 @@ grub_minix_read_file (struct grub_minix_data *data,
|
|||
|
||||
for (i = posblock; i < blockcnt; i++)
|
||||
{
|
||||
grub_disk_addr_t blknr;
|
||||
grub_minix_uintn_t blknr;
|
||||
grub_uint64_t blockend = data->block_size << GRUB_DISK_SECTOR_BITS;
|
||||
grub_off_t skipfirst = 0;
|
||||
|
||||
|
@ -307,7 +316,7 @@ grub_minix_read_file (struct grub_minix_data *data,
|
|||
data->disk->read_hook = read_hook;
|
||||
data->disk->read_hook_data = read_hook_data;
|
||||
grub_disk_read (data->disk,
|
||||
GRUB_MINIX_ZONE2SECT(blknr),
|
||||
grub_minix_zone2sect(data, blknr),
|
||||
skipfirst, blockend, buf);
|
||||
data->disk->read_hook = 0;
|
||||
if (grub_errno)
|
||||
|
@ -333,7 +342,8 @@ grub_minix_read_inode (struct grub_minix_data *data, grub_minix_ino_t ino)
|
|||
|
||||
/* The first inode in minix is inode 1. */
|
||||
ino--;
|
||||
block = GRUB_MINIX_ZONE2SECT (2 + grub_minix_to_cpu16 (sblock->inode_bmap_size)
|
||||
block = grub_minix_zone2sect (data,
|
||||
2 + grub_minix_to_cpu16 (sblock->inode_bmap_size)
|
||||
+ grub_minix_to_cpu16 (sblock->zone_bmap_size));
|
||||
block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_inode));
|
||||
int offs = (ino % (GRUB_DISK_SECTOR_SIZE
|
||||
|
@ -508,6 +518,12 @@ grub_minix_mount (grub_disk_t disk)
|
|||
data->block_size = 2;
|
||||
#endif
|
||||
|
||||
data->block_per_zone = (((grub_uint64_t) data->block_size << \
|
||||
(GRUB_DISK_SECTOR_BITS + grub_minix_to_cpu16 (data->sblock.log2_zone_size)))
|
||||
/ sizeof (grub_minix_uintn_t));
|
||||
if (!data->block_per_zone)
|
||||
goto fail;
|
||||
|
||||
return data;
|
||||
|
||||
fail:
|
||||
|
|
|
@ -724,6 +724,10 @@ grub_nilfs2_valid_sb (struct grub_nilfs2_super_block *sbp)
|
|||
if (grub_le_to_cpu32 (sbp->s_rev_level) != NILFS_SUPORT_REV)
|
||||
return 0;
|
||||
|
||||
/* 20 already means 1GiB blocks. We don't want to deal with blocks overflowing int32. */
|
||||
if (grub_le_to_cpu32 (sbp->s_log_block_size) > 20)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -618,7 +618,10 @@ list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos,
|
|||
|
||||
ustr = get_utf8 (np, ns);
|
||||
if (ustr == NULL)
|
||||
return 0;
|
||||
{
|
||||
grub_free (fdiro);
|
||||
return 0;
|
||||
}
|
||||
if (namespace)
|
||||
type |= GRUB_FSHELP_CASE_INSENSITIVE;
|
||||
|
||||
|
@ -917,12 +920,16 @@ grub_ntfs_mount (grub_disk_t disk)
|
|||
|
||||
if (bpb.clusters_per_mft > 0)
|
||||
data->mft_size = ((grub_disk_addr_t) bpb.clusters_per_mft) << data->log_spc;
|
||||
else if (-bpb.clusters_per_mft < GRUB_NTFS_BLK_SHR || -bpb.clusters_per_mft >= 31)
|
||||
goto fail;
|
||||
else
|
||||
data->mft_size = 1ULL << (-bpb.clusters_per_mft - GRUB_NTFS_BLK_SHR);
|
||||
|
||||
if (bpb.clusters_per_index > 0)
|
||||
data->idx_size = (((grub_disk_addr_t) bpb.clusters_per_index)
|
||||
<< data->log_spc);
|
||||
else if (-bpb.clusters_per_index < GRUB_NTFS_BLK_SHR || -bpb.clusters_per_index >= 31)
|
||||
goto fail;
|
||||
else
|
||||
data->idx_size = 1ULL << (-bpb.clusters_per_index - GRUB_NTFS_BLK_SHR);
|
||||
|
||||
|
|
|
@ -1090,7 +1090,7 @@ grub_reiserfs_read_real (struct grub_fshelp_node *node,
|
|||
switch (found.type)
|
||||
{
|
||||
case GRUB_REISERFS_DIRECT:
|
||||
block = found.block_number * (block_size >> GRUB_DISK_SECTOR_BITS);
|
||||
block = ((grub_disk_addr_t) found.block_number) * (block_size >> GRUB_DISK_SECTOR_BITS);
|
||||
grub_dprintf ("reiserfs_blocktype", "D: %u\n", (unsigned) block);
|
||||
if (initial_position < current_position + item_size)
|
||||
{
|
||||
|
|
|
@ -173,10 +173,11 @@ grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block,
|
|||
struct grub_sfs_btree *tree;
|
||||
int i;
|
||||
grub_uint32_t next;
|
||||
grub_size_t blocksize = GRUB_DISK_SECTOR_SIZE << data->log_blocksize;
|
||||
|
||||
treeblock = grub_malloc (GRUB_DISK_SECTOR_SIZE << data->log_blocksize);
|
||||
if (!block)
|
||||
return 0;
|
||||
treeblock = grub_malloc (blocksize);
|
||||
if (!treeblock)
|
||||
return grub_errno;
|
||||
|
||||
next = grub_be_to_cpu32 (data->rblock.btree);
|
||||
tree = (struct grub_sfs_btree *) treeblock;
|
||||
|
@ -184,17 +185,21 @@ grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block,
|
|||
/* Handle this level in the btree. */
|
||||
do
|
||||
{
|
||||
grub_uint16_t nnodes;
|
||||
grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t) next) << data->log_blocksize,
|
||||
0, GRUB_DISK_SECTOR_SIZE << data->log_blocksize,
|
||||
treeblock);
|
||||
0, blocksize, treeblock);
|
||||
if (grub_errno)
|
||||
{
|
||||
grub_free (treeblock);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
for (i = grub_be_to_cpu16 (tree->nodes) - 1; i >= 0; i--)
|
||||
nnodes = grub_be_to_cpu16 (tree->nodes);
|
||||
if (nnodes * (grub_uint32_t) (tree)->nodesize > blocksize)
|
||||
break;
|
||||
|
||||
for (i = (int) nnodes - 1; i >= 0; i--)
|
||||
{
|
||||
|
||||
#define EXTNODE(tree, index) \
|
||||
|
|
|
@ -986,6 +986,7 @@ grub_udf_read_symlink (grub_fshelp_node_t node)
|
|||
case 1:
|
||||
if (ptr[1])
|
||||
goto fail;
|
||||
/* Fallthrough. */
|
||||
case 2:
|
||||
/* in 4 bytes. out: 1 byte. */
|
||||
optr = out;
|
||||
|
|
|
@ -465,7 +465,13 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino)
|
|||
&& INODE_SIZE (data) <= sizeof (data->inode.symlink))
|
||||
grub_strcpy (symlink, (char *) data->inode.symlink);
|
||||
else
|
||||
grub_ufs_read_file (data, 0, 0, 0, sz, symlink);
|
||||
{
|
||||
if (grub_ufs_read_file (data, 0, 0, 0, sz, symlink) < 0)
|
||||
{
|
||||
grub_free(symlink);
|
||||
return grub_errno;
|
||||
}
|
||||
}
|
||||
symlink[sz] = '\0';
|
||||
|
||||
/* The symlink is an absolute path, go back to the root inode. */
|
||||
|
@ -604,7 +610,8 @@ grub_ufs_mount (grub_disk_t disk)
|
|||
endiannesses. */
|
||||
if (data->sblock.magic == grub_cpu_to_ufs32_compile_time (GRUB_UFS_MAGIC)
|
||||
&& data->sblock.bsize != 0
|
||||
&& ((data->sblock.bsize & (data->sblock.bsize - 1)) == 0))
|
||||
&& ((data->sblock.bsize & (data->sblock.bsize - 1)) == 0)
|
||||
&& data->sblock.ino_per_group != 0)
|
||||
{
|
||||
for (data->log2_blksz = 0;
|
||||
(1U << data->log2_blksz) < grub_ufs_to_cpu32 (data->sblock.bsize);
|
||||
|
|
|
@ -252,7 +252,6 @@ struct grub_zfs_data
|
|||
|
||||
uberblock_t current_uberblock;
|
||||
|
||||
int mounted;
|
||||
grub_uint64_t guid;
|
||||
};
|
||||
|
||||
|
@ -286,7 +285,7 @@ static const char *spa_feature_names[] = {
|
|||
|
||||
static int
|
||||
check_feature(const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx);
|
||||
static int
|
||||
static grub_err_t
|
||||
check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data );
|
||||
|
||||
static grub_err_t
|
||||
|
@ -957,7 +956,7 @@ nvpair_value (const char *nvp,char **val,
|
|||
static grub_err_t
|
||||
check_pool_label (struct grub_zfs_data *data,
|
||||
struct grub_zfs_device_desc *diskdesc,
|
||||
int *inserted)
|
||||
int *inserted, int original)
|
||||
{
|
||||
grub_uint64_t pool_state, txg = 0;
|
||||
char *nvlist,*features;
|
||||
|
@ -1081,11 +1080,12 @@ check_pool_label (struct grub_zfs_data *data,
|
|||
|
||||
grub_dprintf ("zfs", "check 11 passed\n");
|
||||
|
||||
if (data->mounted && data->guid != poolguid)
|
||||
return grub_error (GRUB_ERR_BAD_FS, "another zpool");
|
||||
else
|
||||
if (original)
|
||||
data->guid = poolguid;
|
||||
|
||||
if (data->guid != poolguid)
|
||||
return grub_error (GRUB_ERR_BAD_FS, "another zpool");
|
||||
|
||||
{
|
||||
char *nv;
|
||||
nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE);
|
||||
|
@ -1186,7 +1186,7 @@ scan_disk (grub_device_t dev, struct grub_zfs_data *data,
|
|||
}
|
||||
grub_dprintf ("zfs", "label ok %d\n", label);
|
||||
|
||||
err = check_pool_label (data, &desc, inserted);
|
||||
err = check_pool_label (data, &desc, inserted, original);
|
||||
if (err || !*inserted)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
@ -1501,6 +1501,9 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc,
|
|||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"raidz%d is not supported", desc->nparity);
|
||||
|
||||
if (desc->n_children <= desc->nparity || desc->n_children < 1)
|
||||
return grub_error(GRUB_ERR_BAD_FS, "too little devices for given parity");
|
||||
|
||||
orig_s = (((len + (1 << desc->ashift) - 1) >> desc->ashift)
|
||||
+ (desc->n_children - desc->nparity) - 1);
|
||||
s = orig_s;
|
||||
|
@ -1972,7 +1975,7 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf,
|
|||
dn->endian)
|
||||
<< SPA_MINBLOCKSHIFT;
|
||||
*buf = grub_malloc (size);
|
||||
if (*buf)
|
||||
if (!*buf)
|
||||
{
|
||||
err = grub_errno;
|
||||
break;
|
||||
|
@ -2010,12 +2013,14 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf,
|
|||
*/
|
||||
static grub_err_t
|
||||
mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian,
|
||||
int objsize, const char *name, grub_uint64_t * value,
|
||||
grub_uint16_t objsize, const char *name, grub_uint64_t * value,
|
||||
int case_insensitive)
|
||||
{
|
||||
int i, chunks;
|
||||
grub_uint16_t i, chunks;
|
||||
mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk;
|
||||
|
||||
if (objsize < MZAP_ENT_LEN)
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), name);
|
||||
chunks = objsize / MZAP_ENT_LEN - 1;
|
||||
for (i = 0; i < chunks; i++)
|
||||
{
|
||||
|
@ -2423,7 +2428,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val,
|
|||
struct grub_zfs_data *data, int case_insensitive)
|
||||
{
|
||||
grub_uint64_t block_type;
|
||||
int size;
|
||||
grub_uint16_t size;
|
||||
void *zapbuf;
|
||||
grub_err_t err;
|
||||
grub_zfs_endian_t endian;
|
||||
|
@ -2804,6 +2809,9 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
|
|||
dnode_path->dn.endian)
|
||||
<< SPA_MINBLOCKSHIFT);
|
||||
|
||||
if (blksz == 0)
|
||||
return grub_error(GRUB_ERR_BAD_FS, "0-sized block");
|
||||
|
||||
sym_value = grub_malloc (sym_sz);
|
||||
if (!sym_value)
|
||||
return grub_errno;
|
||||
|
@ -2829,6 +2837,8 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
|
|||
if (!path_buf)
|
||||
{
|
||||
grub_free (oldpathbuf);
|
||||
if (free_symval)
|
||||
grub_free (sym_value);
|
||||
return grub_errno;
|
||||
}
|
||||
grub_memcpy (path, sym_value, sym_sz);
|
||||
|
@ -3606,8 +3616,6 @@ zfs_mount (grub_device_t dev)
|
|||
ub_endian) >> 63) & 1;
|
||||
grub_free (osp);
|
||||
|
||||
data->mounted = 1;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -3798,6 +3806,12 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
|
|||
blksz = grub_zfs_to_cpu16 (data->dnode.dn.dn_datablkszsec,
|
||||
data->dnode.endian) << SPA_MINBLOCKSHIFT;
|
||||
|
||||
if (blksz == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "0-sized block");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Entire Dnode is too big to fit into the space available. We
|
||||
* will need to read it in chunks. This could be optimized to
|
||||
|
@ -3969,7 +3983,12 @@ iterate_zap (const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx)
|
|||
dnode_end_t dn;
|
||||
grub_memset (&info, 0, sizeof (info));
|
||||
|
||||
dnode_get (&(ctx->data->subvol.mdn), val, 0, &dn, ctx->data);
|
||||
err = dnode_get (&(ctx->data->subvol.mdn), val, 0, &dn, ctx->data);
|
||||
if (err)
|
||||
{
|
||||
grub_print_error ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dn.dn.dn_bonustype == DMU_OT_SA)
|
||||
{
|
||||
|
@ -4190,11 +4209,11 @@ check_feature (const char *name, grub_uint64_t val,
|
|||
* errnum: Failure.
|
||||
*/
|
||||
|
||||
static int
|
||||
static grub_err_t
|
||||
check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data )
|
||||
{
|
||||
grub_uint64_t objnum;
|
||||
grub_uint8_t errnum = 0;
|
||||
grub_err_t errnum = 0;
|
||||
dnode_end_t dn,mosmdn;
|
||||
mzap_phys_t* mzp;
|
||||
grub_zfs_endian_t endianzap;
|
||||
|
|
|
@ -238,7 +238,7 @@ grub_gcm_decrypt (grub_crypto_cipher_handle_t cipher,
|
|||
grub_crypto_xor (out + 16 * i, in + 16 * i, mul, csize);
|
||||
}
|
||||
for (j = 0; j < 8; j++)
|
||||
mac[15 - j] ^= ((psize * 8) >> (8 * j));
|
||||
mac[15 - j] ^= ((((grub_uint64_t) psize) * 8) >> (8 * j));
|
||||
grub_gcm_mul (mac, h);
|
||||
|
||||
if (mac_out)
|
||||
|
@ -354,6 +354,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
|
|||
if (err)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_crypto_cipher_close (cipher);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -362,6 +363,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
|
|||
if (err)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_crypto_cipher_close (cipher);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -372,6 +374,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
|
|||
{
|
||||
grub_dprintf ("zfs", "key loading failed\n");
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_crypto_cipher_close (cipher);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -381,21 +384,25 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
|
|||
{
|
||||
grub_dprintf ("zfs", "key loading failed\n");
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_crypto_cipher_close (cipher);
|
||||
continue;
|
||||
}
|
||||
ret = grub_crypto_cipher_open (GRUB_CIPHER_AES);
|
||||
if (!ret)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_crypto_cipher_close (cipher);
|
||||
continue;
|
||||
}
|
||||
err = grub_crypto_cipher_set_key (ret, decrypted, keylen);
|
||||
if (err)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_crypto_cipher_close (ret);
|
||||
continue;
|
||||
}
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_crypto_cipher_close (ret);
|
||||
grub_crypto_cipher_close (cipher);
|
||||
continue;
|
||||
}
|
||||
grub_crypto_cipher_close (cipher);
|
||||
return ret;
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -130,10 +130,12 @@ print_vdev_info (char *nvlist, int tab)
|
|||
grub_free (bootpath);
|
||||
grub_free (devid);
|
||||
grub_free (path);
|
||||
grub_free (type);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
char is_mirror=(grub_strcmp(type,VDEV_TYPE_MIRROR) == 0);
|
||||
char is_raidz=(grub_strcmp(type,VDEV_TYPE_RAIDZ) == 0);
|
||||
grub_free (type);
|
||||
|
||||
if (is_mirror || is_raidz)
|
||||
{
|
||||
|
|
|
@ -138,51 +138,53 @@ circprog_paint (void *vself, const grub_video_rect_t *region)
|
|||
(height - center_height) / 2, 0, 0,
|
||||
center_width, center_height);
|
||||
|
||||
int radius = grub_min (height, width) / 2 - grub_max (tick_height, tick_width) / 2 - 1;
|
||||
unsigned nticks;
|
||||
unsigned tick_begin;
|
||||
unsigned tick_end;
|
||||
if (self->end <= self->start
|
||||
|| self->value <= self->start)
|
||||
nticks = 0;
|
||||
else
|
||||
nticks = ((unsigned) (self->num_ticks
|
||||
* (self->value - self->start)))
|
||||
/ ((unsigned) (self->end - self->start));
|
||||
/* Do ticks appear or disappear as the value approached the end? */
|
||||
if (self->ticks_disappear)
|
||||
if (self->num_ticks)
|
||||
{
|
||||
tick_begin = nticks;
|
||||
tick_end = self->num_ticks;
|
||||
int radius = grub_min (height, width) / 2 - grub_max (tick_height, tick_width) / 2 - 1;
|
||||
unsigned nticks;
|
||||
unsigned tick_begin;
|
||||
unsigned tick_end;
|
||||
if (self->end <= self->start
|
||||
|| self->value <= self->start)
|
||||
nticks = 0;
|
||||
else
|
||||
nticks = ((unsigned) (self->num_ticks
|
||||
* (self->value - self->start)))
|
||||
/ ((unsigned) (self->end - self->start));
|
||||
/* Do ticks appear or disappear as the value approached the end? */
|
||||
if (self->ticks_disappear)
|
||||
{
|
||||
tick_begin = nticks;
|
||||
tick_end = self->num_ticks;
|
||||
}
|
||||
else
|
||||
{
|
||||
tick_begin = 0;
|
||||
tick_end = nticks;
|
||||
}
|
||||
|
||||
unsigned i;
|
||||
for (i = tick_begin; i < tick_end; i++)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int angle;
|
||||
|
||||
/* Calculate the location of the tick. */
|
||||
angle = self->start_angle
|
||||
+ i * GRUB_TRIG_ANGLE_MAX / self->num_ticks;
|
||||
x = width / 2 + (grub_cos (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
|
||||
y = height / 2 + (grub_sin (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
|
||||
|
||||
/* Adjust (x,y) so the tick is centered. */
|
||||
x -= tick_width / 2;
|
||||
y -= tick_height / 2;
|
||||
|
||||
/* Draw the tick. */
|
||||
grub_video_blit_bitmap (self->tick_bitmap, GRUB_VIDEO_BLIT_BLEND,
|
||||
x, y, 0, 0, tick_width, tick_height);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tick_begin = 0;
|
||||
tick_end = nticks;
|
||||
}
|
||||
|
||||
unsigned i;
|
||||
for (i = tick_begin; i < tick_end; i++)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int angle;
|
||||
|
||||
/* Calculate the location of the tick. */
|
||||
angle = self->start_angle
|
||||
+ i * GRUB_TRIG_ANGLE_MAX / self->num_ticks;
|
||||
x = width / 2 + (grub_cos (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
|
||||
y = height / 2 + (grub_sin (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
|
||||
|
||||
/* Adjust (x,y) so the tick is centered. */
|
||||
x -= tick_width / 2;
|
||||
y -= tick_height / 2;
|
||||
|
||||
/* Draw the tick. */
|
||||
grub_video_blit_bitmap (self->tick_bitmap, GRUB_VIDEO_BLIT_BLEND,
|
||||
x, y, 0, 0, tick_width, tick_height);
|
||||
}
|
||||
|
||||
grub_gui_restore_viewport (&vpsave);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,6 +131,9 @@ get_num_shown_items (list_impl_t self)
|
|||
int max_top_pad = grub_max (item_top_pad, sel_top_pad);
|
||||
int max_bottom_pad = grub_max (item_bottom_pad, sel_bottom_pad);
|
||||
|
||||
if (item_height + item_vspace <= 0)
|
||||
return 1;
|
||||
|
||||
return (self->bounds.height + item_vspace - 2 * boxpad
|
||||
- max_top_pad - max_bottom_pad
|
||||
- box_top_pad - box_bottom_pad) / (item_height + item_vspace);
|
||||
|
|
|
@ -118,9 +118,15 @@ draw_filled_rect_bar (grub_gui_progress_bar_t self)
|
|||
f.width + 2, f.height + 2);
|
||||
|
||||
/* Bar background. */
|
||||
int barwidth = (f.width
|
||||
* (self->value - self->start)
|
||||
/ (self->end - self->start));
|
||||
unsigned barwidth;
|
||||
|
||||
if (self->end <= self->start
|
||||
|| self->value <= self->start)
|
||||
barwidth = 0;
|
||||
else
|
||||
barwidth = (f.width
|
||||
* (self->value - self->start)
|
||||
/ (self->end - self->start));
|
||||
grub_video_fill_rect (grub_video_map_rgba_color (self->bg_color),
|
||||
f.x + barwidth, f.y,
|
||||
f.width - barwidth, f.height);
|
||||
|
|
|
@ -106,8 +106,10 @@ grub_gfxmenu_icon_manager_set_theme_path (grub_gfxmenu_icon_manager_t mgr,
|
|||
const char *path)
|
||||
{
|
||||
/* Clear the cache if the theme path has changed. */
|
||||
if (((mgr->theme_path == 0) != (path == 0))
|
||||
|| (grub_strcmp (mgr->theme_path, path) != 0))
|
||||
if (mgr->theme_path == 0 && path == 0)
|
||||
return;
|
||||
if (mgr->theme_path == 0 || path == 0
|
||||
|| grub_strcmp (mgr->theme_path, path) != 0)
|
||||
grub_gfxmenu_icon_manager_clear_cache (mgr);
|
||||
|
||||
grub_free (mgr->theme_path);
|
||||
|
|
|
@ -774,6 +774,8 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
|||
view->canvas->component.ops->destroy (view->canvas);
|
||||
|
||||
view->canvas = grub_gui_canvas_new ();
|
||||
if (!view->canvas)
|
||||
goto fail;
|
||||
((grub_gui_component_t) view->canvas)
|
||||
->ops->set_bounds ((grub_gui_component_t) view->canvas,
|
||||
&view->screen);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Hierarchical argument parsing help output
|
||||
Copyright (C) 1995-2005, 2007, 2009-2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-2005, 2007, 2009-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
|
@ -650,7 +650,7 @@ hol_find_entry (struct hol *hol, const char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* If an entry with the long option NAME occurs in HOL, set it's special
|
||||
/* If an entry with the long option NAME occurs in HOL, set its special
|
||||
sort position to GROUP. */
|
||||
static void
|
||||
hol_set_group (struct hol *hol, const char *name, int group)
|
||||
|
@ -1507,11 +1507,15 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
|
|||
if (vt)
|
||||
{
|
||||
if (post)
|
||||
inp_text = vt + 1;
|
||||
{
|
||||
inp_text = vt + 1;
|
||||
if (! *inp_text)
|
||||
inp_text = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
inp_text_len = vt - argp->doc;
|
||||
inp_text = __strndup (argp->doc, inp_text_len);
|
||||
inp_text = inp_text_len ? __strndup (argp->doc, inp_text_len) : 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1161,6 +1161,19 @@ grub_gzio_open (grub_file_t io, const char *name __attribute__ ((unused)))
|
|||
return file;
|
||||
}
|
||||
|
||||
static grub_uint8_t
|
||||
mod_31 (grub_uint16_t v)
|
||||
{
|
||||
/* At most 2 iterations for any number that
|
||||
we can get here.
|
||||
In any case faster than real division. */
|
||||
while (v > 0x1f)
|
||||
v = (v & 0x1f) + (v >> 5);
|
||||
if (v == 0x1f)
|
||||
return 0;
|
||||
return v;
|
||||
}
|
||||
|
||||
static int
|
||||
test_zlib_header (grub_gzio_t gzio)
|
||||
{
|
||||
|
@ -1178,7 +1191,10 @@ test_zlib_header (grub_gzio_t gzio)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if ((cmf * 256U + flg) % 31U)
|
||||
/* Usually it would be: (cmf * 256 + flg) % 31 != 0. */
|
||||
/* But 256 == 8 (31). */
|
||||
/* By multiplying by 4 and using 32 == 1 (31). We get our formula. */
|
||||
if (mod_31 (cmf + flg * 4) != 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, N_("unsupported gzip format"));
|
||||
return 0;
|
||||
|
|
|
@ -403,8 +403,6 @@ test_header (grub_file_t file)
|
|||
return 1;
|
||||
|
||||
CORRUPTED:
|
||||
grub_free(name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,25 +58,22 @@ FUNCTION(__aeabi_lmul)
|
|||
ldmfd sp!, {r4, fp}
|
||||
bx lr
|
||||
|
||||
.macro division parent
|
||||
.macro division32 parent
|
||||
|
||||
stmfd sp!, {lr}
|
||||
sub sp, sp, #12
|
||||
mov r2, r1
|
||||
add r1, sp, #4
|
||||
str r1, [sp, #0]
|
||||
mov r1, #0
|
||||
mov r3, #0
|
||||
sub sp, sp, #8 @ Allocate naturally aligned 64-bit space
|
||||
stmfd sp!, {r3,lr} @ Dummy r3 to maintain stack alignment
|
||||
add r2, sp, #8 @ Set r2 to address of 64-bit space
|
||||
bl \parent
|
||||
ldr r1, [sp, #4]
|
||||
add sp, sp, #12
|
||||
ldmfd sp!, {lr}
|
||||
ldr r1, [sp, #8] @ Extract remainder
|
||||
ldmfd sp!, {r3,lr} @ Pop into an unused arg/scratch register
|
||||
add sp, sp, #8
|
||||
bx lr
|
||||
.endm
|
||||
|
||||
FUNCTION(__aeabi_uidivmod)
|
||||
division grub_divmod64
|
||||
|
||||
division32 grub_divmod32
|
||||
FUNCTION(__aeabi_idivmod)
|
||||
division32 grub_divmod32s
|
||||
|
||||
/*
|
||||
* Null divide-by-zero handler
|
|
@ -78,9 +78,9 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
|||
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++)
|
||||
max = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_size);
|
||||
rel + 1 <= max;
|
||||
rel = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_entsize))
|
||||
switch (ELF_R_TYPE (rel->r_info))
|
||||
{
|
||||
case R_ARM_CALL:
|
||||
|
@ -205,6 +205,21 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
|
|||
*/
|
||||
case R_ARM_V4BX:
|
||||
break;
|
||||
case R_ARM_THM_MOVW_ABS_NC:
|
||||
case R_ARM_THM_MOVT_ABS:
|
||||
{
|
||||
grub_uint32_t offset;
|
||||
offset = grub_arm_thm_movw_movt_get_value((grub_uint16_t *) target);
|
||||
offset += sym_addr;
|
||||
|
||||
if (ELF_R_TYPE (rel->r_info) == R_ARM_THM_MOVT_ABS)
|
||||
offset >>= 16;
|
||||
else
|
||||
offset &= 0xffff;
|
||||
|
||||
grub_arm_thm_movw_movt_set_value((grub_uint16_t *) target, offset);
|
||||
}
|
||||
break;
|
||||
case R_ARM_THM_JUMP19:
|
||||
{
|
||||
/* Thumb instructions can be 16-bit aligned */
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue