[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug report: bad check for ELF binary format
From: |
Bruno Haible |
Subject: |
Re: Bug report: bad check for ELF binary format |
Date: |
Mon, 30 Nov 2020 08:39:16 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-193-generic; KDE/5.18.0; x86_64; ; ) |
Hi,
comex wrote:
> From m4/lib-prefix.m4:
>
> --
> AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf],
> [AC_EGREP_CPP([Extensible Linking Format],
> [#ifdef __ELF__
> Extensible Linking Format
> #endif
> ],
> [gl_cv_elf=yes],
> [gl_cv_elf=no])
> ])
> if test $gl_cv_elf; then
> —
>
> I believe this does not work as intended. 'test $gl_cv_elf' is equivalent to
> 'test -n $gl_cv_elf', i.e. it tests whether the variable is nonempty. Both
> ‘yes’ and ‘no’ are nonempty, so the ‘if’ will always be taken.
Ouch, indeed. This probably breaks the whole 'havelib' module for platforms
such as macOS, AIX, HP-UX. Thanks for the report!!
2020-11-30 Bruno Haible <bruno@clisp.org>
havelib: Fix for non-ELF platforms (regression 2019-11-17).
Reported by comex <comexk@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-11/msg00188.html>.
* m4/lib-prefix.m4 (AC_LIB_PREPARE_MULTILIB): On non-ELF platforms,
don't expect an ELF header.
diff --git a/m4/lib-prefix.m4 b/m4/lib-prefix.m4
index c8a0b46..28bb3d3 100644
--- a/m4/lib-prefix.m4
+++ b/m4/lib-prefix.m4
@@ -1,4 +1,4 @@
-# lib-prefix.m4 serial 17
+# lib-prefix.m4 serial 18
dnl Copyright (C) 2001-2005, 2008-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -180,8 +180,8 @@ AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
],
[gl_cv_elf=yes],
[gl_cv_elf=no])
- ])
- if test $gl_cv_elf; then
+ ])
+ if test $gl_cv_elf = yes; then
# Extract the ELF class of a file (5th byte) in decimal.
# Cf.
https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
if od -A x < /dev/null >/dev/null 2>/dev/null; then