From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VkdN7-0003Nk-2G for mharc-grub-devel@gnu.org; Sun, 24 Nov 2013 12:21:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VkdN1-0003Lu-Ki for grub-devel@gnu.org; Sun, 24 Nov 2013 12:21:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VkdMw-00031A-RV for grub-devel@gnu.org; Sun, 24 Nov 2013 12:21:19 -0500 Received: from mail-lb0-x22c.google.com ([2a00:1450:4010:c04::22c]:50275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VkdMw-00030v-JV for grub-devel@gnu.org; Sun, 24 Nov 2013 12:21:14 -0500 Received: by mail-lb0-f172.google.com with SMTP id z5so2459794lbh.17 for ; Sun, 24 Nov 2013 09:21:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=npwEwwFa3qOTQZPsuetzVcuARW3DIXvKSg+2uduCgyU=; b=yNvonDyJsuox6b2OaHqHoiC0hdiGs0CDx5IPKPahfoBBqZTaNqsDJJ7zHkEXb0y81T 3r4sGm5RsaHqPHsS/BF154pIP3inIKmEIooqxZQhpN+0whgJlC8RQE2it2hz2H8dp4R9 0MM7B0sBYJpXN+BaZP2jbamiO7CSaTqFZcU8ayys0J1vhdpUyuHDqYgEYavkwnPAskSj xYJISLff3Ny9GnKxBX5uKWIp06iMU27gooa3lyIzCP07jCfGRG3W8karAyjpow1mIn1+ dSB1xc+vl6/PZedywQ5YaFDlDKJKwIaYduEMXStNZz5xrPUDZZ7JnawzrSKfwFsxcPrE /KhQ== X-Received: by 10.112.77.98 with SMTP id r2mr2039505lbw.26.1385313673411; Sun, 24 Nov 2013 09:21:13 -0800 (PST) Received: from localhost.localdomain (ppp91-76-170-113.pppoe.mtu-net.ru. [91.76.170.113]) by mx.google.com with ESMTPSA id ox6sm7229886lbb.6.2013.11.24.09.21.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Nov 2013 09:21:12 -0800 (PST) From: Andrey Borzenkov To: grub-devel@gnu.org Subject: [PATCH] Explicitly check for linking format to use for efiemu64 module Date: Sun, 24 Nov 2013 21:21:04 +0400 Message-Id: <1385313664-5982-1-git-send-email-arvidjaar@gmail.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22c Cc: Beeblebrox X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Nov 2013 17:21:24 -0000 Similar to check for target linking format, also check for efiemu64 instead of hardcoding -melf_x86_64. This fixes compilation on *BSD variants. We cannot easily reuse main target check because platforms are different (main target is 32 bit and efiemu64 - 64 bit). This commit adds EFIEMU64_LINK_FORMAT that contains detected link option and is used in efiemu64.o linking instead of hardcoded value. Reported-By: Beeblebrox --- Could you test this patch? configure.ac | 29 +++++++++++++++++++++++++++-- grub-core/Makefile.am | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 8619a67..be558de 100644 --- a/configure.ac +++ b/configure.ac @@ -654,6 +654,30 @@ if test x"$efiemu_excuse" = x ; then efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib" fi fi +if test x"$efiemu_excuse" = x ; then + AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [ + grub_cv_target_cc_efiemu64_link_format=unknown + for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -mx86_64pe -arch,x86_64; do + CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" + LDFLAGS="-m64 -Wl,$format -nostdlib" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + asm (".globl start; start:"); + asm (".globl _start; _start:"); + asm (".globl __start; __start:"); + void __main (void); + void __main (void) {} + ]], [[]])], [flag=1], [flag=0]) + if test x"$flag" = x1; then + grub_cv_target_cc_efiemu64_link_format="$format" + break; + fi + done]) + if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then + efiemu_excuse="no suitable link format for efiemu64 found" + else + EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format" + fi +fi if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled]) fi @@ -663,11 +687,12 @@ else enable_efiemu=no fi AC_SUBST([enable_efiemu]) +AC_SUBST([EFIEMU64_LINK_FORMAT]) CFLAGS="$TARGET_CFLAGS" if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then - AC_CACHE_CHECK([for linking format], [grub_cv_target_cc_link_format], [ + AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [ grub_cv_target_cc_link_format=unknown 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 @@ -681,7 +706,7 @@ if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then asm (".globl __start; __start:"); void __main (void); void __main (void) {} - ]], [[]])], [flag=1], []) + ]], [[]])], [flag=1], [flag=0]) if test x"$flag" = x1; then grub_cv_target_cc_link_format="$format" break; diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index e2da083..e6862b7 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -421,7 +421,7 @@ efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) $(TARGET_OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \ rm -f $@.bin; \ else \ - $(TARGET_CC) -m64 -Wl,-melf_x86_64 -nostdlib -Wl,-r -o $@ $^ || exit 1; \ + $(TARGET_CC) -m64 $(EFIEMU64_LINK_FORMAT) -nostdlib -Wl,-r -o $@ $^ || exit 1; \ if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \ fi -- 1.8.1.4