Skip to content

Commit

Permalink
Add support for converting PE+ to Elf64.
Browse files Browse the repository at this point in the history
  • Loading branch information
phcoder committed Dec 16, 2013
1 parent 66a07ce commit 6f1f6a0
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 101 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2013-12-16 Vladimir Serbinenko <[email protected]>

Add support for converting PE+ to Elf64.

2013-12-16 Vladimir Serbinenko <[email protected]>

* grub-core/commands/minicmd.c (grub_mini_cmd_dump): Handle LLP case.
Expand Down
16 changes: 11 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ AC_ARG_ENABLE([efiemu],
if test x"$enable_efiemu" = xno ; then
efiemu_excuse="explicitly disabled"
fi
if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
efiemu_excuse="not available on cygwin"
fi
if test x"$target_cpu" != xi386 ; then
Expand Down Expand Up @@ -759,8 +759,11 @@ CFLAGS="$TARGET_CFLAGS"
if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
grub_cv_target_cc_link_format=unknown
for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -m${target_cpu}pe -arch,${target_cpu}; do
if test x${target_cpu} != xi386 && test x$format = x${target_cpu}pe; then
for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -mi386pe -mi386pep -arch,${target_cpu}; do
if test x${target_cpu} != xi386 && test x$format = xi386pe; then
continue
fi
if test x${target_cpu} != xx86_64 && test x$format = xi386pep; then
continue
fi
CFLAGS="$TARGET_CFLAGS"
Expand All @@ -781,9 +784,12 @@ if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
AC_MSG_ERROR([no suitable link format found])
fi
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
if test x"$grub_cv_target_cc_link_format" = x-mi386pe; then
if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
TARGET_OBJ2ELF='./build-grub-pe2elf';
fi
if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
TARGET_OBJ2ELF='./build-grub-pep2elf';
fi
fi

if test x$grub_cv_target_cc_link_format = x-arch,i386 || test x$grub_cv_target_cc_link_format = x-arch,x86_64; then
Expand All @@ -801,7 +807,7 @@ if test x$grub_cv_target_cc_link_format = x-arch,i386 || test x$grub_cv_target_c
TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
TARGET_LDFLAGS_OLDMAGIC=""
elif test x$grub_cv_target_cc_link_format = x-mi386pe; then
elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_cc_link_format = x-mi386pep ; then
TARGET_APPLE_LINKER=0
TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
Expand Down
5 changes: 4 additions & 1 deletion grub-core/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ CFLAGS_LIBRARY += $(CFLAGS_PLATFORM) -fno-builtin
CPPFLAGS_LIBRARY += $(CPPFLAGS_PLATFORM)
CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM)

build-grub-pep2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=64 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pep2elf\" $^

build-grub-pe2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=32 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^

# gentrigtables
gentrigtables: gentrigtables.c
Expand Down
Loading

0 comments on commit 6f1f6a0

Please sign in to comment.