Merge branch 'upstream' into experimental

This commit is contained in:
Colin Watson 2013-12-08 19:20:37 +00:00
commit 8b25ef4a30
101 changed files with 2180 additions and 1422 deletions

251
ChangeLog
View File

@ -1,3 +1,254 @@
2013-12-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/ia64/efi/init.c (grub_arch_sync_caches): Move to ...
* grub-core/kern/ia64/cache.c (grub_arch_sync_caches): ... here.
2013-12-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/emu/main.c: Silence missing prototypes to allow emu
compilation with GCC <= 4.2.
* grub-core/kern/emu/argp_common.c: Likewise.
2013-12-08 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/kernel.h [__sparc__]: Restrict sparc64-ieee1275 to
right platform rather than leaking to sparc64-emu.
2013-12-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/windows/emuconsole.c: Remove unsigned comparison >= 0.
But ensure that the variables in question are indeed unsigned.
2013-12-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/emu/lite.c: Add missing include of ../ia64/dl_helper.c.
2013-12-08 Vladimir Serbinenko <phcoder@gmail.com>
Remove grub_memalign on emu.
2013-12-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/ia64/efi/init.c: Fix alignment code so it doesn't
truncate incomplete lines but instead flushes them.
2013-12-08 Vladimir Serbinenko <phcoder@gmail.com>
Move OS-dependent mprotect for module loading to grub-core/osdep/*/dl.c
and implement windows variant.
2013-12-08 Vladimir Serbinenko <phcoder@gmail.com>
Fix mips-emu compilation.
2013-12-08 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Check for freetype library usability.
2013-12-08 Vladimir Serbinenko <phcoder@gmail.com>
Make arm-emu work.
2013-12-07 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkfont.c: Replace stpcpy with grub_stpcpy.
2013-12-07 Andrey Borzenkov <arvidjaar@gmail.com>
* docs/grub.texi (Environment): Update color_normal and color_highlight
defaults (light-gray instead of white).
2013-12-07 Andrey Borzenkov <arvidjaar@gmail.com>
* grub-core/normal/main.c (INIT): Set default color to light-gray
to match GRUB_TERM_DEFAULT_NORMAL_COLOR (i.e. rescue mode), Linux
and apparently BIOS defaults.
2013-12-07 Vladimir Serbinenko <phcoder@gmail.com>
Transform -C option to grub-mkstandalone to --core-compress available
in all grub-install flavours.
2013-12-07 Vladimir Serbinenko <phcoder@gmail.com>
Merge GRUBFS and GRUB_FS variables.
2013-12-07 Andrey Borzenkov <arvidjaar@gmail.com>
Revert commit 69ca97c820, it caused failures when using OS device name
in grub-install. Instead just strip off parenthesis in grub-install
if (hdX) was passed.
2013-12-07 Andrey Borzenkov <arvidjaar@gmail.com>
* util/grub-install.c (push_partmap_module): Add helper to convert
partmap names to module names and use it in probe_mods(). Fixes
failure to find partmap modules in diskfilter case.
2013-12-07 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Make unifont mandatory on coreboot.
2013-12-07 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Skip unifont 6.3 pcf and bdf.
2013-12-07 Vladimir Serbinenko <phcoder@gmail.com>
* Makefile.am: Remove partial font files if generation failed.
2013-12-07 Andrey Borzenkov <arvidjaar@gmail.com>
* util/misc.c (grub_qsort_strcmp): Add qsort helper function to sort
strings.
* include/grub/util/misc.h: Define it ...
* util/grub-install.c (device_map_check_duplicates): ... and use it.
2013-12-07 Andrey Borzenkov <arvidjaar@gmail.com>
* util/grub.d/30_os-prober.in: Fix use of grub-probe instead of
${grub_probe}.
2013-12-06 Vladimir Serbinenko <phcoder@gmail.com>
Don't add -mlong-calls when compiling with clang.
2013-12-06 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Fix a typo.
2013-12-06 Vladimir Serbinenko <phcoder@gmail.com>
Revamp relocation handling.
Move more code to common dl.c. Add missing veneers for arm and arm64.
Decreases kernel size by 70 bytes on i386-pc (40-50 compressed)
2013-12-05 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkimagexx.c: Fix reloc section generation for ia64.
2013-12-05 Mike Gilbert <floppym@gentoo.org>
* INSTALL: Raise minimum python version to 2.6.
* gentpl.py: Use python3-style print function.
2013-12-05 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-install.c: Mention Boot* variable.
2013-12-05 Colin Watson <cjwatson@ubuntu.com>
* grub-core/osdep/linux/hostdisk.c
(grub_util_find_partition_start_os): Initialise start to avoid
spurious compiler warning.
2013-12-05 Colin Watson <cjwatson@ubuntu.com>
On Linux, read partition start offsets from sysfs if possible, to
cope with block device drivers that don't implement HDIO_GETGEO.
Fixes Ubuntu bug #1237519.
* grub-core/osdep/linux/hostdisk.c (sysfs_partition_path): New
function.
(sysfs_partition_start): Likewise.
(grub_util_find_partition_start_os): Try sysfs_partition_start
before HDIO_GETGEO.
2013-12-05 Leif Lindholm <leif.lindholm@linaro.org>
* grub-core/kern/fdt.c: Update struct size when adding node.
2013-12-05 Vladimir Serbinenko <phcoder@gmail.com>
Handle unaligned .bss on sparc64.
Current code improperly assumes that both __bss_start and _end are
aligned to 8-bytes. Eliminating this assumption and explicitly align
modules.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/boot/sparc64/ieee1275/boot.S [CDBOOT]: Move scratchpad
so it doesn't land in the middle of loaded image.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Move all warning options that may be absent in
gcc >= 3.1 to optional.
Note: while this allows to compile with older GCC, official requirements
remain the same and no support for older GCC.
2013-12-04 Colin Watson <cjwatson@ubuntu.com>
Copying the themes directory in grub-shell isn't
parallel-test-friendly and breaks on the second test when the source
directory is read-only (as in "make distcheck"). Instead, add a
hidden --themes-directory option to grub-mkrescue et al, and use it
in grub-shell.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* conf/Makefile.common (CFLAGS_GNULIB): Remove -Wno-old-style-definition
as it's no longer necessarry.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Allow compilation with older GCC for ARM.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Add -no-integrated-as if {addme|ame} isn't supported.
* INSTALL: Note that GRUBwas successfully compiled with clang 3.2 for
ppc.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/emu/main.c: Ignore missing prototype for main.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
Pass font config to config.h and not by TARGET_CFLAGS as adding
arguments doesn't work if TARGET_CFLAGS is specified on command
line.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Add -Wvla if compiler supports it.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/windows/emuconsole.c (grub_console_putchar):
Remove variable length arrays.
* grub-core/term/efi/console.c (grub_console_putchar): Likewise.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/i386/qemu/init.c: Remove variable length arrays.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/types.h: Declare all byteswaps as inline functions
except compile-time ones.
Solves variable shadowing in constructions like
cpu_to_le (le_to_cpu(x) + 1).
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/efi/efi.c: Remove variable length arrays.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/uboot/init.c (uboot_timer_ms): Fix overflow after 71
minutes.
2013-12-04 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/ieee1275/ofdisk.c: Remove variable length arrays.
* grub-core/net/drivers/ieee1275/ofnet.c: Likewise.
2013-12-03 Colin Watson <cjwatson@ubuntu.com>
* grub-core/Makefile.core.def (setjmp): Distribute

View File

@ -23,8 +23,8 @@ configuring the GRUB.
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 3.2 or later works for powerpc
earlier versions not tested
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
@ -54,7 +54,7 @@ To build GRUB's graphical terminal (gfxterm), you need:
If you use a development snapshot or want to hack on GRUB you may
need the following.
* Python 2.5.2 or later
* Python 2.6 or later
* Autoconf 2.60 or later
* Automake 1.10.1 or later

View File

@ -103,7 +103,7 @@ EXTRA_DIST += $(starfield_theme_files)
EXTRA_DIST += $(srcdir)/themes/starfield/src/slider_s.xcf $(srcdir)/themes/starfield/src/slider_n.xcf $(srcdir)/themes/starfield/src/slider_c.xcf $(srcdir)/themes/starfield/src/blob_nw.xcf $(srcdir)/themes/starfield/src/bootmenu/center.xcf $(srcdir)/themes/starfield/src/bootmenu/corner.xcf $(srcdir)/themes/starfield/src/bootmenu/side.xcf $(srcdir)/themes/starfield/src/terminalbox/side.xcf $(srcdir)/themes/starfield/src/terminalbox/corner.xcf $(srcdir)/themes/starfield/src/terminalbox/center.xcf
unicode.pf2: $(FONT_SOURCE) build-grub-mkfont
./build-grub-mkfont -o $@ $(FONT_SOURCE)
./build-grub-mkfont -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1)
CLEANFILES += unicode.pf2
# Arrows and lines are needed to draw the menu, so always include them
@ -111,19 +111,19 @@ UNICODE_ARROWS=0x2190-0x2193
UNICODE_LINES=0x2501-0x251B
ascii.pf2: $(FONT_SOURCE) build-grub-mkfont
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES)
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
CLEANFILES += ascii.pf2
euro.pf2: $(FONT_SOURCE) build-grub-mkfont
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES)
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
CLEANFILES += euro.pf2
ascii.h: $(FONT_SOURCE) build-grub-gen-asciih
./build-grub-gen-asciih $(FONT_SOURCE) $@
./build-grub-gen-asciih $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
CLEANFILES += ascii.h
widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec
./build-grub-gen-widthspec $(FONT_SOURCE) $@
./build-grub-gen-widthspec $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
CLEANFILES += widthspec.h
# Install config.h into platformdir

View File

@ -11,10 +11,12 @@ if COND_sparc64_ieee1275
LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax
endif
if COND_arm
CFLAGS_PLATFORM += -mthumb-interwork -mlong-calls
CFLAGS_PLATFORM += -mthumb-interwork
CCASFLAGS_PLATFORM = -mthumb-interwork
if !COND_emu
LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache
endif
endif
if COND_arm64
CFLAGS_PLATFORM += -mcmodel=large
endif
@ -73,7 +75,7 @@ grubconfdir = $(sysconfdir)/grub.d
platformdir = $(pkglibdir)/$(target_cpu)-$(platform)
starfielddir = $(pkgdatadir)/themes/starfield
CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-old-style-definition
CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion
CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib
CFLAGS_POSIX = -fno-builtin

View File

@ -30,6 +30,7 @@
#elif defined (GRUB_UTIL) || !defined (GRUB_MACHINE)
#include <config-util.h>
#else
#define HAVE_FONT_SOURCE @HAVE_FONT_SOURCE@
/* Define if C symbols get an underscore after compilation. */
#define HAVE_ASM_USCORE @HAVE_ASM_USCORE@
/* Define it to \"addr32\" or \"addr32;\" to make GAS happy. */

View File

