mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-28 18:19:23 +00:00
Compare commits
53
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebd289335a | ||
|
|
d2f7902af0 | ||
|
|
1005bed722 | ||
|
|
d6c92cdc34 | ||
|
|
61e1b9a49d | ||
|
|
c98dd165b0 | ||
|
|
ff1c277ef8 | ||
|
|
c8f7614b98 | ||
|
|
246a434f61 | ||
|
|
5c066a81c2 | ||
|
|
78f961efe9 | ||
|
|
09bc0a577d | ||
|
|
b700a427d2 | ||
|
|
4480b95dcd | ||
|
|
e77c81f6f8 | ||
|
|
971dbee521 | ||
|
|
6f2e82be3a | ||
|
|
9eec9699b9 | ||
|
|
5ae5c54c7e | ||
|
|
7b04fe6c9e | ||
|
|
e67566ce0a | ||
|
|
f93ddcfd1c | ||
|
|
1bba40f578 | ||
|
|
f65e14dc3a | ||
|
|
14a94bba6f | ||
|
|
8109c5d4e2 | ||
|
|
a92b5cb8d8 | ||
|
|
4a23e2fe29 | ||
|
|
a3ba74104e | ||
|
|
e1c22419ac | ||
|
|
189090cee9 | ||
|
|
1a5b7b404f | ||
|
|
9cf12b20af | ||
|
|
63a45330cb | ||
|
|
4a0aaad022 | ||
|
|
095bb1bfa5 | ||
|
|
3937bd962b | ||
|
|
ddb3efc906 | ||
|
|
4e42521d8c | ||
|
|
054efe541f | ||
|
|
a0e1befb57 | ||
|
|
c36c73f681 | ||
|
|
6f4a19f59f | ||
|
|
0d8f04cd83 | ||
|
|
4906052019 | ||
|
|
c6a823e267 | ||
|
|
b7f9aedfac | ||
|
|
7dd0a30361 | ||
|
|
ca120e31f2 | ||
|
|
8a07b55a04 | ||
|
|
d3def58c52 | ||
|
|
96fa2d9d02 | ||
|
|
15a463d742 |
No files matched your search
@@ -1,3 +1,232 @@
|
||||
2013-11-25 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/osdep/unix/platform.c (get_ofpathname): Trim ending newline.
|
||||
Don't rely on PATH_MAX.
|
||||
|
||||
2013-11-25 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/genmoddep.awk: Use more portable && rather than and.
|
||||
|
||||
2013-11-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/i386/pc/startup.S [__APPLE__]: Create _edata by placing
|
||||
an object after data. While it doesn't seem right solution, it
|
||||
works well enough and OSX isn't main compilation platform.
|
||||
|
||||
2013-11-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* gentpl.py: Add -ed2016 in order to make objconv accept our binary.
|
||||
While it doesn't seem right solution, it works well enough and
|
||||
OSX isn't main compilation platform.
|
||||
|
||||
2013-11-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* configure.ac: Add -static to LDFLAGS when using apple linker to
|
||||
prevent it from pulling in dynamic linker.
|
||||
|
||||
2013-11-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Apple assembly doesn't handle symbol arithmetic well. So define an
|
||||
offset symbol in boot.S and use it.
|
||||
|
||||
2013-11-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Apple assembly doesn't handle symbol arithmetic well. So instead
|
||||
of getting addres of kernel_sector + 4 define kernel_sector_high.
|
||||
It also makes code more readable.
|
||||
|
||||
2013-11-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
With Apple assembly in .macro environvemnt you have to use $$ instead
|
||||
of $. So introduce new preprocessor macro MACRO_DOLLAR(x) which expands
|
||||
to $$x on Apple and to $x on everything else.
|
||||
|
||||
2013-11-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/Makefile.am: Use correct TARGET_OBJCONV rather than
|
||||
OBJCONV.
|
||||
|
||||
2013-11-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/gdb/i386/machdep.S: Use xorl %eax, %eax on both Apple
|
||||
and non-Apple. This instruction is shorter and faster,
|
||||
so no reason not to use it on both.
|
||||
|
||||
2013-11-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/lib/reed_solomon.c: Use section _text, _text rather than
|
||||
.text when compiling for Apple.
|
||||
|
||||
2013-11-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/term/arc/console.c: Add missing cast to silence warning.
|
||||
|
||||
2013-11-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/boot/i386/pc/boot.S: Fix floppy probe. Due to missing
|
||||
%dx restore the probe worked on non-existant drive. Reorganize the
|
||||
code a little bit to free 2 bytes necessary for push/pop.
|
||||
|
||||
2013-11-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/mips/arc/init.c (grub_machine_get_bootlocation):
|
||||
Add missing cast to silence warning.
|
||||
|
||||
2013-11-23 Keshav Padram Amburay <the.ridikulus.rat@gmail.com>
|
||||
|
||||
* util/grub-install.c (update_nvram): Support --no-nvram flag
|
||||
for EFI targets.
|
||||
|
||||
2013-11-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* INSTALL: Add note about sparc64/ia64 with clang (unsupported).
|
||||
|
||||
2013-11-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/garbage-gen.c: Add missing include of sys/time.h.
|
||||
|
||||
2013-11-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Don't add -mflush-func if it's not supported by compiler.
|
||||
|
||||
2013-11-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Move common BIOS/coreboot memory map declarations to
|
||||
include/grub/i386/memory_raw.h and eliminate duplicate declarations.
|
||||
|
||||
2013-11-22 Andrey Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* Makefile.am: Add util/garbage-gen.c to EXTRA_DIST.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* INSTALL: Document why older clang versions aren't appropriate.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* INSTALL: Document about clang for mips.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/lib/libgcrypt/mpi/longlong.h: Use C version with mips
|
||||
clang.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Add *-xen to the list of grub-install-common platforms.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* configure.ac: Do not enforce -mcmodel=large. It's not necessarry with
|
||||
3 last commits.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/xen/init.c: Do not map more pages than we can address.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/efi/mm.c: Limit allocations to 2GiB when not compiling
|
||||
with -mcmodel=large.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Add
|
||||
range-checking for 32-bit quantities.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* configure.ac: Compile with -fPIC when compiling with clang on
|
||||
mips.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* configure.ac: Add -no-integrated-as on mips(el) to TARGET_CCASFLAGS
|
||||
when compiling with clang.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
clang emits calls to abort () under some unknown conditions.
|
||||
Export abort () when compiling with clang.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* docs/grub-dev.texi: Document stack and heap sizes.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* include/grub/i386/pc/memory.h: Decrease
|
||||
GRUB_MEMORY_MACHINE_SCRATCH_SIZE and increase
|
||||
GRUB_MEMORY_MACHINE_PROT_STACK_SIZE.
|
||||
The binary doesn't change (checked). It's more to better reflect actual
|
||||
usage.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/i386/pc/biosdisk.c (grub_biosdisk_open): Ensure
|
||||
at compile time that enough of scratch size is available.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/x86_64/efi/callwrap.S: Fix stack alignment.
|
||||
Previously we misaligned stack by 8 in startup.S and compensated
|
||||
for it in callwrap.S. According to ABI docs (EFI and sysv amd64)
|
||||
right behaviour is to align stack in startup.S and keep it aligned
|
||||
in callwrap.S. startup.S part was committed few commits before. This
|
||||
takes care of callwrap.S.
|
||||
Reported by: Gary Lin.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/boot/mips/startup_raw.S: Handle the case of gap between
|
||||
.data and .bss. May happen if compiler and assembly use different
|
||||
alignment.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
On MIPS handle got16 relocations to local symbols in an ABI-compliant
|
||||
way.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Add support for a new magic symbol _gp_disp on mips to handle PIC
|
||||
binaries.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Use $t9 for indirect calls from asm to C as PIC ABI requires.
|
||||
|
||||
2013-11-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Remove -march=mips3 from TARGET_CCASFLAGS as it creates linking problem
|
||||
when rest of GRUB is compiled for hisher stepping. Instead use
|
||||
.set mips3/.set mips1 around cache and sync opcodes.
|
||||
|
||||
2013-11-21 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Unify GOT/trampoline handling between PPC, MIPS and IA64 as they
|
||||
do essentially the same thing, do it in similar way.
|
||||
|
||||
2013-11-21 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub-mkrescue.c (main): If a source directory is not
|
||||
specified, read platform-specific files from subdirectories of
|
||||
pkglibdir, not pkgdatadir.
|
||||
|
||||
2013-11-21 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/normal/progress.c: Remove unused file.
|
||||
|
||||
2013-11-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/lib/crypto.c (grub_crypto_hash): Remove variable length
|
||||
array.
|
||||
|
||||
2013-11-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-mkconfig.in: Say explicit "grub configuration" rather
|
||||
than grub.cfg.
|
||||
|
||||
2013-11-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* coreboot.cfg: Add missing file.
|
||||
|
||||
@@ -15,8 +15,20 @@ configuring the GRUB.
|
||||
Note: older versions may work but support is limited
|
||||
Note: clang 3.2 or later works for i386 and x86_64 targets but results in
|
||||
much bigger binaries.
|
||||
earlier versions not tested
|
||||
Note: clang 3.2 or later works for arm
|
||||
earlier versions not tested
|
||||
Note: clang 3.3 or later works for arm64
|
||||
earlier versions have no arm64 support
|
||||
Note: clang 3.3 or later works for mips(el)
|
||||
earlier versions fail to generate .reginfo and hence gprel relocations
|
||||
fail.
|
||||
Note: clang 3.4 or later works for powerpc
|
||||
earlier versions suffer from vacopy bug (#15286)
|
||||
Note: clang has no support for generating 64-bit sparc code and hence you
|
||||
can't compile GRUB for sparc64 with clang
|
||||
Note: clang has no support for ia64 and hence you can't compile GRUB
|
||||
for ia64 with clang
|
||||
* GNU Make
|
||||
* GNU Bison 2.3 or later
|
||||
* GNU gettext 0.17 or later
|
||||
|
||||
@@ -73,6 +73,7 @@ CLEANFILES += build-grub-mkfont
|
||||
garbage-gen: util/garbage-gen.c
|
||||
$(BUILD_CC) -o $@ $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $^
|
||||
CLEANFILES += garbage-gen
|
||||
EXTRA_DIST += util/garbage-gen.c
|
||||
|
||||
build-grub-gen-asciih: util/grub-gen-asciih.c
|
||||
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
|
||||
|
||||
+2
-10
@@ -156,6 +156,8 @@ library = {
|
||||
common = grub-core/io/gzio.c;
|
||||
common = grub-core/io/lzopio.c;
|
||||
common = grub-core/kern/ia64/dl_helper.c;
|
||||
common = grub-core/kern/arm/dl_helper.c;
|
||||
common = grub-core/kern/arm64/dl_helper.c;
|
||||
common = grub-core/lib/minilzo/minilzo.c;
|
||||
common = grub-core/lib/xzembed/xz_dec_bcj.c;
|
||||
common = grub-core/lib/xzembed/xz_dec_lzma2.c;
|
||||
@@ -177,8 +179,6 @@ program = {
|
||||
extra_dist = grub-core/osdep/unix/config.c;
|
||||
common = util/config.c;
|
||||
|
||||
common = grub-core/kern/arm/dl_helper.c;
|
||||
|
||||
extra_dist = util/grub-mkimagexx.c;
|
||||
|
||||
ldadd = libgrubmods.a;
|
||||
@@ -512,8 +512,6 @@ program = {
|
||||
common = grub-core/kern/emu/hostfs.c;
|
||||
common = grub-core/disk/host.c;
|
||||
|
||||
common = grub-core/kern/arm/dl_helper.c;
|
||||
|
||||
common = util/resolve.c;
|
||||
|
||||
common = grub-core/kern/emu/argp_common.c;
|
||||
@@ -558,8 +556,6 @@ program = {
|
||||
common = grub-core/kern/emu/hostfs.c;
|
||||
common = grub-core/disk/host.c;
|
||||
|
||||
common = grub-core/kern/arm/dl_helper.c;
|
||||
|
||||
common = util/resolve.c;
|
||||
|
||||
common = grub-core/kern/emu/argp_common.c;
|
||||
@@ -595,8 +591,6 @@ program = {
|
||||
common = grub-core/osdep/config.c;
|
||||
common = util/config.c;
|
||||
|
||||
common = grub-core/kern/arm/dl_helper.c;
|
||||
|
||||
common = util/resolve.c;
|
||||
enable = noemu;
|
||||
common = grub-core/kern/emu/argp_common.c;
|
||||
@@ -632,8 +626,6 @@ program = {
|
||||
common = grub-core/osdep/config.c;
|
||||
common = util/config.c;
|
||||
|
||||
common = grub-core/kern/arm/dl_helper.c;
|
||||
|
||||
common = util/resolve.c;
|
||||
common = grub-core/kern/emu/argp_common.c;
|
||||
common = grub-core/osdep/init.c;
|
||||
|
||||
@@ -10,10 +10,6 @@ if COND_mips_loongson
|
||||
CFLAGS_PLATFORM += -mexplicit-relocs
|
||||
CPPFLAGS_PLATFORM = -DUSE_ASCII_FALLBACK
|
||||
endif
|
||||
if COND_mips
|
||||
CFLAGS_PLATFORM += -mflush-func=grub_red_herring
|
||||
CCASFLAGS_PLATFORM = -march=mips3
|
||||
endif
|
||||
if COND_sparc64_ieee1275
|
||||
CFLAGS_PLATFORM += -mno-app-regs
|
||||
LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax
|
||||
@@ -23,6 +19,9 @@ if COND_arm
|
||||
CCASFLAGS_PLATFORM = -mthumb-interwork
|
||||
LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache
|
||||
endif
|
||||
if COND_arm64
|
||||
CFLAGS_PLATFORM += -mcmodel=large
|
||||
endif
|
||||
|
||||
#FIXME: discover and check XEN headers
|
||||
CPPFLAGS_XEN = -I/usr/include
|
||||
|
||||
+44
-12
@@ -99,6 +99,9 @@ case "$target_cpu" in
|
||||
arm*)
|
||||
target_cpu=arm;
|
||||
;;
|
||||
aarch64*)
|
||||
target_cpu=arm64;
|
||||
;;
|
||||
esac
|
||||
|
||||
# Specify the platform (such as firmware).
|
||||
@@ -120,6 +123,7 @@ if test "x$with_platform" = x; then
|
||||
mips-*) platform=arc ;;
|
||||
ia64-*) platform=efi ;;
|
||||
arm-*) platform=uboot ;;
|
||||
arm64-*) platform=efi ;;
|
||||
*) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
|
||||
esac
|
||||
else
|
||||
@@ -160,6 +164,7 @@ case "$target_cpu"-"$platform" in
|
||||
mipsel-loongson) ;;
|
||||
arm-uboot) ;;
|
||||
arm-efi) ;;
|
||||
arm64-efi) ;;
|
||||
*-emu) ;;
|
||||
*) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
|
||||
esac
|
||||
@@ -210,6 +215,7 @@ case "$platform" in
|
||||
esac
|
||||
case "$target_cpu" in
|
||||
arm) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM=1" ;;
|
||||
arm64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM64=1" ;;
|
||||
mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
|
||||
sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
|
||||
esac
|
||||
@@ -486,7 +492,11 @@ AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang]
|
||||
|
||||
# on x86 clang doesn't support .code16
|
||||
# on arm clang doesn't support .arch directive
|
||||
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 ); then
|
||||
# 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"
|
||||
fi
|
||||
|
||||
@@ -516,6 +526,21 @@ if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
|
||||
fi
|
||||
|
||||
# on mips redirect cache flushing function to non-existant one.
|
||||
if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
|
||||
AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [
|
||||
CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_cc_mflush_func=yes],
|
||||
[grub_cv_cc_mflush_func=no])
|
||||
])
|
||||
|
||||
if test "x$grub_cv_cc_mflush_func" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Force no alignment to save space on i386.
|
||||
if test "x$target_cpu" = xi386; then
|
||||
AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
|
||||
@@ -654,8 +679,8 @@ if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
|
||||
if test x${target_cpu} != xi386 && test x$format = x${target_cpu}pe; then
|
||||
continue
|
||||
fi
|
||||
CFLAGS="$TARGET_CFLAGS -static"
|
||||
LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib"
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
asm (".globl start; start:");
|
||||
asm (".globl _start; _start:");
|
||||
@@ -723,9 +748,7 @@ if test "$target_cpu" = x86_64; then
|
||||
[grub_cv_cc_mcmodel=yes],
|
||||
[grub_cv_cc_mcmodel=no])
|
||||
])
|
||||
if test "x$grub_cv_cc_mcmodel" = xno; then
|
||||
AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
|
||||
else
|
||||
if test "x$grub_cv_cc_mcmodel" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
|
||||
fi
|
||||
fi
|
||||
@@ -763,10 +786,17 @@ CFLAGS="$TARGET_CFLAGS"
|
||||
|
||||
# Position independent executable.
|
||||
grub_CHECK_PIC
|
||||
[# Need that, because some distributions ship compilers that include
|
||||
# `-fPIC' in the default specs.
|
||||
if [ x"$pic_possible" = xyes ]; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
|
||||
[# On most platforms we don't want PIC as it only makes relocations harder
|
||||
# and code less efficient. On mips we want to have one got table per module
|
||||
# and reload $gp in every function.
|
||||
# GCC implements it using symbol __gnu_local_gp in non-PIC as well.
|
||||
# However with clang we need PIC for this reloading to happen.
|
||||
# Since default varies across dictributions use either -fPIC or -fno-PIC
|
||||
# explicitly.
|
||||
if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel ) && test "x$grub_cv_cc_target_clang" = xyes ; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
|
||||
elif [ x"$pic_possible" = xyes ]; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
|
||||
fi]
|
||||
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
@@ -801,7 +831,7 @@ fi
|
||||
# Set them to their new values for the tests below.
|
||||
CC="$TARGET_CC"
|
||||
if test "x$TARGET_APPLE_LINKER" = x1 ; then
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
|
||||
else
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
|
||||
fi
|
||||
@@ -827,7 +857,7 @@ fi
|
||||
AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x)
|
||||
|
||||
if test "x$TARGET_APPLE_LINKER" = x1 ; then
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib"
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -static"
|
||||
else
|
||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
|
||||
fi
|
||||
@@ -1434,6 +1464,8 @@ AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
|
||||
AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
|
||||
AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
|
||||
AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
|
||||
AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
|
||||
AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
|
||||
|
||||
AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
|
||||
AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
|
||||
|
||||
+65
-2
@@ -79,6 +79,7 @@ This edition documents version @value{VERSION}.
|
||||
* Contributing Changes::
|
||||
* Porting::
|
||||
* Error Handling::
|
||||
* Stack and heap size::
|
||||
* BIOS port memory map::
|
||||
* Video Subsystem::
|
||||
* PFF2 Font File Format::
|
||||
@@ -906,6 +907,69 @@ if (grub_errno != GRUB_ERR_NONE)
|
||||
grub_error_pop ();
|
||||
@end example
|
||||
|
||||
@node Stack and heap size
|
||||
@chapter Stack and heap size
|
||||
|
||||
On emu stack and heap are just normal host OS stack and heap. Stack is typically
|
||||
8 MiB although it's OS-dependent.
|
||||
|
||||
On i386-pc, i386-coreboot, i386-qemu and i386-multiboot the stack is 60KiB.
|
||||
All available space between 1MiB and 4GiB marks is part of heap.
|
||||
|
||||
On *-xen stack is 4MiB. If compiled for x86-64 with GCC 4.4 or later adressable
|
||||
space is unlimited. When compiled for x86-64 with older GCC version adressable
|
||||
space is limited to 2GiB. When compiling for i386 adressable space is limited
|
||||
to 4GiB. All adressable pages except the ones for stack, GRUB binary, special
|
||||
pages and page table are in the heap.
|
||||
|
||||
On *-efi GRUB uses same stack as EFI. If compiled for x86-64 with GCC 4.4 or
|
||||
later adressable space is unlimited. When compiled for x86-64 with older GCC
|
||||
version adressable space is limited to 2GiB. For all other platforms adressable
|
||||
space is limited to 4GiB. GRUB allocates pages from EFI for its heap, at most
|
||||
1.6 GiB.
|
||||
|
||||
On i386-ieee1275 and powerpc-ieee1275 GRUB uses same stack as IEEE1275.
|
||||
It allocates at most 32MiB for its heap.
|
||||
|
||||
On sparc64-ieee1275 stack is 256KiB and heap is 2MiB.
|
||||
|
||||
On mips(el)-qemu_mips and mipsel-loongson stack is 2MiB (everything below
|
||||
GRUB image) and everything above GRUB image (from 2MiB + kernel size)
|
||||
until 256MiB is part of heap.
|
||||
|
||||
On mips-arc stack is 2MiB (everything below GRUB image) and everything above
|
||||
GRUB image(from 2MiB + kernel size) until 128MiB is part of heap.
|
||||
|
||||
On mipsel-arc stack is 2MiB (everything below GRUB image which is not part
|
||||
of ARC) and everything above GRUB image (from 7MiB + kernel size)
|
||||
until 256MiB is part of heap.
|
||||
|
||||
On arm-uboot stack is 256KiB and heap is 2MiB.
|
||||
|
||||
In short:
|
||||
|
||||
@multitable @columnfractions .15 .25 .5
|
||||
@headitem Platform @tab Stack @tab Heap
|
||||
@item emu @tab 8 MiB @tab ?
|
||||
@item i386-pc @tab 60 KiB @tab < 4 GiB
|
||||
@item i386-coreboot @tab 60 KiB @tab < 4 GiB
|
||||
@item i386-multiboot @tab 60 KiB @tab < 4 GiB
|
||||
@item i386-qemu @tab 60 KiB @tab < 4 GiB
|
||||
@item *-efi @tab ? @tab < 1.6 GiB
|
||||
@item i386-ieee1275 @tab ? @tab < 32 MiB
|
||||
@item powerpc-ieee1275 @tab ? @tab < 32 MiB
|
||||
@item sparc64-ieee1275 @tab 256KiB @tab 2 MiB
|
||||
@item arm-uboot @tab 256KiB @tab 2 MiB
|
||||
@item mips(el)-qemu_mips @tab 2MiB @tab 253 MiB
|
||||
@item mipsel-loongson @tab 2MiB @tab 253 MiB
|
||||
@item mips-arc @tab 2MiB @tab 125 MiB
|
||||
@item mipsel-arc @tab 2MiB @tab 248 MiB
|
||||
@item x86_64-xen (GCC >= 4.4) @tab 4MiB @tab unlimited
|
||||
@item x86_64-xen (GCC < 4.4) @tab 4MiB @tab < 2GiB
|
||||
@item i386-xen @tab 4MiB @tab < 4GiB
|
||||
@end multitable
|
||||
|
||||
|
||||
@node BIOS port memory map
|
||||
@chapter BIOS port memory map
|
||||
@c By Yoshinori K Okuji
|
||||
@@ -917,9 +981,8 @@ grub_error_pop ();
|
||||
@item ? @tab 0x2000 - 1 @tab Real mode stack
|
||||
@item 0x7C00 @tab 0x7D00 - 1 @tab Boot sector
|
||||
@item 0x8000 @tab ? @tab GRUB kernel
|
||||
@item 0x68000 @tab 0x78000 - 1 @tab Disk buffer
|
||||
@item 0x68000 @tab 0x71000 - 1 @tab Disk buffer
|
||||
@item ? @tab 0x80000 - 1 @tab Protected mode stack
|
||||
@item 0x80000 @tab ? @tab Heap
|
||||
@item ? @tab 0xA0000 - 1 @tab Extended BIOS Data Area
|
||||
@item 0xA0000 @tab 0xC0000 - 1 @tab Video RAM
|
||||
@item 0xC0000 @tab 0x100000 - 1 @tab BIOS
|
||||
|
||||
@@ -24,7 +24,7 @@ GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot",
|
||||
"i386_xen", "x86_64_xen",
|
||||
"mips_loongson", "sparc64_ieee1275",
|
||||
"powerpc_ieee1275", "mips_arc", "ia64_efi",
|
||||
"mips_qemu_mips", "arm_uboot", "arm_efi" ]
|
||||
"mips_qemu_mips", "arm_uboot", "arm_efi", "arm64_efi" ]
|
||||
|
||||
GROUPS = {}
|
||||
|
||||
@@ -38,9 +38,10 @@ GROUPS["mips"] = [ "mips_loongson", "mips_qemu_mips", "mips_arc" ]
|
||||
GROUPS["sparc64"] = [ "sparc64_ieee1275" ]
|
||||
GROUPS["powerpc"] = [ "powerpc_ieee1275" ]
|
||||
GROUPS["arm"] = [ "arm_uboot", "arm_efi" ]
|
||||
GROUPS["arm64"] = [ "arm64_efi" ]
|
||||
|
||||
# Groups based on firmware
|
||||
GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi" ]
|
||||
GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi", "arm64_efi" ]
|
||||
GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ]
|
||||
GROUPS["uboot"] = [ "arm_uboot" ]
|
||||
GROUPS["xen"] = [ "i386_xen", "x86_64_xen" ]
|
||||
@@ -66,7 +67,7 @@ GROUPS["terminfomodule"] = GRUB_PLATFORMS[:];
|
||||
for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i)
|
||||
|
||||
# Flattened Device Trees (FDT)
|
||||
GROUPS["fdt"] = [ "arm_uboot", "arm_efi" ]
|
||||
GROUPS["fdt"] = [ "arm64_efi", "arm_uboot", "arm_efi" ]
|
||||
|
||||
# Miscelaneous groups schedulded to disappear in future
|
||||
GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"]
|
||||
@@ -432,7 +433,7 @@ def kernel(platform):
|
||||
else cp $< $@; fi""",
|
||||
"""if test x$(TARGET_APPLE_LINKER) = x1; then \
|
||||
$(TARGET_STRIP) -S -x $(""" + cname() + """) -o $@.bin $<; \
|
||||
$(TARGET_OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -ed2022 -wd1106 -nu -nd $@.bin $@; \
|
||||
$(TARGET_OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -ed2022 -ed2016 -wd1106 -nu -nd $@.bin $@; \
|
||||
else """ + "$(TARGET_STRIP) $(" + cname() + "_STRIPFLAGS) -o $@ $<; \
|
||||
fi"""))
|
||||
return r
|
||||
|
||||
@@ -234,6 +234,11 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||
endif
|
||||
|
||||
if COND_arm64_efi
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||
endif
|
||||
|
||||
if COND_emu
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/datetime.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/misc.h
|
||||
@@ -391,7 +396,7 @@ efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
|
||||
-rm -f $@; \
|
||||
if test "x$(TARGET_APPLE_LINKER)" = x1; then \
|
||||
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m32 -Wall -Werror -nostdlib -O2 -c -o $@.bin $< || exit 1; \
|
||||
$(OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \
|
||||
$(TARGET_OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \
|
||||
rm -f $@.bin; \
|
||||
else \
|
||||
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m32 -Wall -Werror -nostdlib -O2 -c -o $@ $< || exit 1; \
|
||||
@@ -418,7 +423,7 @@ efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF)
|
||||
if test "x$(TARGET_APPLE_LINKER)" = x1; then \
|
||||
rm -f $@.bin; \
|
||||
$(TARGET_CC) -m64 -Wl,-r -nostdlib -o $@.bin $^ || exit 1; \
|
||||
$(OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
|
||||
$(TARGET_OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
|
||||
rm -f $@.bin; \
|
||||
else \
|
||||
$(TARGET_CC) -m64 -Wl,-melf_x86_64 -nostdlib -Wl,-r -o $@ $^ || exit 1; \
|
||||
|
||||
@@ -67,6 +67,9 @@ kernel = {
|
||||
arm_efi_ldflags = '-Wl,-r,-d';
|
||||
arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
|
||||
|
||||
arm64_efi_ldflags = '-Wl,-r,-d';
|
||||
arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
|
||||
|
||||
i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
|
||||
i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
|
||||
|
||||
@@ -106,6 +109,7 @@ kernel = {
|
||||
powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S;
|
||||
arm_uboot_startup = kern/arm/uboot/startup.S;
|
||||
arm_efi_startup = kern/arm/efi/startup.S;
|
||||
arm64_efi_startup = kern/arm64/efi/startup.S;
|
||||
|
||||
common = kern/command.c;
|
||||
common = kern/corecmd.c;
|
||||
@@ -194,6 +198,8 @@ kernel = {
|
||||
arm_efi = kern/arm/efi/init.c;
|
||||
arm_efi = kern/arm/efi/misc.c;
|
||||
|
||||
arm64_efi = kern/arm/efi/init.c;
|
||||
|
||||
i386_pc = kern/i386/pc/init.c;
|
||||
i386_pc = kern/i386/pc/mmap.c;
|
||||
i386_pc = term/i386/pc/console.c;
|
||||
@@ -254,6 +260,11 @@ kernel = {
|
||||
arm = kern/arm/cache.c;
|
||||
arm = kern/arm/misc.S;
|
||||
|
||||
arm64 = kern/arm64/cache.c;
|
||||
arm64 = kern/arm64/cache_flush.S;
|
||||
arm64 = kern/arm64/dl.c;
|
||||
arm64 = kern/arm64/dl_helper.c;
|
||||
|
||||
emu = disk/host.c;
|
||||
emu = kern/emu/cache_s.S;
|
||||
emu = kern/emu/hostdisk.c;
|
||||
@@ -751,6 +762,7 @@ module = {
|
||||
enable = mips_arc;
|
||||
enable = ia64_efi;
|
||||
enable = arm_efi;
|
||||
enable = arm64_efi;
|
||||
enable = arm_uboot;
|
||||
};
|
||||
|
||||
@@ -846,6 +858,7 @@ module = {
|
||||
ia64_efi = lib/efi/reboot.c;
|
||||
x86_64_efi = lib/efi/reboot.c;
|
||||
arm_efi = lib/efi/reboot.c;
|
||||
arm64_efi = lib/efi/reboot.c;
|
||||
powerpc_ieee1275 = lib/ieee1275/reboot.c;
|
||||
sparc64_ieee1275 = lib/ieee1275/reboot.c;
|
||||
mips_arc = lib/mips/arc/reboot.c;
|
||||
@@ -1708,6 +1721,7 @@ module = {
|
||||
enable = x86;
|
||||
enable = ia64_efi;
|
||||
enable = arm_efi;
|
||||
enable = arm64_efi;
|
||||
enable = mips;
|
||||
};
|
||||
|
||||
|
||||
@@ -31,27 +31,32 @@
|
||||
.macro floppy
|
||||
part_start:
|
||||
|
||||
probe_values:
|
||||
LOCAL(probe_values):
|
||||
.byte 36, 18, 15, 9, 0
|
||||
|
||||
LOCAL(floppy_probe):
|
||||
pushw %dx
|
||||
/*
|
||||
* Perform floppy probe.
|
||||
*/
|
||||
|
||||
movw $probe_values - 1, %si
|
||||
#ifdef __APPLE__
|
||||
LOCAL(probe_values_minus_one) = LOCAL(probe_values) - 1
|
||||
movw MACRO_DOLLAR(LOCAL(probe_values_minus_one)), %si
|
||||
#else
|
||||
movw MACRO_DOLLAR(LOCAL(probe_values)) - 1, %si
|
||||
#endif
|
||||
|
||||
LOCAL(probe_loop):
|
||||
/* reset floppy controller INT 13h AH=0 */
|
||||
xorw %ax, %ax
|
||||
int $0x13
|
||||
int MACRO_DOLLAR(0x13)
|
||||
|
||||
incw %si
|
||||
movb (%si), %cl
|
||||
|
||||
/* if number of sectors is 0, display error and die */
|
||||
cmpb $0, %cl
|
||||
jne 1f
|
||||
testb %cl, %cl
|
||||
jnz 1f
|
||||
|
||||
/*
|
||||
* Floppy disk probe failure.
|
||||
@@ -64,20 +69,20 @@ fd_probe_error_string: .asciz "Floppy"
|
||||
|
||||
1:
|
||||
/* perform read */
|
||||
movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
|
||||
movw MACRO_DOLLAR(GRUB_BOOT_MACHINE_BUFFER_SEG), %bx
|
||||
movw %bx, %es
|
||||
xorw %bx, %bx
|
||||
movw $0x201, %ax
|
||||
movb $0, %ch
|
||||
movb $0, %dh
|
||||
int $0x13
|
||||
movw MACRO_DOLLAR(0x201), %ax
|
||||
movb MACRO_DOLLAR(0), %ch
|
||||
movb MACRO_DOLLAR(0), %dh
|
||||
int MACRO_DOLLAR(0x13)
|
||||
|
||||
/* if error, jump to "LOCAL(probe_loop)" */
|
||||
jc LOCAL(probe_loop)
|
||||
|
||||
/* %cl is already the correct value! */
|
||||
movb $1, %dh
|
||||
movb $79, %ch
|
||||
movb MACRO_DOLLAR(1), %dh
|
||||
movb MACRO_DOLLAR(79), %ch
|
||||
|
||||
jmp LOCAL(final_init)
|
||||
.endm
|
||||
@@ -180,7 +185,9 @@ kernel_address:
|
||||
#ifndef HYBRID_BOOT
|
||||
. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
|
||||
kernel_sector:
|
||||
.long 1, 0
|
||||
.long 1
|
||||
kernel_sector_high:
|
||||
.long 0
|
||||
#endif
|
||||
|
||||
. = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE
|
||||
@@ -285,7 +292,7 @@ lba_mode:
|
||||
/* the absolute address */
|
||||
movl kernel_sector, %ebx
|
||||
movl %ebx, 8(%si)
|
||||
movl kernel_sector + 4, %ebx
|
||||
movl kernel_sector_high, %ebx
|
||||
movl %ebx, 12(%si)
|
||||
|
||||
/* the segment of buffer address */
|
||||
@@ -318,11 +325,12 @@ LOCAL(chs_mode):
|
||||
int $0x13
|
||||
jnc LOCAL(final_init)
|
||||
|
||||
popw %dx
|
||||
/*
|
||||
* The call failed, so maybe use the floppy probe instead.
|
||||
*/
|
||||
testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
|
||||
jz LOCAL(floppy_probe)
|
||||
testb %dl, %dl
|
||||
jnb LOCAL(floppy_probe)
|
||||
|
||||
/* Nope, we definitely have a hard disk, and we're screwed. */
|
||||
ERR(hd_probe_error_string)
|
||||
@@ -353,7 +361,7 @@ LOCAL(final_init):
|
||||
|
||||
setup_sectors:
|
||||
/* load logical sector start (top half) */
|
||||
movl kernel_sector + 4, %eax
|
||||
movl kernel_sector_high, %eax
|
||||
|
||||
orl %eax, %eax
|
||||
jnz LOCAL(geometry_error)
|
||||
@@ -505,7 +513,9 @@ LOCAL(message):
|
||||
#ifdef HYBRID_BOOT
|
||||
. = _start + 0x1b0
|
||||
kernel_sector:
|
||||
.long 1, 0
|
||||
.long 1
|
||||
kernel_sector_high:
|
||||
.long 0
|
||||
#endif
|
||||
. = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
|
||||
nt_magic:
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/boot.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
.extern __bss_start
|
||||
.extern _end
|
||||
.extern _edata
|
||||
|
||||
.globl __start, _start, start
|
||||
.set noreorder
|
||||
@@ -248,8 +249,9 @@ cmdlinedone:
|
||||
#include "../../kern/mips/cache_flush.S"
|
||||
|
||||
/* Decompress the payload. */
|
||||
lui $a0, %hi(__bss_start)
|
||||
addiu $a0, $a0, %lo(__bss_start)
|
||||
lui $a0, %hi(_edata)
|
||||
addiu $a0, $a0, %lo(_edata)
|
||||
|
||||
lui $t0, %hi(base)
|
||||
addiu $t0, $t0, %lo(base)
|
||||
subu $a0, $a0, $t0
|
||||
@@ -265,16 +267,16 @@ cmdlinedone:
|
||||
*/
|
||||
move $s6, $a3
|
||||
|
||||
lui $t0, %hi(EXT_C(grub_decompress_core))
|
||||
addiu $t0, $t0, %lo(EXT_C(grub_decompress_core))
|
||||
lui $t9, %hi(EXT_C(grub_decompress_core))
|
||||
addiu $t9, $t9, %lo(EXT_C(grub_decompress_core))
|
||||
|
||||
#ifdef GRUB_MACHINE_ARC
|
||||
lui $sp, %hi(_start - 512)
|
||||
jalr $t0
|
||||
jalr $t9
|
||||
addiu $sp, $sp, %lo(_start - 512)
|
||||
#else
|
||||
lui $sp, %hi(_start - 256)
|
||||
jalr $t0
|
||||
jalr $t9
|
||||
addiu $sp, $sp, %lo(_start - 256)
|
||||
#endif
|
||||
move $a0, $s1
|
||||
@@ -287,3 +289,11 @@ cmdlinedone:
|
||||
|
||||
jr $t1
|
||||
nop
|
||||
/* Ensure that .data section is created. In code we suppose that _edata
|
||||
is first location not in decompressor image. Strictly speaking it's
|
||||
_edata only when .data is present and _etext otherwise. But checking
|
||||
for .data presence would cost more in code than it is to ensure that
|
||||
.data is created.
|
||||
*/
|
||||
.data
|
||||
.long 0
|
||||
@@ -639,7 +639,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
|
||||
grub_size_t size;
|
||||
char *buf;
|
||||
|
||||
file = grub_file_open (args[i], GRUB_FILE_TYPE_ACPI_TABLE);
|
||||
file = grub_file_open (args[i]);
|
||||
if (! file)
|
||||
{
|
||||
free_tables ();
|
||||
|
||||
@@ -121,8 +121,8 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
|
||||
if (argc < 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
|
||||
|
||||
file = grub_file_open (args[0], GRUB_FILE_TYPE_PRINT_BLOCKLIST
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS);
|
||||
grub_file_filter_disable_compression ();
|
||||
file = grub_file_open (args[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
|
||||
|
||||
file = grub_file_open (args[0], GRUB_FILE_TYPE_CAT);
|
||||
file = grub_file_open (args[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
|
||||
grub_printf_ (N_("Compare file `%s' with `%s':\n"), args[0],
|
||||
args[1]);
|
||||
|
||||
file1 = grub_file_open (args[0], GRUB_FILE_TYPE_CMP);
|
||||
file2 = grub_file_open (args[1], GRUB_FILE_TYPE_CMP);
|
||||
file1 = grub_file_open (args[0]);
|
||||
file2 = grub_file_open (args[1]);
|
||||
if (! file1 || ! file2)
|
||||
goto cleanup;
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
file = grub_file_open (argv[1], GRUB_FILE_TYPE_VBE_DUMP);
|
||||
file = grub_file_open (argv[1]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
@@ -183,7 +183,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)),
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_VBE_DUMP);
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
|
||||
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
|
||||
|
||||
hashlist = grub_file_open (hashfilename, GRUB_FILE_TYPE_HASHLIST);
|
||||
hashlist = grub_file_open (hashfilename);
|
||||
if (!hashlist)
|
||||
return grub_errno;
|
||||
|
||||
@@ -141,15 +141,17 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
|
||||
filename = grub_xasprintf ("%s/%s", prefix, p);
|
||||
if (!filename)
|
||||
return grub_errno;
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_TO_HASH
|
||||
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
: 0));
|
||||
if (!uncompress)
|
||||
grub_file_filter_disable_compression ();
|
||||
file = grub_file_open (filename);
|
||||
grub_free (filename);
|
||||
}
|
||||
else
|
||||
file = grub_file_open (p, GRUB_FILE_TYPE_TO_HASH
|
||||
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
: 0));
|
||||
{
|
||||
if (!uncompress)
|
||||
grub_file_filter_disable_compression ();
|
||||
file = grub_file_open (p);
|
||||
}
|
||||
if (!file)
|
||||
{
|
||||
grub_file_close (hashlist);
|
||||
@@ -240,9 +242,9 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
|
||||
grub_file_t file;
|
||||
grub_err_t err;
|
||||
unsigned j;
|
||||
file = grub_file_open (args[i], GRUB_FILE_TYPE_TO_HASH
|
||||
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
: 0));
|
||||
if (!uncompress)
|
||||
grub_file_filter_disable_compression ();
|
||||
file = grub_file_open (args[i]);
|
||||
if (!file)
|
||||
{
|
||||
if (!keep)
|
||||
|
||||
@@ -90,7 +90,7 @@ grub_cmd_hexdump (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_file_t file;
|
||||
|
||||
file = grub_file_open (args[0], GRUB_FILE_TYPE_HEXCAT);
|
||||
file = grub_file_open (args[0]);
|
||||
if (! file)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ grub_cmd_nthibr (grub_command_t cmd __attribute__ ((unused)),
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
|
||||
|
||||
hibr_file = grub_file_open (args[0], GRUB_FILE_TYPE_FILE_ID);
|
||||
hibr_file = grub_file_open (args[0]);
|
||||
if (!hibr_file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
|
||||
grub_uint32_t tempo;
|
||||
grub_file_t file;
|
||||
|
||||
file = grub_file_open (args[0], GRUB_FILE_TYPE_AUDIO);
|
||||
file = grub_file_open (args[0]);
|
||||
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
@@ -218,7 +218,7 @@ grub_cmd_keymap (struct grub_command *cmd __attribute__ ((unused)),
|
||||
else
|
||||
filename = argv[0];
|
||||
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_KEYBOARD_LAYOUT);
|
||||
file = grub_file_open (filename);
|
||||
if (! file)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ legacy_file (const char *filename)
|
||||
if (!suffix)
|
||||
return grub_errno;
|
||||
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_CONFIG);
|
||||
file = grub_file_open (filename);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -44,8 +44,7 @@ static const struct grub_arg_option options[] =
|
||||
PUBKEY filter (that insists upon properly signed files) as well. PUBKEY
|
||||
filter is restored before the function returns. */
|
||||
static grub_file_t
|
||||
open_envblk_file (char *filename,
|
||||
enum grub_file_type type)
|
||||
open_envblk_file (char *filename, int untrusted)
|
||||
{
|
||||
grub_file_t file;
|
||||
char *buf = 0;
|
||||
@@ -73,7 +72,13 @@ open_envblk_file (char *filename,
|
||||
grub_strcpy (filename + len + 1, GRUB_ENVBLK_DEFCFG);
|
||||
}
|
||||
|
||||
file = grub_file_open (filename, type);
|
||||
/* The filters that are disabled will be re-enabled by the call to
|
||||
grub_file_open() after this particular file is opened. */
|
||||
grub_file_filter_disable_compression ();
|
||||
if (untrusted)
|
||||
grub_file_filter_disable_pubkey ();
|
||||
|
||||
file = grub_file_open (filename);
|
||||
|
||||
grub_free (buf);
|
||||
return file;
|
||||
@@ -166,10 +171,7 @@ grub_cmd_load_env (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
whitelist.list = args;
|
||||
|
||||
/* state[0] is the -f flag; state[1] is the --skip-sig flag */
|
||||
file = open_envblk_file ((state[0].set) ? state[0].arg : 0,
|
||||
GRUB_FILE_TYPE_LOADENV
|
||||
| (state[1].set
|
||||
? GRUB_FILE_TYPE_SKIP_SIGNATURE : 0));
|
||||
file = open_envblk_file ((state[0].set) ? state[0].arg : 0, state[1].set);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
@@ -204,10 +206,7 @@ grub_cmd_list_env (grub_extcmd_context_t ctxt,
|
||||
grub_file_t file;
|
||||
grub_envblk_t envblk;
|
||||
|
||||
file = open_envblk_file ((state[0].set) ? state[0].arg : 0,
|
||||
GRUB_FILE_TYPE_LOADENV
|
||||
| (state[1].set
|
||||
? GRUB_FILE_TYPE_SKIP_SIGNATURE : 0));
|
||||
file = open_envblk_file ((state[0].set) ? state[0].arg : 0, 0);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
@@ -400,8 +399,7 @@ grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no variable is specified");
|
||||
|
||||
file = open_envblk_file ((state[0].set) ? state[0].arg : 0,
|
||||
GRUB_FILE_TYPE_SAVEENV
|
||||
| GRUB_FILE_TYPE_SKIP_SIGNATURE);
|
||||
1 /* allow untrusted */);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -129,8 +129,8 @@ print_files_long (const char *filename, const struct grub_dirhook_info *info,
|
||||
|
||||
/* XXX: For ext2fs symlinks are detected as files while they
|
||||
should be reported as directories. */
|
||||
file = grub_file_open (pathname, GRUB_FILE_TYPE_GET_SIZE
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS);
|
||||
grub_file_filter_disable_compression ();
|
||||
file = grub_file_open (pathname);
|
||||
if (! file)
|
||||
{
|
||||
grub_errno = 0;
|
||||
@@ -225,8 +225,8 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
||||
struct grub_dirhook_info info;
|
||||
grub_errno = 0;
|
||||
|
||||
file = grub_file_open (dirname, GRUB_FILE_TYPE_GET_SIZE
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS);
|
||||
grub_file_filter_disable_compression ();
|
||||
file = grub_file_open (dirname);
|
||||
if (! file)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ grub_mini_cmd_cat (struct grub_command *cmd __attribute__ ((unused)),
|
||||
if (argc < 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_CAT);
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -234,8 +234,7 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
|
||||
if (! filename)
|
||||
goto fail;
|
||||
|
||||
file = grub_file_open (filename,
|
||||
GRUB_FILE_TYPE_GRUB_MODULE);
|
||||
file = grub_file_open (filename);
|
||||
grub_free (filename);
|
||||
if (! file)
|
||||
goto fail;
|
||||
|
||||
@@ -193,7 +193,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
||||
{
|
||||
grub_file_t file;
|
||||
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
|
||||
file = grub_file_open (filename);
|
||||
if (file)
|
||||
{
|
||||
char *buf = 0;
|
||||
|
||||
@@ -81,8 +81,8 @@ iterate_device (const char *name, void *data)
|
||||
if (! buf)
|
||||
return 1;
|
||||
|
||||
file = grub_file_open (buf, GRUB_FILE_TYPE_FS_SEARCH
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS);
|
||||
grub_file_filter_disable_compression ();
|
||||
file = grub_file_open (buf);
|
||||
if (file)
|
||||
{
|
||||
found = 1;
|
||||
|
||||
@@ -355,8 +355,8 @@ test_parse (char **args, int *argn, int argc)
|
||||
if (grub_strcmp (args[*argn], "-s") == 0)
|
||||
{
|
||||
grub_file_t file;
|
||||
file = grub_file_open (args[*argn + 1], GRUB_FILE_TYPE_GET_SIZE
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS);
|
||||
grub_file_filter_disable_compression ();
|
||||
file = grub_file_open (args[*argn + 1]);
|
||||
update_val (file && (grub_file_size (file) != 0), &ctx);
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
||||
@@ -57,7 +57,7 @@ grub_cmd_testload (struct grub_command *cmd __attribute__ ((unused)),
|
||||
if (argc < 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_TESTLOAD);
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ grub_cmd_testspeed (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
if (buffer == NULL)
|
||||
return grub_errno;
|
||||
|
||||
file = grub_file_open (args[0], GRUB_FILE_TYPE_TESTLOAD);
|
||||
file = grub_file_open (args[0]);
|
||||
if (file == NULL)
|
||||
goto quit;
|
||||
|
||||
|
||||
+30
-452
@@ -30,7 +30,6 @@
|
||||
#include <grub/env.h>
|
||||
#include <grub/kernel.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/efi/pe32.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
@@ -433,356 +432,6 @@ rsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
get (char *buf, grub_size_t size,
|
||||
grub_file_t f, void *out,
|
||||
grub_off_t off, grub_size_t sz)
|
||||
{
|
||||
if (buf)
|
||||
{
|
||||
if (off > ~(grub_uint32_t) sz
|
||||
|| off + sz > size)
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
grub_memcpy (out, buf + off, sz);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
if (grub_file_seek (f, off) == (grub_size_t) -1)
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
if (grub_file_read (f, out, sz) != (grub_ssize_t) sz)
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
read_len (char *buf, grub_size_t size,
|
||||
grub_file_t f, grub_off_t *curoff, grub_uint32_t *endoff)
|
||||
{
|
||||
grub_uint8_t cb;
|
||||
unsigned ss, rl;
|
||||
grub_uint32_t v = 0;
|
||||
grub_err_t err;
|
||||
|
||||
err = get (buf, size, f, &cb, (*curoff)++, 1);
|
||||
if (err)
|
||||
return err;
|
||||
if (!(cb & 0x80))
|
||||
{
|
||||
*endoff = *curoff + (cb & 0x7f);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
ss = cb & 0x7f;
|
||||
if (ss > 4)
|
||||
rl = 4;
|
||||
else
|
||||
rl = ss;
|
||||
*curoff += (ss - rl);
|
||||
err = get (buf, size, f, (char *) &v + (4 - rl), *curoff,
|
||||
rl);
|
||||
if (err)
|
||||
return err;
|
||||
*curoff += rl;
|
||||
*endoff = *curoff + (grub_be_to_cpu32 (v) & 0x7fffff);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
#define MAX_FULLASN 128
|
||||
|
||||
static grub_err_t
|
||||
grub_verify_pe_signature_real (char *buf, grub_size_t size,
|
||||
grub_file_t f,
|
||||
struct grub_public_key *pkey)
|
||||
{
|
||||
grub_uint8_t mz[2];
|
||||
const gcry_md_spec_t *hash;
|
||||
grub_uint32_t coff_offset, opt_offset;
|
||||
union
|
||||
{
|
||||
struct grub_pe32_optional_header o32;
|
||||
struct grub_pe64_optional_header o64;
|
||||
} opt_head;
|
||||
struct grub_pe32_data_directory *certtab;
|
||||
grub_err_t err;
|
||||
void *context = NULL;
|
||||
void *read_buf = NULL;
|
||||
grub_uint8_t *hval;
|
||||
grub_off_t curoff;
|
||||
grub_uint8_t cb;
|
||||
grub_uint8_t full_asn[MAX_FULLASN];
|
||||
/*
|
||||
hash as:
|
||||
offs[0] - offs[1]
|
||||
skip: checksum
|
||||
offs[2] - offs[3]
|
||||
skip: cert entry
|
||||
offs[4] - offs[5]
|
||||
skip: cert
|
||||
offs[6] - offs[7]
|
||||
*/
|
||||
grub_uint32_t offs[8];
|
||||
grub_uint32_t endoff[5];
|
||||
grub_uint32_t full_asn_offset, full_asn_offset_end;
|
||||
grub_size_t i;
|
||||
|
||||
err = get (buf, size, f, mz, 0, 2);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (mz[0] != 'M' || mz[1] != 'Z')
|
||||
goto fail;
|
||||
|
||||
err = get (buf, size, f, &coff_offset, 0x3c, 4);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
opt_offset = grub_cpu_to_le32 (coff_offset) + sizeof (struct grub_pe32_coff_header) + 4;
|
||||
|
||||
err = get (buf, size, f, &opt_head, opt_offset, sizeof (opt_head));
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
grub_dprintf ("crypt", "opt_offset = %x\n", (int) opt_offset);
|
||||
|
||||
if (opt_head.o32.magic == grub_cpu_to_le16_compile_time (GRUB_PE32_PE32_MAGIC))
|
||||
{
|
||||
offs[1] = (char *) &opt_head.o32.checksum - (char *) &opt_head + opt_offset;
|
||||
certtab = &opt_head.o32.certificate_table;
|
||||
}
|
||||
else if (opt_head.o64.magic == grub_cpu_to_le16_compile_time (GRUB_PE32_PE64_MAGIC))
|
||||
{
|
||||
offs[1] = (char *) &opt_head.o64.checksum - (char *) &opt_head + opt_offset;
|
||||
certtab = &opt_head.o64.certificate_table;
|
||||
}
|
||||
else
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
|
||||
if (certtab->size == 0)
|
||||
goto fail;
|
||||
|
||||
offs[0] = 0;
|
||||
offs[2] = offs[1] + 4;
|
||||
offs[3] = (char *) certtab - (char *) &opt_head + opt_offset;
|
||||
offs[4] = offs[3] + sizeof (*certtab);
|
||||
offs[5] = grub_le_to_cpu32 (certtab->rva);
|
||||
offs[6] = offs[5] + grub_le_to_cpu32 (certtab->size);
|
||||
offs[7] = buf ? size : grub_file_size (f);
|
||||
|
||||
/* Verify that offset sequence is valid. */
|
||||
for (i = 0; i < 7; i++)
|
||||
if (offs[i + 1] < offs[i])
|
||||
goto fail;
|
||||
|
||||
grub_dprintf ("crypt", "sig @%x+%x\n", (int)certtab->rva,
|
||||
(int)certtab->size);
|
||||
|
||||
|
||||
curoff = grub_le_to_cpu32 (certtab->rva) + 8;
|
||||
err = get (buf, size, f, &cb, curoff++, 1);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (cb != 0x30)
|
||||
goto fail;
|
||||
|
||||
/* into. */
|
||||
err = read_len (buf, size, f, &curoff, &endoff[0]);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = get (buf, size, f, &cb, curoff++, 1);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (cb != 0x06)
|
||||
goto fail;
|
||||
|
||||
/* skip. */
|
||||
err = read_len (buf, size, f, &curoff, &endoff[1]);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
curoff = endoff[1];
|
||||
|
||||
err = get (buf, size, f, &cb, curoff++, 1);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (cb != 0xa0)
|
||||
goto fail;
|
||||
|
||||
/* into. */
|
||||
err = read_len (buf, size, f, &curoff, &endoff[1]);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = get (buf, size, f, &cb, curoff++, 1);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (cb != 0x30)
|
||||
goto fail;
|
||||
|
||||
/* into. */
|
||||
err = read_len (buf, size, f, &curoff, &endoff[2]);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = get (buf, size, f, &cb, curoff++, 1);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (cb != 0x02)
|
||||
goto fail;
|
||||
|
||||
/* skip */
|
||||
err = read_len (buf, size, f, &curoff, &endoff[2]);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
curoff = endoff[2];
|
||||
|
||||
err = get (buf, size, f, &cb, curoff++, 1);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (cb != 0x31)
|
||||
goto fail;
|
||||
|
||||
err = get (buf, size, f, &cb, curoff++, 1);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (cb != 0x0f)
|
||||
goto fail;
|
||||
|
||||
err = read_len (buf, size, f, &curoff, &endoff[3]);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
curoff = endoff[3];
|
||||
|
||||
err = get (buf, size, f, &cb, curoff++, 1);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (cb != 0x03)
|
||||
goto fail;
|
||||
|
||||
err = read_len (buf, size, f, &curoff, &endoff[3]);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
curoff = endoff[3];
|
||||
|
||||
err = get (buf, size, f, &cb, curoff++, 1);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (cb != 0xa0)
|
||||
goto fail;
|
||||
|
||||
err = read_len (buf, size, f, &curoff, &endoff[3]);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
curoff = endoff[3];
|
||||
|
||||
grub_dprintf ("crypt", "off: %x\n",
|
||||
(int)curoff - grub_le_to_cpu32 (certtab->rva));
|
||||
|
||||
/* At this point we have the full ASN at current offset */
|
||||
full_asn_offset = curoff;
|
||||
err = get (buf, size, f, &cb, curoff++, 1);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (cb != 0x30)
|
||||
goto fail;
|
||||
|
||||
err = read_len (buf, size, f, &curoff, &endoff[3]);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
curoff = endoff[3];
|
||||
full_asn_offset_end = curoff;
|
||||
|
||||
grub_dprintf ("crypt", "off: %x\n",
|
||||
(int)full_asn_offset_end - grub_le_to_cpu32 (certtab->rva));
|
||||
|
||||
if (full_asn_offset_end - full_asn_offset > MAX_FULLASN)
|
||||
goto fail;
|
||||
|
||||
err = get (buf, size, f, full_asn, full_asn_offset,
|
||||
full_asn_offset_end - full_asn_offset);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
hash = grub_crypto_lookup_md_by_asn (full_asn,
|
||||
full_asn_offset_end - full_asn_offset);
|
||||
if (!hash)
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, "hash not loaded");
|
||||
|
||||
if (hash->asnlen + hash->mdlen != full_asn_offset_end - full_asn_offset)
|
||||
goto fail;
|
||||
|
||||
context = grub_zalloc (hash->contextsize);
|
||||
if (!context)
|
||||
goto fail;
|
||||
|
||||
hash->init (context);
|
||||
|
||||
if (buf)
|
||||
{
|
||||
for (i = 0; i <= 3; i++)
|
||||
hash->write (context, buf + offs[2 * i],
|
||||
offs[2 * i + 1] - offs[2 * i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
read_buf = grub_malloc (READBUF_SIZE);
|
||||
for (i = 0; i <= 3; i++)
|
||||
{
|
||||
grub_size_t rem;
|
||||
grub_ssize_t r;
|
||||
if (grub_file_seek (f, offs[2 * i]) == (grub_size_t) -1)
|
||||
goto fail;
|
||||
rem = offs[2 * i + 1] - offs[2 * i];
|
||||
COMPILE_TIME_ASSERT (sizeof (rem) >= sizeof (offs[0]));
|
||||
while (rem)
|
||||
{
|
||||
r = grub_file_read (f, read_buf,
|
||||
rem < READBUF_SIZE ? rem : READBUF_SIZE);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
if (r == 0)
|
||||
break;
|
||||
hash->write (context, read_buf, r);
|
||||
rem -= r;
|
||||
}
|
||||
if (rem)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
hash->final (context);
|
||||
hval = hash->read (context);
|
||||
|
||||
if (grub_memcmp (full_asn + hash->asnlen,
|
||||
hval, hash->mdlen) != 0)
|
||||
goto fail;
|
||||
for (i = 0; i < hash->mdlen; i++)
|
||||
grub_printf ("%02x ", hval[i]);
|
||||
grub_printf ("\n");
|
||||
|
||||
(void) pkey;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
fail:
|
||||
grub_free (context);
|
||||
grub_free (read_buf);
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_verify_signature_real (char *buf, grub_size_t size,
|
||||
grub_file_t f, grub_file_t sig,
|
||||
@@ -881,8 +530,6 @@ grub_verify_signature_real (char *buf, grub_size_t size,
|
||||
hash->write (context, readbuf, r);
|
||||
rem -= r;
|
||||
}
|
||||
if (rem)
|
||||
goto fail;
|
||||
hash->write (context, &v, sizeof (v));
|
||||
s = 0xff;
|
||||
hash->write (context, &s, sizeof (s));
|
||||
@@ -1020,12 +667,10 @@ grub_cmd_trust (grub_extcmd_context_t ctxt,
|
||||
if (argc < 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
|
||||
|
||||
pkf = grub_file_open (args[0],
|
||||
GRUB_FILE_TYPE_PUBLIC_KEY_TRUST
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
| (ctxt->state[OPTION_SKIP_SIG].set
|
||||
? GRUB_FILE_TYPE_SKIP_SIGNATURE
|
||||
: 0));
|
||||
grub_file_filter_disable_compression ();
|
||||
if (ctxt->state[OPTION_SKIP_SIG].set)
|
||||
grub_file_filter_disable_pubkey ();
|
||||
pkf = grub_file_open (args[0]);
|
||||
if (!pkf)
|
||||
return grub_errno;
|
||||
pk = grub_load_public_key (pkf);
|
||||
@@ -1113,12 +758,10 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
|
||||
if (argc > 2)
|
||||
{
|
||||
grub_file_t pkf;
|
||||
pkf = grub_file_open (args[2],
|
||||
GRUB_FILE_TYPE_PUBLIC_KEY
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
| (ctxt->state[OPTION_SKIP_SIG].set
|
||||
? GRUB_FILE_TYPE_SKIP_SIGNATURE
|
||||
: 0));
|
||||
grub_file_filter_disable_compression ();
|
||||
if (ctxt->state[OPTION_SKIP_SIG].set)
|
||||
grub_file_filter_disable_pubkey ();
|
||||
pkf = grub_file_open (args[2]);
|
||||
if (!pkf)
|
||||
return grub_errno;
|
||||
pk = grub_load_public_key (pkf);
|
||||
@@ -1130,16 +773,16 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
|
||||
grub_file_close (pkf);
|
||||
}
|
||||
|
||||
f = grub_file_open (args[0], GRUB_FILE_TYPE_VERIFY_SIGNATURE);
|
||||
grub_file_filter_disable_all ();
|
||||
f = grub_file_open (args[0]);
|
||||
if (!f)
|
||||
{
|
||||
err = grub_errno;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
sig = grub_file_open (args[1],
|
||||
GRUB_FILE_TYPE_SIGNATURE
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS);
|
||||
grub_file_filter_disable_all ();
|
||||
sig = grub_file_open (args[1]);
|
||||
if (!sig)
|
||||
{
|
||||
err = grub_errno;
|
||||
@@ -1157,57 +800,6 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
|
||||
return err;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_verify_pe_signature (grub_extcmd_context_t ctxt,
|
||||
int argc, char **args)
|
||||
{
|
||||
grub_file_t f = NULL;
|
||||
grub_err_t err = GRUB_ERR_NONE;
|
||||
struct grub_public_key *pk = NULL;
|
||||
|
||||
grub_dprintf ("crypt", "alive\n");
|
||||
|
||||
if (argc < 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
|
||||
|
||||
grub_dprintf ("crypt", "alive\n");
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
grub_file_t pkf;
|
||||
pkf = grub_file_open (args[1],
|
||||
GRUB_FILE_TYPE_PUBLIC_KEY
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
| (ctxt->state[OPTION_SKIP_SIG].set
|
||||
? GRUB_FILE_TYPE_SKIP_SIGNATURE
|
||||
: 0));
|
||||
if (!pkf)
|
||||
return grub_errno;
|
||||
pk = grub_load_public_key (pkf);
|
||||
if (!pk)
|
||||
{
|
||||
grub_file_close (pkf);
|
||||
return grub_errno;
|
||||
}
|
||||
grub_file_close (pkf);
|
||||
}
|
||||
|
||||
f = grub_file_open (args[0], GRUB_FILE_TYPE_VERIFY_SIGNATURE);
|
||||
if (!f)
|
||||
{
|
||||
err = grub_errno;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
err = grub_verify_pe_signature_real (0, 0, f, pk);
|
||||
fail:
|
||||
if (f)
|
||||
grub_file_close (f);
|
||||
if (pk)
|
||||
free_pk (pk);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int sec = 0;
|
||||
|
||||
static grub_ssize_t
|
||||
@@ -1233,25 +825,33 @@ struct grub_fs verified_fs =
|
||||
};
|
||||
|
||||
static grub_file_t
|
||||
grub_pubkey_open (grub_file_t io, enum grub_file_type type)
|
||||
grub_pubkey_open (grub_file_t io, const char *filename)
|
||||
{
|
||||
grub_file_t sig;
|
||||
char *fsuf, *ptr;
|
||||
grub_err_t err;
|
||||
grub_file_filter_t curfilt[GRUB_FILE_FILTER_MAX];
|
||||
grub_file_t ret;
|
||||
|
||||
if ((type & GRUB_FILE_TYPE_MASK) == GRUB_FILE_TYPE_SIGNATURE
|
||||
|| (type & GRUB_FILE_TYPE_MASK) == GRUB_FILE_TYPE_VERIFY_SIGNATURE
|
||||
|| (type & GRUB_FILE_TYPE_SKIP_SIGNATURE))
|
||||
return io;
|
||||
|
||||
if (!sec)
|
||||
return io;
|
||||
if (io->device->disk && io->device->disk->id == GRUB_DISK_DEVICE_MEMDISK_ID)
|
||||
return io;
|
||||
fsuf = grub_malloc (grub_strlen (io->name) + sizeof (".sig"));
|
||||
fsuf = grub_malloc (grub_strlen (filename) + sizeof (".sig"));
|
||||
if (!fsuf)
|
||||
return NULL;
|
||||
ptr = grub_stpcpy (fsuf, filename);
|
||||
grub_memcpy (ptr, ".sig", sizeof (".sig"));
|
||||
|
||||
grub_memcpy (curfilt, grub_file_filters_enabled,
|
||||
sizeof (curfilt));
|
||||
grub_file_filter_disable_all ();
|
||||
sig = grub_file_open (fsuf);
|
||||
grub_memcpy (grub_file_filters_enabled, curfilt,
|
||||
sizeof (curfilt));
|
||||
grub_free (fsuf);
|
||||
if (!sig)
|
||||
return NULL;
|
||||
|
||||
ret = grub_malloc (sizeof (*ret));
|
||||
if (!ret)
|
||||
@@ -1276,30 +876,12 @@ grub_pubkey_open (grub_file_t io, enum grub_file_type type)
|
||||
{
|
||||
if (!grub_errno)
|
||||
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
|
||||
io->name);
|
||||
filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptr = grub_stpcpy (fsuf, io->name);
|
||||
grub_memcpy (ptr, ".sig", sizeof (".sig"));
|
||||
|
||||
sig = grub_file_open (fsuf, GRUB_FILE_TYPE_SIGNATURE);
|
||||
grub_free (fsuf);
|
||||
if (!sig)
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
if (sig)
|
||||
{
|
||||
err = grub_verify_signature_real (ret->data, ret->size, 0, sig, NULL);
|
||||
grub_file_close (sig);
|
||||
if (err == GRUB_ERR_BAD_SIGNATURE)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
err = grub_verify_pe_signature_real (ret->data, ret->size, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
err = grub_verify_pe_signature_real (ret->data, ret->size, 0, 0);
|
||||
err = grub_verify_signature_real (ret->data, ret->size, 0, sig, NULL);
|
||||
grub_file_close (sig);
|
||||
if (err)
|
||||
return NULL;
|
||||
io->device = 0;
|
||||
@@ -1381,10 +963,6 @@ GRUB_MOD_INIT(verify)
|
||||
N_("[-s|--skip-sig] FILE SIGNATURE_FILE [PUBKEY_FILE]"),
|
||||
N_("Verify detached signature."),
|
||||
options);
|
||||
cmd = grub_register_extcmd ("verify_pe", grub_cmd_verify_pe_signature, 0,
|
||||
N_("[-s|--skip-sig] FILE [PUBKEY_FILE]"),
|
||||
N_("Verify PE signature."),
|
||||
options);
|
||||
cmd_trust = grub_register_extcmd ("trust", grub_cmd_trust, 0,
|
||||
N_("[-s|--skip-sig] PUBKEY_FILE"),
|
||||
N_("Add PKFILE to trusted keys."),
|
||||
|
||||
@@ -426,6 +426,10 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
|
||||
disk->total_sectors = total_sectors;
|
||||
/* Limit the max to 0x7f because of Phoenix EDD. */
|
||||
disk->max_agglomerate = 0x7f >> GRUB_DISK_CACHE_BITS;
|
||||
COMPILE_TIME_ASSERT ((0x7f >> GRUB_DISK_CACHE_BITS
|
||||
<< (GRUB_DISK_SECTOR_BITS + GRUB_DISK_CACHE_BITS))
|
||||
+ sizeof (struct grub_biosdisk_dap)
|
||||
< GRUB_MEMORY_MACHINE_SCRATCH_SIZE);
|
||||
|
||||
disk->data = data;
|
||||
|
||||
|
||||
@@ -90,8 +90,7 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
if (argc < 2)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
|
||||
|
||||
file = grub_file_open (args[1], GRUB_FILE_TYPE_LOOPBACK
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS);
|
||||
file = grub_file_open (args[1]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -418,7 +418,7 @@ grub_font_load (const char *filename)
|
||||
#endif
|
||||
|
||||
if (filename[0] == '(' || filename[0] == '/' || filename[0] == '+')
|
||||
file = grub_buffile_open (filename, GRUB_FILE_TYPE_FONT, 1024);
|
||||
file = grub_buffile_open (filename, 1024);
|
||||
else
|
||||
{
|
||||
const char *prefix = grub_env_get ("prefix");
|
||||
@@ -438,7 +438,7 @@ grub_font_load (const char *filename)
|
||||
ptr = grub_stpcpy (ptr, filename);
|
||||
ptr = grub_stpcpy (ptr, ".pf2");
|
||||
*ptr = 0;
|
||||
file = grub_buffile_open (fullname, GRUB_FILE_TYPE_FONT, 1024);
|
||||
file = grub_buffile_open (fullname, 1024);
|
||||
grub_free (fullname);
|
||||
}
|
||||
if (!file)
|
||||
|
||||
@@ -418,7 +418,7 @@ grub_cmd_zfs_key (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
if (argc > 0)
|
||||
{
|
||||
grub_file_t file;
|
||||
file = grub_file_open (args[0], GRUB_FILE_TYPE_ZFS_ENCRYPTION_KEY);
|
||||
file = grub_file_open (args[0]);
|
||||
if (!file)
|
||||
return grub_errno;
|
||||
real_size = grub_file_read (file, buf, 1024);
|
||||
|
||||
@@ -71,11 +71,7 @@ VARIABLE(grub_gdb_stack)
|
||||
#define REG \reg
|
||||
#define NDX \ndx
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
xorl %eax, %eax
|
||||
#else
|
||||
movl $0, %eax
|
||||
#endif
|
||||
movw REG, EXT_C(grub_gdb_regs)+(NDX * 4)
|
||||
movw %ax, EXT_C(grub_gdb_regs)+(NDX * 4 + 2)
|
||||
movl EXT_C(grub_gdb_regs)+(EAX * 4), %eax
|
||||
@@ -190,11 +186,7 @@ VARIABLE(grub_gdb_stack)
|
||||
.text
|
||||
1:
|
||||
.if EC
|
||||
#ifdef __APPLE__
|
||||
add $$4, %esp
|
||||
#else
|
||||
add $4, %esp
|
||||
#endif
|
||||
add MACRO_DOLLAR(4), %esp
|
||||
.endif
|
||||
|
||||
save_context
|
||||
|
||||
@@ -23,7 +23,7 @@ BEGIN {
|
||||
} else if ($1 == "undefined") {
|
||||
if ($3 in symtab)
|
||||
modtab[$2] = modtab[$2] " " symtab[$3];
|
||||
else if ($3 != "__gnu_local_gp") {
|
||||
else if ($3 != "__gnu_local_gp" && $3 != "_gp_disp") {
|
||||
printf "%s in %s is not defined\n", $3, $2 >"/dev/stderr";
|
||||
error++;
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ grub_mofile_open (struct grub_gettext_context *ctx,
|
||||
/* Using fd_mo and not another variable because
|
||||
it's needed for grub_gettext_get_info. */
|
||||
|
||||
fd = grub_file_open (filename, GRUB_FILE_TYPE_GETTEXT_CATALOG);
|
||||
fd = grub_file_open (filename);
|
||||
|
||||
if (!fd)
|
||||
return grub_errno;
|
||||
|
||||
@@ -743,7 +743,7 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
||||
p.view = view;
|
||||
p.theme_dir = grub_get_dirname (theme_path);
|
||||
|
||||
file = grub_file_open (theme_path, GRUB_FILE_TYPE_THEME);
|
||||
file = grub_file_open (theme_path);
|
||||
if (! file)
|
||||
{
|
||||
grub_free (p.theme_dir);
|
||||
|
||||
@@ -43,8 +43,7 @@ typedef struct grub_bufio *grub_bufio_t;
|
||||
static struct grub_fs grub_bufio_fs;
|
||||
|
||||
grub_file_t
|
||||
grub_bufio_open (grub_file_t io,
|
||||
grub_size_t size)
|
||||
grub_bufio_open (grub_file_t io, int size)
|
||||
{
|
||||
grub_file_t file;
|
||||
grub_bufio_t bufio = 0;
|
||||
@@ -58,7 +57,7 @@ grub_bufio_open (grub_file_t io,
|
||||
else if (size > GRUB_BUFIO_MAX_SIZE)
|
||||
size = GRUB_BUFIO_MAX_SIZE;
|
||||
|
||||
if (size > io->size)
|
||||
if ((size < 0) || ((unsigned) size > io->size))
|
||||
size = ((io->size > GRUB_BUFIO_MAX_SIZE) ? GRUB_BUFIO_MAX_SIZE :
|
||||
io->size);
|
||||
|
||||
@@ -82,12 +81,11 @@ grub_bufio_open (grub_file_t io,
|
||||
}
|
||||
|
||||
grub_file_t
|
||||
grub_buffile_open (const char *name, enum grub_file_type type,
|
||||
grub_size_t size)
|
||||
grub_buffile_open (const char *name, int size)
|
||||
{
|
||||
grub_file_t io, file;
|
||||
|
||||
io = grub_file_open (name, type);
|
||||
io = grub_file_open (name);
|
||||
if (! io)
|
||||
return 0;
|
||||
|
||||
|
||||
+1
-4
@@ -1125,14 +1125,11 @@ initialize_tables (grub_gzio_t gzio)
|
||||
even if IO does not contain data compressed by gzip, return a valid file
|
||||
object. Note that this function won't close IO, even if an error occurs. */
|
||||
static grub_file_t
|
||||
grub_gzio_open (grub_file_t io, enum grub_file_type type)
|
||||
grub_gzio_open (grub_file_t io, const char *name __attribute__ ((unused)))
|
||||
{
|
||||
grub_file_t file;
|
||||
grub_gzio_t gzio = 0;
|
||||
|
||||
if (type & GRUB_FILE_TYPE_NO_DECOMPRESS)
|
||||
return io;
|
||||
|
||||
file = (grub_file_t) grub_zalloc (sizeof (*file));
|
||||
if (! file)
|
||||
return 0;
|
||||
|
||||
@@ -409,14 +409,12 @@ CORRUPTED:
|
||||
}
|
||||
|
||||
static grub_file_t
|
||||
grub_lzopio_open (grub_file_t io, enum grub_file_type type)
|
||||
grub_lzopio_open (grub_file_t io,
|
||||
const char *name __attribute__ ((unused)))
|
||||
{
|
||||
grub_file_t file;
|
||||
grub_lzopio_t lzopio;
|
||||
|
||||
if (type & GRUB_FILE_TYPE_NO_DECOMPRESS)
|
||||
return io;
|
||||
|
||||
file = (grub_file_t) grub_zalloc (sizeof (*file));
|
||||
if (!file)
|
||||
return 0;
|
||||
|
||||
@@ -69,8 +69,7 @@ grub_file_offset_close (grub_file_t file)
|
||||
}
|
||||
|
||||
grub_file_t
|
||||
grub_file_offset_open (grub_file_t parent, enum grub_file_type type,
|
||||
grub_off_t start, grub_off_t size)
|
||||
grub_file_offset_open (grub_file_t parent, grub_off_t start, grub_off_t size)
|
||||
{
|
||||
struct grub_offset_file *off_data;
|
||||
grub_file_t off_file, last_off_file;
|
||||
@@ -96,10 +95,10 @@ grub_file_offset_open (grub_file_t parent, enum grub_file_type type,
|
||||
last_off_file = NULL;
|
||||
for (filter = GRUB_FILE_FILTER_COMPRESSION_FIRST;
|
||||
off_file && filter <= GRUB_FILE_FILTER_COMPRESSION_LAST; filter++)
|
||||
if (grub_file_filters[filter])
|
||||
if (grub_file_filters_enabled[filter])
|
||||
{
|
||||
last_off_file = off_file;
|
||||
off_file = grub_file_filters[filter] (off_file, type);
|
||||
off_file = grub_file_filters_enabled[filter] (off_file, parent->name);
|
||||
}
|
||||
|
||||
if (!off_file)
|
||||
|
||||
+2
-4
@@ -169,14 +169,12 @@ ERROR:
|
||||
}
|
||||
|
||||
static grub_file_t
|
||||
grub_xzio_open (grub_file_t io, enum grub_file_type type)
|
||||
grub_xzio_open (grub_file_t io,
|
||||
const char *name __attribute__ ((unused)))
|
||||
{
|
||||
grub_file_t file;
|
||||
grub_xzio_t xzio;
|
||||
|
||||
if (type & GRUB_FILE_TYPE_NO_DECOMPRESS)
|
||||
return io;
|
||||
|
||||
file = (grub_file_t) grub_zalloc (sizeof (*file));
|
||||
if (!file)
|
||||
return 0;
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 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 <grub/cache.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
static grub_int64_t dlinesz;
|
||||
static grub_int64_t ilinesz;
|
||||
|
||||
/* Prototypes for asm functions. */
|
||||
void grub_arch_clean_dcache_range (grub_addr_t beg, grub_addr_t end,
|
||||
grub_uint64_t line_size);
|
||||
void grub_arch_invalidate_icache_range (grub_addr_t beg, grub_addr_t end,
|
||||
grub_uint64_t line_size);
|
||||
|
||||
static void
|
||||
probe_caches (void)
|
||||
{
|
||||
grub_uint64_t cache_type;
|
||||
|
||||
/* Read Cache Type Register */
|
||||
asm volatile ("mrs %0, ctr_el0": "=r"(cache_type));
|
||||
|
||||
dlinesz = 4 << ((cache_type >> 16) & 0xf);
|
||||
ilinesz = 4 << (cache_type & 0xf);
|
||||
|
||||
grub_dprintf("cache", "D$ line size: %lld\n", (long long) dlinesz);
|
||||
grub_dprintf("cache", "I$ line size: %lld\n", (long long) ilinesz);
|
||||
}
|
||||
|
||||
void
|
||||
grub_arch_sync_caches (void *address, grub_size_t len)
|
||||
{
|
||||
grub_uint64_t start, end, max_align;
|
||||
|
||||
if (dlinesz == 0)
|
||||
probe_caches();
|
||||
if (dlinesz == 0)
|
||||
grub_fatal ("Unknown cache line size!");
|
||||
|
||||
max_align = dlinesz > ilinesz ? dlinesz : ilinesz;
|
||||
|
||||
start = ALIGN_DOWN ((grub_uint64_t) address, max_align);
|
||||
end = ALIGN_UP ((grub_uint64_t) address + len, max_align);
|
||||
|
||||
grub_arch_clean_dcache_range (start, end, dlinesz);
|
||||
grub_arch_invalidate_icache_range (start, end, ilinesz);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 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 <grub/symbol.h>
|
||||
|
||||
.file "cache_flush.S"
|
||||
.text
|
||||
|
||||
/*
|
||||
* Simple cache maintenance functions
|
||||
*/
|
||||
|
||||
// x0 - *beg (inclusive)
|
||||
// x1 - *end (exclusive)
|
||||
// x2 - line size
|
||||
FUNCTION(grub_arch_clean_dcache_range)
|
||||
// Clean data cache for range to point-of-unification
|
||||
1: cmp x0, x1
|
||||
b.ge 2f
|
||||
dc cvau, x0 // Clean Virtual Address to PoU
|
||||
add x0, x0, x2 // Next line
|
||||
b 1b
|
||||
2: dsb ish
|
||||
isb
|
||||
ret
|
||||
|
||||
// x0 - *beg (inclusive)
|
||||
// x1 - *end (exclusive)
|
||||
// x2 - line size
|
||||
FUNCTION(grub_arch_invalidate_icache_range)
|
||||
// Invalidate instruction cache for range to point-of-unification
|
||||
1: cmp x0, x1
|
||||
b.ge 2f
|
||||
ic ivau, x0 // Invalidate Virtual Address to PoU
|
||||
add x0, x0, x2 // Next line
|
||||
b 1b
|
||||
// Branch predictor invalidation not needed on AArch64
|
||||
2: dsb ish
|
||||
isb
|
||||
ret
|
||||
@@ -0,0 +1,199 @@
|
||||
/* dl.c - arch-dependent part of loadable module support */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 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 <grub/dl.h>
|
||||
#include <grub/elf.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/cpu/reloc.h>
|
||||
|
||||
/*
|
||||
* Check if EHDR is a valid ELF header.
|
||||
*/
|
||||
grub_err_t
|
||||
grub_arch_dl_check_header (void *ehdr)
|
||||
{
|
||||
Elf_Ehdr *e = ehdr;
|
||||
|
||||
/* Check the magic numbers. */
|
||||
if (e->e_ident[EI_CLASS] != ELFCLASS64
|
||||
|| e->e_ident[EI_DATA] != ELFDATA2LSB || e->e_machine != EM_AARCH64)
|
||||
return grub_error (GRUB_ERR_BAD_OS,
|
||||
N_("invalid arch-dependent ELF magic"));
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unified function for both REL and RELA
|
||||
*/
|
||||
static grub_err_t
|
||||
do_relX (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod)
|
||||
{
|
||||
grub_err_t retval;
|
||||
grub_dl_segment_t segment;
|
||||
Elf_Rel *rel;
|
||||
Elf_Rela *rela;
|
||||
Elf_Sym *symbol;
|
||||
int i, entnum;
|
||||
unsigned long long entsize;
|
||||
|
||||
/* Find the target segment for this relocation section. */
|
||||
for (segment = mod->segment ; segment != 0 ; segment = segment->next)
|
||||
if (segment->section == relhdr->sh_info)
|
||||
break;
|
||||
if (!segment)
|
||||
return grub_error (GRUB_ERR_EOF, N_("relocation segment not found"));
|
||||
|
||||
rel = (Elf_Rel *) ((grub_addr_t) e + relhdr->sh_offset);
|
||||
rela = (Elf_Rela *) rel;
|
||||
if (relhdr->sh_type == SHT_RELA)
|
||||
entsize = sizeof (Elf_Rela);
|
||||
else
|
||||
entsize = sizeof (Elf_Rel);
|
||||
|
||||
entnum = relhdr->sh_size / entsize;
|
||||
retval = GRUB_ERR_NONE;
|
||||
|
||||
grub_dprintf("dl", "Processing %d relocation entries.\n", entnum);
|
||||
|
||||
/* Step through all relocations */
|
||||
for (i = 0, symbol = mod->symtab; i < entnum; i++)
|
||||
{
|
||||
void *place;
|
||||
grub_uint64_t sym_addr, symidx, reltype;
|
||||
|
||||
if (rel->r_offset >= segment->size)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"reloc offset is out of the segment");
|
||||
|
||||
symidx = ELF_R_SYM (rel->r_info);
|
||||
reltype = ELF_R_TYPE (rel->r_info);
|
||||
|
||||
sym_addr = symbol[symidx].st_value;
|
||||
if (relhdr->sh_type == SHT_RELA)
|
||||
sym_addr += rela->r_addend;
|
||||
|
||||
place = (void *) ((grub_addr_t) segment->addr + rel->r_offset);
|
||||
|
||||
switch (reltype)
|
||||
{
|
||||
case R_AARCH64_ABS64:
|
||||
{
|
||||
grub_uint64_t *abs_place = place;
|
||||
|
||||
grub_dprintf ("dl", " reloc_abs64 %p => 0x%016llx\n",
|
||||
place, (unsigned long long) sym_addr);
|
||||
|
||||
*abs_place = (grub_uint64_t) sym_addr;
|
||||
}
|
||||
break;
|
||||
case R_AARCH64_CALL26:
|
||||
case R_AARCH64_JUMP26:
|
||||
retval = grub_arm64_reloc_xxxx26 (place, sym_addr);
|
||||
break;
|
||||
default:
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
N_("relocation 0x%x is not implemented yet"),
|
||||
reltype);
|
||||
}
|
||||
|
||||
if (retval != GRUB_ERR_NONE)
|
||||
break;
|
||||
|
||||
rel = (Elf_Rel *) ((grub_addr_t) rel + entsize);
|
||||
rela++;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that provided ELF header contains reference to a symbol table
|
||||
*/
|
||||
static int
|
||||
has_symtab (Elf_Ehdr * e)
|
||||
{
|
||||
int i;
|
||||
Elf_Shdr *s;
|
||||
|
||||
for (i = 0, s = (Elf_Shdr *) ((grub_addr_t) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (Elf_Shdr *) ((grub_addr_t) s + e->e_shentsize))
|
||||
if (s->sh_type == SHT_SYMTAB)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* grub_arch_dl_relocate_symbols():
|
||||
* Locates the relocations section of the ELF object, and calls
|
||||
* do_relX() to deal with it.
|
||||
*/
|
||||
grub_err_t
|
||||
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
{
|
||||
Elf_Ehdr *e = ehdr;
|
||||
Elf_Shdr *s;
|
||||
unsigned i;
|
||||
|
||||
if (!has_symtab (e))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
|
||||
|
||||
#define FIRST_SHDR(x) ((Elf_Shdr *) ((grub_addr_t)(x) + (x)->e_shoff))
|
||||
#define NEXT_SHDR(x, y) ((Elf_Shdr *) ((grub_addr_t)(y) + (x)->e_shentsize))
|
||||
|
||||
for (i = 0, s = FIRST_SHDR (e); i < e->e_shnum; i++, s = NEXT_SHDR (e, s))
|
||||
{
|
||||
grub_err_t ret;
|
||||
|
||||
switch (s->sh_type)
|
||||
{
|
||||
case SHT_REL:
|
||||
case SHT_RELA:
|
||||
{
|
||||
ret = do_relX (s, e, mod);
|
||||
if (ret != GRUB_ERR_NONE)
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
case SHT_ARM_ATTRIBUTES:
|
||||
case SHT_NOBITS:
|
||||
case SHT_NULL:
|
||||
case SHT_PROGBITS:
|
||||
case SHT_SYMTAB:
|
||||
case SHT_STRTAB:
|
||||
break;
|
||||
default:
|
||||
{
|
||||
grub_dprintf ("dl", "unhandled section_type: %d (0x%08x)\n",
|
||||
s->sh_type, s->sh_type);
|
||||
return GRUB_ERR_NOT_IMPLEMENTED_YET;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#undef FIRST_SHDR
|
||||
#undef NEXT_SHDR
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/* dl_helper.c - relocation helper functions for modules and grub-mkimage */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 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 <grub/dl.h>
|
||||
#include <grub/elf.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/cpu/reloc.h>
|
||||
|
||||
static grub_ssize_t
|
||||
sign_compress_offset (grub_ssize_t offset, int bitpos)
|
||||
{
|
||||
return offset & ((1LL << (bitpos + 1)) - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* grub_arm64_reloc_xxxx26():
|
||||
*
|
||||
* JUMP26/CALL26 relocations for B and BL instructions.
|
||||
*/
|
||||
|
||||
grub_err_t
|
||||
grub_arm64_reloc_xxxx26 (grub_uint32_t *place, Elf64_Addr adjust)
|
||||
{
|
||||
grub_uint32_t insword, insmask;
|
||||
grub_ssize_t offset;
|
||||
const grub_ssize_t offset_low = -(1 << 27), offset_high = (1 << 27) - 1;
|
||||
|
||||
insword = grub_le_to_cpu32 (*place);
|
||||
insmask = 0xfc000000;
|
||||
|
||||
offset = adjust;
|
||||
#ifndef GRUB_UTIL
|
||||
offset -= (grub_addr_t) place;
|
||||
#endif
|
||||
|
||||
if ((offset < offset_low) || (offset > offset_high))
|
||||
{
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
N_("CALL26 Relocation out of range"));
|
||||
}
|
||||
|
||||
grub_dprintf ("dl", " reloc_xxxx64 %p %c= 0x%llx\n",
|
||||
place, offset > 0 ? '+' : '-',
|
||||
offset < 0 ? (long long) -(unsigned long long) offset : offset);
|
||||
|
||||
offset = sign_compress_offset (offset, 27) >> 2;
|
||||
|
||||
*place = grub_cpu_to_le32 ((insword & insmask) | offset);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 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 <grub/symbol.h>
|
||||
|
||||
.file "startup.S"
|
||||
.text
|
||||
FUNCTION(_start)
|
||||
/*
|
||||
* EFI_SYSTEM_TABLE and EFI_HANDLE are passed in x1/x0.
|
||||
*/
|
||||
ldr x2, efi_image_handle_val
|
||||
str x0, [x2]
|
||||
ldr x2, efi_system_table_val
|
||||
str x1, [x2]
|
||||
ldr x2, grub_main_val
|
||||
br x2
|
||||
grub_main_val:
|
||||
.quad EXT_C(grub_main)
|
||||
efi_system_table_val:
|
||||
.quad EXT_C(grub_efi_system_table)
|
||||
efi_image_handle_val:
|
||||
.quad EXT_C(grub_efi_image_handle)
|
||||
|
||||
+8
-7
@@ -229,9 +229,10 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
|
||||
unsigned i;
|
||||
Elf_Shdr *s;
|
||||
grub_size_t tsize = 0, talign = 1;
|
||||
#if defined (__ia64__) || defined (__powerpc__)
|
||||
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__)
|
||||
grub_size_t tramp;
|
||||
grub_size_t got;
|
||||
grub_err_t err;
|
||||
#endif
|
||||
char *ptr;
|
||||
|
||||
@@ -244,10 +245,10 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
|
||||
talign = s->sh_addralign;
|
||||
}
|
||||
|
||||
#if defined (__ia64__) || defined (__powerpc__)
|
||||
grub_arch_dl_get_tramp_got_size (e, &tramp, &got);
|
||||
tramp *= GRUB_ARCH_DL_TRAMP_SIZE;
|
||||
got *= sizeof (grub_uint64_t);
|
||||
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__)
|
||||
err = grub_arch_dl_get_tramp_got_size (e, &tramp, &got);
|
||||
if (err)
|
||||
return err;
|
||||
tsize += ALIGN_UP (tramp, GRUB_ARCH_DL_TRAMP_ALIGN);
|
||||
if (talign < GRUB_ARCH_DL_TRAMP_ALIGN)
|
||||
talign = GRUB_ARCH_DL_TRAMP_ALIGN;
|
||||
@@ -313,7 +314,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
|
||||
mod->segment = seg;
|
||||
}
|
||||
}
|
||||
#if defined (__ia64__) || defined (__powerpc__)
|
||||
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__)
|
||||
ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN);
|
||||
mod->tramp = ptr;
|
||||
ptr += tramp;
|
||||
@@ -653,7 +654,7 @@ grub_dl_load_file (const char *filename)
|
||||
void *core = 0;
|
||||
grub_dl_t mod = 0;
|
||||
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE);
|
||||
file = grub_file_open (filename);
|
||||
if (! file)
|
||||
return 0;
|
||||
|
||||
|
||||
+12
-6
@@ -32,6 +32,12 @@
|
||||
#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12)
|
||||
#define PAGES_TO_BYTES(pages) ((pages) << 12)
|
||||
|
||||
#if defined (__code_model_large__) || !defined (__x86_64__)
|
||||
#define MAX_USABLE_ADDRESS 0xffffffff
|
||||
#else
|
||||
#define MAX_USABLE_ADDRESS 0x7fffffff
|
||||
#endif
|
||||
|
||||
/* The size of a memory map obtained from the firmware. This must be
|
||||
a multiplier of 4KB. */
|
||||
#define MEMORY_MAP_SIZE 0x3000
|
||||
@@ -58,7 +64,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
|
||||
|
||||
#if 1
|
||||
/* Limit the memory access to less than 4GB for 32-bit platforms. */
|
||||
if (address > 0xffffffff)
|
||||
if (address > MAX_USABLE_ADDRESS)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
@@ -66,7 +72,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
|
||||
if (address == 0)
|
||||
{
|
||||
type = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
|
||||
address = 0xffffffff;
|
||||
address = MAX_USABLE_ADDRESS;
|
||||
}
|
||||
else
|
||||
type = GRUB_EFI_ALLOCATE_ADDRESS;
|
||||
@@ -86,7 +92,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
|
||||
{
|
||||
/* Uggh, the address 0 was allocated... This is too annoying,
|
||||
so reallocate another one. */
|
||||
address = 0xffffffff;
|
||||
address = MAX_USABLE_ADDRESS;
|
||||
status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address);
|
||||
grub_efi_free_pages (0, pages);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
@@ -319,7 +325,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
||||
{
|
||||
if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
|
||||
#if 1
|
||||
&& desc->physical_start <= 0xffffffff
|
||||
&& desc->physical_start <= MAX_USABLE_ADDRESS
|
||||
#endif
|
||||
&& desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
|
||||
&& desc->num_pages != 0)
|
||||
@@ -337,9 +343,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
||||
#if 1
|
||||
if (BYTES_TO_PAGES (filtered_desc->physical_start)
|
||||
+ filtered_desc->num_pages
|
||||
> BYTES_TO_PAGES (0x100000000LL))
|
||||
> BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL))
|
||||
filtered_desc->num_pages
|
||||
= (BYTES_TO_PAGES (0x100000000LL)
|
||||
= (BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL)
|
||||
- BYTES_TO_PAGES (filtered_desc->physical_start));
|
||||
#endif
|
||||
|
||||
|
||||
@@ -100,12 +100,12 @@ fail:
|
||||
}
|
||||
|
||||
grub_elf_t
|
||||
grub_elf_open (const char *name, enum grub_file_type type)
|
||||
grub_elf_open (const char *name)
|
||||
{
|
||||
grub_file_t file;
|
||||
grub_elf_t elf;
|
||||
|
||||
file = grub_file_open (name, type);
|
||||
file = grub_file_open (name);
|
||||
if (! file)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
return GRUB_ERR_BAD_MODULE;
|
||||
}
|
||||
|
||||
#if defined (__ia64__) || defined (__powerpc__)
|
||||
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__)
|
||||
void grub_arch_dl_get_tramp_got_size (const void *ehdr __attribute__ ((unused)),
|
||||
grub_size_t *tramp, grub_size_t *got)
|
||||
{
|
||||
|
||||
+12
-10
@@ -28,7 +28,8 @@
|
||||
|
||||
void (*EXPORT_VAR (grub_grubnet_fini)) (void);
|
||||
|
||||
grub_file_filter_t grub_file_filters[GRUB_FILE_FILTER_MAX];
|
||||
grub_file_filter_t grub_file_filters_all[GRUB_FILE_FILTER_MAX];
|
||||
grub_file_filter_t grub_file_filters_enabled[GRUB_FILE_FILTER_MAX];
|
||||
|
||||
/* Get the device part of the filename NAME. It is enclosed by parentheses. */
|
||||
char *
|
||||
@@ -58,7 +59,7 @@ grub_file_get_device_name (const char *name)
|
||||
}
|
||||
|
||||
grub_file_t
|
||||
grub_file_open (const char *name, enum grub_file_type type)
|
||||
grub_file_open (const char *name)
|
||||
{
|
||||
grub_device_t device = 0;
|
||||
grub_file_t file = 0, last_file = 0;
|
||||
@@ -104,20 +105,18 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
file->name = grub_strdup (name);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
for (filter = 0; file && filter < ARRAY_SIZE (grub_file_filters);
|
||||
for (filter = 0; file && filter < ARRAY_SIZE (grub_file_filters_enabled);
|
||||
filter++)
|
||||
if (grub_file_filters[filter])
|
||||
if (grub_file_filters_enabled[filter])
|
||||
{
|
||||
last_file = file;
|
||||
file = grub_file_filters[filter] (file, type);
|
||||
if (file && file != last_file)
|
||||
{
|
||||
file->name = grub_strdup (name);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
file = grub_file_filters_enabled[filter] (file, name);
|
||||
}
|
||||
if (!file)
|
||||
grub_file_close (last_file);
|
||||
|
||||
grub_memcpy (grub_file_filters_enabled, grub_file_filters_all,
|
||||
sizeof (grub_file_filters_enabled));
|
||||
|
||||
return file;
|
||||
|
||||
@@ -129,6 +128,9 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
|
||||
grub_free (file);
|
||||
|
||||
grub_memcpy (grub_file_filters_enabled, grub_file_filters_all,
|
||||
sizeof (grub_file_filters_enabled));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
/* For stack parameters. */
|
||||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/cpu/linux.h>
|
||||
#include <grub/offsets.h>
|
||||
|
||||
@@ -161,13 +161,13 @@ mmap_iterate_hook (grub_uint64_t addr, grub_uint64_t size,
|
||||
void *data __attribute__ ((unused)))
|
||||
{
|
||||
/* Avoid the lower memory. */
|
||||
if (addr < 0x100000)
|
||||
if (addr < GRUB_MEMORY_MACHINE_UPPER_START)
|
||||
{
|
||||
if (size <= 0x100000 - addr)
|
||||
if (size <= GRUB_MEMORY_MACHINE_UPPER_START - addr)
|
||||
return 0;
|
||||
|
||||
size -= 0x100000 - addr;
|
||||
addr = 0x100000;
|
||||
size -= GRUB_MEMORY_MACHINE_UPPER_START - addr;
|
||||
addr = GRUB_MEMORY_MACHINE_UPPER_START;
|
||||
}
|
||||
|
||||
/* Ignore >4GB. */
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <config.h>
|
||||
#include <grub/symbol.h>
|
||||
|
||||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/i386/pc/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
|
||||
/*
|
||||
* Note: These functions defined in this file may be called from C.
|
||||
@@ -196,8 +196,6 @@ protcseg:
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/i386/pc/memory.h>
|
||||
|
||||
prot_to_real:
|
||||
/* just in case, set GDT */
|
||||
lgdt gdtdesc
|
||||
|
||||
@@ -170,7 +170,7 @@ grub_ia64_make_trampoline (struct grub_ia64_trampoline *tr, grub_uint64_t addr)
|
||||
grub_memcpy (tr->jump, jump, sizeof (tr->jump));
|
||||
}
|
||||
|
||||
void
|
||||
grub_err_t
|
||||
grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
grub_size_t *got)
|
||||
{
|
||||
@@ -187,7 +187,7 @@ grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
break;
|
||||
|
||||
if (i == grub_le_to_cpu16 (e->e_shnum))
|
||||
return;
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
for (i = 0, s = (Elf64_Shdr *) ((char *) e + grub_le_to_cpu64 (e->e_shoff));
|
||||
i < grub_le_to_cpu16 (e->e_shnum);
|
||||
@@ -211,7 +211,9 @@ grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
break;
|
||||
}
|
||||
}
|
||||
*tramp = cntt;
|
||||
*got = cntg;
|
||||
*tramp = cntt * sizeof (struct grub_ia64_trampoline);
|
||||
*got = cntg * sizeof (grub_uint64_t);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -396,8 +396,8 @@ grub_machine_get_bootlocation (char **device, char **path)
|
||||
const char *syspart = 0;
|
||||
|
||||
if (GRUB_ARC_SYSTEM_PARAMETER_BLOCK->firmware_vector_length
|
||||
>= ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable + 1)
|
||||
- (char *) GRUB_ARC_FIRMWARE_VECTOR)
|
||||
>= (unsigned) ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable + 1)
|
||||
- (char *) GRUB_ARC_FIRMWARE_VECTOR)
|
||||
&& GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable)
|
||||
syspart = GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable ("SystemPartition");
|
||||
if (!syspart)
|
||||
|
||||
+11
-11
@@ -20,11 +20,11 @@ FUNCTION (grub_arch_sync_dma_caches)
|
||||
move $t0, $t2
|
||||
subu $t1, $t3, $t2
|
||||
1:
|
||||
cache 1, 0($t0)
|
||||
cache_op 1, 0($t0)
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
cache 1, 1($t0)
|
||||
cache 1, 2($t0)
|
||||
cache 1, 3($t0)
|
||||
cache_op 1, 1($t0)
|
||||
cache_op 1, 2($t0)
|
||||
cache_op 1, 3($t0)
|
||||
|
||||
addiu $t1, $t1, -0x20
|
||||
bne $t1, $zero, 1b
|
||||
@@ -34,36 +34,36 @@ FUNCTION (grub_arch_sync_dma_caches)
|
||||
bne $t1, $zero, 1b
|
||||
addiu $t0, $t0, 0x4
|
||||
#endif
|
||||
sync
|
||||
sync_op
|
||||
move $t0, $t2
|
||||
subu $t1, $t3, $t2
|
||||
2:
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
cache 0, 0($t0)
|
||||
cache_op 0, 0($t0)
|
||||
addiu $t1, $t1, -0x20
|
||||
bne $t1, $zero, 2b
|
||||
addiu $t0, $t0, 0x20
|
||||
#else
|
||||
cache 0, 0($t0)
|
||||
cache_op 0, 0($t0)
|
||||
addiu $t1, $t1, -4
|
||||
bne $t1, $zero, 2b
|
||||
addiu $t0, $t0, 0x4
|
||||
#endif
|
||||
sync
|
||||
sync_op
|
||||
move $t0, $t2
|
||||
subu $t1, $t3, $t2
|
||||
2:
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
cache 23, 0($t0)
|
||||
cache_op 23, 0($t0)
|
||||
addiu $t1, $t1, -0x20
|
||||
bne $t1, $zero, 2b
|
||||
addiu $t0, $t0, 0x20
|
||||
#else
|
||||
cache 23, 0($t0)
|
||||
cache_op 23, 0($t0)
|
||||
addiu $t1, $t1, -0x4
|
||||
bne $t1, $zero, 2b
|
||||
addiu $t0, $t0, 0x4
|
||||
#endif
|
||||
sync
|
||||
sync_op
|
||||
|
||||
jr $ra
|
||||
@@ -1,3 +1,17 @@
|
||||
#ifndef CACHE_OP_DEFINED
|
||||
#define CACHE_OP_DEFINED 1
|
||||
.macro cache_op op addr
|
||||
.set mips3
|
||||
cache \op, \addr
|
||||
.set mips1
|
||||
.endm
|
||||
.macro sync_op
|
||||
.set mips3
|
||||
sync
|
||||
.set mips1
|
||||
.endm
|
||||
#endif
|
||||
|
||||
move $t2, $a0
|
||||
addu $t3, $a0, $a1
|
||||
srl $t2, $t2, 5
|
||||
@@ -8,12 +22,12 @@
|
||||
move $t0, $t2
|
||||
subu $t1, $t3, $t2
|
||||
1:
|
||||
cache 1, 0($t0)
|
||||
cache_op 1, 0($t0)
|
||||
/* All four ways. */
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
cache 1, 1($t0)
|
||||
cache 1, 2($t0)
|
||||
cache 1, 3($t0)
|
||||
cache_op 1, 1($t0)
|
||||
cache_op 1, 2($t0)
|
||||
cache_op 1, 3($t0)
|
||||
addiu $t1, $t1, -0x20
|
||||
bne $t1, $zero, 1b
|
||||
addiu $t0, $t0, 0x20
|
||||
@@ -23,11 +37,11 @@
|
||||
bne $t1, $zero, 1b
|
||||
addiu $t0, $t0, 0x4
|
||||
#endif
|
||||
sync
|
||||
sync_op
|
||||
move $t0, $t2
|
||||
subu $t1, $t3, $t2
|
||||
2:
|
||||
cache 0, 0($t0)
|
||||
cache_op 0, 0($t0)
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
addiu $t1, $t1, -0x20
|
||||
bne $t1, $zero, 2b
|
||||
@@ -37,4 +51,4 @@
|
||||
bne $t1, $zero, 2b
|
||||
addiu $t0, $t0, 0x4
|
||||
#endif
|
||||
sync
|
||||
sync_op
|
||||
+97
-48
@@ -27,6 +27,7 @@
|
||||
|
||||
/* Dummy __gnu_local_gp. Resolved by linker. */
|
||||
static char __gnu_local_gp_dummy;
|
||||
static char _gp_disp_dummy;
|
||||
|
||||
/* Check if EHDR is a valid ELF header. */
|
||||
grub_err_t
|
||||
@@ -51,6 +52,58 @@ grub_arch_dl_check_header (void *ehdr)
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
|
||||
grub_err_t
|
||||
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
grub_size_t *got)
|
||||
{
|
||||
const Elf_Ehdr *e = ehdr;
|
||||
const Elf_Shdr *s;
|
||||
unsigned i;
|
||||
/* FIXME: suboptimal. */
|
||||
grub_size_t gp_size = 0;
|
||||
|
||||
*tramp = 0;
|
||||
*got = 0;
|
||||
|
||||
/* Find a symbol table. */
|
||||
for (i = 0, s = (const Elf_Shdr *) ((const char *) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (const Elf_Shdr *) ((const char *) s + e->e_shentsize))
|
||||
if (s->sh_type == SHT_SYMTAB)
|
||||
break;
|
||||
|
||||
if (i == e->e_shnum)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
|
||||
|
||||
for (i = 0, s = (const Elf_Shdr *) ((const char *) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (const Elf_Shdr *) ((const char *) s + e->e_shentsize))
|
||||
if (s->sh_type == SHT_REL)
|
||||
{
|
||||
const Elf_Rel *rel, *max;
|
||||
|
||||
for (rel = (const Elf_Rel *) ((const char *) e + s->sh_offset),
|
||||
max = rel + s->sh_size / s->sh_entsize;
|
||||
rel < max;
|
||||
rel++)
|
||||
switch (ELF_R_TYPE (rel->r_info))
|
||||
{
|
||||
case R_MIPS_GOT16:
|
||||
case R_MIPS_CALL16:
|
||||
case R_MIPS_GPREL32:
|
||||
gp_size += 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (gp_size > 0x08000)
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, "__gnu_local_gp is too big\n");
|
||||
|
||||
*got = gp_size;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* Relocate symbols. */
|
||||
grub_err_t
|
||||
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
@@ -59,7 +112,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
Elf_Shdr *s;
|
||||
Elf_Word entsize;
|
||||
unsigned i;
|
||||
grub_size_t gp_size = 0;
|
||||
/* FIXME: suboptimal. */
|
||||
grub_uint32_t *gp, *gpptr;
|
||||
grub_uint32_t gp0;
|
||||
@@ -88,43 +140,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
|
||||
gp0 = ((grub_uint32_t *)((char *) e + s->sh_offset))[5];
|
||||
|
||||
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
|
||||
if (s->sh_type == SHT_REL)
|
||||
{
|
||||
grub_dl_segment_t seg;
|
||||
|
||||
/* Find the target segment. */
|
||||
for (seg = mod->segment; seg; seg = seg->next)
|
||||
if (seg->section == s->sh_info)
|
||||
break;
|
||||
|
||||
if (seg)
|
||||
{
|
||||
Elf_Rel *rel, *max;
|
||||
|
||||
for (rel = (Elf_Rel *) ((char *) e + s->sh_offset),
|
||||
max = rel + s->sh_size / s->sh_entsize;
|
||||
rel < max;
|
||||
rel++)
|
||||
switch (ELF_R_TYPE (rel->r_info))
|
||||
{
|
||||
case R_MIPS_GOT16:
|
||||
case R_MIPS_CALL16:
|
||||
case R_MIPS_GPREL32:
|
||||
gp_size += 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gp_size > 0x08000)
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, "__gnu_local_gp is too big\n");
|
||||
|
||||
gpptr = gp = grub_malloc (gp_size);
|
||||
if (!gp)
|
||||
return grub_errno;
|
||||
gpptr = gp = mod->got;
|
||||
|
||||
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
@@ -149,6 +165,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
{
|
||||
grub_uint8_t *addr;
|
||||
Elf_Sym *sym;
|
||||
grub_uint32_t sym_value;
|
||||
|
||||
if (seg->size < rel->r_offset)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
@@ -157,9 +174,17 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
addr = (grub_uint8_t *) ((char *) seg->addr + rel->r_offset);
|
||||
sym = (Elf_Sym *) ((char *) mod->symtab
|
||||
+ entsize * ELF_R_SYM (rel->r_info));
|
||||
if (sym->st_value == (grub_addr_t) &__gnu_local_gp_dummy)
|
||||
sym->st_value = (grub_addr_t) gp;
|
||||
|
||||
sym_value = sym->st_value;
|
||||
if (sym_value == (grub_addr_t) &__gnu_local_gp_dummy)
|
||||
sym_value = (grub_addr_t) gp;
|
||||
else if (sym_value == (grub_addr_t) &_gp_disp_dummy)
|
||||
{
|
||||
sym_value = (grub_addr_t) gp - (grub_addr_t) addr;
|
||||
if (ELF_R_TYPE (rel->r_info) == R_MIPS_LO16)
|
||||
/* ABI mandates +4 even if partner lui doesn't
|
||||
immediately precede addiu. */
|
||||
sym_value += 4;
|
||||
}
|
||||
switch (ELF_R_TYPE (rel->r_info))
|
||||
{
|
||||
case R_MIPS_HI16:
|
||||
@@ -175,7 +200,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
treated as signed. Hence add 0x8000 to compensate.
|
||||
*/
|
||||
value = (*(grub_uint16_t *) addr << 16)
|
||||
+ sym->st_value + 0x8000;
|
||||
+ sym_value + 0x8000;
|
||||
for (rel2 = rel + 1; rel2 < max; rel2++)
|
||||
if (ELF_R_SYM (rel2->r_info)
|
||||
== ELF_R_SYM (rel->r_info)
|
||||
@@ -196,13 +221,13 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
#ifdef GRUB_CPU_WORDS_BIGENDIAN
|
||||
addr += 2;
|
||||
#endif
|
||||
*(grub_uint16_t *) addr += (sym->st_value) & 0xffff;
|
||||
*(grub_uint16_t *) addr += sym_value & 0xffff;
|
||||
break;
|
||||
case R_MIPS_32:
|
||||
*(grub_uint32_t *) addr += sym->st_value;
|
||||
*(grub_uint32_t *) addr += sym_value;
|
||||
break;
|
||||
case R_MIPS_GPREL32:
|
||||
*(grub_uint32_t *) addr = sym->st_value
|
||||
*(grub_uint32_t *) addr = sym_value
|
||||
+ *(grub_uint32_t *) addr + gp0 - (grub_uint32_t)gp;
|
||||
break;
|
||||
|
||||
@@ -212,7 +237,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
grub_uint32_t raw;
|
||||
raw = (*(grub_uint32_t *) addr) & 0x3ffffff;
|
||||
value = raw << 2;
|
||||
value += sym->st_value;
|
||||
value += sym_value;
|
||||
raw = (value >> 2) & 0x3ffffff;
|
||||
|
||||
*(grub_uint32_t *) addr =
|
||||
@@ -220,12 +245,36 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
}
|
||||
break;
|
||||
case R_MIPS_GOT16:
|
||||
if (ELF_ST_BIND (sym->st_info) == STB_LOCAL)
|
||||
{
|
||||
Elf_Rel *rel2;
|
||||
/* Handle partner lo16 relocation. Lower part is
|
||||
treated as signed. Hence add 0x8000 to compensate.
|
||||
*/
|
||||
sym_value += (*(grub_uint16_t *) addr << 16)
|
||||
+ 0x8000;
|
||||
for (rel2 = rel + 1; rel2 < max; rel2++)
|
||||
if (ELF_R_SYM (rel2->r_info)
|
||||
== ELF_R_SYM (rel->r_info)
|
||||
&& ELF_R_TYPE (rel2->r_info) == R_MIPS_LO16)
|
||||
{
|
||||
sym_value += *(grub_int16_t *)
|
||||
((char *) seg->addr + rel2->r_offset
|
||||
#ifdef GRUB_CPU_WORDS_BIGENDIAN
|
||||
+ 2
|
||||
#endif
|
||||
);
|
||||
break;
|
||||
}
|
||||
sym_value &= 0xffff0000;
|
||||
*(grub_uint16_t *) addr = 0;
|
||||
}
|
||||
case R_MIPS_CALL16:
|
||||
/* FIXME: reuse*/
|
||||
#ifdef GRUB_CPU_WORDS_BIGENDIAN
|
||||
addr += 2;
|
||||
#endif
|
||||
*gpptr = sym->st_value + *(grub_uint16_t *) addr;
|
||||
*gpptr = sym_value + *(grub_uint16_t *) addr;
|
||||
*(grub_uint16_t *) addr
|
||||
= sizeof (grub_uint32_t) * (gpptr - gp);
|
||||
gpptr++;
|
||||
@@ -234,7 +283,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
break;
|
||||
default:
|
||||
{
|
||||
grub_free (gp);
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
N_("relocation 0x%x is not implemented yet"),
|
||||
ELF_R_TYPE (rel->r_info));
|
||||
@@ -252,5 +300,6 @@ void
|
||||
grub_arch_dl_init_linker (void)
|
||||
{
|
||||
grub_dl_register_symbol ("__gnu_local_gp", &__gnu_local_gp_dummy, 0, 0);
|
||||
grub_dl_register_symbol ("_gp_disp", &_gp_disp_dummy, 0, 0);
|
||||
}
|
||||
|
||||
@@ -116,10 +116,10 @@ bsscont:
|
||||
bne $t3, $0, bsscont
|
||||
nop
|
||||
|
||||
lui $t1, %hi(grub_main)
|
||||
addiu $t1, %lo(grub_main)
|
||||
lui $t9, %hi(grub_main)
|
||||
addiu $t9, %lo(grub_main)
|
||||
|
||||
lui $sp, %hi(GRUB_MACHINE_MEMORY_STACK_HIGH)
|
||||
jr $t1
|
||||
jr $t9
|
||||
addiu $sp, $sp, %lo(GRUB_MACHINE_MEMORY_STACK_HIGH)
|
||||
|
||||
@@ -1220,6 +1220,15 @@ grub_abort (void)
|
||||
grub_exit ();
|
||||
}
|
||||
|
||||
#if defined (__clang__) && !defined (GRUB_UTIL)
|
||||
/* clang emits references to abort(). */
|
||||
void __attribute__ ((noreturn))
|
||||
abort (void)
|
||||
{
|
||||
grub_abort ();
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
grub_fatal (const char *fmt, ...)
|
||||
{
|
||||
|
||||
+22
-22
@@ -38,9 +38,26 @@ grub_arch_dl_check_header (void *ehdr)
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* For low-endian reverse lis and addr_high as well as ori and addr_low. */
|
||||
struct trampoline
|
||||
{
|
||||
grub_uint32_t lis;
|
||||
grub_uint32_t ori;
|
||||
grub_uint32_t mtctr;
|
||||
grub_uint32_t bctr;
|
||||
};
|
||||
|
||||
static const struct trampoline trampoline_template =
|
||||
{
|
||||
0x3d800000,
|
||||
0x618c0000,
|
||||
0x7d8903a6,
|
||||
0x4e800420,
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
|
||||
void
|
||||
grub_err_t
|
||||
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
grub_size_t *got)
|
||||
{
|
||||
@@ -59,7 +76,7 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
break;
|
||||
|
||||
if (i == e->e_shnum)
|
||||
return;
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
for (i = 0, s = (const Elf_Shdr *) ((const char *) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
@@ -77,26 +94,11 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
*tramp *= sizeof (struct trampoline);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* For low-endian reverse lis and addr_high as well as ori and addr_low. */
|
||||
struct trampoline
|
||||
{
|
||||
grub_uint32_t lis;
|
||||
grub_uint32_t ori;
|
||||
grub_uint32_t mtctr;
|
||||
grub_uint32_t bctr;
|
||||
};
|
||||
|
||||
static const struct trampoline trampoline_template =
|
||||
{
|
||||
0x3d800000,
|
||||
0x618c0000,
|
||||
0x7d8903a6,
|
||||
0x4e800420,
|
||||
};
|
||||
|
||||
/* Relocate symbols. */
|
||||
grub_err_t
|
||||
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
@@ -167,8 +169,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
|
||||
if (delta << 6 >> 6 != delta)
|
||||
{
|
||||
COMPILE_TIME_ASSERT (sizeof (struct trampoline)
|
||||
== GRUB_ARCH_DL_TRAMP_SIZE);
|
||||
grub_memcpy (tptr, &trampoline_template,
|
||||
sizeof (*tptr));
|
||||
delta = (grub_uint8_t *) tptr - (grub_uint8_t *) addr;
|
||||
|
||||
@@ -100,14 +100,32 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||
break;
|
||||
|
||||
case R_X86_64_PC32:
|
||||
*addr32 += rel->r_addend + sym->st_value -
|
||||
(Elf64_Xword) seg->addr - rel->r_offset;
|
||||
{
|
||||
grub_int64_t value;
|
||||
value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value -
|
||||
(Elf64_Xword) seg->addr - rel->r_offset;
|
||||
if (value != (grub_int32_t) value)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
|
||||
*addr32 = value;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_X86_64_32:
|
||||
{
|
||||
grub_uint64_t value = *addr32 + rel->r_addend + sym->st_value;
|
||||
if (value != (grub_uint32_t) value)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
|
||||
*addr32 = value;
|
||||
}
|
||||
break;
|
||||
case R_X86_64_32S:
|
||||
*addr32 += rel->r_addend + sym->st_value;
|
||||
break;
|
||||
{
|
||||
grub_int64_t value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value;
|
||||
if (value != (grub_int32_t) value)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
|
||||
*addr32 = value;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
|
||||
@@ -36,94 +36,94 @@
|
||||
.text
|
||||
|
||||
FUNCTION(efi_wrap_0)
|
||||
subq $48, %rsp
|
||||
subq $40, %rsp
|
||||
call *%rdi
|
||||
addq $48, %rsp
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
FUNCTION(efi_wrap_1)
|
||||
subq $48, %rsp
|
||||
subq $40, %rsp
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $48, %rsp
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
FUNCTION(efi_wrap_2)
|
||||
subq $48, %rsp
|
||||
subq $40, %rsp
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $48, %rsp
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
FUNCTION(efi_wrap_3)
|
||||
subq $48, %rsp
|
||||
subq $40, %rsp
|
||||
mov %rcx, %r8
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $48, %rsp
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
FUNCTION(efi_wrap_4)
|
||||
subq $48, %rsp
|
||||
subq $40, %rsp
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $48, %rsp
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
FUNCTION(efi_wrap_5)
|
||||
subq $48, %rsp
|
||||
subq $40, %rsp
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $48, %rsp
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
FUNCTION(efi_wrap_6)
|
||||
subq $64, %rsp
|
||||
mov 64+8(%rsp), %rax
|
||||
subq $56, %rsp
|
||||
mov 56+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $64, %rsp
|
||||
addq $56, %rsp
|
||||
ret
|
||||
|
||||
FUNCTION(efi_wrap_7)
|
||||
subq $96, %rsp
|
||||
mov 96+16(%rsp), %rax
|
||||
subq $88, %rsp
|
||||
mov 88+16(%rsp), %rax
|
||||
mov %rax, 48(%rsp)
|
||||
mov 96+8(%rsp), %rax
|
||||
mov 88+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $96, %rsp
|
||||
addq $88, %rsp
|
||||
ret
|
||||
|
||||
FUNCTION(efi_wrap_10)
|
||||
subq $96, %rsp
|
||||
mov 96+40(%rsp), %rax
|
||||
subq $88, %rsp
|
||||
mov 88+40(%rsp), %rax
|
||||
mov %rax, 72(%rsp)
|
||||
mov 96+32(%rsp), %rax
|
||||
mov 88+32(%rsp), %rax
|
||||
mov %rax, 64(%rsp)
|
||||
mov 96+24(%rsp), %rax
|
||||
mov 88+24(%rsp), %rax
|
||||
mov %rax, 56(%rsp)
|
||||
mov 96+16(%rsp), %rax
|
||||
mov 88+16(%rsp), %rax
|
||||
mov %rax, 48(%rsp)
|
||||
mov 96+8(%rsp), %rax
|
||||
mov 88+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $96, %rsp
|
||||
addq $88, %rsp
|
||||
ret
|
||||
@@ -341,6 +341,14 @@ page2offset (grub_uint64_t page)
|
||||
return page << 12;
|
||||
}
|
||||
|
||||
#if defined (__x86_64__) && defined (__code_model_large__)
|
||||
#define MAX_TOTAL_PAGES (1LL << (64 - 12))
|
||||
#elif defined (__x86_64__)
|
||||
#define MAX_TOTAL_PAGES (1LL << (31 - 12))
|
||||
#else
|
||||
#define MAX_TOTAL_PAGES (1LL << (32 - 12))
|
||||
#endif
|
||||
|
||||
static void
|
||||
map_all_pages (void)
|
||||
{
|
||||
@@ -355,6 +363,9 @@ map_all_pages (void)
|
||||
grub_size_t n_unusable_pages = 0;
|
||||
struct mmu_update m2p_updates[2 * MAX_N_UNUSABLE_PAGES];
|
||||
|
||||
if (total_pages > MAX_TOTAL_PAGES - 4)
|
||||
total_pages = MAX_TOTAL_PAGES - 4;
|
||||
|
||||
grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver));
|
||||
|
||||
gnttab_setver.version = 2;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 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 <grub/symbol.h>
|
||||
|
||||
.file "setjmp.S"
|
||||
.text
|
||||
|
||||
/*
|
||||
* int grub_setjmp (grub_jmp_buf env)
|
||||
*/
|
||||
FUNCTION(grub_setjmp)
|
||||
stp x19, x20, [x0], #16
|
||||
stp x21, x22, [x0], #16
|
||||
stp x23, x24, [x0], #16
|
||||
stp x25, x26, [x0], #16
|
||||
stp x27, x28, [x0], #16
|
||||
stp x29, x30, [x0], #16
|
||||
mov x1, sp
|
||||
str x1, [x0]
|
||||
mov x0, #0
|
||||
ret
|
||||
|
||||
/*
|
||||
* int grub_longjmp (grub_jmp_buf env, int val)
|
||||
*/
|
||||
FUNCTION(grub_longjmp)
|
||||
ldp x19, x20, [x0], #16
|
||||
ldp x21, x22, [x0], #16
|
||||
ldp x23, x24, [x0], #16
|
||||
ldp x25, x26, [x0], #16
|
||||
ldp x27, x28, [x0], #16
|
||||
ldp x29, x30, [x0], #16
|
||||
ldr x2, [x0]
|
||||
mov sp, x2
|
||||
cmp x1, #0
|
||||
csel x0, x1, x0, ne
|
||||
ret
|
||||
+4
-22
@@ -125,7 +125,10 @@ void
|
||||
grub_crypto_hash (const gcry_md_spec_t *hash, void *out, const void *in,
|
||||
grub_size_t inlen)
|
||||
{
|
||||
grub_uint8_t ctx[hash->contextsize];
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (ctx, GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
|
||||
|
||||
if (hash->contextsize > sizeof (ctx))
|
||||
grub_fatal ("Too large md context");
|
||||
hash->init (&ctx);
|
||||
hash->write (&ctx, in, inlen);
|
||||
hash->final (&ctx);
|
||||
@@ -150,27 +153,6 @@ grub_crypto_lookup_md_by_name (const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
const gcry_md_spec_t *
|
||||
grub_crypto_lookup_md_by_asn (const void *asn, grub_size_t asnlen)
|
||||
{
|
||||
const gcry_md_spec_t *md;
|
||||
int first = 1;
|
||||
while (1)
|
||||
{
|
||||
for (md = grub_digests; md; md = md->next)
|
||||
if (md->asnlen
|
||||
&& (grub_size_t) md->asnlen <= asnlen
|
||||
&& grub_memcmp (asn, md->asnoid, md->asnlen) == 0)
|
||||
return md;
|
||||
if (grub_crypto_autoload_hook && first)
|
||||
/* FIXME */
|
||||
grub_crypto_autoload_hook ("sha256");
|
||||
else
|
||||
return NULL;
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const gcry_cipher_spec_t *
|
||||
grub_crypto_lookup_cipher_by_name (const char *name)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ void
|
||||
grub_halt (void)
|
||||
{
|
||||
grub_machine_fini (GRUB_LOADER_FLAG_NORETURN);
|
||||
#if !defined(__ia64__) && !defined(__arm__)
|
||||
#if !defined(__ia64__) && !defined(__arm__) && !defined(__aarch64__)
|
||||
grub_acpi_halt ();
|
||||
#endif
|
||||
efi_call_4 (grub_efi_system_table->runtime_services->reset_system,
|
||||
|
||||
@@ -749,7 +749,7 @@ extern USItype __udiv_qrnnd ();
|
||||
************** MIPS *****************
|
||||
***************************************/
|
||||
#if defined (__mips__) && W_TYPE_SIZE == 32
|
||||
#if (__GNUC__ >= 5) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
|
||||
#if defined (__clang__) || (__GNUC__ >= 5) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
|
||||
#define umul_ppmm(w1, w0, u, v) \
|
||||
do { \
|
||||
UDItype _r; \
|
||||
|
||||
@@ -69,16 +69,23 @@ typedef grub_uint8_t gf_single_t;
|
||||
#define GF_POLYNOMIAL 0x1d
|
||||
#define GF_INVERT2 0x8e
|
||||
#if defined (STANDALONE) && !defined (TEST)
|
||||
static gf_single_t * const gf_powx __attribute__ ((section(".text"))) = (void *) 0x100000;
|
||||
static gf_single_t * const gf_powx_inv __attribute__ ((section(".text"))) = (void *) 0x100200;
|
||||
static int *const chosenstat __attribute__ ((section(".text"))) = (void *) 0x100300;
|
||||
static gf_single_t *const sigma __attribute__ ((section(".text"))) = (void *) 0x100700;
|
||||
static gf_single_t *const errpot __attribute__ ((section(".text"))) = (void *) 0x100800;
|
||||
static int *const errpos __attribute__ ((section(".text"))) = (void *) 0x100900;
|
||||
static gf_single_t *const sy __attribute__ ((section(".text"))) = (void *) 0x100d00;
|
||||
static gf_single_t *const mstat __attribute__ ((section(".text"))) = (void *) 0x100e00;
|
||||
static gf_single_t *const errvals __attribute__ ((section(".text"))) = (void *) 0x100f00;
|
||||
static gf_single_t *const eqstat __attribute__ ((section(".text"))) = (void *) 0x101000;
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define ATTRIBUTE_TEXT __attribute__ ((section("_text,_text")))
|
||||
#else
|
||||
#define ATTRIBUTE_TEXT __attribute__ ((section(".text")))
|
||||
#endif
|
||||
|
||||
static gf_single_t * const gf_powx ATTRIBUTE_TEXT = (void *) 0x100000;
|
||||
static gf_single_t * const gf_powx_inv ATTRIBUTE_TEXT = (void *) 0x100200;
|
||||
static int *const chosenstat ATTRIBUTE_TEXT = (void *) 0x100300;
|
||||
static gf_single_t *const sigma ATTRIBUTE_TEXT = (void *) 0x100700;
|
||||
static gf_single_t *const errpot ATTRIBUTE_TEXT = (void *) 0x100800;
|
||||
static int *const errpos ATTRIBUTE_TEXT = (void *) 0x100900;
|
||||
static gf_single_t *const sy ATTRIBUTE_TEXT = (void *) 0x100d00;
|
||||
static gf_single_t *const mstat ATTRIBUTE_TEXT = (void *) 0x100e00;
|
||||
static gf_single_t *const errvals ATTRIBUTE_TEXT = (void *) 0x100f00;
|
||||
static gf_single_t *const eqstat ATTRIBUTE_TEXT = (void *) 0x101000;
|
||||
/* Next available address: (void *) 0x112000. */
|
||||
#else
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "./ia64/longjmp.S"
|
||||
#elif defined(__arm__)
|
||||
#include "./arm/setjmp.S"
|
||||
#elif defined(__aarch64__)
|
||||
#include "./arm64/setjmp.S"
|
||||
#else
|
||||
#error "Unknown target cpu type"
|
||||
#endif
|
||||
@@ -218,7 +218,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE);
|
||||
file = grub_file_open (filename);
|
||||
if (! file)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -1448,7 +1448,7 @@ grub_bsd_load (int argc, char *argv[])
|
||||
goto fail;
|
||||
}
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_BSD_KERNEL);
|
||||
file = grub_file_open (argv[0]);
|
||||
if (!file)
|
||||
goto fail;
|
||||
|
||||
@@ -1525,7 +1525,7 @@ grub_cmd_freebsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_BSD_KERNEL);
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
@@ -1682,7 +1682,7 @@ grub_cmd_netbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
|
||||
{
|
||||
grub_file_t file;
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_BSD_KERNEL);
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
@@ -1791,7 +1791,7 @@ grub_cmd_freebsd_loadenv (grub_command_t cmd __attribute__ ((unused)),
|
||||
goto fail;
|
||||
}
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEBSD_ENV);
|
||||
file = grub_file_open (argv[0]);
|
||||
if ((!file) || (!file->size))
|
||||
goto fail;
|
||||
|
||||
@@ -1892,7 +1892,7 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)),
|
||||
return 0;
|
||||
}
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEBSD_MODULE);
|
||||
file = grub_file_open (argv[0]);
|
||||
if ((!file) || (!file->size))
|
||||
goto fail;
|
||||
|
||||
@@ -1943,7 +1943,7 @@ grub_netbsd_module_load (char *filename, grub_uint32_t type)
|
||||
void *src;
|
||||
grub_err_t err;
|
||||
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_NETBSD_MODULE);
|
||||
file = grub_file_open (filename);
|
||||
if ((!file) || (!file->size))
|
||||
goto fail;
|
||||
|
||||
@@ -2029,7 +2029,7 @@ grub_cmd_freebsd_module_elf (grub_command_t cmd __attribute__ ((unused)),
|
||||
return 0;
|
||||
}
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEBSD_MODULE_ELF);
|
||||
file = grub_file_open (argv[0]);
|
||||
if (!file)
|
||||
return grub_errno;
|
||||
if (!file->size)
|
||||
@@ -2065,7 +2065,7 @@ grub_cmd_openbsd_ramdisk (grub_command_t cmd __attribute__ ((unused)),
|
||||
if (!openbsd_ramdisk.max_size)
|
||||
return grub_error (GRUB_ERR_BAD_OS, "your kOpenBSD doesn't support ramdisk");
|
||||
|
||||
file = grub_file_open (args[0], GRUB_FILE_TYPE_OPENBSD_RAMDISK);
|
||||
file = grub_file_open (args[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -694,7 +694,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
goto fail;
|
||||
}
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
goto fail;
|
||||
}
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -484,7 +484,7 @@ grub_cmd_devprop_load (grub_command_t cmd __attribute__ ((unused)),
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
|
||||
|
||||
file = grub_file_open (args[0], GRUB_FILE_XNU_DEVPROP);
|
||||
file = grub_file_open (args[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
size = grub_file_size (file);
|
||||
|
||||
@@ -170,6 +170,7 @@ grub_initrd_init (int argc, char *argv[],
|
||||
eptr = grub_strchr (ptr, ':');
|
||||
if (eptr)
|
||||
{
|
||||
grub_file_filter_disable_compression ();
|
||||
initrd_ctx->components[i].newc_name = grub_strndup (ptr, eptr - ptr);
|
||||
if (!initrd_ctx->components[i].newc_name)
|
||||
{
|
||||
@@ -194,9 +195,8 @@ grub_initrd_init (int argc, char *argv[],
|
||||
root = 0;
|
||||
newc = 0;
|
||||
}
|
||||
initrd_ctx->components[i].file = grub_file_open (fname,
|
||||
GRUB_FILE_TYPE_LINUX_INITRD
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS);
|
||||
grub_file_filter_disable_compression ();
|
||||
initrd_ctx->components[i].file = grub_file_open (fname);
|
||||
if (!initrd_ctx->components[i].file)
|
||||
{
|
||||
grub_initrd_close (initrd_ctx);
|
||||
|
||||
@@ -184,12 +184,12 @@ fail:
|
||||
}
|
||||
|
||||
grub_macho_t
|
||||
grub_macho_open (const char *name, enum grub_file_type type, int is_64bit)
|
||||
grub_macho_open (const char *name, int is_64bit)
|
||||
{
|
||||
grub_file_t file;
|
||||
grub_macho_t macho;
|
||||
|
||||
file = grub_file_open (name, type);
|
||||
file = grub_file_open (name);
|
||||
if (! file)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)),
|
||||
if (argc == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_MULTIBOOT_KERNEL);
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
@@ -325,8 +325,10 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
N_("you need to load the kernel first"));
|
||||
|
||||
file = grub_file_open (argv[0], GRUB_FILE_TYPE_MULTIBOOT_MODULE
|
||||
| (nounzip ? GRUB_FILE_TYPE_NO_DECOMPRESS : 0));
|
||||
if (nounzip)
|
||||
grub_file_filter_disable_compression ();
|
||||
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
grub_xnu_unload ();
|
||||
|
||||
macho = grub_macho_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL, 0);
|
||||
macho = grub_macho_open (args[0], 0);
|
||||
if (! macho)
|
||||
return grub_errno;
|
||||
|
||||
@@ -456,7 +456,7 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
grub_xnu_unload ();
|
||||
|
||||
macho = grub_macho_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL, 1);
|
||||
macho = grub_macho_open (args[0], 1);
|
||||
if (! macho)
|
||||
return grub_errno;
|
||||
|
||||
@@ -674,7 +674,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
|
||||
macho = 0;
|
||||
|
||||
if (infoplistname)
|
||||
infoplist = grub_file_open (infoplistname, GRUB_FILE_TYPE_XNU_INFO_PLIST);
|
||||
infoplist = grub_file_open (infoplistname);
|
||||
else
|
||||
infoplist = 0;
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
@@ -770,7 +770,7 @@ grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)),
|
||||
if (! grub_xnu_heap_size)
|
||||
return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first"));
|
||||
|
||||
file = grub_file_open (args[0], GRUB_FILE_TYPE_XNU_MKEXT);
|
||||
file = grub_file_open (args[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
@@ -884,7 +884,7 @@ grub_cmd_xnu_ramdisk (grub_command_t cmd __attribute__ ((unused)),
|
||||
if (! grub_xnu_heap_size)
|
||||
return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first"));
|
||||
|
||||
file = grub_file_open (args[0], GRUB_FILE_TYPE_XNU_RAMDISK);
|
||||
file = grub_file_open (args[0]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
@@ -924,7 +924,7 @@ grub_xnu_check_os_bundle_required (char *plistname,
|
||||
if (binname)
|
||||
*binname = 0;
|
||||
|
||||
file = grub_file_open (plistname, GRUB_FILE_TYPE_XNU_INFO_PLIST);
|
||||
file = grub_file_open (plistname);
|
||||
if (! file)
|
||||
return 0;
|
||||
|
||||
@@ -1209,7 +1209,7 @@ grub_xnu_load_kext_from_dir (char *dirname, const char *osbundlerequired,
|
||||
grub_strcpy (binname + grub_strlen (binname), "/");
|
||||
grub_strcpy (binname + grub_strlen (binname), binsuffix);
|
||||
grub_dprintf ("xnu", "%s:%s\n", ctx.plistname, binname);
|
||||
binfile = grub_file_open (binname, GRUB_FILE_TYPE_XNU_KEXT);
|
||||
binfile = grub_file_open (binname);
|
||||
if (! binfile)
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
@@ -1252,7 +1252,7 @@ grub_cmd_xnu_kext (grub_command_t cmd __attribute__ ((unused)),
|
||||
/* User explicitly specified plist and binary. */
|
||||
if (grub_strcmp (args[1], "-") != 0)
|
||||
{
|
||||
binfile = grub_file_open (args[1], GRUB_FILE_TYPE_XNU_KEXT);
|
||||
binfile = grub_file_open (args[1]);
|
||||
if (! binfile)
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ grub_xnu_resume (char *imagename)
|
||||
grub_addr_t target_image;
|
||||
grub_err_t err;
|
||||
|
||||
file = grub_file_open (imagename, GRUB_FILE_TYPE_XNU_HIBERNATE_IMAGE
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS);
|
||||
grub_file_filter_disable_compression ();
|
||||
file = grub_file_open (imagename);
|
||||
if (! file)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -33,6 +33,12 @@ autoload_fs_module (void)
|
||||
{
|
||||
grub_named_list_t p;
|
||||
int ret = 0;
|
||||
grub_file_filter_t grub_file_filters_was[GRUB_FILE_FILTER_MAX];
|
||||
|
||||
grub_memcpy (grub_file_filters_was, grub_file_filters_enabled,
|
||||
sizeof (grub_file_filters_enabled));
|
||||
grub_memcpy (grub_file_filters_enabled, grub_file_filters_all,
|
||||
sizeof (grub_file_filters_enabled));
|
||||
|
||||
while ((p = fs_module_list) != NULL)
|
||||
{
|
||||
@@ -50,6 +56,9 @@ autoload_fs_module (void)
|
||||
grub_free (p);
|
||||
}
|
||||
|
||||
grub_memcpy (grub_file_filters_enabled, grub_file_filters_was,
|
||||
sizeof (grub_file_filters_enabled));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -73,7 +82,7 @@ read_fs_list (const char *prefix)
|
||||
tmp_autoload_hook = grub_fs_autoload_hook;
|
||||
grub_fs_autoload_hook = NULL;
|
||||
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
|
||||
file = grub_file_open (filename);
|
||||
if (file)
|
||||
{
|
||||
/* Override previous fs.lst. */
|
||||
|
||||
@@ -94,7 +94,7 @@ read_crypto_list (const char *prefix)
|
||||
return;
|
||||
}
|
||||
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
|
||||
file = grub_file_open (filename);
|
||||
grub_free (filename);
|
||||
if (!file)
|
||||
{
|
||||
|
||||
@@ -106,7 +106,7 @@ read_command_list (const char *prefix)
|
||||
{
|
||||
grub_file_t file;
|
||||
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
|
||||
file = grub_file_open (filename);
|
||||
if (file)
|
||||
{
|
||||
char *buf = NULL;
|
||||
|
||||
@@ -180,7 +180,7 @@ read_config_file (const char *config)
|
||||
}
|
||||
|
||||
/* Try to open the config file. */
|
||||
file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
|
||||
file = grub_file_open (config);
|
||||
if (! file)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
|
||||
static void
|
||||
grub_file_progress_hook_real (grub_disk_addr_t sector,
|
||||
unsigned offset, unsigned length,
|
||||
void *data)
|
||||
{
|
||||
grub_file_t file = data;
|
||||
file->progress_offset += length;
|
||||
show_progress (file->progress_offset, file->size);
|
||||
}
|
||||
|
||||
|
||||
GRUB_MOD_INIT (progress)
|
||||
{
|
||||
grub_file_progress_hook = grub_file_progress_hook_real;
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (progress)
|
||||
{
|
||||
grub_file_progress_hook = 0;
|
||||
}
|
||||
@@ -331,7 +331,7 @@ read_terminal_list (const char *prefix)
|
||||
return;
|
||||
}
|
||||
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
|
||||
file = grub_file_open (filename);
|
||||
grub_free (filename);
|
||||
if (!file)
|
||||
{
|
||||
|
||||
@@ -31,11 +31,11 @@
|
||||
static char *
|
||||
get_ofpathname (const char *dev)
|
||||
{
|
||||
char *ret = xmalloc (2 * PATH_MAX);
|
||||
char *end = ret + 2 * PATH_MAX - 1;
|
||||
size_t alloced = 4096;
|
||||
char *ret = xmalloc (alloced);
|
||||
size_t offset = 0;
|
||||
int fd;
|
||||
pid_t pid;
|
||||
char *ptr = ret;
|
||||
|
||||
pid = grub_util_exec_pipe ((const char * []){ "ofpathname", dev, NULL }, &fd);
|
||||
if (!pid)
|
||||
@@ -45,13 +45,29 @@ get_ofpathname (const char *dev)
|
||||
if (!fp)
|
||||
goto fail;
|
||||
|
||||
while (!feof (fp) && ptr < end)
|
||||
while (!feof (fp))
|
||||
{
|
||||
size_t r;
|
||||
r = fread (ptr, 1, end - ptr, fp);
|
||||
ptr += r;
|
||||
if (alloced == offset)
|
||||
{
|
||||
alloced *= 2;
|
||||
ret = xrealloc (ret, alloced);
|
||||
}
|
||||
r = fread (ret + offset, 1, alloced - offset, fp);
|
||||
offset += r;
|
||||
}
|
||||
|
||||
if (offset > 0 && ret[offset - 1] == '\n')
|
||||
offset--;
|
||||
if (offset > 0 && ret[offset - 1] == '\r')
|
||||
offset--;
|
||||
if (alloced == offset)
|
||||
{
|
||||
alloced++;
|
||||
ret = xrealloc (ret, alloced);
|
||||
}
|
||||
ret[offset] = '\0';
|
||||
|
||||
fclose (fp);
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -114,8 +114,8 @@ check_is_serial (void)
|
||||
isn't critical.
|
||||
*/
|
||||
if (GRUB_ARC_SYSTEM_PARAMETER_BLOCK->firmware_vector_length
|
||||
>= ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable + 1)
|
||||
- (char *) GRUB_ARC_FIRMWARE_VECTOR)
|
||||
>= (unsigned) ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable + 1)
|
||||
- (char *) GRUB_ARC_FIRMWARE_VECTOR)
|
||||
&& GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable)
|
||||
consout = GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable ("ConsoleOut");
|
||||
if (!consout)
|
||||
@@ -136,8 +136,8 @@ set_console_dimensions (void)
|
||||
}
|
||||
|
||||
if (GRUB_ARC_SYSTEM_PARAMETER_BLOCK->firmware_vector_length
|
||||
>= ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus + 1)
|
||||
- (char *) GRUB_ARC_FIRMWARE_VECTOR)
|
||||
>= (unsigned) ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus + 1)
|
||||
- (char *) GRUB_ARC_FIRMWARE_VECTOR)
|
||||
&& GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus)
|
||||
info = GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus (GRUB_ARC_STDOUT);
|
||||
if (info)
|
||||
|
||||
@@ -768,7 +768,7 @@ grub_video_reader_jpeg (struct grub_video_bitmap **bitmap,
|
||||
grub_file_t file;
|
||||
struct grub_jpeg_data *data;
|
||||
|
||||
file = grub_buffile_open (filename, GRUB_FILE_TYPE_PIXMAP, 0);
|
||||
file = grub_buffile_open (filename, 0);
|
||||
if (!file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -1075,7 +1075,7 @@ grub_video_reader_png (struct grub_video_bitmap **bitmap,
|
||||
grub_file_t file;
|
||||
struct grub_png_data *data;
|
||||
|
||||
file = grub_buffile_open (filename, GRUB_FILE_TYPE_PIXMAP, 0);
|
||||
file = grub_buffile_open (filename, 0);
|
||||
if (!file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -297,7 +297,7 @@ grub_video_reader_tga (struct grub_video_bitmap **bitmap,
|
||||
|
||||
grub_memset (&data, 0, sizeof (data));
|
||||
|
||||
data.file = grub_buffile_open (filename, GRUB_FILE_TYPE_PIXMAP, 0);
|
||||
data.file = grub_buffile_open (filename, 0);
|
||||
if (! data.file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include <grub/efi/memory.h>
|
||||
Loaded 100 of 131 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user