@ -422,6 +422,26 @@ esac
# For gnulib.
gl_INIT
WARN_FLAGS="-Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wpointer-arith -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes"
EXTRA_WARN_FLAGS="-Wold-style-definition -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign"
HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [
SAVED_CFLAGS="$CFLAGS"
grub_cv_cc_w_extra_flags=
for x in $EXTRA_WARN_FLAGS; do
CFLAGS="$HOST_CFLAGS $x -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
if test x$flag = x1 ; then
grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x"
fi
done
CFLAGS="$SAVED_CFLAGS"
])
HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
#
# Check for target programs.
#
@ -472,8 +492,6 @@ LDFLAGS="$TARGET_LDFLAGS"
LIBS=""
# debug flags.
WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
@ -481,8 +499,25 @@ if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
fi
AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
grub_cv_target_cc_w_extra_flags=
for x in $EXTRA_WARN_FLAGS; do
CFLAGS="$TARGET_CFLAGS $x -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
if test x$flag = x1 ; then
grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x"
fi
done
])
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang]
[AC_COMPILE_IFELSE(
[
CFLAGS="$TARGET_CFLAGS"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifdef __clang__
#error "is clang"
@ -500,6 +535,26 @@ if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
fi
if test "x$grub_cv_cc_target_clang" = xyes && test "x$target_cpu" = xpowerpc; then
AC_CACHE_CHECK([if clang can handle ame instruction], [grub_cv_cc_target_clang_ame]
[
CFLAGS="$TARGET_CFLAGS"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
unsigned int a = 0, b = 0;
asm volatile ("{ame|addme} %0,%1" : "=r" (a) : "r" (b));
if (a)
return 1;
]])],
[grub_cv_cc_target_clang_ame=yes], [grub_cv_cc_target_clang_ame=no])])
# clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly
# used by gcrypt
if test x$grub_cv_cc_target_clang_ame = xno ; then
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
TARGET_CFLAGS="$TARGET_CFLAGS -no-integrated-as"
fi
fi
if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
fi
@ -793,6 +848,18 @@ if test "$target_cpu"-"$platform" = x86_64-efi; then
TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
fi
if test "x$target_cpu" = xarm; then
AC_CACHE_CHECK([whether option -mlong-calls works], grub_cv_cc_mlong_calls, [
CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_mlong_calls=yes],
[grub_cv_cc_mlong_calls=no])
])
if test "x$grub_cv_cc_mlong_calls" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -mlong-calls"
fi
fi
#
# Compiler features.
#
@ -848,7 +915,7 @@ CFLAGS="$TARGET_CFLAGS"
# -mno-unaligned-access -mstrict-align
if test "$target_cpu" = arm; then
AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
grub_cv_target_cc_strict_align=unknown
grub_cv_target_cc_strict_align=
for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
CFLAGS="$TARGET_CFLAGS $arg -Werror"
LDFLAGS="$TARGET_LDFLAGS"
@ -859,13 +926,21 @@ if test "$target_cpu" = arm; then
fi
done])
if test x"$grub_cv_target_cc_strict_align" = xunknown; then
AC_MSG_ERROR([couldnt instruct compiler not to use unaligned access])
fi
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
fi
AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned],
[CFLAGS="$TARGET_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
#ifdef __ARM_FEATURE_UNALIGNED
#error "unaligned"
#endif
]])],
[grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])])
if test x$grub_cv_cc_target_emits_unaligned = xyes; then
AC_MSG_ERROR([compiler generates unaligned accesses])
fi
fi
# Set them to their new values for the tests below.
@ -1126,10 +1201,14 @@ if test x"$grub_mkfont_excuse" = x ; then
freetype_cflags=`$FREETYPE --cflags`
freetype_libs=`$FREETYPE --libs`
SAVED_CPPFLAGS="$CPPFLAGS"
SAVED_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $freetype_cflags"
LIBS="$LIBS $freetype_libs"
AC_CHECK_HEADERS([ft2build.h], [],
[grub_mkfont_excuse=["need freetype2 headers"]])
AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], [grub_mkfont_excuse=["freetype2 library unusable"]])
CPPFLAGS="$SAVED_CPPFLAGS"
LIBS="$SAVED_LIBS"
fi
if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
@ -1181,9 +1260,13 @@ if test x"$grub_build_mkfont_excuse" = x ; then
build_freetype_cflags=`$BUILD_FREETYPE --cflags`
build_freetype_libs=`$BUILD_FREETYPE --libs`
SAVED_CPPFLAGS_2="$CPPFLAGS"
SAVED_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $build_freetype_cflags"
LIBS="$LIBS $build_freetype_libs"
AC_CHECK_HEADERS([ft2build.h], [],
[grub_build_mkfont_excuse=["need freetype2 headers"]])
AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], [grub_build_mkfont_excuse=["freetype2 library unusable"]])
LIBS="$SAVED_LIBS"
CPPFLAGS="$SAVED_CPPFLAGS_2"
fi
@ -1195,8 +1278,8 @@ if test x"$grub_build_mkfont_excuse" = x ; then
else
enable_build_grub_mkfont=no
fi
if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 ); then
AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports needs build-time grub-mkfont])
if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont])
fi
AC_SUBST([build_freetype_cflags])
@ -1249,6 +1332,11 @@ FONT_SOURCE=
for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc; do
if test -f "$dir/unifont.$ext"; then
md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
# PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
continue;
fi
FONT_SOURCE="$dir/unifont.$ext"
break 2
fi
@ -1259,8 +1347,8 @@ if test x"$enable_build_grub_mkfont" = xno ; then
FONT_SOURCE=
fi
if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 ); then
AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports need unifont])
if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont])
fi
AC_SUBST([FONT_SOURCE])
@ -1577,6 +1665,12 @@ AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
if test x$FONT_SOURCE != x ; then
HAVE_FONT_SOURCE=1
else
HAVE_FONT_SOURCE=0
fi
AC_SUBST(HAVE_FONT_SOURCE)
AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
grub2 (2.00+20131203-1) UNRELEASED; urgency=low
grub2 (2.00+20131208-1) UNRELEASED; urgency=low
* New upstream snapshot.
- Skip issuing cursor on/off sequences on Macs (closes: #683068).

View File

@ -11,7 +11,7 @@ Index: b/util/setup.c
/* On SPARC this program fills in various fields inside of the 'boot' and 'core'
* image files.
*
@@ -601,6 +603,8 @@
@@ -577,6 +579,8 @@
grub_free (sectors);
@ -20,7 +20,7 @@ Index: b/util/setup.c
goto finish;
}
@@ -643,6 +647,10 @@
@@ -619,6 +623,10 @@
/* The core image must be put on a filesystem unfortunately. */
grub_util_info ("will leave the core image on the filesystem");

View File

@ -2,7 +2,7 @@ Description: Read /etc/default/grub.d/*.cfg after /etc/default/grub
Author: Colin Watson <cjwatson@ubuntu.com>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/901600
Forwarded: no
Last-Update: 2013-11-19
Last-Update: 2013-12-08
Index: b/grub-core/osdep/unix/config.c
===================================================================
@ -92,7 +92,7 @@ Index: b/util/grub-mkconfig.in
===================================================================
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -149,6 +149,11 @@
@@ -153,6 +153,11 @@
if test -f ${sysconfdir}/default/grub ; then
. ${sysconfdir}/default/grub
fi

View File

@ -5,13 +5,13 @@ Description: Add configure option to enable gfxpayload=keep dynamically
Author: Evan Broder <evan@ebroder.net>
Author: Colin Watson <cjwatson@ubuntu.com>
Forwarded: no
Last-Update: 2013-12-03
Last-Update: 2013-12-08
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -1446,6 +1446,17 @@
@@ -1534,6 +1534,17 @@
fi
AC_SUBST([QUICK_BOOT])
@ -33,7 +33,7 @@ Index: b/grub-core/Makefile.core.def
===================================================================
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -894,6 +894,15 @@
@@ -897,6 +897,15 @@
};
module = {
@ -212,7 +212,7 @@ Index: b/util/grub.d/10_linux.in
. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
@@ -139,9 +140,10 @@
@@ -133,9 +134,10 @@
if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then
echo " load_video" | sed "s/^/$submenu_indentation/"
fi
@ -226,7 +226,7 @@ Index: b/util/grub.d/10_linux.in
fi
echo " insmod gzio" | sed "s/^/$submenu_indentation/"
@@ -214,6 +216,35 @@
@@ -208,6 +210,35 @@
boot_device_id=
title_correction_code=

View File

@ -11,13 +11,13 @@ Description: Disable gfxpayload=keep by default
Author: Colin Watson <cjwatson@debian.org>
Bug-Debian: http://bugs.debian.org/567245
Forwarded: no
Last-Update: 2010-03-09
Last-Update: 2013-12-08
Index: b/util/grub.d/10_linux.in
===================================================================
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -108,10 +108,6 @@
@@ -102,10 +102,6 @@
# FIXME: We need an interface to select vesafb in case efifb can't be used.
if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
echo " load_video" | sed "s/^/$submenu_indentation/"

View File

@ -2,7 +2,7 @@ Index: b/util/grub-mkconfig.in
===================================================================
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -256,6 +256,10 @@
@@ -260,6 +260,10 @@
esac
done

View File

@ -5,13 +5,13 @@ Description: Cope with Kubuntu setting GRUB_DISTRIBUTOR
Author: Colin Watson <cjwatson@ubuntu.com>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1242417
Forwarded: not-needed
Last-Update: 2013-12-03
Last-Update: 2013-12-08
Index: b/util/grub-install.c
===================================================================
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -945,6 +945,8 @@
@@ -950,6 +950,8 @@
*/
char *t;
efi_distributor = bootloader_id;

View File

@ -2,13 +2,13 @@ Description: Prefer translations from Ubuntu language packs if available
Author: Colin Watson <cjwatson@ubuntu.com>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/537998
Forwarded: not-needed
Last-Update: 2013-12-03
Last-Update: 2013-12-08
Index: b/util/grub-install-common.c
===================================================================
--- a/util/grub-install-common.c
+++ b/util/grub-install-common.c
@@ -567,17 +567,24 @@
@@ -590,17 +590,24 @@
}
static void
@ -36,7 +36,7 @@ Index: b/util/grub-install-common.c
return;
}
@@ -594,14 +601,14 @@
@@ -617,14 +624,14 @@
if (ext && (grub_strcmp (ext, ".mo") == 0
|| grub_strcmp (ext, ".gmo") == 0))
{
@ -53,7 +53,7 @@ Index: b/util/grub-install-common.c
"LC_MESSAGES", PACKAGE, ".mo");
dstf = grub_util_path_concat_ext (2, dstd, de->d_name, ".mo");
}
@@ -610,6 +617,7 @@
@@ -633,6 +640,7 @@
free (dstf);
}
grub_util_fd_closedir (d);
@ -61,7 +61,7 @@ Index: b/util/grub-install-common.c
}
static struct
@@ -732,12 +740,14 @@
@@ -756,12 +764,14 @@
{
char *srcd = grub_util_path_concat (2, src, "po");
copy_by_ext (srcd, dst_locale, ".mo", 0);
@ -77,7 +77,7 @@ Index: b/util/grub-install-common.c
for (i = 0; i < install_locales.n_entries; i++)
{
@@ -756,6 +766,19 @@
@@ -780,6 +790,19 @@
}
free (srcf);
srcf = grub_util_path_concat_ext (4,
@ -97,7 +97,7 @@ Index: b/util/grub-install-common.c
locale_dir,
install_locales.entries[i],
"LC_MESSAGES",
@@ -770,6 +793,8 @@
@@ -794,6 +817,8 @@
grub_util_error (_("cannot find locale `%s'"),
install_locales.entries[i]);
}

View File

@ -3,7 +3,7 @@ Author: Colin Watson <cjwatson@ubuntu.com>
Author: Stéphane Graber <stgraber@ubuntu.com>
Author: Steve Langasek <steve.langasek@ubuntu.com>
Forwarded: no
Last-Update: 2013-12-03
Last-Update: 2013-12-08
Index: b/util/grub-install.c
===================================================================
@ -58,7 +58,7 @@ Index: b/util/grub-install.c
{0, 0, 0, 0, 0, 0}
};
@@ -689,7 +708,8 @@
@@ -694,7 +713,8 @@
{
int is_efi = 0;
const char *efi_distributor = NULL;
@ -68,7 +68,7 @@ Index: b/util/grub-install.c
char **grub_devices;
grub_fs_t grub_fs;
grub_device_t grub_dev = NULL;
@@ -925,6 +945,31 @@
@@ -930,6 +950,31 @@
*/
char *t;
efi_distributor = bootloader_id;
@ -100,7 +100,7 @@ Index: b/util/grub-install.c
if (removable)
{
/* The specification makes stricter requirements of removable
@@ -933,54 +978,16 @@
@@ -938,54 +983,16 @@
must have a specific file name depending on the architecture.
*/
efi_distributor = "BOOT";
@ -159,7 +159,7 @@ Index: b/util/grub-install.c
}
t = grub_util_path_concat (3, efidir, "EFI", efi_distributor);
free (efidir);
@@ -1110,6 +1117,31 @@
@@ -1120,6 +1127,31 @@
}
}
@ -191,7 +191,7 @@ Index: b/util/grub-install.c
if (!have_abstractions)
{
if ((disk_module && grub_strcmp (disk_module, "biosdisk") != 0)
@@ -1117,7 +1149,8 @@
@@ -1127,7 +1159,8 @@
|| (!install_drive
&& platform != GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275)
|| (install_drive && !is_same_disk (grub_drives[0], install_drive))
@ -201,7 +201,7 @@ Index: b/util/grub-install.c
{
char *uuid = NULL;
/* generic method (used on coreboot and ata mod). */
@@ -1549,7 +1582,47 @@
@@ -1557,7 +1590,47 @@
case GRUB_INSTALL_PLATFORM_IA64_EFI:
{
char *dst = grub_util_path_concat (2, efidir, efi_file);

View File

@ -2,7 +2,7 @@ Description: If GRUB Legacy is still around, tell packaging to ignore it
Author: Colin Watson <cjwatson@debian.org>
Bug-Debian: http://bugs.debian.org/586143
Forwarded: not-needed
Last-Update: 2013-12-03
Last-Update: 2013-12-08
Index: b/util/grub-install.c
===================================================================
@ -16,7 +16,7 @@ Index: b/util/grub-install.c
#include <string.h>
@@ -1442,6 +1443,19 @@
@@ -1450,6 +1451,19 @@
grub_util_bios_setup (platdir, "boot.img", "core.img",
install_drive, force,
fs_probe, allow_floppy);

View File

@ -2,13 +2,13 @@ Description: Add "linuxefi" loader which avoids ExitBootServices
Author: Matthew Garrett <mjg@redhat.com>
Origin: vendor, http://pkgs.fedoraproject.org/cgit/grub2.git/tree/grub2-linuxefi.patch
Forwarded: no
Last-Update: 2013-12-03
Last-Update: 2013-12-08
Index: b/grub-core/Makefile.core.def
===================================================================
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -1688,6 +1688,14 @@
@@ -1691,6 +1691,14 @@
};
module = {

View File

@ -1,13 +1,13 @@
Description: Only build linuxefi on amd64
Author: Colin Watson <cjwatson@ubuntu.com>
Forwarded: no
Last-Update: 2013-12-03
Last-Update: 2013-12-08
Index: b/grub-core/Makefile.core.def
===================================================================
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -1691,7 +1691,6 @@
@@ -1694,7 +1694,6 @@
name = linuxefi;
efi = loader/i386/efi/linux.c;
efi = lib/cmdline.c;

View File

@ -25,7 +25,7 @@ Author: Colin Watson <cjwatson@ubuntu.com>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/386922
Bug-Ubuntu: https://bugs.launchpad.net/bugs/861048
Forwarded: (partial) http://lists.gnu.org/archive/html/grub-devel/2009-09/msg00056.html
Last-Update: 2013-12-04
Last-Update: 2013-12-08
Index: b/config.h.in
===================================================================
@ -44,7 +44,7 @@ Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -1424,6 +1424,17 @@
@@ -1512,6 +1512,17 @@
fi
AC_SUBST([UBUNTU_RECOVERY])
@ -62,7 +62,7 @@ Index: b/configure.ac
LIBS=""
AC_SUBST([FONT_SOURCE])
@@ -1673,5 +1684,10 @@
@@ -1767,5 +1778,10 @@
else
echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
fi
@ -331,7 +331,7 @@ Index: b/util/grub.d/10_linux.in
. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
@@ -152,10 +153,12 @@
@@ -146,10 +147,12 @@
fi
printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
fi
@ -346,7 +346,7 @@ Index: b/util/grub.d/10_linux.in
if test -d /sys/firmware/efi && test -e "${linux}.efi.signed"; then
sed "s/^/$submenu_indentation/" << EOF
linux ${rel_dirname}/${basename}.efi.signed root=${linux_root_device_thisversion} ro ${args}
@@ -167,9 +170,13 @@
@@ -161,9 +164,13 @@
fi
if test -n "${initrd}" ; then
# TRANSLATORS: ramdisk isn't identifier. Should be translated.

View File

@ -3,7 +3,7 @@ Description: Add GRUB_RECOVERY_TITLE option
Author: Colin Watson <cjwatson@ubuntu.com>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1240360
Forwarded: no
Last-Update: 2013-12-03
Last-Update: 2013-12-08
Index: b/docs/grub.texi
===================================================================
@ -25,7 +25,7 @@ Index: b/util/grub-mkconfig.in
===================================================================
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -181,6 +181,10 @@
@@ -185,6 +185,10 @@
if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub_editenv}" - list | sed -n '/^saved_entry=/ s,^saved_entry=,,p'`" ; fi
@ -36,7 +36,7 @@ Index: b/util/grub-mkconfig.in
# These are defined in this script, export them here so that user can
# override them.
@@ -232,7 +236,8 @@
@@ -236,7 +240,8 @@
GRUB_BADRAM \
GRUB_OS_PROBER_SKIP_LIST \
GRUB_DISABLE_SUBMENU \
@ -78,7 +78,7 @@ Index: b/util/grub.d/10_linux.in
===================================================================
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -120,7 +120,7 @@
@@ -114,7 +114,7 @@
if [ x$type != xsimple ] ; then
case $type in
recovery)
@ -104,7 +104,7 @@ Index: b/util/grub.d/20_linux_xen.in
===================================================================
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -99,7 +99,7 @@
@@ -93,7 +93,7 @@
fi
if [ x$type != xsimple ] ; then
if [ x$type = xrecovery ] ; then

View File

@ -1,13 +1,13 @@
Description: Generate configuration for signed UEFI kernels if available
Author: Colin Watson <cjwatson@ubuntu.com>
Forwarded: no
Last-Update: 2013-11-14
Last-Update: 2013-12-08
Index: b/util/grub.d/10_linux.in
===================================================================
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -155,8 +155,16 @@
@@ -149,8 +149,16 @@
message="$(gettext_printf "Loading Linux %s ..." ${version})"
sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)'
@ -24,7 +24,7 @@ Index: b/util/grub.d/10_linux.in
if test -n "${initrd}" ; then
# TRANSLATORS: ramdisk isn't identifier. Should be translated.
message="$(gettext_printf "Loading initial ramdisk ...")"
@@ -202,6 +210,13 @@
@@ -196,6 +204,13 @@
is_top_level=true
while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`

View File

@ -6,13 +6,13 @@ Description: "single" -> "recovery" when friendly-recovery is installed
Author: Colin Watson <cjwatson@ubuntu.com>
Author: Stéphane Graber <stgraber@ubuntu.com>
Forwarded: no
Last-Update: 2013-12-03
Last-Update: 2013-12-08
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -1413,6 +1413,17 @@
@@ -1501,6 +1501,17 @@
AC_SUBST([LIBZFS])
AC_SUBST([LIBNVPAIR])
@ -42,7 +42,7 @@ Index: b/util/grub.d/10_linux.in
. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
@@ -78,6 +79,15 @@
@@ -72,6 +73,15 @@
title_correction_code=
@ -58,7 +58,7 @@ Index: b/util/grub.d/10_linux.in
linux_entry ()
{
os="$1"
@@ -117,7 +127,9 @@
@@ -111,7 +121,9 @@
if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then
echo " load_video" | sed "s/^/$submenu_indentation/"
fi
@ -69,7 +69,7 @@ Index: b/util/grub.d/10_linux.in
fi
echo " insmod gzio" | sed "s/^/$submenu_indentation/"
@@ -245,7 +257,7 @@
@@ -239,7 +251,7 @@
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
linux_entry "${OS}" "${version}" recovery \

View File

@ -3,13 +3,13 @@ Author: Mario Limonciello <Mario_Limonciello@dell.com>
Author: Colin Watson <cjwatson@ubuntu.com>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/677758
Forwarded: http://lists.gnu.org/archive/html/grub-devel/2011-01/msg00028.html
Last-Update: 2013-11-29
Last-Update: 2013-12-08
Index: b/util/grub-mkrescue.c
===================================================================
--- a/util/grub-mkrescue.c
+++ b/util/grub-mkrescue.c
@@ -638,12 +638,18 @@
@@ -631,12 +631,18 @@
make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_IA64_EFI, "ia64-efi", imgname);
free (imgname);

View File

@ -3,14 +3,14 @@ Author: Matthew Garrett <mjg@redhat.com>
Author: Colin Watson <cjwatson@ubuntu.com>
Origin: vendor, http://pkgs.fedoraproject.org/cgit/grub2.git/tree/grub-2.00-no-insmod-on-sb.patch
Forwarded: no
Last-Update: 2013-11-26
Last-Update: 2013-12-08
Index: b/grub-core/kern/dl.c
===================================================================
--- a/grub-core/kern/dl.c
+++ b/grub-core/kern/dl.c
@@ -42,6 +42,10 @@
#include <sys/mman.h>
@@ -38,6 +38,10 @@
#define GRUB_MODULES_MACHINE_READONLY
#endif
+#ifdef GRUB_MACHINE_EFI
@ -20,7 +20,7 @@ Index: b/grub-core/kern/dl.c
#pragma GCC diagnostic ignored "-Wcast-align"
@@ -654,6 +658,15 @@
@@ -678,6 +682,15 @@
void *core = 0;
grub_dl_t mod = 0;

View File

@ -14,13 +14,13 @@ Description: Add configure option to bypass boot menu if possible
Author: Colin Watson <cjwatson@ubuntu.com>
Author: Richard Laager <rlaager@wiktel.com>
Forwarded: no
Last-Update: 2013-12-03
Last-Update: 2013-12-08
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -1435,6 +1435,17 @@
@@ -1523,6 +1523,17 @@
fi
AC_SUBST([QUIET_BOOT])
@ -97,7 +97,7 @@ Index: b/util/grub-mkconfig.in
===================================================================
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -231,7 +231,8 @@
@@ -235,7 +235,8 @@
GRUB_ENABLE_CRYPTODISK \
GRUB_BADRAM \
GRUB_OS_PROBER_SKIP_LIST \
@ -224,7 +224,7 @@ Index: b/util/grub.d/10_linux.in
. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
@@ -123,6 +124,9 @@
@@ -117,6 +118,9 @@
else
echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
fi

View File

@ -4,13 +4,13 @@ Description: Add configure option to use vt.handoff=7
Author: Colin Watson <cjwatson@ubuntu.com>
Author: Andy Whitcroft <apw@canonical.com>
Forwarded: not-needed
Last-Update: 2013-12-03
Last-Update: 2013-12-08
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -1457,6 +1457,17 @@
@@ -1545,6 +1545,17 @@
fi
AC_SUBST([GFXPAYLOAD_DYNAMIC])
@ -40,7 +40,7 @@ Index: b/util/grub.d/10_linux.in
. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
@@ -98,6 +99,14 @@
@@ -92,6 +93,14 @@
GRUB_CMDLINE_LINUX_RECOVERY="$GRUB_CMDLINE_LINUX_RECOVERY nomodeset"
fi
@ -55,7 +55,7 @@ Index: b/util/grub.d/10_linux.in
linux_entry ()
{
os="$1"
@@ -143,7 +152,7 @@
@@ -137,7 +146,7 @@
fi
if ([ "$ubuntu_recovery" = 0 ] || [ x$type != xrecovery ]) && \
([ "x$GRUB_GFXPAYLOAD_LINUX" != x ] || [ "$gfxpayload_dynamic" = 1 ]); then
@ -64,7 +64,7 @@ Index: b/util/grub.d/10_linux.in
fi
echo " insmod gzio" | sed "s/^/$submenu_indentation/"
@@ -216,6 +225,23 @@
@@ -210,6 +219,23 @@
boot_device_id=
title_correction_code=

View File

@ -3137,7 +3137,7 @@ This variable contains the ``highlight'' foreground and background terminal
colors, separated by a slash (@samp{/}). Setting this variable changes
those colors. For the available color names, @pxref{color_normal}.
The default is @samp{black/white}.
The default is @samp{black/light-gray}.
@node color_normal
@ -3166,7 +3166,7 @@ those colors. Each color must be a name from the following list:
@item white
@end itemize
The default is @samp{white/black}.
The default is @samp{light-gray/black}.
The color support support varies from terminal to terminal.

View File

@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
__metaclass__ = type
from optparse import OptionParser
@ -434,7 +436,7 @@ def output(s, section=''):
def write_output(section=''):
for s in outputs.get(section, []):
print s,
print(s, end='')
#
# Global variables

View File

@ -10,10 +10,6 @@ CCAS=$(TARGET_CC)
RANLIB=$(TARGET_RANLIB)
STRIP=$(TARGET_STRIP)
if COND_HAVE_FONT_SOURCE
TARGET_CFLAGS += -DUSE_ASCII_FALLBACK=1 -DHAVE_UNIFONT_WIDTHSPEC=1
endif
MACHO2IMG=$(top_builddir)/grub-macho2img
AM_CFLAGS = $(TARGET_CFLAGS)
@ -173,7 +169,6 @@ endif
if COND_mips_qemu_mips
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/serial.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
@ -185,7 +180,6 @@ if COND_mips_loongson
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/time.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h

View File

@ -88,7 +88,6 @@ kernel = {
mips_qemu_mips_ldflags = '-Wl,-Ttext,0x80200000';
mips_arc_cppflags = '-DGRUB_DECOMPRESSOR_LINK_ADDR=$(TARGET_DECOMPRESSOR_LINK_ADDR)';
mips_loongson_cppflags = '-DUSE_ASCII_FALLBACK';
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
emu_cflags = '$(CFLAGS_GNULIB)';
emu_cppflags = '$(CPPFLAGS_GNULIB)';
@ -194,6 +193,7 @@ kernel = {
ia64_efi = kern/ia64/efi/init.c;
ia64_efi = kern/ia64/dl.c;
ia64_efi = kern/ia64/dl_helper.c;
ia64_efi = kern/ia64/cache.c;
arm_efi = kern/arm/efi/init.c;
arm_efi = kern/arm/efi/misc.c;
@ -283,6 +283,9 @@ kernel = {
emu = osdep/emuconsole.c;
extra_dist = osdep/unix/emuconsole.c;
extra_dist = osdep/windows/emuconsole.c;
emu = osdep/dl.c;
extra_dist = osdep/unix/dl.c;
extra_dist = osdep/windows/dl.c;
emu = osdep/sleep.c;
emu = osdep/init.c;
emu = osdep/emunet.c;

View File

@ -48,7 +48,7 @@ kernel_byte: .xword (2 << 9)
boot_path_end:
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
#else
#define boot_path (_start + 512)
#define boot_path (_start + 512 + SCRATCH_PAD_BOOT_SIZE)
#define boot_path_end (_start + 1024)
#include <grub/offsets.h>
@ -140,7 +140,11 @@ prom_call:
boot_continue:
mov %o7, PIC_REG /* PIC base */
#ifndef CDBOOT
sethi %hi(SCRATCH_PAD_BOOT), %l1 /* OF argument slots */
#else
GET_ABS(_start + 512, %l1) /* OF argument slots */
#endif
/* Find the /chosen node so we can fetch the stdout handle,
* and thus perform console output.

View File

@ -31,11 +31,14 @@ static grub_ieee1275_ihandle_t last_ihandle;
struct ofdisk_hash_ent
{
char *devpath;
char *open_path;
char *grub_devpath;
int is_boot;
int is_cdrom;
/* Pointer to shortest available name on nodes representing canonical names,
otherwise NULL. */
const char *shortest;
const char *grub_shortest;
struct ofdisk_hash_ent *next;
};
@ -70,12 +73,50 @@ ofdisk_hash_add_real (char *devpath)
{
struct ofdisk_hash_ent *p;
struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)];
const char *iptr;
char *optr;
p = grub_zalloc (sizeof (*p));
if (!p)
return NULL;
p->devpath = devpath;
p->grub_devpath = grub_malloc (sizeof ("ieee1275/")
+ 2 * grub_strlen (p->devpath));
if (!p->grub_devpath)
{
grub_free (p);
return NULL;
}
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0))
{
p->open_path = grub_malloc (grub_strlen (p->devpath) + 3);
if (!p->open_path)
{
grub_free (p->grub_devpath);
grub_free (p);
return NULL;
}
optr = grub_stpcpy (p->open_path, p->devpath);
*optr++ = ':';
*optr++ = '0';
*optr = '\0';
}
else
p->open_path = p->devpath;
optr = grub_stpcpy (p->grub_devpath, "ieee1275/");
for (iptr = p->devpath; *iptr; )
{
if (*iptr == ',')
*optr++ = '\\';
*optr++ = *iptr++;
}
*optr = 0;
p->next = *head;
*head = p;
return p;
@ -104,7 +145,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
if (!curcan)
{
p->shortest = devpath;
p->shortest = p->devpath;
p->grub_shortest = p->grub_devpath;
if (check_string_cdrom (devpath))
p->is_cdrom = 1;
return p;
@ -125,7 +167,10 @@ ofdisk_hash_add (char *devpath, char *curcan)
{
if (!pcan->shortest
|| grub_strlen (pcan->shortest) > grub_strlen (devpath))
pcan->shortest = devpath;
{
pcan->shortest = p->devpath;
pcan->grub_shortest = p->grub_devpath;
}
}
return p;
@ -288,23 +333,10 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
if (!ent->is_boot && ent->is_cdrom)
continue;
{
char buffer[sizeof ("ieee1275/") + 2 * grub_strlen (ent->shortest)];
const char *iptr;
char *optr;
optr = grub_stpcpy (buffer, "ieee1275/");
for (iptr = ent->shortest; *iptr; )
{
if (*iptr == ',')
*optr++ = '\\';
*optr++ = *iptr++;
}
*optr = 0;
if (hook (buffer, hook_data))
if (hook (ent->grub_shortest, hook_data))
return 1;
}
}
}
return 0;
}
@ -396,7 +428,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
if (!op)
return grub_errno;
disk->id = (unsigned long) op;
disk->data = op->devpath;
disk->data = op->open_path;
}
return 0;
@ -428,19 +460,6 @@ grub_ofdisk_prepare (grub_disk_t disk, grub_disk_addr_t sector)
last_ihandle = 0;
last_devpath = NULL;
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0))
{
char name2[grub_strlen (disk->data) + 3];
char *p;
grub_strcpy (name2, disk->data);
p = name2 + grub_strlen (name2);
*p++ = ':';
*p++ = '0';
*p = 0;
grub_ieee1275_open (name2, &last_ihandle);
}
else
grub_ieee1275_open (disk->data, &last_ihandle);
if (! last_ihandle)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");

View File

@ -33,7 +33,7 @@
GRUB_MOD_LICENSE ("GPLv3+");
#ifdef USE_ASCII_FALLBACK
#if HAVE_FONT_SOURCE
#include "ascii.h"
#endif
@ -110,14 +110,14 @@ static struct grub_font null_font;
/* Flag to ensure module is initialized only once. */
static grub_uint8_t font_loader_initialized;
#ifdef USE_ASCII_FALLBACK
#if HAVE_FONT_SOURCE
static struct grub_font_glyph *ascii_font_glyph[0x80];
#endif
static struct grub_font_glyph *
ascii_glyph_lookup (grub_uint32_t code)
{
#ifdef USE_ASCII_FALLBACK
#if HAVE_FONT_SOURCE
static int ascii_failback_initialized = 0;
if (code >= 0x80)

View File

@ -25,45 +25,113 @@
#include <grub/i18n.h>
#include <grub/arm/reloc.h>
struct trampoline_arm
{
#define ARM_LOAD_IP 0xe59fc000
#define ARM_BX 0xe12fff1c
#define ARM_MOV_PC 0xe1a0f00c
grub_uint32_t load_ip; /* ldr ip, [pc] */
grub_uint32_t bx; /* bx ip or mov pc, ip*/
grub_uint32_t addr;
};
static grub_uint16_t thumb_template[8] =
{
0x468c, /* mov ip, r1 */
0x4903, /* ldr r1, [pc, #12] ; (10 <.text+0x10>) */
/* Exchange R1 and IP in limited Thumb instruction set.
IP gets negated but we compensate it by C code. */
/* R1 IP */
/* -A R1 */
0x4461, /* add r1, ip */ /* R1-A R1 */
0x4249, /* negs r1, r1 */ /* A-R1 R1 */
0x448c, /* add ip, r1 */ /* A-R1 A */
0x4249, /* negs r1, r1 */ /* R1-A A */
0x4461, /* add r1, ip */ /* R1 A */
0x4760 /* bx ip */
};
struct trampoline_thumb
{
grub_uint16_t template[8];
grub_uint32_t neg_addr;
};
#pragma GCC diagnostic ignored "-Wcast-align"
grub_err_t
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
grub_size_t *got)
{
const Elf_Ehdr *e = ehdr;
const Elf_Shdr *s;
unsigned i;
*tramp = 0;
*got = 0;
for (i = 0, s = (const Elf_Shdr *) ((grub_addr_t) e + e->e_shoff);
i < e->e_shnum;
i++, s = (const Elf_Shdr *) ((grub_addr_t) s + e->e_shentsize))
if (s->sh_type == SHT_REL)
{
const Elf_Rel *rel, *max;
for (rel = (const Elf_Rel *) ((grub_addr_t) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
rel < max;
rel++)
switch (ELF_R_TYPE (rel->r_info))
{
case R_ARM_CALL:
case R_ARM_JUMP24:
{
*tramp += sizeof (struct trampoline_arm);
break;
}
case R_ARM_THM_CALL:
case R_ARM_THM_JUMP24:
case R_ARM_THM_JUMP19:
{
*tramp += sizeof (struct trampoline_thumb);
break;
}
}
}
grub_dprintf ("dl", "trampoline size %x\n", *tramp);
return GRUB_ERR_NONE;
}
/*************************************************
* Runtime dynamic linker with helper functions. *
*************************************************/
static grub_err_t
do_relocations (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod)
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{
grub_dl_segment_t seg;
Elf_Rel *rel;
Elf_Sym *sym;
int i, entnum;
Elf_Rel *rel, *max;
entnum = relhdr->sh_size / sizeof (Elf_Rel);
/* Find the target segment for this relocation section. */
for (seg = mod->segment ; seg ; seg = seg->next)
if (seg->section == relhdr->sh_info)
break;
if (!seg)
return grub_error (GRUB_ERR_EOF, N_("relocation segment not found"));
rel = (Elf_Rel *) ((grub_addr_t) e + relhdr->sh_offset);
/* Step through all relocations */
for (i = 0, sym = mod->symtab; i < entnum; i++)
for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
max = (Elf_Rel *) ((char *) rel + s->sh_size);
rel < max;
rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
{
Elf_Addr *target, sym_addr;
int relsym, reltype;
grub_err_t retval;
Elf_Sym *sym;
if (seg->size < rel[i].r_offset)
if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
relsym = ELF_R_SYM (rel[i].r_info);
reltype = ELF_R_TYPE (rel[i].r_info);
target = (void *) ((grub_addr_t) seg->addr + rel[i].r_offset);
target = (void *) ((char *) seg->addr + rel->r_offset);
sym = (Elf_Sym *) ((char *) mod->symtab
+ mod->symsize * ELF_R_SYM (rel->r_info));
sym_addr = sym[relsym].st_value;
sym_addr = sym->st_value;
switch (reltype)
switch (ELF_R_TYPE (rel->r_info))
{
case R_ARM_ABS32:
{
@ -76,16 +144,58 @@ do_relocations (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod)
case R_ARM_CALL:
case R_ARM_JUMP24:
{
retval = grub_arm_reloc_jump24 (target, sym_addr);
if (retval != GRUB_ERR_NONE)
return retval;
grub_int32_t offset;
sym_addr += grub_arm_jump24_get_offset (target);
offset = sym_addr - (grub_uint32_t) target;
if ((sym_addr & 1) || !grub_arm_jump24_check_offset (offset))
{
struct trampoline_arm *tp = mod->trampptr;
mod->trampptr = tp + 1;
tp->load_ip = ARM_LOAD_IP;
tp->bx = (sym_addr & 1) ? ARM_BX : ARM_MOV_PC;
tp->addr = sym_addr + 8;
offset = (grub_uint8_t *) tp - (grub_uint8_t *) target - 8;
}
if (!grub_arm_jump24_check_offset (offset))
return grub_error (GRUB_ERR_BAD_MODULE,
"trampoline out of range");
grub_arm_jump24_set_offset (target, offset);
}
break;
case R_ARM_THM_CALL:
case R_ARM_THM_JUMP24:
{
/* Thumb instructions can be 16-bit aligned */
retval = grub_arm_reloc_thm_call ((grub_uint16_t *) target, sym_addr);
grub_int32_t offset;
sym_addr += grub_arm_thm_call_get_offset ((grub_uint16_t *) target);
grub_dprintf ("dl", " sym_addr = 0x%08x\n", sym_addr);
offset = sym_addr - (grub_uint32_t) target;
grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n",
target, sym_addr, offset);
if (!(sym_addr & 1) || (offset < -0x200000 || offset >= 0x200000))
{
struct trampoline_thumb *tp = mod->trampptr;
mod->trampptr = tp + 1;
grub_memcpy (tp->template, thumb_template, sizeof (tp->template));
tp->neg_addr = -sym_addr - 4;
offset = ((grub_uint8_t *) tp - (grub_uint8_t *) target - 4) | 1;
}
if (offset < -0x200000 || offset >= 0x200000)
return grub_error (GRUB_ERR_BAD_MODULE,
"trampoline out of range");
grub_dprintf ("dl", " relative destination = %p\n",
(char *) target + offset);
retval = grub_arm_thm_call_set_offset ((grub_uint16_t *) target, offset);
if (retval != GRUB_ERR_NONE)
return retval;
}
@ -98,15 +208,37 @@ do_relocations (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod)
case R_ARM_THM_JUMP19:
{
/* Thumb instructions can be 16-bit aligned */
retval = grub_arm_reloc_thm_jump19 ((grub_uint16_t *) target, sym_addr);
if (retval != GRUB_ERR_NONE)
return retval;
grub_int32_t offset;
if (!(sym_addr & 1))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("Relocation targeting wrong execution state"));
sym_addr += grub_arm_thm_jump19_get_offset ((grub_uint16_t *) target);
offset = sym_addr - (grub_uint32_t) target;
if (!grub_arm_thm_jump19_check_offset (offset)
|| !(sym_addr & 1))
{
struct trampoline_thumb *tp = mod->gotptr;
mod->gotptr = tp + 1;
grub_memcpy (tp->template, thumb_template, sizeof (tp->template));
tp->neg_addr = -sym_addr - 4;
offset = ((grub_uint8_t *) tp - (grub_uint8_t *) target - 4) | 1;
}
if (!grub_arm_thm_jump19_check_offset (offset))
return grub_error (GRUB_ERR_BAD_MODULE,
"trampoline out of range");
grub_arm_thm_jump19_set_offset ((grub_uint16_t *) target, offset);
}
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
reltype);
ELF_R_TYPE (rel->r_info));
}
}
@ -130,77 +262,3 @@ grub_arch_dl_check_header (void *ehdr)
return GRUB_ERR_NONE;
}
/*
* Verify that provided ELF header contains reference to a symbol table
*/
static int
has_symtab (Elf_Ehdr * e)
{
int i;
Elf_Shdr *s;
for (i = 0, s = (Elf_Shdr *) ((grub_uint32_t) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((grub_uint32_t) s + e->e_shentsize))
if (s->sh_type == SHT_SYMTAB)
return 1;
return 0;
}
/*
* grub_arch_dl_relocate_symbols():
* Only externally visible function in this file.
* Locates the relocations section of the ELF object, and calls
* do_relocations() to deal with it.
*/
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
{
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
unsigned i;
if (!has_symtab (e))
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
#define FIRST_SHDR(x) ((Elf_Shdr *) ((grub_addr_t)(x) + (x)->e_shoff))
#define NEXT_SHDR(x, y) ((Elf_Shdr *) ((grub_addr_t)(y) + (x)->e_shentsize))
for (i = 0, s = FIRST_SHDR (e); i < e->e_shnum; i++, s = NEXT_SHDR (e, s))
{
grub_err_t ret;
switch (s->sh_type)
{
case SHT_REL:
{
/* Relocations, no addends */
ret = do_relocations (s, e, mod);
if (ret != GRUB_ERR_NONE)
return ret;
}
break;
case SHT_NULL:
case SHT_PROGBITS:
case SHT_SYMTAB:
case SHT_STRTAB:
case SHT_NOBITS:
case SHT_ARM_ATTRIBUTES:
break;
case SHT_RELA:
default:
{
grub_dprintf ("dl", "unhandled section_type: %d (0x%08x)\n",
s->sh_type, s->sh_type);
return GRUB_ERR_NOT_IMPLEMENTED_YET;
};
}
}
#undef FIRST_SHDR
#undef NEXT_SHDR
return GRUB_ERR_NONE;
}

View File

@ -38,8 +38,6 @@ grub_arm_reloc_abs32 (Elf32_Word *target, Elf32_Addr sym_addr)
tmp = grub_le_to_cpu32 (*target);
tmp += sym_addr;
*target = grub_cpu_to_le32 (tmp);
grub_dprintf ("dl", " %s: reloc_abs32 0x%08x => 0x%08x", __FUNCTION__,
(unsigned int) sym_addr, (unsigned int) tmp);
return GRUB_ERR_NONE;
}
@ -51,37 +49,16 @@ grub_arm_reloc_abs32 (Elf32_Word *target, Elf32_Addr sym_addr)
* little-endian, requiring some additional fiddling. *
********************************************************************/
/*
* R_ARM_THM_CALL/THM_JUMP24
*
* Relocate Thumb (T32) instruction set relative branches:
* B.W, BL and BLX
*/
grub_err_t
grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
grub_int32_t
grub_arm_thm_call_get_offset (grub_uint16_t *target)
{
grub_int32_t offset, offset_low, offset_high;
grub_uint32_t sign, j1, j2, is_blx;
grub_uint32_t insword, insmask;
grub_uint32_t sign, j1, j2;
grub_uint32_t insword;
grub_int32_t offset;
/* Extract instruction word in alignment-safe manner */
insword = (grub_le_to_cpu16 (*target) << 16)
| (grub_le_to_cpu16(*(target + 1)));
insmask = 0xf800d000;
/* B.W/BL or BLX? Affects range and expected target state */
if (((insword >> 12) & 0xd) == 0xc)
is_blx = 1;
else
is_blx = 0;
/* If BLX, target symbol must be ARM (target address LSB == 0) */
if (is_blx && (sym_addr & 1))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("Relocation targeting wrong execution state"));
offset_low = -16777216;
offset_high = is_blx ? 16777212 : 16777214;
/* Extract bitfields from instruction words */
sign = (insword >> 26) & 1;
@ -95,22 +72,32 @@ grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
if (offset & (1 << 24))
offset -= (1 << 25);
grub_dprintf ("dl", " sym_addr = 0x%08x", sym_addr);
return offset;
}
offset += sym_addr;
#ifndef GRUB_UTIL
offset -= (grub_uint32_t) target;
#endif
grub_err_t
grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset)
{
grub_uint32_t sign, j1, j2;
const grub_uint32_t insmask = 0xf800d000;
grub_uint32_t insword;
int is_blx;
grub_dprintf("dl", " %s: target=%p, sym_addr=0x%08x, offset=%d\n",
is_blx ? "BLX" : "BL", target, sym_addr, offset);
/* Extract instruction word in alignment-safe manner */
insword = (grub_le_to_cpu16 (*target) << 16)
| (grub_le_to_cpu16(*(target + 1)));
if ((offset < offset_low) || (offset > offset_high))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("THM_CALL Relocation out of range."));
if (((insword >> 12) & 0xd) == 0xc)
is_blx = 1;
else
is_blx = 0;
grub_dprintf ("dl", " relative destination = %p",
(char *) target + offset);
if (!is_blx && !(offset & 1))
return grub_error (GRUB_ERR_BAD_MODULE, "bl/b.w targettting ARM");
/* Transform blx into bl if necessarry. */
if (is_blx && (offset & 1))
insword |= (1 << 12);
/* Reassemble instruction word */
sign = (offset >> 24) & 1;
@ -130,21 +117,15 @@ grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
return GRUB_ERR_NONE;
}
/*
* R_ARM_THM_JUMP19
*
* Relocate conditional Thumb (T32) B<c>.W
*/
grub_err_t
grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
grub_int32_t
grub_arm_thm_jump19_get_offset (grub_uint16_t *target)
{
grub_int32_t offset;
grub_uint32_t insword, insmask;
grub_uint32_t insword;
/* Extract instruction word in alignment-safe manner */
insword = grub_le_to_cpu16 ((*target)) << 16
| grub_le_to_cpu16 (*(target + 1));
insmask = 0xfbc0d000;
insword = (grub_le_to_cpu16 (*target) << 16)
| (grub_le_to_cpu16(*(target + 1)));
/* Extract and sign extend offset */
offset = ((insword >> 26) & 1) << 19
@ -156,18 +137,22 @@ grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
if (offset & (1 << 20))
offset -= (1 << 21);
/* Adjust and re-truncate offset */
offset += sym_addr;
#ifndef GRUB_UTIL
offset -= (grub_uint32_t) target;
#endif
if ((offset > 1048574) || (offset < -1048576))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("THM_JUMP19 Relocation out of range."));
return offset;
}
void
grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset)
{
grub_uint32_t insword;
const grub_uint32_t insmask = 0xfbc0d000;
offset >>= 1;
offset &= 0xfffff;
/* Extract instruction word in alignment-safe manner */
insword = grub_le_to_cpu16 ((*target)) << 16
| grub_le_to_cpu16 (*(target + 1));
/* Reassemble instruction word and write back */
insword &= insmask;
insword |= ((offset >> 19) & 1) << 26
@ -177,9 +162,15 @@ grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
| (offset & 0x7ff);
*target = grub_cpu_to_le16 (insword >> 16);
*(target + 1) = grub_cpu_to_le16 (insword & 0xffff);
return GRUB_ERR_NONE;
}
int
grub_arm_thm_jump19_check_offset (grub_int32_t offset)
{
if ((offset > 1048574) || (offset < -1048576))
return 0;
return 1;
}
/***********************************************************
@ -188,35 +179,38 @@ grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
* ARM instructions are 32-bit in size and 32-bit aligned. *
***********************************************************/
/*
* R_ARM_JUMP24
*
* Relocate ARM (A32) B
*/
grub_err_t
grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr)
grub_int32_t
grub_arm_jump24_get_offset (grub_uint32_t *target)
{
grub_uint32_t insword;
grub_int32_t offset;
if (sym_addr & 1)
return grub_error (GRUB_ERR_BAD_MODULE,
N_("Relocation targeting wrong execution state"));
grub_uint32_t insword;
insword = grub_le_to_cpu32 (*target);
offset = (insword & 0x00ffffff) << 2;
if (offset & 0x02000000)
offset -= 0x04000000;
offset += sym_addr;
#ifndef GRUB_UTIL
offset -= (grub_uint32_t) target;
#endif
return offset;
}
int
grub_arm_jump24_check_offset (grub_int32_t offset)
{
if (offset >= 0x02000000 || offset < -0x02000000)
return 0;
return 1;
}
void
grub_arm_jump24_set_offset (grub_uint32_t *target,
grub_int32_t offset)
{
grub_uint32_t insword;
insword = grub_le_to_cpu32 (*target);
insword &= 0xff000000;
insword |= (offset >> 2) & 0x00ffffff;
*target = grub_cpu_to_le32 (insword);
return GRUB_ERR_NONE;
}

View File

@ -25,6 +25,15 @@
#include <grub/i18n.h>
#include <grub/cpu/reloc.h>
struct trampoline
{
#define LDR 0x58000050
#define BR 0xd61f0200
grub_uint32_t ldr; /* ldr x16, 8 */
grub_uint32_t br; /* br x16 */
grub_uint64_t addr;
};
/*
* Check if EHDR is a valid ELF header.
*/
@ -42,59 +51,76 @@ grub_arch_dl_check_header (void *ehdr)
return GRUB_ERR_NONE;
}
#pragma GCC diagnostic ignored "-Wcast-align"
grub_err_t
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
grub_size_t *got)
{
const Elf_Ehdr *e = ehdr;
const Elf_Shdr *s;
unsigned i;
*tramp = 0;
*got = 0;
for (i = 0, s = (const Elf_Shdr *) ((grub_addr_t) e + e->e_shoff);
i < e->e_shnum;
i++, s = (const Elf_Shdr *) ((grub_addr_t) s + e->e_shentsize))
if (s->sh_type == SHT_REL || s->sh_type == SHT_RELA)
{
const Elf_Rel *rel, *max;
for (rel = (const Elf_Rel *) ((grub_addr_t) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
rel < max;
rel = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_entsize))
switch (ELF_R_TYPE (rel->r_info))
{
case R_AARCH64_CALL26:
case R_AARCH64_JUMP26:
{
*tramp += sizeof (struct trampoline);
break;
}
}
}
return GRUB_ERR_NONE;
}
/*
* Unified function for both REL and RELA
*/
static grub_err_t
do_relX (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod)
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{
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;
Elf_Rel *rel, *max;
/* 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++)
for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
max = (Elf_Rel *) ((char *) rel + s->sh_size);
rel < max;
rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
{
Elf_Sym *sym;
void *place;
grub_uint64_t sym_addr, symidx, reltype;
grub_uint64_t sym_addr;
if (rel->r_offset >= segment->size)
if (rel->r_offset >= seg->size)
return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
symidx = ELF_R_SYM (rel->r_info);
reltype = ELF_R_TYPE (rel->r_info);
sym = (Elf_Sym *) ((char *) mod->symtab
+ mod->symsize * ELF_R_SYM (rel->r_info));
sym_addr = symbol[symidx].st_value;
if (relhdr->sh_type == SHT_RELA)
sym_addr += rela->r_addend;
sym_addr = sym->st_value;
if (s->sh_type == SHT_RELA)
sym_addr += ((Elf_Rela *) rel)->r_addend;
place = (void *) ((grub_addr_t) segment->addr + rel->r_offset);
place = (void *) ((grub_addr_t) seg->addr + rel->r_offset);
switch (reltype)
switch (ELF_R_TYPE (rel->r_info))
{
case R_AARCH64_ABS64:
{
@ -108,92 +134,32 @@ do_relX (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod)
break;
case R_AARCH64_CALL26:
case R_AARCH64_JUMP26:
retval = grub_arm64_reloc_xxxx26 (place, sym_addr);
{
grub_int64_t offset = sym_addr - (grub_uint64_t) place;
if (!grub_arm_64_check_xxxx26_offset (offset))
{
struct trampoline *tp = mod->trampptr;
mod->trampptr = tp + 1;
tp->ldr = LDR;
tp->br = BR;
tp->addr = sym_addr;
offset = (grub_uint8_t *) tp - (grub_uint8_t *) place;
}
if (!grub_arm_64_check_xxxx26_offset (offset))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("Trampoline out of range"));
grub_arm64_set_xxxx26_offset (place, offset);
}
break;
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;
};
ELF_R_TYPE (rel->r_info));
}
}
#undef FIRST_SHDR
#undef NEXT_SHDR
return GRUB_ERR_NONE;
}

View File

@ -25,46 +25,31 @@
#include <grub/i18n.h>
#include <grub/arm64/reloc.h>
static grub_ssize_t
sign_compress_offset (grub_ssize_t offset, int bitpos)
{
return offset & ((1LL << (bitpos + 1)) - 1);
}
/*
* grub_arm64_reloc_xxxx26():
*
* JUMP26/CALL26 relocations for B and BL instructions.
*/
grub_err_t
grub_arm64_reloc_xxxx26 (grub_uint32_t *place, Elf64_Addr adjust)
int
grub_arm_64_check_xxxx26_offset (grub_int64_t offset)
{
grub_uint32_t insword, insmask;
grub_ssize_t offset;
const grub_ssize_t offset_low = -(1 << 27), offset_high = (1 << 27) - 1;
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"));
}
return 0;
return 1;
}
void
grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset)
{
const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xfc000000);
grub_dprintf ("dl", " reloc_xxxx64 %p %c= 0x%llx\n",
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;
*place &= insmask;
*place |= grub_cpu_to_le32 (offset >> 2) & ~insmask;
}

View File

@ -38,10 +38,6 @@
#define GRUB_MODULES_MACHINE_READONLY
#endif
#ifdef GRUB_MACHINE_EMU
#include <sys/mman.h>
#endif
#ifdef GRUB_MACHINE_EFI
#include <grub/efi/efi.h>
#endif
@ -233,7 +229,7 @@ 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__) || defined (__mips__)
#if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__)
grub_size_t tramp;
grub_size_t got;
grub_err_t err;
@ -249,7 +245,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
talign = s->sh_addralign;
}
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__)
#if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__)
err = grub_arch_dl_get_tramp_got_size (e, &tramp, &got);
if (err)
return err;
@ -262,21 +258,15 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
#endif
#ifdef GRUB_MACHINE_EMU
if (talign < 8192 * 16)
talign = 8192 * 16;
tsize = ALIGN_UP (tsize, 8192 * 16);
#endif
mod->base = grub_osdep_dl_memalign (talign, tsize);
#else
mod->base = grub_memalign (talign, tsize);
#endif
if (!mod->base)
return grub_errno;
mod->sz = tsize;
ptr = mod->base;
#ifdef GRUB_MACHINE_EMU
mprotect (mod->base, tsize, PROT_READ | PROT_WRITE | PROT_EXEC);
#endif
for (i = 0, s = (Elf_Shdr *)((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *)((char *) s + e->e_shentsize))
@ -318,12 +308,14 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
mod->segment = seg;
}
}
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__)
#if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__)
ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN);
mod->tramp = ptr;
mod->trampptr = ptr;
ptr += tramp;
ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_GOT_ALIGN);
mod->got = ptr;
mod->gotptr = ptr;
ptr += got;
#endif
@ -356,6 +348,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
#else
mod->symtab = (Elf_Sym *) ((char *) e + s->sh_offset);
#endif
mod->symsize = s->sh_entsize;
sym = mod->symtab;
size = s->sh_size;
entsize = s->sh_entsize;
@ -565,6 +558,37 @@ grub_dl_flush_cache (grub_dl_t mod)
grub_arch_sync_caches (mod->base, mod->sz);
}
static grub_err_t
grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
{
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
unsigned i;
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_REL || s->sh_type == SHT_RELA)
{
grub_dl_segment_t seg;
grub_err_t err;
/* Find the target segment. */
for (seg = mod->segment; seg; seg = seg->next)
if (seg->section == s->sh_info)
break;
if (seg)
{
err = grub_arch_dl_relocate_symbols (mod, ehdr, s, seg);
if (err)
return err;
}
}
return GRUB_ERR_NONE;
}
/* Load a module from core memory. */
grub_dl_t
grub_dl_load_core_noinit (void *addr, grub_size_t size)
@ -611,7 +635,7 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size)
|| grub_dl_resolve_dependencies (mod, e)
|| grub_dl_load_segments (mod, e)
|| grub_dl_resolve_symbols (mod, e)
|| grub_arch_dl_relocate_symbols (mod, e))
|| grub_dl_relocate_symbols (mod, e))
{
mod->fini = 0;
grub_dl_unload (mod);
@ -761,7 +785,11 @@ grub_dl_unload (grub_dl_t mod)
grub_free (dep);
}
#ifdef GRUB_MACHINE_EMU
grub_dl_osdep_dl_free (mod->base);
#else
grub_free (mod->base);
#endif
grub_free (mod->name);
#ifdef GRUB_MODULES_MACHINE_READONLY
grub_free (mod->symtab);

View File

@ -769,12 +769,17 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
case GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE:
{
grub_efi_file_path_device_path_t *fp;
grub_uint8_t buf[(len - 4) * 2 + 1];
grub_uint8_t *buf;
fp = (grub_efi_file_path_device_path_t *) dp;
buf = grub_malloc ((len - 4) * 2 + 1);
if (buf)
*grub_utf16_to_utf8 (buf, fp->path_name,
(len - 4) / sizeof (grub_efi_char16_t))
= '\0';
else
grub_errno = GRUB_ERR_NONE;
grub_printf ("/File(%s)", buf);
grub_free (buf);
}
break;
case GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE:

View File

@ -20,6 +20,8 @@
#include <config.h>
#include <config-util.h>
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
#define _GNU_SOURCE 1
#include <stdlib.h>
#include <unistd.h>

View File

@ -1,7 +1,8 @@
#if defined(__ia64__)
#include <grub/cache.h>
#if defined(__ia64__) || defined (__arm__) || defined (__aarch64__)
void __clear_cache (char *beg, char *end);
void
@ -9,5 +10,15 @@ grub_arch_sync_caches (void *address, grub_size_t len)
{
__clear_cache (address, (char *) address + len);
}
#elif defined (__mips__)
void _flush_cache (void *address, grub_size_t len, int type);
void
grub_arch_sync_caches (void *address, grub_size_t len)
{
return _flush_cache (address, len, 0);
}
#endif

View File

@ -6,24 +6,9 @@
/* Nothing is necessary. */
#elif defined(__sparc__)
#include "../sparc64/cache.S"
#elif defined(__mips__)
/* On MIPS we must go through standard functions. */
#include <grub/symbol.h>
FUNCTION (grub_cpu_flush_cache)
FUNCTION (grub_arch_sync_caches)
.set nomacro
.set noreorder
lui $t0, %hi(_flush_cache)
addui $t0, $t0, %lo(_flush_cache)
move $a3, $zero
jr $t0
nop
.set reorder
.set macro
#elif defined(__powerpc__)
#include "../powerpc/cache.S"
#elif defined(__ia64__)
#elif defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__)
#else
#error "No target cpu type is defined"
#endif

View File

@ -39,19 +39,24 @@ grub_arch_dl_check_header (void *ehdr)
}
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{
(void) mod;
(void) ehdr;
(void) s;
(void) seg;
return GRUB_ERR_BAD_MODULE;
}
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__)
void grub_arch_dl_get_tramp_got_size (const void *ehdr __attribute__ ((unused)),
#if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__)
grub_err_t
grub_arch_dl_get_tramp_got_size (const void *ehdr __attribute__ ((unused)),
grub_size_t *tramp, grub_size_t *got)
{
*tramp = 0;
*got = 0;
return GRUB_ERR_BAD_MODULE;
}
#endif

View File

@ -16,7 +16,14 @@
#elif defined(__powerpc__)
#include "../powerpc/dl.c"
#elif defined(__ia64__)
#include "../ia64/dl_helper.c"
#include "../ia64/dl.c"
#elif defined(__arm__)
#include "../arm/dl_helper.c"
#include "../arm/dl.c"
#elif defined(__aarch64__)
#include "../arm64/dl_helper.c"
#include "../arm64/dl.c"
#else
#error "No target cpu type is defined"
#endif

View File

@ -44,6 +44,8 @@
#include <grub/loader.h>
#include <grub/util/misc.h>
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
#include "progname.h"
#include <argp.h>
@ -166,6 +168,8 @@ static struct argp argp = {
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
int
main (int argc, char *argv[])
{

View File

@ -62,26 +62,3 @@ grub_realloc (void *ptr, grub_size_t size)
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
return ret;
}
#if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_MEMALIGN)
void *
grub_memalign (grub_size_t align, grub_size_t size)
{
void *p;
if (align < sizeof (void *))
align = sizeof (void *);
#if defined(HAVE_POSIX_MEMALIGN)
if (posix_memalign (&p, align, size) != 0)
p = 0;
#elif defined(HAVE_MEMALIGN)
p = memalign (align, size);
#endif
if (!p)
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
return p;
}
#endif

View File

@ -40,45 +40,15 @@ grub_arch_dl_check_header (void *ehdr)
/* Relocate symbols. */
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
/* Find a symbol table. */
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_SYMTAB)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
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;
for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
max = (Elf_Rel *) ((char *) rel + s->sh_size);
rel < max;
rel++)
rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
{
Elf_Word *addr;
Elf_Sym *sym;
@ -89,7 +59,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
sym = (Elf_Sym *) ((char *) mod->symtab
+ entsize * ELF_R_SYM (rel->r_info));
+ mod->symsize * ELF_R_SYM (rel->r_info));
switch (ELF_R_TYPE (rel->r_info))
{
@ -98,8 +68,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
case R_386_PC32:
*addr += (sym->st_value - (Elf_Word) seg->addr
- rel->r_offset);
*addr += (sym->st_value - (grub_addr_t) addr);
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
@ -107,8 +76,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
ELF_R_TYPE (rel->r_info));
}
}
}
}
return GRUB_ERR_NONE;
}

View File

@ -96,17 +96,8 @@ struct iterator_ctx
grub_size_t nresources;
};
static int
count_cards (grub_pci_device_t dev __attribute__ ((unused)),
grub_pci_id_t pciid __attribute__ ((unused)),
void *data)
{
int *cnt = data;
(*cnt)++;
return 0;
}
/* We don't support bridges, so can't have more than 32 devices. */
#define MAX_DEVICES 32
static int
find_resources (grub_pci_device_t dev,
@ -116,6 +107,9 @@ find_resources (grub_pci_device_t dev,
struct iterator_ctx *ctx = data;
int bar;
if (ctx->nresources >= MAX_DEVICES * 6)
return 1;
for (bar = 0; bar < 6; bar++)
{
grub_pci_address_t addr;
@ -190,13 +184,10 @@ enable_cards (grub_pci_device_t dev,
static void
grub_pci_assign_addresses (void)
{
int ncards = 0;
struct iterator_ctx ctx;
grub_pci_iterate (count_cards, &ncards);
{
struct resource resources[ncards * 6];
struct resource resources[MAX_DEVICES * 6];
int done;
unsigned i;
ctx.nresources = 0;

View File

@ -1,7 +1,7 @@
/* cache.h - Flush the processor's cache. */
/* init.c - initialize an ia64-based EFI system */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2004,2007 Free Software Foundation, Inc.
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,11 +17,19 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_CPU_CACHE_H
#define GRUB_CPU_CACHE_H 1
#include <grub/symbol.h>
#include <grub/types.h>
#include <grub/cache.h>
void EXPORT_FUNC(grub_cpu_flush_cache) (void *start, grub_size_t size, int type);
#endif
void
grub_arch_sync_caches (void *address, grub_size_t len)
{
/* Cache line length is at least 32. */
len += (grub_uint64_t)address & 0x1f;
grub_uint64_t a = (grub_uint64_t)address & ~0x1f;
/* Flush data. */
for (len = (len + 31) & ~0x1f; len > 0; len -= 0x20, a += 0x20)
asm volatile ("fc.i %0" : : "r" (a));
/* Sync and serialize. Maybe extra. */
asm volatile (";; sync.i;; srlz.i;;");
}

View File

@ -46,51 +46,15 @@ grub_arch_dl_check_header (void *ehdr)
/* Relocate symbols. */
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
grub_uint64_t *gp, *gpptr;
struct grub_ia64_trampoline *tr;
gp = (grub_uint64_t *) mod->base;
gpptr = (grub_uint64_t *) mod->got;
tr = mod->tramp;
/* Find a symbol table. */
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_SYMTAB)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
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_RELA)
{
grub_dl_segment_t seg;
/* Find the target segment. */
for (seg = mod->segment; seg; seg = seg->next)
if (seg->section == s->sh_info)
break;
if (seg)
{
Elf_Rela *rel, *max;
for (rel = (Elf_Rela *) ((char *) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset),
max = (Elf_Rela *) ((char *) rel + s->sh_size);
rel < max;
rel++)
rel = (Elf_Rela *) ((char *) rel + s->sh_entsize))
{
grub_addr_t addr;
Elf_Sym *sym;
@ -102,7 +66,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
addr = (grub_addr_t) seg->addr + rel->r_offset;
sym = (Elf_Sym *) ((char *) mod->symtab
+ entsize * ELF_R_SYM (rel->r_info));
+ mod->symsize * ELF_R_SYM (rel->r_info));
/* On the PPC the value does not have an explicit
addend, add it. */
@ -113,9 +77,10 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
case R_IA64_PCREL21B:
{
grub_uint64_t noff;
struct grub_ia64_trampoline *tr = mod->trampptr;
grub_ia64_make_trampoline (tr, value);
noff = ((char *) tr - (char *) (addr & ~3)) >> 4;
tr++;
mod->trampptr = tr + 1;
if (noff & ~MASK19)
return grub_error (GRUB_ERR_BAD_OS,
@ -134,7 +99,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
*(grub_uint64_t *) addr += value - addr;
break;
case R_IA64_GPREL22:
grub_ia64_add_value_to_slot_21 (addr, value - (grub_addr_t) gp);
grub_ia64_add_value_to_slot_21 (addr, value - (grub_addr_t) mod->base);
break;
case R_IA64_LTOFF22X:
@ -142,11 +107,13 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
if (ELF_ST_TYPE (sym->st_info) == STT_FUNC)
value = *(grub_uint64_t *) sym->st_value + rel->r_addend;
case R_IA64_LTOFF_FPTR22:
{
grub_uint64_t *gpptr = mod->gotptr;
*gpptr = value;
grub_ia64_add_value_to_slot_21 (addr, (grub_addr_t) gpptr - (grub_addr_t) gp);
gpptr++;
grub_ia64_add_value_to_slot_21 (addr, (grub_addr_t) gpptr - (grub_addr_t) mod->base);
mod->gotptr = gpptr + 1;
break;
}
/* We treat LTOFF22X as LTOFF22, so we can ignore LDXMOV. */
case R_IA64_LDXMOV:
break;
@ -156,8 +123,5 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
ELF_R_TYPE (rel->r_info));
}
}
}
}
return GRUB_ERR_NONE;
}

View File

@ -23,7 +23,6 @@
#include <grub/time.h>
#include <grub/err.h>
#include <grub/dl.h>
#include <grub/cache.h>
#include <grub/kernel.h>
#include <grub/efi/efi.h>
#include <grub/loader.h>
@ -74,16 +73,3 @@ grub_machine_fini (int flags)
if (flags & GRUB_LOADER_FLAG_NORETURN)
grub_efi_fini ();
}
void
grub_arch_sync_caches (void *address, grub_size_t len)
{
/* Cache line length is at least 32. */
grub_uint64_t a = (grub_uint64_t)address & ~0x1f;
/* Flush data. */
for (len = (len + 31) & ~0x1f; len > 0; len -= 0x20, a += 0x20)
asm volatile ("fc.i %0" : : "r" (a));
/* Sync and serialize. Maybe extra. */
asm volatile (";; sync.i;; srlz.i;;");
}

View File

@ -4,7 +4,6 @@
.set noreorder
.set nomacro
FUNCTION (grub_cpu_flush_cache)
FUNCTION (grub_arch_sync_caches)
#include "cache_flush.S"
j $ra

View File

@ -58,23 +58,13 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
{
const Elf_Ehdr *e = ehdr;
const Elf_Shdr *s;
unsigned i;
/* FIXME: suboptimal. */
grub_size_t gp_size = 0;
unsigned i;
*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))
@ -106,62 +96,35 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
/* Relocate symbols. */
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
/* FIXME: suboptimal. */
grub_uint32_t *gp, *gpptr;
grub_uint32_t gp0;
Elf_Ehdr *e = ehdr;
/* Find a symbol table. */
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_SYMTAB)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
if (!mod->reginfo)
{
unsigned i;
Elf_Shdr *ri;
/* Find reginfo. */
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
for (i = 0, ri = (Elf_Shdr *) ((char *) ehdr + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_MIPS_REGINFO)
i++, ri = (Elf_Shdr *) ((char *) ri + e->e_shentsize))
if (ri->sh_type == SHT_MIPS_REGINFO)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no reginfo found");
mod->reginfo = (grub_uint32_t *)((char *) ehdr + ri->sh_offset);
}
gp0 = ((grub_uint32_t *)((char *) e + s->sh_offset))[5];
gpptr = gp = mod->got;
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)
{
gp0 = mod->reginfo[5];
Elf_Rel *rel, *max;
for (rel = (Elf_Rel *) ((char *) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
max = (Elf_Rel *) ((char *) rel + s->sh_size);
rel < max;
rel++)
rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
{
grub_uint8_t *addr;
Elf_Sym *sym;
@ -173,13 +136,13 @@ 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));
+ mod->symsize * ELF_R_SYM (rel->r_info));
sym_value = sym->st_value;
if (sym_value == (grub_addr_t) &__gnu_local_gp_dummy)
sym_value = (grub_addr_t) gp;
sym_value = (grub_addr_t) mod->got;
else if (sym_value == (grub_addr_t) &_gp_disp_dummy)
{
sym_value = (grub_addr_t) gp - (grub_addr_t) addr;
sym_value = (grub_addr_t) mod->got - (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. */
@ -228,7 +191,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
case R_MIPS_GPREL32:
*(grub_uint32_t *) addr = sym_value
+ *(grub_uint32_t *) addr + gp0 - (grub_uint32_t)gp;
+ *(grub_uint32_t *) addr + gp0 - (grub_uint32_t)mod->got;
break;
case R_MIPS_26:
@ -270,15 +233,18 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
*(grub_uint16_t *) addr = 0;
}
case R_MIPS_CALL16:
{
grub_uint32_t *gpptr = mod->gotptr;
/* FIXME: reuse*/
#ifdef GRUB_CPU_WORDS_BIGENDIAN
addr += 2;
#endif
*gpptr = sym_value + *(grub_uint16_t *) addr;
*(grub_uint16_t *) addr
= sizeof (grub_uint32_t) * (gpptr - gp);
gpptr++;
= sizeof (grub_uint32_t) * (gpptr - (grub_uint32_t *) mod->got);
mod->gotptr = gpptr + 1;
break;
}
case R_MIPS_JALR:
break;
default:
@ -290,8 +256,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
}
}
}
}
return GRUB_ERR_NONE;
}

View File

@ -628,7 +628,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)
return q;
}
#ifndef GRUB_UTIL
#if !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
#if defined (__arm__)

View File

@ -101,46 +101,15 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
/* Relocate symbols. */
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
struct trampoline *tptr = mod->tramp;
/* Find a symbol table. */
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_SYMTAB)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
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_RELA)
{
grub_dl_segment_t seg;
/* Find the target segment. */
for (seg = mod->segment; seg; seg = seg->next)
if (seg->section == s->sh_info)
break;
if (seg)
{
Elf_Rela *rel, *max;
for (rel = (Elf_Rela *) ((char *) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset),
max = (Elf_Rela *) ((char *) rel + s->sh_size);
rel < max;
rel++)
rel = (Elf_Rela *) ((char *) rel + s->sh_entsize))
{
Elf_Word *addr;
Elf_Sym *sym;
@ -152,7 +121,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
sym = (Elf_Sym *) ((char *) mod->symtab
+ entsize * ELF_R_SYM (rel->r_info));
+ mod->symsize * ELF_R_SYM (rel->r_info));
/* On the PPC the value does not have an explicit
addend, add it. */
@ -169,12 +138,13 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
if (delta << 6 >> 6 != delta)
{
struct trampoline *tptr = mod->trampptr;
grub_memcpy (tptr, &trampoline_template,
sizeof (*tptr));
delta = (grub_uint8_t *) tptr - (grub_uint8_t *) addr;
tptr->lis |= (((value) >> 16) & 0xffff);
tptr->ori |= ((value) & 0xffff);
tptr++;
mod->trampptr = tptr + 1;
}
if (delta << 6 >> 6 != delta)
@ -202,8 +172,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
ELF_R_TYPE (rel->r_info));
}
}
}
}
return GRUB_ERR_NONE;
}

View File

@ -42,45 +42,15 @@ grub_arch_dl_check_header (void *ehdr)
/* Relocate symbols. */
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
/* Find a symbol table. */
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_SYMTAB)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
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_RELA)
{
grub_dl_segment_t seg;
/* Find the target segment. */
for (seg = mod->segment; seg; seg = seg->next)
if (seg->section == s->sh_info)
break;
if (seg)
{
Elf_Rela *rel, *max;
for (rel = (Elf_Rela *) ((char *) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset),
max = (Elf_Rela *) ((char *) rel + s->sh_size);
rel < max;
rel++)
rel = (Elf_Rela *) ((char *) rel + s->sh_entsize))
{
Elf_Word *addr;
Elf_Sym *sym;
@ -92,7 +62,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
sym = (Elf_Sym *) ((char *) mod->symtab
+ entsize * ELF_R_SYM (rel->r_info));
+ mod->symsize * ELF_R_SYM (rel->r_info));
value = sym->st_value + rel->r_addend;
switch (ELF_R_TYPE (rel->r_info) & 0xff)
@ -140,8 +110,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
ELF_R_TYPE (rel->r_info));
}
}
}
}
return GRUB_ERR_NONE;
}

View File

@ -36,10 +36,14 @@ codestart:
/* Copy the modules past the end of the kernel image.
* They are currently sitting in the BSS.
*/
sethi %hi(__bss_start), %o2
or %o2, %lo(__bss_start), %o2
sethi %hi(_end), %o3
or %o3, %lo(_end), %o3
sethi %hi(__bss_start + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o2
or %o2, %lo(__bss_start + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o2
srl %o2, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o2
sll %o2, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o2
sethi %hi(_end + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o3
or %o3, %lo(_end + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o3
srl %o3, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o3
sll %o3, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o3
sethi %hi(grub_total_module_size), %o4
lduw [%o4 + %lo(grub_total_module_size)], %o4
@ -67,16 +71,34 @@ codestart:
/* Now it's safe to clear out the BSS. */
sethi %hi(__bss_start), %o2
or %o2, %lo(__bss_start), %o2
sethi %hi(_end), %o3
or %o3, %lo(_end), %o3
1: stb %g0, [%o2]
add %o2, 1, %o2
and %o2, 7, %o3
brnz %o3, 1b
nop
sethi %hi(_end - 1), %o3
or %o3, %lo(_end - 1), %o3
srl %o3, 3, %o3
sll %o3, 3, %o3
1: stx %g0, [%o2]
add %o2, 8, %o2
cmp %o2, %o3
blt,pt %xcc, 1b
nop
sethi %hi(_end), %o3
or %o3, %lo(_end), %o3
1: stb %g0, [%o2]
add %o2, 1, %o2
cmp %o2, %o3
blt,pt %xcc, 1b
nop
sethi %hi(grub_ieee1275_original_stack), %o2
stx %o1, [%o2 + %lo(grub_ieee1275_original_stack)]
sethi %hi(grub_ieee1275_entry_fn), %o2
call grub_main
stx %o0, [%o2 + %lo(grub_ieee1275_entry_fn)]
1: ba,a 1b
nop

View File

@ -61,7 +61,13 @@ grub_uboot_get_boot_data (void)
static grub_uint64_t
uboot_timer_ms (void)
{
return (grub_uint64_t) grub_uboot_get_timer (timer_start) / 1000;
static grub_uint32_t last = 0, high = 0;
grub_uint32_t cur = grub_uboot_get_timer (timer_start);
if (cur < last)
high++;
last = cur;
return grub_divmod64 ((((grub_uint64_t) high) << 32) | cur,
1000, 0);
}
void

View File

@ -40,45 +40,15 @@ grub_arch_dl_check_header (void *ehdr)
/* Relocate symbols. */
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg)
{
Elf64_Ehdr *e = ehdr;
Elf64_Shdr *s;
Elf64_Word entsize;
unsigned i;
/* Find a symbol table. */
for (i = 0, s = (Elf64_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf64_Shdr *) ((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"));
entsize = s->sh_entsize;
for (i = 0, s = (Elf64_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf64_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_RELA)
{
grub_dl_segment_t seg;
/* Find the target segment. */
for (seg = mod->segment; seg; seg = seg->next)
if (seg->section == s->sh_info)
break;
if (seg)
{
Elf64_Rela *rel, *max;
for (rel = (Elf64_Rela *) ((char *) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
for (rel = (Elf64_Rela *) ((char *) ehdr + s->sh_offset),
max = (Elf64_Rela *) ((char *) rel + s->sh_size);
rel < max;
rel++)
rel = (Elf64_Rela *) ((char *) rel + s->sh_entsize))
{
Elf64_Word *addr32;
Elf64_Xword *addr64;
@ -91,7 +61,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
addr32 = (Elf64_Word *) ((char *) seg->addr + rel->r_offset);
addr64 = (Elf64_Xword *) addr32;
sym = (Elf64_Sym *) ((char *) mod->symtab
+ entsize * ELF_R_SYM (rel->r_info));
+ mod->symsize * ELF_R_SYM (rel->r_info));
switch (ELF_R_TYPE (rel->r_info))
{
@ -133,8 +103,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
ELF_R_TYPE (rel->r_info));
}
}
}
}
return GRUB_ERR_NONE;
}

View File

@ -132,6 +132,7 @@ static int add_subnode (void *fdt, int parentoffset, const char *name)
+ parentoffset);
grub_uint32_t *end = (void *) struct_end (fdt);
unsigned int entry_size = node_entry_size (name);
unsigned int struct_size = grub_fdt_get_size_dt_struct(fdt);
char *node_name;
SKIP_NODE_NAME(node_name, token, end);
@ -167,6 +168,7 @@ insert:
token[entry_size / sizeof(*token) - 2] = 0; /* padding bytes */
grub_strcpy((char *) (token + 1), name);
token[entry_size / sizeof(*token) - 1] = grub_cpu_to_be32(FDT_END_NODE);
grub_fdt_set_size_dt_struct (fdt, struct_size + entry_size);
return ((grub_addr_t) token - (grub_addr_t) fdt
- grub_fdt_get_off_dt_struct(fdt));
}

View File

@ -28,6 +28,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
struct grub_ofnetcard_data
{
char *path;
char *suffix;
grub_ieee1275_ihandle_t handle;
};
@ -37,17 +38,6 @@ card_open (struct grub_net_card *dev)
int status;
struct grub_ofnetcard_data *data = dev->data;
if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
{
char path[grub_strlen (data->path) +
sizeof (":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512")];
/* The full string will prevent a bootp packet to be sent. Just put some valid ip in there. */
grub_snprintf (path, sizeof (path), "%s%s", data->path,
":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512");
status = grub_ieee1275_open (path, &(data->handle));
}
else
status = grub_ieee1275_open (data->path, &(data->handle));
if (status)
@ -146,8 +136,9 @@ grub_ieee1275_net_config_real (const char *devpath, char **device, char **path)
FOR_NET_CARDS (card)
{
char *bootp_response;
char *cardpath;
char *canon;
char c;
struct grub_ofnetcard_data *data;
grub_ssize_t size = -1;
unsigned int i;
@ -155,8 +146,11 @@ grub_ieee1275_net_config_real (const char *devpath, char **device, char **path)
if (card->driver != &ofdriver)
continue;
cardpath = ((struct grub_ofnetcard_data *) card->data)->path;
canon = grub_ieee1275_canonicalise_devname (cardpath);
data = card->data;
c = *data->suffix;
*data->suffix = '\0';
canon = grub_ieee1275_canonicalise_devname (data->path);
*data->suffix = c;
if (grub_strcmp (devpath, canon) != 0)
{
grub_free (canon);
@ -224,7 +218,22 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
return 1;
}
ofdata->path = grub_strdup (alias->path);
#define SUFFIX ":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512"
if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof (SUFFIX));
else
ofdata->path = grub_malloc (grub_strlen (alias->path) + 1);
if (!ofdata->path)
{
grub_print_error ();
return 0;
}
ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
else
*ofdata->suffix = '\0';
grub_ieee1275_finddevice (ofdata->path, &devhandle);

View File

@ -83,7 +83,11 @@ grub_netbuff_alloc (grub_size_t len)
len = NETBUFFMINLEN;
len = ALIGN_UP (len, NETBUFF_ALIGN);
#ifdef GRUB_MACHINE_EMU
data = grub_malloc (len + sizeof (*nb));
#else
data = grub_memalign (NETBUFF_ALIGN, len + sizeof (*nb));
#endif
if (!data)
return NULL;
nb = (struct grub_net_buff *) ((grub_properly_aligned_t *) data

View File

@ -49,7 +49,7 @@
#include <grub/term.h>
#include <grub/normal.h>
#ifdef HAVE_UNIFONT_WIDTHSPEC
#if HAVE_FONT_SOURCE
#include "widthspec.h"
#endif
@ -387,7 +387,7 @@ grub_unicode_get_comb_type (grub_uint32_t c)
return GRUB_UNICODE_COMB_NONE;
}
#ifdef HAVE_UNIFONT_WIDTHSPEC
#if HAVE_FONT_SOURCE
grub_size_t
grub_unicode_estimate_width (const struct grub_unicode_glyph *c)

View File

@ -583,8 +583,8 @@ GRUB_MOD_INIT(normal)
grub_env_export ("color_highlight");
/* Set default color names. */
grub_env_set ("color_normal", "white/black");
grub_env_set ("color_highlight", "black/white");
grub_env_set ("color_normal", "light-gray/black");
grub_env_set ("color_highlight", "black/light-gray");
for (i = 0; i < ARRAY_SIZE (features); i++)
{

5
grub-core/osdep/dl.c Normal file
View File

@ -0,0 +1,5 @@
#if defined (__MINGW32__) || defined (__CYGWIN__)
#include "windows/dl.c"
#else
#include "unix/dl.c"
#endif

View File

@ -27,6 +27,7 @@
#include <grub/emu/misc.h>
#include <grub/emu/hostdisk.h>
#include <grub/emu/getroot.h>
#include <grub/emu/exec.h>
#include <grub/misc.h>
#include <grub/i18n.h>
#include <grub/list.h>
@ -39,6 +40,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
@ -93,12 +95,99 @@ grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_sec
return nr;
}
static char *
sysfs_partition_path (const char *dev, const char *entry)
{
const char *argv[7];
int fd;
pid_t pid;
FILE *udevadm;
char *buf = NULL;
size_t len = 0;
char *path = NULL;
argv[0] = "udevadm";
argv[1] = "info";
argv[2] = "--query";
argv[3] = "path";
argv[4] = "--name";
argv[5] = dev;
argv[6] = NULL;
pid = grub_util_exec_pipe (argv, &fd);
if (!pid)
return NULL;
/* Parent. Read udevadm's output. */
udevadm = fdopen (fd, "r");
if (!udevadm)
{
grub_util_warn (_("Unable to open stream from %s: %s"),
"udevadm", strerror (errno));
close (fd);
goto out;
}
if (getline (&buf, &len, udevadm) > 0)
{
char *newline;
newline = strchr (buf, '\n');
if (newline)
*newline = '\0';
path = xasprintf ("/sys%s/%s", buf, entry);
}
out:
if (udevadm)
fclose (udevadm);
waitpid (pid, NULL, 0);
free (buf);
return path;
}
static int
sysfs_partition_start (const char *dev, grub_disk_addr_t *start)
{
char *path;
FILE *fp;
unsigned long long val;
int ret = 0;
path = sysfs_partition_path (dev, "start");
if (!path)
return 0;
fp = grub_util_fopen (path, "r");
if (!fp)
goto out;
if (fscanf (fp, "%llu", &val) == 1)
{
*start = (grub_disk_addr_t) val;
ret = 1;
}
out:
free (path);
if (fp)
fclose (fp);
return ret;
}
grub_disk_addr_t
grub_util_find_partition_start_os (const char *dev)
{
grub_disk_addr_t start = 0;
grub_util_fd_t fd;
struct hd_geometry hdg;
if (sysfs_partition_start (dev, &start))
return start;
fd = open (dev, O_RDONLY);
if (fd == -1)
{

61
grub-core/osdep/unix/dl.c Normal file
View File

@ -0,0 +1,61 @@
/*
* 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 <config.h>
#include <config-util.h>
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <string.h>
void *
grub_osdep_dl_memalign (grub_size_t align, grub_size_t size)
{
void *ret;
if (align < 8192 * 16)
align = 8192 * 16;
size = ALIGN_UP (size, 8192 * 16);
#if defined(HAVE_POSIX_MEMALIGN)
if (posix_memalign (&ret, align, size) != 0)
ret = 0;
#elif defined(HAVE_MEMALIGN)
ret = memalign (align, size);
#else
#error "Complete this"
#endif
if (!ret)
{
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
return NULL;
}
mprotect (ret, size, PROT_READ | PROT_WRITE | PROT_EXEC);
return ret;
}
void
grub_dl_osdep_dl_free (void *ptr)
{
if (ptr)
free (ptr);
}

View File

@ -0,0 +1,59 @@
/*
* 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 <config.h>
#include <config-util.h>
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
void *
grub_osdep_dl_memalign (grub_size_t align, grub_size_t size)
{
void *ret;
if (align > 4096)
{
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("too large alignment"));
return NULL;
}
size = ALIGN_UP (size, 4096);
ret = VirtualAlloc (NULL, size, MEM_COMMIT | MEM_RESERVE,
PAGE_EXECUTE_READWRITE);
if (!ret)
{
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
return NULL;
}
return ret;
}
void
grub_dl_osdep_dl_free (void *ptr)
{
if (!ptr)
return;
VirtualFree (ptr, 0, MEM_RELEASE);
}

View File

@ -37,7 +37,7 @@ static void
grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
const struct grub_unicode_glyph *c)
{
TCHAR str[2 + c->ncomb];
TCHAR str[2 + 30];
unsigned i, j;
DWORD written;
@ -47,7 +47,7 @@ grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
else
str[0] = (c->base & 0xffff);
j = 1;
for (i = 0; i < c->ncomb; i++)
for (i = 0; i < c->ncomb && j+1 < ARRAY_SIZE (str); i++)
if (c->base < 0xffff)
str[j++] = grub_unicode_get_comb (c)[i].code;
str[j] = 0;
@ -108,11 +108,9 @@ grub_console_getkey (struct grub_term_input *term __attribute__ ((unused)))
ret = ir.Event.KeyEvent.uChar.UnicodeChar;
if (ret == 0)
{
if (ir.Event.KeyEvent.wVirtualKeyCode >= 0
&& ir.Event.KeyEvent.wVirtualKeyCode
< ARRAY_SIZE (windows_codes)
&& windows_codes[(int) ir.Event.KeyEvent.wVirtualKeyCode])
ret = windows_codes[(int) ir.Event.KeyEvent.wVirtualKeyCode];
unsigned kc = ir.Event.KeyEvent.wVirtualKeyCode;
if (kc < ARRAY_SIZE (windows_codes) && windows_codes[kc])
ret = windows_codes[kc];
else
continue;
if (ir.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED)

View File

@ -69,7 +69,7 @@ static void
grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
const struct grub_unicode_glyph *c)
{
grub_efi_char16_t str[2 + c->ncomb];
grub_efi_char16_t str[2 + 30];
grub_efi_simple_text_output_interface_t *o;
unsigned i, j;
@ -84,7 +84,7 @@ grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
else
str[0] = (grub_efi_char16_t) map_char (c->base & 0xffff);
j = 1;
for (i = 0; i < c->ncomb; i++)
for (i = 0; i < c->ncomb && j + 1 < ARRAY_SIZE (str); i++)
if (c->base < 0xffff)
str[j++] = grub_unicode_get_comb (c)[i].code;
str[j] = 0;

View File

@ -350,7 +350,7 @@ grub_video_capture_write_bmp (const char *fname,
for (y = mode_info->height - 1; y >= 0; y--)
{
grub_uint32_t *iptr = (grub_uint32_t *) ((grub_uint8_t *) ptr + mode_info->pitch * y);
grub_uint32_t *iptr = (grub_uint32_t *) ptr + (mode_info->pitch / 4) * y;
int x;
grub_uint8_t *optr = buffer;
for (x = 0; x < (int) mode_info->width; x++)
@ -421,7 +421,7 @@ grub_video_capture_write_bmp (const char *fname,
for (y = mode_info->height - 1; y >= 0; y--)
{
grub_uint16_t *iptr = (grub_uint16_t *) ((grub_uint8_t *) ptr + mode_info->pitch * y);
grub_uint16_t *iptr = (grub_uint16_t *) ptr + (mode_info->pitch / 2) * y;
int x;
grub_uint8_t *optr = buffer;
for (x = 0; x < (int) mode_info->width; x++)

View File

@ -20,8 +20,27 @@
#define GRUB_ARM_RELOC_H 1
grub_err_t grub_arm_reloc_abs32 (grub_uint32_t *addr, Elf32_Addr sym_addr);
grub_err_t grub_arm_reloc_jump24 (grub_uint32_t *addr, Elf32_Addr sym_addr);
grub_err_t grub_arm_reloc_thm_call (grub_uint16_t *addr, Elf32_Addr sym_addr);
grub_err_t grub_arm_reloc_thm_jump19 (grub_uint16_t *addr, Elf32_Addr sym_addr);
int
grub_arm_thm_call_check_offset (grub_int32_t offset, int is_thumb);
grub_int32_t
grub_arm_thm_call_get_offset (grub_uint16_t *target);
grub_err_t
grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset);
grub_int32_t
grub_arm_thm_jump19_get_offset (grub_uint16_t *target);
void
grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset);
int
grub_arm_thm_jump19_check_offset (grub_int32_t offset);
grub_int32_t
grub_arm_jump24_get_offset (grub_uint32_t *target);
int
grub_arm_jump24_check_offset (grub_int32_t offset);
void
grub_arm_jump24_set_offset (grub_uint32_t *target,
grub_int32_t offset);
#endif

View File

@ -19,6 +19,8 @@
#ifndef GRUB_ARM64_RELOC_H
#define GRUB_ARM64_RELOC_H 1
grub_err_t grub_arm64_reloc_xxxx26 (grub_uint32_t *target, Elf64_Addr sym_addr);
int grub_arm_64_check_xxxx26_offset (grub_int64_t offset);
void
grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset);
#endif

View File

@ -23,10 +23,6 @@
#include <grub/symbol.h>
#include <grub/types.h>
#ifdef _mips
#include <grub/mips/cache.h>
#endif
#if defined (__i386__) || defined (__x86_64__)
static inline void
grub_arch_sync_caches (void *address __attribute__ ((unused)),
@ -37,6 +33,7 @@ grub_arch_sync_caches (void *address __attribute__ ((unused)),
void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len);
#endif
#ifndef GRUB_MACHINE_EMU
#ifdef _mips
void EXPORT_FUNC(grub_arch_sync_dma_caches) (void *address, grub_size_t len);
#else
@ -46,5 +43,6 @@ grub_arch_sync_dma_caches (void *address __attribute__ ((unused)),
{
}
#endif
#endif
#endif /* ! GRUB_CACHE_HEADER */

View File

@ -177,11 +177,17 @@ struct grub_dl
grub_dl_dep_t dep;
grub_dl_segment_t segment;
Elf_Sym *symtab;
grub_size_t symsize;
void (*init) (struct grub_dl *mod);
void (*fini) (void);
#if defined (__ia64__) || defined (__powerpc__) || defined (__mips__)
#if !defined (__i386__) && !defined (__x86_64__) && !defined (__sparc__)
void *got;
void *gotptr;
void *tramp;
void *trampptr;
#endif
#ifdef __mips__
grub_uint32_t *reginfo;
#endif
void *base;
grub_size_t sz;
@ -204,6 +210,13 @@ extern grub_dl_t EXPORT_VAR(grub_dl_head);
#define FOR_DL_MODULES(var) FOR_LIST_ELEMENTS ((var), (grub_dl_head))
#ifdef GRUB_MACHINE_EMU
void *
grub_osdep_dl_memalign (grub_size_t align, grub_size_t size);
void
grub_dl_osdep_dl_free (void *ptr);
#endif
static inline void
grub_dl_init (grub_dl_t mod)
{
@ -232,7 +245,11 @@ grub_err_t grub_dl_register_symbol (const char *name, void *addr,
int isfunc, grub_dl_t mod);
grub_err_t grub_arch_dl_check_header (void *ehdr);
grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
#ifndef GRUB_UTIL
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
Elf_Shdr *s, grub_dl_segment_t seg);
#endif
#if defined (_mips)
#define GRUB_LINKER_HAVE_INIT 1
@ -256,11 +273,16 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
grub_size_t *got);
#endif
#if defined (__powerpc__) || defined (__mips__)
#if defined (__powerpc__) || defined (__mips__) || defined (__arm__)
#define GRUB_ARCH_DL_TRAMP_ALIGN 4
#define GRUB_ARCH_DL_GOT_ALIGN 4
#endif
#if defined (__aarch64__)
#define GRUB_ARCH_DL_TRAMP_ALIGN 8
#define GRUB_ARCH_DL_GOT_ALIGN 8
#endif
#endif
#endif /* ! GRUB_DL_H */

View File

@ -78,7 +78,7 @@ struct grub_module_info64
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) \
|| defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS) \
|| defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_ARC) \
|| defined (__sparc__) || defined (GRUB_MACHINE_UBOOT) || defined (GRUB_MACHINE_XEN)
|| (defined (__sparc__) && defined (GRUB_MACHINE_IEEE1275)) || defined (GRUB_MACHINE_UBOOT) || defined (GRUB_MACHINE_XEN)
/* FIXME: stack is between 2 heap regions. Move it. */
#define GRUB_KERNEL_PRELOAD_SPACE_REUSABLE 1
#endif

View File

@ -429,7 +429,7 @@ void __attribute__ ((noreturn)) EXPORT_FUNC (abort) (void);
/* Halt the system, using APM if possible. If NO_APM is true, don't
* use APM even if it is available. */
void grub_halt (int no_apm) __attribute__ ((noreturn));
#elif defined (__mips__)
#elif defined (__mips__) && !defined (GRUB_MACHINE_EMU)
void EXPORT_FUNC (grub_halt) (void) __attribute__ ((noreturn));
#else
void grub_halt (void) __attribute__ ((noreturn));

View File

@ -33,7 +33,9 @@ void *EXPORT_FUNC(grub_malloc) (grub_size_t size);
void *EXPORT_FUNC(grub_zalloc) (grub_size_t size);
void EXPORT_FUNC(grub_free) (void *ptr);
void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size);
#ifndef GRUB_MACHINE_EMU
void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
#endif
void grub_mm_check_real (const char *file, int line);
#define grub_mm_check() grub_mm_check_real (GRUB_FILE, __LINE__);

View File

@ -111,7 +111,8 @@
#define GRUB_KERNEL_ARM_UBOOT_MOD_GAP 0x0
#define GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN 0x1000
#define GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN 0x1
#define GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN 3
#define GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN (1 << GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN)
#define GRUB_KERNEL_MIPS_LOONGSON_MOD_ALIGN 0x1
#define GRUB_KERNEL_MIPS_ARC_MOD_ALIGN 0x1

View File

@ -27,6 +27,7 @@
#define SCRATCH_PAD_BOOT 0x5000
#define SCRATCH_PAD_DISKBOOT 0x4000
#define SCRATCH_PAD_BOOT_SIZE 0x110
#define GET_ABS(symbol, reg) \
add PIC_REG, (symbol - pic_base), reg

View File

@ -398,7 +398,7 @@ grub_term_cls (struct grub_term_output *term)
}
}
#ifdef HAVE_UNIFONT_WIDTHSPEC
#if HAVE_FONT_SOURCE
grub_size_t
grub_unicode_estimate_width (const struct grub_unicode_glyph *c);

View File

@ -21,7 +21,14 @@
#include <grub/types.h>
#include <grub/symbol.h>
#ifndef GRUB_MACHINE_EMU
#include <grub/cpu/time.h>
#else
static inline void
grub_cpu_idle(void)
{
}
#endif
void EXPORT_FUNC(grub_millisleep) (grub_uint32_t ms);
grub_uint64_t EXPORT_FUNC(grub_get_time_ms) (void);

View File

@ -153,11 +153,10 @@ typedef grub_uint64_t grub_off_t;
typedef grub_uint64_t grub_disk_addr_t;
/* Byte-orders. */
#define grub_swap_bytes16(x) \
({ \
grub_uint16_t _x = (x); \
(grub_uint16_t) ((_x << 8) | (_x >> 8)); \
})
static inline grub_uint16_t grub_swap_bytes16(grub_uint16_t _x)
{
return (grub_uint16_t) ((_x << 8) | (_x >> 8));
}
#define grub_swap_bytes16_compile_time(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
#define grub_swap_bytes32_compile_time(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000UL) >> 24))
@ -185,27 +184,25 @@ static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t x)
return __builtin_bswap64(x);
}
#else /* not gcc 4.3 or newer */
#define grub_swap_bytes32(x) \
({ \
grub_uint32_t _x = (x); \
(grub_uint32_t) ((_x << 24) \
| ((_x & (grub_uint32_t) 0xFF00UL) << 8) \
| ((_x & (grub_uint32_t) 0xFF0000UL) >> 8) \
| (_x >> 24)); \
})
static inline grub_uint32_t grub_swap_bytes32(grub_uint32_t _x)
{
return ((_x << 24)
| ((_x & (grub_uint32_t) 0xFF00UL) << 8)
| ((_x & (grub_uint32_t) 0xFF0000UL) >> 8)
| (_x >> 24));
}
#define grub_swap_bytes64(x) \
({ \
grub_uint64_t _x = (x); \
(grub_uint64_t) ((_x << 56) \
| ((_x & (grub_uint64_t) 0xFF00ULL) << 40) \
| ((_x & (grub_uint64_t) 0xFF0000ULL) << 24) \
| ((_x & (grub_uint64_t) 0xFF000000ULL) << 8) \
| ((_x & (grub_uint64_t) 0xFF00000000ULL) >> 8) \
| ((_x & (grub_uint64_t) 0xFF0000000000ULL) >> 24) \
| ((_x & (grub_uint64_t) 0xFF000000000000ULL) >> 40) \
| (_x >> 56)); \
})
static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t _x)
{
return ((_x << 56)
| ((_x & (grub_uint64_t) 0xFF00ULL) << 40)
| ((_x & (grub_uint64_t) 0xFF0000ULL) << 24)
| ((_x & (grub_uint64_t) 0xFF000000ULL) << 8)
| ((_x & (grub_uint64_t) 0xFF00000000ULL) >> 8)
| ((_x & (grub_uint64_t) 0xFF0000000000ULL) >> 24)
| ((_x & (grub_uint64_t) 0xFF000000000000ULL) >> 40)
| (_x >> 56));
}
#endif /* not gcc 4.3 or newer */
#ifdef GRUB_CPU_WORDS_BIGENDIAN

View File

@ -41,6 +41,9 @@
{ "compress", GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS, \
"no,xz,gz,lzo", OPTION_ARG_OPTIONAL, \
N_("compress GRUB files [optional]"), 1 }, \
{"core-compress", GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS, \
N_("xz|none|auto"), \
0, N_("choose the compression to use for core image"), 2}, \
/* TRANSLATORS: platform here isn't identifier. It can be translated. */ \
{ "directory", 'd', N_("DIR"), 0, \
N_("use images and modules under DIR [default=%s/<platform>]"), 1 }, \
@ -50,6 +53,9 @@
{ "locale-directory", GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY, \
N_("DIR"), 0, \
N_("use translations under DIR [default=%s]"), 1 }, \
{ "themes-directory", GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY, \
N_("DIR"), OPTION_HIDDEN, \
N_("use themes under DIR [default=%s]"), 1 }, \
{ "grub-mkimage", GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE, \
"FILE", OPTION_HIDDEN, 0, 1 }, \
/* TRANSLATORS: "embed" is a verb (command description). "*/ \
@ -107,7 +113,9 @@ enum grub_install_options {
GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS,
GRUB_INSTALL_OPTIONS_DIRECTORY2,
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY,
GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE
GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY,
GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE,
GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS
};
extern char *grub_install_source_directory;
@ -142,15 +150,13 @@ void
grub_install_make_image_wrap (const char *dir, const char *prefix,
const char *outname, char *memdisk_path,
char *config_path,
const char *format, int note,
grub_compression_t comp);
const char *format, int note);
void
grub_install_make_image_wrap_file (const char *dir, const char *prefix,
FILE *fp, const char *outname,
char *memdisk_path,
char *config_path,
const char *mkimage_target, int note,
grub_compression_t comp);
const char *mkimage_target, int note);
int
grub_install_copy_file (const char *src,

View File

@ -47,4 +47,6 @@ void grub_util_init_nls (void);
void grub_util_host_init (int *argc, char ***argv);
int grub_qsort_strcmp (const void *, const void *);
#endif /* ! GRUB_UTIL_MISC_HEADER */

View File

@ -347,9 +347,10 @@ if test -z "$debug"; then
fi
if [ x$boot != xnet ] && [ x$boot != xemu ]; then
cp -R "@srcdir@/themes" "@builddir@"
pkgdatadir="@builddir@" "@builddir@/grub-mkrescue" "--output=${isofile}" "--override-directory=${builddir}/grub-core" \
--rom-directory="${rom_directory}" $mkimage_extra_arg ${mkrescue_args} \
--rom-directory="${rom_directory}" \
--themes-directory="@srcdir@/themes" \
$mkimage_extra_arg ${mkrescue_args} \
"/boot/grub/grub.cfg=${cfgfile}" "/boot/grub/testcase.cfg=${source}" \
${files} >/dev/null 2>&1
fi

View File

@ -60,6 +60,8 @@ grub_install_help_filter (int key, const char *text,
return xasprintf(text, grub_util_get_pkglibdir ());
case GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY:
return xasprintf(text, grub_util_get_localedir ());
case GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY:
return grub_util_path_concat (2, grub_util_get_pkgdatadir (), "themes");
default:
return (char *) text;
}
@ -220,6 +222,7 @@ struct install_list install_fonts = { 1, 0, 0, 0 };
struct install_list install_themes = { 1, 0, 0, 0 };
char *grub_install_source_directory = NULL;
char *grub_install_locale_directory = NULL;
char *grub_install_themes_directory = NULL;
void
grub_install_push_module (const char *val)
@ -294,12 +297,30 @@ handle_install_list (struct install_list *il, const char *val,
static char **pubkeys;
static size_t npubkeys;
static grub_compression_t compression;
int
grub_install_parse (int key, char *arg)
{
switch (key)
{
case 'C':
if (grub_strcmp (arg, "xz") == 0)
{
#ifdef HAVE_LIBLZMA
compression = GRUB_COMPRESSION_XZ;
#else
grub_util_error ("%s",
_("grub-mkimage is compiled without XZ support"));
#endif
}
else if (grub_strcmp (arg, "none") == 0)
compression = GRUB_COMPRESSION_NONE;
else if (grub_strcmp (arg, "auto") == 0)
compression = GRUB_COMPRESSION_AUTO;
else
grub_util_error (_("Unknown compression format %s"), arg);
return 1;
case 'k':
pubkeys = xrealloc (pubkeys,
sizeof (pubkeys[0])
@ -320,6 +341,10 @@ grub_install_parse (int key, char *arg)
free (grub_install_locale_directory);
grub_install_locale_directory = xstrdup (arg);
return 1;
case GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY:
free (grub_install_themes_directory);
grub_install_themes_directory = xstrdup (arg);
return 1;
case GRUB_INSTALL_OPTIONS_INSTALL_MODULES:
handle_install_list (&install_modules, arg, 0);
return 1;
@ -394,8 +419,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix,
FILE *fp, const char *outname,
char *memdisk_path,
char *config_path,
const char *mkimage_target, int note,
grub_compression_t comp)
const char *mkimage_target, int note)
{
const struct grub_install_image_target_desc *tgt;
const char *const compnames[] =
@ -461,7 +485,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix,
"--format '%s' --compression '%s' %s %s\n",
dir, prefix,
outname, mkimage_target,
compnames[comp], note ? "--note" : "", s);
compnames[compression], note ? "--note" : "", s);
tgt = grub_install_get_image_target (mkimage_target);
if (!tgt)
@ -470,7 +494,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix,
grub_install_generate_image (dir, prefix, fp, outname,
modules.entries, memdisk_path,
pubkeys, npubkeys, config_path, tgt,
note, comp);
note, compression);
while (dc--)
grub_install_pop_module ();
}
@ -479,8 +503,7 @@ void
grub_install_make_image_wrap (const char *dir, const char *prefix,
const char *outname, char *memdisk_path,
char *config_path,
const char *mkimage_target, int note,
grub_compression_t comp)
const char *mkimage_target, int note)
{
FILE *fp;
@ -490,7 +513,7 @@ grub_install_make_image_wrap (const char *dir, const char *prefix,
strerror (errno));
grub_install_make_image_wrap_file (dir, prefix, fp, outname,
memdisk_path, config_path,
mkimage_target, note, comp);
mkimage_target, note);
grub_util_file_sync (fp);
fclose (fp);
}
@ -675,6 +698,7 @@ grub_install_copy_files (const char *src,
{
char *dst_platform, *dst_locale, *dst_fonts;
const char *pkgdatadir = grub_util_get_pkgdatadir ();
char *themes_dir;
{
char *platform;
@ -806,14 +830,20 @@ grub_install_copy_files (const char *src,
install_themes.entries[1] = NULL;
}
if (grub_install_themes_directory)
themes_dir = xstrdup (grub_install_themes_directory);
else
themes_dir = grub_util_path_concat (2, grub_util_get_pkgdatadir (),
"themes");
for (i = 0; i < install_themes.n_entries; i++)
{
char *srcf = grub_util_path_concat (4, pkgdatadir, "themes",
char *srcf = grub_util_path_concat (3, themes_dir,
install_themes.entries[i],
"theme.txt");
if (grub_util_is_regular (srcf))
{
char *srcd = grub_util_path_concat (3, pkgdatadir, "themes",
char *srcd = grub_util_path_concat (2, themes_dir,
install_themes.entries[i]);
char *dstd = grub_util_path_concat (3, dst, "themes",
install_themes.entries[i]);
@ -825,6 +855,8 @@ grub_install_copy_files (const char *src,
free (srcf);
}
free (themes_dir);
if (install_fonts.is_default)
{
install_fonts.is_default = 0;

View File

@ -244,7 +244,7 @@ static struct argp_option options[] = {
N_("disk module to use (biosdisk or native). "
"This option is only available on BIOS target."), 2},
{"no-nvram", OPTION_NO_NVRAM, 0, 0,
N_("don't update the `boot-device' NVRAM variable. "
N_("don't update the `boot-device'/`Boot*' NVRAM variables. "
"This option is only available on EFI and IEEE1275 targets."), 2},
{"skip-fs-probe",'s',0, 0,
N_("do not probe for filesystems in DEVICE"), 0},
@ -342,6 +342,21 @@ probe_raid_level (grub_disk_t disk)
return ((struct grub_diskfilter_lv *) disk->data)->segments->type;
}
static void
push_partmap_module (const char *map)
{
char buf[50];
if (strcmp (map, "openbsd") == 0 || strcmp (map, "netbsd") == 0)
{
grub_install_push_module ("part_bsd");
return;
}
snprintf (buf, sizeof (buf), "part_%s", map);
grub_install_push_module (buf);
}
static void
probe_mods (grub_disk_t disk)
{
@ -353,21 +368,11 @@ probe_mods (grub_disk_t disk)
grub_util_info ("no partition map found for %s", disk->name);
for (part = disk->partition; part; part = part->parent)
{
char buf[50];
if (strcmp (part->partmap->name, "openbsd") == 0
|| strcmp (part->partmap->name, "netbsd") == 0)
{
grub_install_push_module ("part_bsd");
continue;
}
snprintf (buf, sizeof (buf), "part_%s", part->partmap->name);
grub_install_push_module (buf);
}
push_partmap_module (part->partmap->name);
if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID)
{
grub_diskfilter_get_partmap (disk, grub_install_push_module);
grub_diskfilter_get_partmap (disk, push_partmap_module);
have_abstractions = 1;
}
@ -606,7 +611,7 @@ device_map_check_duplicates (const char *dev_map)
fclose (fp);
qsort (d, filled, sizeof (d[0]), (int (*) (const void *, const void *))strcmp);
qsort (d, filled, sizeof (d[0]), grub_qsort_strcmp);
for (i = 0; i + 1 < filled; i++)
if (strcmp (d[i], d[i+1]) == 0)
@ -1108,7 +1113,12 @@ main (int argc, char *argv[])
{
if (install_device[0] == '('
&& install_device[grub_strlen (install_device) - 1] == ')')
install_drive = xstrdup (install_device);
{
size_t len = grub_strlen (install_device) - 2;
install_drive = xmalloc (len + 1);
memcpy (install_drive, install_device + 1, len);
install_drive[len] = '\0';
}
else
{
grub_util_pull_device (install_device);
@ -1394,8 +1404,7 @@ main (int argc, char *argv[])
/* output */ imgfile,
/* memdisk */ NULL,
have_load_cfg ? load_cfg : NULL,
/* image target */ mkimage_target,
0, GRUB_COMPRESSION_AUTO);
/* image target */ mkimage_target, 0);
/* Backward-compatibility kludges. */
switch (platform)
{
@ -1425,8 +1434,7 @@ main (int argc, char *argv[])
/* output */ dst,
/* memdisk */ NULL,
have_load_cfg ? load_cfg : NULL,
/* image target */ mkimage_target,
0, GRUB_COMPRESSION_AUTO);
/* image target */ mkimage_target, 0);
}
break;
case GRUB_INSTALL_PLATFORM_ARM_EFI:

View File

@ -146,6 +146,10 @@ GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_u
# choosing Hurd filesystem module.
GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
if [ x"$GRUB_FS" = xunknown ]; then
GRUB_FS="$(stat -f --printf=%T / || echo unknown)"
fi
if test -f ${sysconfdir}/default/grub ; then
. ${sysconfdir}/default/grub
fi

View File

@ -821,9 +821,9 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
font_name = xmalloc (strlen (font_info->name) + strlen (&style_name[1])
+ 3 + 20);
ptr = stpcpy (font_name, font_info->name);
ptr = grub_stpcpy (font_name, font_info->name);
*ptr++ = ' ';
ptr = stpcpy (ptr, &style_name[1]);
ptr = grub_stpcpy (ptr, &style_name[1]);
*ptr++ = ' ';
snprintf (ptr, 20, "%d", font_info->size);

View File

@ -493,6 +493,85 @@ SUFFIX (count_funcs) (Elf_Ehdr *e, Elf_Shdr *symtab_section,
}
#endif
#ifdef MKIMAGE_ELF32
/* Deal with relocation information. This function relocates addresses
within the virtual address space starting from 0. So only relative
addresses can be fully resolved. Absolute addresses must be relocated
again by a PE32 relocator when loaded. */
static grub_size_t
arm_get_trampoline_size (Elf_Ehdr *e,
Elf_Shdr *sections,
Elf_Half section_entsize,
Elf_Half num_sections,
const struct grub_install_image_target_desc *image_target)
{
Elf_Half i;
Elf_Shdr *s;
grub_size_t ret = 0;
for (i = 0, s = sections;
i < num_sections;
i++, s = (Elf_Shdr *) ((char *) s + section_entsize))
if ((s->sh_type == grub_host_to_target32 (SHT_REL)) ||
(s->sh_type == grub_host_to_target32 (SHT_RELA)))
{
Elf_Rela *r;
Elf_Word rtab_size, r_size, num_rs;
Elf_Off rtab_offset;
Elf_Shdr *symtab_section;
Elf_Word j;
symtab_section = (Elf_Shdr *) ((char *) sections
+ (grub_target_to_host32 (s->sh_link)
* section_entsize));
rtab_size = grub_target_to_host (s->sh_size);
r_size = grub_target_to_host (s->sh_entsize);
rtab_offset = grub_target_to_host (s->sh_offset);
num_rs = rtab_size / r_size;
for (j = 0, r = (Elf_Rela *) ((char *) e + rtab_offset);
j < num_rs;
j++, r = (Elf_Rela *) ((char *) r + r_size))
{
Elf_Addr info;
Elf_Addr sym_addr;
info = grub_target_to_host (r->r_info);
sym_addr = SUFFIX (get_symbol_address) (e, symtab_section,
ELF_R_SYM (info), image_target);
sym_addr += (s->sh_type == grub_target_to_host32 (SHT_RELA)) ?
grub_target_to_host (r->r_addend) : 0;
switch (ELF_R_TYPE (info))
{
case R_ARM_ABS32:
case R_ARM_V4BX:
break;
case R_ARM_THM_CALL:
case R_ARM_THM_JUMP24:
case R_ARM_THM_JUMP19:
if (!(sym_addr & 1))
ret += 8;
break;
case R_ARM_CALL:
case R_ARM_JUMP24:
if (sym_addr & 1)
ret += 16;
break;
default:
grub_util_error (_("relocation 0x%x is not implemented yet!"), ELF_R_TYPE (info));
break;
}
}
}
return ret;
}
#endif
/* Deal with relocation information. This function relocates addresses
within the virtual address space starting from 0. So only relative
addresses can be fully resolved. Absolute addresses must be relocated
@ -512,6 +591,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
struct grub_ia64_trampoline *tr = (void *) (pe_target + tramp_off);
grub_uint64_t *gpptr = (void *) (pe_target + got_off);
#define MASK19 ((1 << 19) - 1)
#else
grub_uint32_t *tr = (void *) (pe_target + tramp_off);
#endif
for (i = 0, s = sections;
@ -731,13 +812,13 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
case R_AARCH64_JUMP26:
case R_AARCH64_CALL26:
{
grub_err_t err;
sym_addr -= offset;
sym_addr -= SUFFIX (entry_point);
err = grub_arm64_reloc_xxxx26((grub_uint32_t *)target,
if (!grub_arm_64_check_xxxx26_offset (sym_addr))
grub_util_error ("%s", _("CALL26 Relocation out of range"));
grub_arm64_set_xxxx26_offset((grub_uint32_t *)target,
sym_addr);
if (err)
grub_util_error ("%s", grub_errmsg);
}
break;
default:
@ -764,32 +845,74 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
*target = grub_host_to_target32 (grub_target_to_host32 (*target) + sym_addr);
}
break;
/* Happens when compiled with -march=armv4.
Since currently we need at least armv5, keep bx as-is.
*/
case R_ARM_V4BX:
break;
case R_ARM_THM_CALL:
case R_ARM_THM_JUMP24:
case R_ARM_THM_JUMP19:
{
grub_err_t err;
grub_util_info (" THM_JUMP24:\ttarget=0x%08lx\toffset=(0x%08x)", (unsigned long) target, sym_addr);
if (!(sym_addr & 1))
{
grub_uint32_t tr_addr;
grub_int32_t new_offset;
tr_addr = (char *) tr - (char *) pe_target
- target_section_addr;
new_offset = sym_addr - tr_addr - 12;
if (!grub_arm_jump24_check_offset (new_offset))
return grub_util_error ("jump24 relocation out of range");
tr[0] = grub_host_to_target32 (0x46c04778); /* bx pc; nop */
tr[1] = grub_host_to_target32 (((new_offset >> 2) & 0xffffff) | 0xea000000); /* b new_offset */
tr += 2;
sym_addr = tr_addr | 1;
}
sym_addr -= offset;
/* Thumb instructions can be 16-bit aligned */
if (ELF_R_TYPE (info) == R_ARM_THM_JUMP19)
err = grub_arm_reloc_thm_jump19 ((grub_uint16_t *) target, sym_addr);
else
err = grub_arm_reloc_thm_call ((grub_uint16_t *) target,
sym_addr);
if (err)
grub_util_error ("%s", grub_errmsg);
}
break;
case R_ARM_THM_JUMP19:
case R_ARM_CALL:
case R_ARM_JUMP24:
{
grub_err_t err;
grub_util_info (" THM_JUMP19:\toffset=%d\t(0x%08x)",
sym_addr, sym_addr);
sym_addr -= offset;
grub_util_info (" JUMP24:\ttarget=0x%08lx\toffset=(0x%08x)", (unsigned long) target, sym_addr);
if (sym_addr & 1)
{
grub_uint32_t tr_addr;
grub_int32_t new_offset;
tr_addr = (char *) tr - (char *) pe_target
- target_section_addr;
new_offset = sym_addr - tr_addr - 12;
/* Thumb instructions can be 16-bit aligned */
err = grub_arm_reloc_thm_jump19 ((grub_uint16_t *) target, sym_addr);
/* There is no immediate version of bx, only register one... */
tr[0] = grub_host_to_target32 (0xe59fc004); /* ldr ip, [pc, #4] */
tr[1] = grub_host_to_target32 (0xe08cc00f); /* add ip, ip, pc */
tr[2] = grub_host_to_target32 (0xe12fff1c); /* bx ip */
tr[3] = grub_host_to_target32 (new_offset | 1);
tr += 4;
sym_addr = tr_addr;
}
sym_addr -= offset;
err = grub_arm_reloc_jump24 (target,
sym_addr);
if (err)
grub_util_error ("%s", grub_errmsg);
}
break;
default:
grub_util_error (_("relocation 0x%x is not implemented yet!"), ELF_R_TYPE (info));
break;
@ -1054,11 +1177,13 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
case EM_ARM:
switch (ELF_R_TYPE (info))
{
case R_ARM_V4BX:
/* Relative relocations do not require fixup entries. */
case R_ARM_JUMP24:
case R_ARM_THM_CALL:
case R_ARM_THM_JUMP19:
case R_ARM_THM_JUMP24:
case R_ARM_CALL:
{
Elf_Addr addr;
@ -1280,7 +1405,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
Elf_Off section_offset;
Elf_Half section_entsize;
grub_size_t kernel_size;
grub_size_t ia64jmp_off = 0, ia64_toff = 0, ia64_got_off = 0;
grub_size_t ia64jmp_off = 0, tramp_off = 0, ia64_got_off = 0;
unsigned ia64jmpnum = 0;
Elf_Shdr *symtab_section = 0;
grub_size_t got = 0;
@ -1356,6 +1481,11 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
else
*bss_size = 0;
if (image_target->id == IMAGE_SPARC64_AOUT
|| image_target->id == IMAGE_SPARC64_RAW
|| image_target->id == IMAGE_SPARC64_CDCORE)
*kernel_sz = ALIGN_UP (*kernel_sz, image_target->mod_align);
if (image_target->id == IMAGE_EFI)
{
symtab_section = NULL;
@ -1368,6 +1498,21 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
break;
}
#ifdef MKIMAGE_ELF32
if (image_target->elf_target == EM_ARM)
{
grub_size_t tramp;
*kernel_sz = ALIGN_UP (*kernel_sz, 16);
tramp = arm_get_trampoline_size (e, sections, section_entsize,
num_sections, image_target);
tramp_off = *kernel_sz;
*kernel_sz += ALIGN_UP (tramp, 16);
}
#endif
#ifdef MKIMAGE_ELF64
if (image_target->elf_target == EM_IA_64)
{
@ -1377,7 +1522,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
grub_ia64_dl_get_tramp_got_size (e, &tramp, &got);
ia64_toff = *kernel_sz;
tramp_off = *kernel_sz;
*kernel_sz += ALIGN_UP (tramp, 16);
ia64jmp_off = *kernel_sz;
@ -1419,7 +1564,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
SUFFIX (relocate_addresses) (e, sections, section_addresses,
section_entsize,
num_sections, strtab,
out_img, ia64_toff, ia64_got_off,
out_img, tramp_off, ia64_got_off,
image_target);
*reloc_size = SUFFIX (make_reloc_section) (e, reloc_section,
@ -1427,7 +1572,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
section_entsize, num_sections,
strtab, ia64jmp_off
+ image_target->vaddr_offset,
2 * ia64jmpnum + got,
2 * ia64jmpnum + (got / 8),
image_target);
}

View File

@ -149,8 +149,7 @@ process_input_dir (const char *input_dir, enum grub_install_plat platform)
output = grub_util_path_concat_ext (2, grubdir, "core", targets[platform].ext);
grub_install_make_image_wrap (input_dir, prefix, output,
0, load_cfg,
targets[platform].mkimage_target, 0,
GRUB_COMPRESSION_AUTO);
targets[platform].mkimage_target, 0);
grub_install_pop_module ();
/* TRANSLATORS: First %s is replaced by platform name. Second one by filename. */

View File

@ -241,8 +241,7 @@ write_part (FILE *f, const char *srcdir)
static void
make_image_abs (enum grub_install_plat plat,
const char *mkimage_target,
const char *output,
grub_compression_t compress)
const char *output)
{
char *load_cfg;
FILE *load_cfg_f;
@ -266,8 +265,7 @@ make_image_abs (enum grub_install_plat plat,
grub_install_push_module ("iso9660");
grub_install_make_image_wrap (source_dirs[plat], "/boot/grub", output,
0, load_cfg,
mkimage_target, 0,
compress);
mkimage_target, 0);
grub_install_pop_module ();
grub_install_pop_module ();
grub_util_unlink (load_cfg);
@ -276,12 +274,10 @@ make_image_abs (enum grub_install_plat plat,
static void
make_image (enum grub_install_plat plat,
const char *mkimage_target,
const char *output_sub,
grub_compression_t compress)
const char *output_sub)
{
char *out = grub_util_path_concat (2, boot_grub, output_sub);
make_image_abs (plat, mkimage_target,
out, GRUB_COMPRESSION_AUTO);
make_image_abs (plat, mkimage_target, out);
free (out);
}
@ -307,8 +303,7 @@ make_image_fwdisk_abs (enum grub_install_plat plat,
grub_install_push_module ("iso9660");
grub_install_make_image_wrap (source_dirs[plat], "()/boot/grub", output,
0, load_cfg, mkimage_target, 0,
GRUB_COMPRESSION_AUTO);
0, load_cfg, mkimage_target, 0);
grub_install_pop_module ();
}
@ -483,8 +478,7 @@ main (int argc, char *argv[])
grub_install_make_image_wrap (source_dirs[GRUB_INSTALL_PLATFORM_I386_PC],
"/boot/grub", output,
0, load_cfg,
"i386-pc-eltorito", 0,
GRUB_COMPRESSION_AUTO);
"i386-pc-eltorito", 0);
xorriso_push ("-b");
xorriso_push ("boot/grub/i386-pc/eltorito.img");
@ -528,8 +522,7 @@ main (int argc, char *argv[])
grub_install_make_image_wrap (source_dirs[GRUB_INSTALL_PLATFORM_I386_PC],
"/boot/grub", output,
0, load_cfg,
"i386-pc", 0,
GRUB_COMPRESSION_AUTO);
"i386-pc", 0);
sz = ftello (sa);
fflush (sa);
grub_util_fd_sync (fileno (sa));
@ -554,7 +547,7 @@ main (int argc, char *argv[])
grub_install_push_module ("pata");
grub_install_push_module ("ahci");
grub_install_push_module ("at_keyboard");
make_image (GRUB_INSTALL_PLATFORM_I386_MULTIBOOT, "i386-multiboot", "i386-multiboot/core.elf", GRUB_COMPRESSION_AUTO);
make_image (GRUB_INSTALL_PLATFORM_I386_MULTIBOOT, "i386-multiboot", "i386-multiboot/core.elf");
grub_install_pop_module ();
grub_install_pop_module ();
grub_install_pop_module ();
@ -781,22 +774,22 @@ main (int argc, char *argv[])
make_image_fwdisk (GRUB_INSTALL_PLATFORM_MIPSEL_ARC, "mipsel-arc", "arc.exe");
grub_install_push_module ("pata");
make_image (GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS, "mipsel-qemu_mips-elf", "roms/mipsel-qemu_mips.elf", GRUB_COMPRESSION_AUTO);
make_image (GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS, "mipsel-qemu_mips-elf", "roms/mipsel-qemu_mips.elf");
make_image (GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON, "mipsel-loongson-elf", "loongson.elf", GRUB_COMPRESSION_XZ);
make_image (GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON, "mipsel-loongson-elf", "loongson.elf");
make_image (GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON, "mipsel-yeeloong-flash", "mipsel-yeeloong.bin", GRUB_COMPRESSION_XZ);
make_image (GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON, "mipsel-fuloong2f-flash", "mipsel-fuloong2f.bin", GRUB_COMPRESSION_XZ);
make_image (GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON, "mipsel-yeeloong-flash", "mipsel-yeeloong.bin");
make_image (GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON, "mipsel-fuloong2f-flash", "mipsel-fuloong2f.bin");
make_image (GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS, "mips-qemu_mips-elf", "roms/mips-qemu_mips.elf", GRUB_COMPRESSION_AUTO);
make_image (GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS, "mips-qemu_mips-elf", "roms/mips-qemu_mips.elf");
grub_install_push_module ("at_keyboard");
make_image (GRUB_INSTALL_PLATFORM_I386_QEMU, "i386-qemu", "roms/qemu.img", GRUB_COMPRESSION_AUTO);
make_image (GRUB_INSTALL_PLATFORM_I386_QEMU, "i386-qemu", "roms/qemu.img");
grub_install_push_module ("ahci");
make_image (GRUB_INSTALL_PLATFORM_I386_COREBOOT, "i386-coreboot", "roms/coreboot.elf", GRUB_COMPRESSION_AUTO);
make_image (GRUB_INSTALL_PLATFORM_I386_COREBOOT, "i386-coreboot", "roms/coreboot.elf");
grub_install_pop_module ();
grub_install_pop_module ();
grub_install_pop_module ();

View File

@ -25,7 +25,6 @@
#include <argp.h>
#include <string.h>
static grub_compression_t compression;
static char *output_image;
static char **files;
static int nfiles;
@ -35,8 +34,7 @@ static FILE *memdisk;
enum
{
OPTION_OUTPUT = 'o',
OPTION_FORMAT = 'C',
OPTION_COMPRESION = 'C'
OPTION_FORMAT = 'O'
};
static struct argp_option options[] = {
@ -44,8 +42,7 @@ static struct argp_option options[] = {
{"output", 'o', N_("FILE"),
0, N_("save output in FILE [required]"), 2},
{"format", 'O', N_("FILE"), 0, 0, 2},
{"compression", 'C', N_("xz|none|auto"),
0, N_("choose the compression to use for core image"), 2},
{"compression", 'C', N_("xz|none|auto"), OPTION_HIDDEN, 0, 2},
{0, 0, 0, 0, 0, 0}
};
@ -70,6 +67,9 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
static error_t
argp_parser (int key, char *arg, struct argp_state *state)
{
if (key == 'C')
key = GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS;
if (grub_install_parse (key, arg))
return 0;
@ -95,23 +95,6 @@ argp_parser (int key, char *arg, struct argp_state *state)
break;
}
case 'C':
if (grub_strcmp (arg, "xz") == 0)
{
#ifdef HAVE_LIBLZMA
compression = GRUB_COMPRESSION_XZ;
#else
grub_util_error ("%s",
_("grub-mkimage is compiled without XZ support"));
#endif
}
else if (grub_strcmp (arg, "none") == 0)
compression = GRUB_COMPRESSION_NONE;
else if (grub_strcmp (arg, "auto") == 0)
compression = GRUB_COMPRESSION_AUTO;
else
grub_util_error (_("Unknown compression format %s"), arg);
break;
case ARGP_KEY_ARG:
files[nfiles++] = xstrdup (arg);
break;
@ -365,8 +348,7 @@ main (int argc, char *argv[])
grub_install_make_image_wrap (grub_install_source_directory,
"(memdisk)/boot/grub", output_image,
memdisk_img, NULL,
grub_util_get_target_name (format), 0,
compression);
grub_util_get_target_name (format), 0);
grub_util_unlink (memdisk_img);
return 0;

View File

@ -209,9 +209,23 @@ DEVICE must be an OS device (e.g. /dev/sda)."),
NULL, help_filter, NULL
};
static char *
get_device_name (char *dev)
{
size_t len = strlen (dev);
if (dev[0] != '(' || dev[len - 1] != ')')
return 0;
dev[len - 1] = '\0';
return dev + 1;
}
int
main (int argc, char *argv[])
{
char *root_dev = NULL;
char *dest_dev = NULL;
struct arguments arguments;
grub_util_host_init (&argc, &argv);
@ -250,11 +264,34 @@ main (int argc, char *argv[])
grub_mdraid1x_init ();
grub_lvm_init ();
dest_dev = get_device_name (arguments.device);
if (! dest_dev)
{
/* Possibly, the user specified an OS device file. */
dest_dev = grub_util_get_grub_dev (arguments.device);
if (! dest_dev)
{
char *program = xstrdup(program_name);
fprintf (stderr, _("Invalid device `%s'.\n"), arguments.device);
argp_help (&argp, stderr, ARGP_HELP_STD_USAGE, program);
free(program);
exit(1);
}
grub_util_info ("transformed OS device `%s' into GRUB device `%s'",
arguments.device, dest_dev);
}
else
{
/* For simplicity. */
dest_dev = xstrdup (dest_dev);
grub_util_info ("Using `%s' as GRUB device", dest_dev);
}
/* Do the real work. */
GRUB_SETUP_FUNC (arguments.dir ? : DEFAULT_DIRECTORY,
arguments.boot_file ? : DEFAULT_BOOT_FILE,
arguments.core_file ? : DEFAULT_CORE_FILE,
arguments.device, arguments.force,
dest_dev, arguments.force,
arguments.fs_probe, arguments.allow_floppy);
/* Free resources. */
@ -266,6 +303,8 @@ main (int argc, char *argv[])
free (arguments.dir);
free (arguments.dev_map);
free (arguments.device);
free (root_dev);
free (dest_dev);
return 0;
}

View File

@ -68,13 +68,7 @@ else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
fi
GRUBFS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null || true`"
if [ x"$GRUBFS" = x ]; then
GRUBFS="$(stat -f --printf=%T / || true)"
fi
case x"$GRUBFS" in
case x"$GRUB_FS" in
xbtrfs)
rootsubvol="`make_system_path_relative_to_its_root /`"
rootsubvol="${rootsubvol#/}"

View File

@ -64,13 +64,7 @@ if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}" ]; then
GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}"
fi
GRUBFS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null || true`"
if [ x"$GRUBFS" = x ]; then
GRUBFS="$(stat -f --printf=%T /)"
fi
case x"$GRUBFS" in
case x"$GRUB_FS" in
xbtrfs)
rootsubvol="`make_system_path_relative_to_its_root /`"
rootsubvol="${rootsubvol#/}"

View File

@ -129,7 +129,7 @@ for OS in ${OSPROBED} ; do
LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
BOOT="`echo ${OS} | cut -d ':' -f 4`"
UUID="`grub-probe --target=fs_uuid --device ${DEVICE%@*}`"
UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"
EXPUUID="$UUID"
if [ x"${DEVICE#*@}" != x ] ; then

View File

@ -256,3 +256,11 @@ void
grub_register_exported_symbols (void)
{
}
/* Used in comparison of arrays of strings with qsort */
int
grub_qsort_strcmp (const void *p1, const void *p2)
{
return strcmp(*(char **)p1, *(char **)p2);
}

View File

@ -383,7 +383,8 @@ static const struct grub_install_image_target_desc image_targets[] =
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR,
.mod_align = GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN,
},
{
.dirname = "sparc64-ieee1275",
@ -398,7 +399,8 @@ static const struct grub_install_image_target_desc image_targets[] =
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR,
.mod_align = GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN,
},
{
.dirname = "sparc64-ieee1275",
@ -413,7 +415,8 @@ static const struct grub_install_image_target_desc image_targets[] =
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR,
.mod_align = GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN,
},
{
.dirname = "ia64-efi",
@ -831,6 +834,94 @@ struct fixup_block_list
struct grub_pe32_fixup_block b;
};
/*
* R_ARM_THM_CALL/THM_JUMP24
*
* Relocate Thumb (T32) instruction set relative branches:
* B.W, BL and BLX
*/
static grub_err_t
grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
{
grub_int32_t offset;
offset = grub_arm_thm_call_get_offset (target);
grub_dprintf ("dl", " sym_addr = 0x%08x", sym_addr);
offset += sym_addr;
grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n",
target, sym_addr, offset);
/* Keep traditional (pre-Thumb2) limits on blx. In any case if the kernel
is bigger than 2M (currently under 150K) then we probably have a problem
somewhere else. */
if (offset < -0x200000 || offset >= 0x200000)
return grub_error (GRUB_ERR_BAD_MODULE,
N_("THM_CALL Relocation out of range."));
grub_dprintf ("dl", " relative destination = %p",
(char *) target + offset);
return grub_arm_thm_call_set_offset (target, offset);
}
/*
* R_ARM_THM_JUMP19
*
* Relocate conditional Thumb (T32) B<c>.W
*/
static grub_err_t
grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
{
grub_int32_t offset;
if (!(sym_addr & 1))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("Relocation targeting wrong execution state"));
offset = grub_arm_thm_jump19_get_offset (target);
/* Adjust and re-truncate offset */
offset += sym_addr;
if (!grub_arm_thm_jump19_check_offset (offset))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("THM_JUMP19 Relocation out of range."));
grub_arm_thm_jump19_set_offset (target, offset);
return GRUB_ERR_NONE;
}
/*
* R_ARM_JUMP24
*
* Relocate ARM (A32) B
*/
static grub_err_t
grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr)
{
grub_int32_t offset;
if (sym_addr & 1)
return grub_error (GRUB_ERR_BAD_MODULE,
N_("Relocation targeting wrong execution state"));
offset = grub_arm_jump24_get_offset (target);
offset += sym_addr;
if (!grub_arm_jump24_check_offset (offset))
return grub_error (GRUB_ERR_BAD_MODULE,
N_("JUMP24 Relocation out of range."));
grub_arm_jump24_set_offset (target, offset);
return GRUB_ERR_NONE;
}
#pragma GCC diagnostic ignored "-Wcast-align"
#define MKIMAGE_ELF32 1

Some files were not shown because too many files have changed in this diff Show More