[PATCH 1/2] configure.ac: remove unneeded AC_CONFIG_MACRO_DIR([m4])

2020-12-15 Thread Dmitry V. Levin
Makefile.am already contains "ACLOCAL_AMFLAGS = -I m4",
that is enough for autoreconf to do the right thing.

Tested with
autoreconf -if && ./configure --enable-maintainer-mode && make && make distcheck

Signed-off-by: Dmitry V. Levin 
---
 ChangeLog| 4 
 configure.ac | 1 -
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 2b2f7437..28a11e75 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-15  Dmitry V. Levin  
+
+   * configure.ac (AC_CONFIG_MACRO_DIR): Remove.
+
 2020-12-12  Dmitry V. Levin  
 
* configure.ac: Fix spelling typos in comments.
diff --git a/configure.ac b/configure.ac
index 9e29f169..268a4674 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,7 +57,6 @@ AC_CONFIG_SRCDIR([libelf/libelf.h])
 AC_CONFIG_FILES([Makefile])
 AC_CONFIG_HEADERS([config.h])
 
-AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_FILES([m4/Makefile])
 
 dnl The RPM spec file.  We substitute a few values in the file.
-- 
ldv


[PATCH 2/2] m4: remove unneeded Makefile.am

2020-12-15 Thread Dmitry V. Levin
m4 files do not have to listed in EXTRA_DIST, in fact,
biarch.m4 has not been listed since its very beginning in 2013,
and nobody seems to have noticed so far.

Tested with
autoreconf -if && ./configure --enable-maintainer-mode && make && make distcheck

Signed-off-by: Dmitry V. Levin 
---
 ChangeLog  |  3 +++
 Makefile.am|  2 +-
 configure.ac   |  2 --
 m4/ChangeLog   |  4 
 m4/Makefile.am | 21 -
 5 files changed, 8 insertions(+), 24 deletions(-)
 delete mode 100644 m4/Makefile.am

diff --git a/ChangeLog b/ChangeLog
index 28a11e75..46568f04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-12-15  Dmitry V. Levin  
 
+   * Makefile.am (SUBDIRS): Remove m4.
+   * configure.ac (AC_CONFIG_FILES): Remove m4/Makefile.
+
* configure.ac (AC_CONFIG_MACRO_DIR): Remove.
 
 2020-12-12  Dmitry V. Levin  
diff --git a/Makefile.am b/Makefile.am
index f68f0966..818e3599 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,7 +26,7 @@ AM_MAKEFLAGS = --no-print-directory
 
 pkginclude_HEADERS = version.h
 
-SUBDIRS = config m4 lib libelf libcpu backends libebl libdwelf libdwfl libdw \
+SUBDIRS = config lib libelf libcpu backends libebl libdwelf libdwfl libdw \
  libasm debuginfod src po doc tests
 
 EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \
diff --git a/configure.ac b/configure.ac
index 268a4674..2d977f28 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,8 +57,6 @@ AC_CONFIG_SRCDIR([libelf/libelf.h])
 AC_CONFIG_FILES([Makefile])
 AC_CONFIG_HEADERS([config.h])
 
-AC_CONFIG_FILES([m4/Makefile])
-
 dnl The RPM spec file.  We substitute a few values in the file.
 AC_CONFIG_FILES([elfutils.spec:config/elfutils.spec.in])
 
diff --git a/m4/ChangeLog b/m4/ChangeLog
index 8ab0ff39..78b1bbc9 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-15  Dmitry V. Levin  
+
+   * Makefile.am: Remove.
+
 2019-10-28  Aaron Merey  
 
* ax_check_compile_flag.m4, ax_cxx_compile_stdcxx.m4: New files.
diff --git a/m4/Makefile.am b/m4/Makefile.am
deleted file mode 100644
index ae7a5657..
--- a/m4/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-## Process this file with automake to produce Makefile.in -*-Makefile-*-
-##
-## Copyright (C) 2000-2009 Red Hat, Inc.
-## This file is part of elfutils.
-##
-## This file 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.
-##
-## elfutils 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 this program.  If not, see .
-##
-
-##m4-files-begin
-EXTRA_DIST = codeset.m4 gettext.m4 iconv.m4 lcmessage.m4 progtest.m4 zip.m4 
ax_check_compile_flag.m4 ax_cxx_compile_stdcxx.m4
-- 
ldv


Re: [PATCH 1/2] configure.ac: remove unneeded AC_CONFIG_MACRO_DIR([m4])

2020-12-15 Thread Mark Wielaard
On Tue, 2020-12-15 at 17:40 +0300, Dmitry V. Levin wrote:
> Makefile.am already contains "ACLOCAL_AMFLAGS = -I m4",
> that is enough for autoreconf to do the right thing.

But is that a good thing to rely on?

The autoconf manual says "be aware that future Automake releases might
start flagging ACLOCAL_AMFLAGS as obsolescent, or even remove
support for it."

And the Autotools Mythbuster says "The search path for local files, as
of version 1.13 of automake, is defined by the directories listed in
AC_CONFIG_MACRO_DIR and AC_CONFIG_MACRO_DIRS arguments. Previously, it
was common to use a variable defined in Makefile.am (ACLOCAL_AMFLAGS)
to pass extra parameters to aclocal. This behaviour is deprecated and
will soon not be supported."

So, might it not be better to keep AC_CONFIG_MACRO_DIR([m4]) and remove
the ACLOCAL_AMFLAGS?

Thanks,

Mark


Re: [PATCH 1/2] configure.ac: remove unneeded AC_CONFIG_MACRO_DIR([m4])

2020-12-15 Thread Dmitry V. Levin
On Tue, Dec 15, 2020 at 04:07:02PM +0100, Mark Wielaard wrote:
> On Tue, 2020-12-15 at 17:40 +0300, Dmitry V. Levin wrote:
> > Makefile.am already contains "ACLOCAL_AMFLAGS = -I m4",
> > that is enough for autoreconf to do the right thing.
> 
> But is that a good thing to rely on?

Looks like that's the common practice nowadays.

> The autoconf manual says "be aware that future Automake releases might
> start flagging ACLOCAL_AMFLAGS as obsolescent, or even remove
> support for it."
> 
> And the Autotools Mythbuster says "The search path for local files, as
> of version 1.13 of automake, is defined by the directories listed in
> AC_CONFIG_MACRO_DIR and AC_CONFIG_MACRO_DIRS arguments. Previously, it
> was common to use a variable defined in Makefile.am (ACLOCAL_AMFLAGS)
> to pass extra parameters to aclocal. This behaviour is deprecated and
> will soon not be supported."
> 
> So, might it not be better to keep AC_CONFIG_MACRO_DIR([m4]) and remove
> the ACLOCAL_AMFLAGS?

Hmm, despite all these recommendation, virtually every project that uses
automake also uses ACLOCAL_AMFLAGS, and very few use AC_CONFIG_MACRO_DIR.

The documentation on AC_CONFIG_MACRO_DIR says that
"you must also set 'ACLOCAL_AMFLAGS = -I DIR'",
so this might be the reason why AC_CONFIG_MACRO_DIR is not popular.

We can keep AC_CONFIG_MACRO_DIR, while it doesn't help, it doesn't harm
either.


-- 
ldv


Re: [PATCH 1/2] configure.ac: remove unneeded AC_CONFIG_MACRO_DIR([m4])

2020-12-15 Thread Mark Wielaard
Hi Dmitry,

On Tue, 2020-12-15 at 20:01 +0300, Dmitry V. Levin wrote:
> Hmm, despite all these recommendation, virtually every project that
> uses
> automake also uses ACLOCAL_AMFLAGS, and very few use
> AC_CONFIG_MACRO_DIR.
> 
> The documentation on AC_CONFIG_MACRO_DIR says that
> "you must also set 'ACLOCAL_AMFLAGS = -I DIR'",
> so this might be the reason why AC_CONFIG_MACRO_DIR is not popular.
> 
> We can keep AC_CONFIG_MACRO_DIR, while it doesn't help, it doesn't
> harm either.

Hohum, this is slightly messy :{

So I looked at autoconf 2.70, just released and it says:

*** New macro AC_CONFIG_MACRO_DIRS.

  This macro can be used more than once and accepts a list of
  directories to search for local M4 macros.  With Automake 1.13 and
  later, use of this macro eliminates a reason to use ACLOCAL_AMFLAGS
  in Makefile.am.

  The older AC_CONFIG_MACRO_DIR, which could only be used once, is
  still supported but considered deprecated.

So it looks like to get rid of ACLOCAL_AMFLAGS we need to update to
autoconf 2.70 and switch to use AC_CONFIG_MACRO_DIRS.

I think it is too early to switch to autoconf 2.70. Currently we
require autoconf 2.63 and automake 1.11. We could probably upgrade to
autconf 2.69 and automake 1.13, but that doesn't seem to help with
AC_CONFIG_MACRO_DIR/ACLOCAL_AMFLAGS.

Since AC_CONFIG_MACRO_DIR is deprecated in 2.70 and ACLOCAL_AMFLAGS is
still needed even with it set lets just go with your patch and remove
it. We can see what we do when we upgrade autoconf/automake versions.

Pushed you original patch.

Cheers,

Mark


Re: [PATCH 1/2] configure.ac: remove unneeded AC_CONFIG_MACRO_DIR([m4])

2020-12-15 Thread Frank Ch. Eigler via Elfutils-devel
Hi -

> I think it is too early to switch to autoconf 2.70. Currently we
> require autoconf 2.63 and automake 1.11. We could probably upgrade to
> autconf 2.69 and automake 1.13, but that doesn't seem to help with
> AC_CONFIG_MACRO_DIR/ACLOCAL_AMFLAGS.
> 
> Since AC_CONFIG_MACRO_DIR is deprecated in 2.70 and ACLOCAL_AMFLAGS is
> still needed even with it set lets just go with your patch and remove
> it. We can see what we do when we upgrade autoconf/automake versions.
> [...]

Note that since we do not commit auto*-generated code into the repo,
we don't really upgrade elfutils autoconf/automake versions.  We are
subject to the whims of each build-host or make-dist-host environment
(which could be relatively old).

- FChE



Re: [PATCH 2/2] m4: remove unneeded Makefile.am

2020-12-15 Thread Mark Wielaard
Hi Dmitry,

On Tue, 2020-12-15 at 17:40 +0300, Dmitry V. Levin wrote:
> m4 files do not have to listed in EXTRA_DIST, in fact,
> biarch.m4 has not been listed since its very beginning in 2013,
> and nobody seems to have noticed so far.

Looks like you are right, the m4 macro files are automatically included
in the DIST_COMMON file list and so don't need to be added manually.

Pushed,

Mark


Re: [PATCH 1/2] configure.ac: remove unneeded AC_CONFIG_MACRO_DIR([m4])

2020-12-15 Thread Dmitry V. Levin
Hi,

On Tue, Dec 15, 2020 at 03:14:27PM -0500, Frank Ch. Eigler wrote:
> Hi -
> 
> > I think it is too early to switch to autoconf 2.70. Currently we
> > require autoconf 2.63 and automake 1.11. We could probably upgrade to
> > autconf 2.69 and automake 1.13, but that doesn't seem to help with
> > AC_CONFIG_MACRO_DIR/ACLOCAL_AMFLAGS.
> > 
> > Since AC_CONFIG_MACRO_DIR is deprecated in 2.70 and ACLOCAL_AMFLAGS is
> > still needed even with it set lets just go with your patch and remove
> > it. We can see what we do when we upgrade autoconf/automake versions.
> > [...]
> 
> Note that since we do not commit auto*-generated code into the repo,
> we don't really upgrade elfutils autoconf/automake versions.  We are
> subject to the whims of each build-host or make-dist-host environment
> (which could be relatively old).

We do have some requirements, though.  For example:

AC_PREREQ(2.63) dnl Minimum Autoconf version required.


-- 
ldv


[PATCH] elflint: Always print symbol name (if known) in error messages.

2020-12-15 Thread Mark Wielaard
Adding the symbol name associated with the symbol index number
makes the error messages a little bit more useful. We used to say:

section [59] '.symtab': symbol 9: st_value out of bounds

But now says:

section [59] '.symtab': symbol 9 (.annobin_size.c.hot): st_value out of bounds

Signed-off-by: Mark Wielaard 
---
 src/ChangeLog |  5 +++
 src/elflint.c | 98 +--
 2 files changed, 54 insertions(+), 49 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index f5a02a36..72f70343 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2020-12-15  Mark Wielaard  
+
+   * elflint.c (check_symtab): Always print symbol name (if known)
+   in error messages.
+
 2020-12-12  Dmitry V. Levin  
 
* ar.c (write_member, do_oper_insert): Fix spelling typo in comment.
diff --git a/src/elflint.c b/src/elflint.c
index 6e219ced..4c129813 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -706,7 +706,7 @@ section [%2d] '%s': XINDEX for zeroth entry not zero\n"),
  continue;
}
 
-  const char *name = NULL;
+  const char *name = "";
   if (strshdr == NULL)
name = "";
   else if (sym->st_name >= strshdr->sh_size)
@@ -726,14 +726,14 @@ section [%2d] '%s': symbol %zu: invalid name value\n"),
{
  if (!no_xndx_warned)
ERROR (gettext ("\
-section [%2d] '%s': symbol %zu: too large section index but no extended 
section index section\n"),
-  idx, section_name (ebl, idx), cnt);
+section [%2d] '%s': symbol %zu (%s): too large section index but no extended 
section index section\n"),
+  idx, section_name (ebl, idx), cnt, name);
  no_xndx_warned = true;
}
  else if (xndx < SHN_LORESERVE)
ERROR (gettext ("\
-section [%2d] '%s': symbol %zu: XINDEX used for index which would fit in 
st_shndx (%" PRIu32 ")\n"),
-  xndxscnidx, section_name (ebl, xndxscnidx), cnt,
+section [%2d] '%s': symbol %zu (%s): XINDEX used for index which would fit in 
st_shndx (%" PRIu32 ")\n"),
+  xndxscnidx, section_name (ebl, xndxscnidx), cnt, name,
   xndx);
}
   else if ((sym->st_shndx >= SHN_LORESERVE
@@ -744,43 +744,43 @@ section [%2d] '%s': symbol %zu: XINDEX used for index 
which would fit in st_shnd
   && (sym->st_shndx < SHN_LORESERVE
   /* || sym->st_shndx > SHN_HIRESERVE  always false */)))
ERROR (gettext ("\
-section [%2d] '%s': symbol %zu: invalid section index\n"),
-  idx, section_name (ebl, idx), cnt);
+section [%2d] '%s': symbol %zu (%s): invalid section index\n"),
+  idx, section_name (ebl, idx), cnt, name);
   else
xndx = sym->st_shndx;
 
   if (GELF_ST_TYPE (sym->st_info) >= STT_NUM
  && !ebl_symbol_type_name (ebl, GELF_ST_TYPE (sym->st_info), NULL, 0))
-   ERROR (gettext ("section [%2d] '%s': symbol %zu: unknown type\n"),
-  idx, section_name (ebl, idx), cnt);
+   ERROR (gettext ("section [%2d] '%s': symbol %zu (%s): unknown type\n"),
+  idx, section_name (ebl, idx), cnt, name);
 
   if (GELF_ST_BIND (sym->st_info) >= STB_NUM
  && !ebl_symbol_binding_name (ebl, GELF_ST_BIND (sym->st_info), NULL,
   0))
ERROR (gettext ("\
-section [%2d] '%s': symbol %zu: unknown symbol binding\n"),
-  idx, section_name (ebl, idx), cnt);
+section [%2d] '%s': symbol %zu (%s): unknown symbol binding\n"),
+  idx, section_name (ebl, idx), cnt, name);
   if (GELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE
  && GELF_ST_TYPE (sym->st_info) != STT_OBJECT)
ERROR (gettext ("\
-section [%2d] '%s': symbol %zu: unique symbol not of object type\n"),
-  idx, section_name (ebl, idx), cnt);
+section [%2d] '%s': symbol %zu (%s): unique symbol not of object type\n"),
+  idx, section_name (ebl, idx), cnt, name);
 
   if (xndx == SHN_COMMON)
{
  /* Common symbols can only appear in relocatable files.  */
  if (ehdr->e_type != ET_REL)
ERROR (gettext ("\
-section [%2d] '%s': symbol %zu: COMMON only allowed in relocatable files\n"),
-  idx, section_name (ebl, idx), cnt);
+section [%2d] '%s': symbol %zu (%s): COMMON only allowed in relocatable 
files\n"),
+  idx, section_name (ebl, idx), cnt, name);
  if (cnt < shdr->sh_info)
ERROR (gettext ("\
-section [%2d] '%s': symbol %zu: local COMMON symbols are nonsense\n"),
-  idx, section_name (ebl, idx), cnt);
+section [%2d] '%s': symbol %zu (%s): local COMMON symbols are nonsense\n"),
+  idx, section_name (ebl, idx), cnt, name);
  if (GELF_R_TYPE (sym->st_info) == STT_FUNC)
ERROR (gettext ("\
-section [%2d] '%s': symbol %zu: function in COMMON section is nonsense\n"),
-  

Re: [PATCH 1/2] configure.ac: remove unneeded AC_CONFIG_MACRO_DIR([m4])

2020-12-15 Thread Mark Wielaard
Hi,

On Tue, 2020-12-15 at 23:31 +0300, Dmitry V. Levin wrote:
> On Tue, Dec 15, 2020 at 03:14:27PM -0500, Frank Ch. Eigler wrote:
> > Note that since we do not commit auto*-generated code into the repo,
> > we don't really upgrade elfutils autoconf/automake versions.  We are
> > subject to the whims of each build-host or make-dist-host environment
> > (which could be relatively old).
> 
> We do have some requirements, though.  For example:
> 
> AC_PREREQ(2.63) dnl Minimum Autoconf version required.

And we likewise specify the minimum version of automake (1.11) to use:

AM_INIT_AUTOMAKE([gnits 1.11 -Wno-portability dist-bzip2 no-dist-gzip 
parallel-tests])

That is why I said we could update those. I think "everybody" now has
at least autoconf 2.69 and automake 1.13. But I don't believe that
really helps us at the moment.

Cheers,

Mark


Re: [PATCH] po: remove empty translation files

2020-12-15 Thread Mark Wielaard
Hi Dmitry,

On Tue, 2020-12-15 at 23:56 +0300, Dmitry V. Levin wrote:
> Remove translation files that do not contain any translation strings,
> not even a single fuzzy one.  These files are also unused because they
> are not listed in the LINGUAS file.

Thanks for noticing. How odd, they were actually submitted completely
empty, some even got updates, but again without any actual translation.

Pushed,

Mark


Re: [PATCH] elflint: Always print symbol name (if known) in error messages.

2020-12-15 Thread Dmitry V. Levin
On Tue, Dec 15, 2020 at 09:52:40PM +0100, Mark Wielaard wrote:
> Adding the symbol name associated with the symbol index number
> makes the error messages a little bit more useful. We used to say:
> 
> section [59] '.symtab': symbol 9: st_value out of bounds
> 
> But now says:
> 
> section [59] '.symtab': symbol 9 (.annobin_size.c.hot): st_value out of bounds

This is nice, thanks.
I have one question about the patch:

[...]
> --- a/src/elflint.c
> +++ b/src/elflint.c
> @@ -706,7 +706,7 @@ section [%2d] '%s': XINDEX for zeroth entry not zero\n"),
> continue;
>   }
>  
> -  const char *name = NULL;
> +  const char *name = "";

This variable is used in some checks, for example, it's being passed
to ebl_check_special_symbol.  I'd like to make sure this change
doesn't have any unintended consequences.


-- 
ldv


Re: [PATCH] elflint: Always print symbol name (if known) in error messages.

2020-12-15 Thread Mark Wielaard
Hi Dmitry,

On Wed, Dec 16, 2020 at 12:44:05AM +0300, Dmitry V. Levin wrote:
> This is nice, thanks.
> I have one question about the patch:
> 
> [...]
> > --- a/src/elflint.c
> > +++ b/src/elflint.c
> > @@ -706,7 +706,7 @@ section [%2d] '%s': XINDEX for zeroth entry not 
> > zero\n"),
> >   continue;
> > }
> >  
> > -  const char *name = NULL;
> > +  const char *name = "";
> 
> This variable is used in some checks, for example, it's being passed
> to ebl_check_special_symbol.  I'd like to make sure this change
> doesn't have any unintended consequences.

Good question. I assumed it was ok, but double checked.  It is used by
ebl_check_special_symbol and various strcmps.  The strcmps would
actually have crashed if the name was NULL (all backends that
implement check_special_symbol did handle NULL first before calling
strcmp). Since "" isn't a valid symbol name (the '<' and '>'
are not normally used) it is fine in all places that use name to check
against a valid symbol name.

Cheers,

Mark


Re: [PATCH] elflint: Always print symbol name (if known) in error messages.

2020-12-15 Thread Dmitry V. Levin
Hi Mark,

On Tue, Dec 15, 2020 at 11:53:48PM +0100, Mark Wielaard wrote:
> Hi Dmitry,
> 
> On Wed, Dec 16, 2020 at 12:44:05AM +0300, Dmitry V. Levin wrote:
> > This is nice, thanks.
> > I have one question about the patch:
> > 
> > [...]
> > > --- a/src/elflint.c
> > > +++ b/src/elflint.c
> > > @@ -706,7 +706,7 @@ section [%2d] '%s': XINDEX for zeroth entry not 
> > > zero\n"),
> > > continue;
> > >   }
> > >  
> > > -  const char *name = NULL;
> > > +  const char *name = "";
> > 
> > This variable is used in some checks, for example, it's being passed
> > to ebl_check_special_symbol.  I'd like to make sure this change
> > doesn't have any unintended consequences.
> 
> Good question. I assumed it was ok, but double checked.  It is used by
> ebl_check_special_symbol and various strcmps.  The strcmps would
> actually have crashed if the name was NULL (all backends that
> implement check_special_symbol did handle NULL first before calling
> strcmp). Since "" isn't a valid symbol name (the '<' and '>'
> are not normally used) it is fine in all places that use name to check
> against a valid symbol name.

So this change is also a fix of potential null dereferences.
Looks good, thanks for double checking.


-- 
ldv


Q: splitting the top level .gitignore file

2020-12-15 Thread Dmitry V. Levin
On Wed, Dec 16, 2020 at 02:40:32AM +0300, Dmitry V. Levin wrote:
[...]
> Use this opportunity to create separate .gitignore files for m4/ and po/
> directories.

By the way, what do you think about moving subdirectory parts of the top
level .gitignore file into subdirectories?  This would be consistent with
ChangeLog files, currently one has to update the top level ChangeLog file
when the top level .gitignore file is changed in a way that affects
specific subdirectories only.


-- 
ldv


[PATCH] libebl: consistently use _(Str) instead of gettext(Str)

2020-12-15 Thread Dmitry V. Levin
libeblP.h defines _(Str) to dgettext ("elfutils", Str) instead of
a simple gettext (Str) for a reason: the library might be indirectly
used by clients that called bindtextdomain with a domain different
from "elfutils".

The change was made automatically using the following command:
$ git grep -l '\
---
 libebl/ChangeLog  | 14 ++
 libebl/eblbackendname.c   |  2 +-
 libebl/eblcorenotetypename.c  |  2 +-
 libebl/ebldynamictagname.c|  2 +-
 libebl/eblobjnote.c   | 22 +++---
 libebl/eblobjnotetypename.c   |  6 +++---
 libebl/eblosabiname.c |  4 ++--
 libebl/eblsectionname.c   |  2 +-
 libebl/eblsectiontypename.c   |  2 +-
 libebl/eblsegmenttypename.c   |  2 +-
 libebl/eblsymbolbindingname.c |  2 +-
 libebl/eblsymboltypename.c|  2 +-
 12 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 04e9cd49..e0862ec3 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,17 @@
+2020-12-15  Dmitry V. Levin  
+
+   * eblbackendname.c (ebl_backend_name): Replace gettext(...) with _(...).
+   * eblcorenotetypename.c (ebl_core_note_type_name): Likewise.
+   * ebldynamictagname.c (ebl_dynamic_tag_name): Likewise.
+   * eblobjnote.c (ebl_object_note): Likewise.
+   * eblobjnotetypename.c (ebl_object_note_type_name): Likewise.
+   * eblosabiname.c (ebl_osabi_name): Likewise.
+   * eblsectionname.c (ebl_section_name): Likewise.
+   * eblsectiontypename.c (ebl_section_type_name): Likewise.
+   * eblsegmenttypename.c (ebl_segment_type_name): Likewise.
+   * eblsymbolbindingname.c (ebl_symbol_binding_name): Likewise.
+   * eblsymboltypename.c (ebl_symbol_type_name): Likewise.
+
 2020-10-19  Mark Wielaard  
 
* eblopenbackend.c (tilegx_init): Removed.
diff --git a/libebl/eblbackendname.c b/libebl/eblbackendname.c
index a2b2df69..e52b1e84 100644
--- a/libebl/eblbackendname.c
+++ b/libebl/eblbackendname.c
@@ -38,5 +38,5 @@
 const char *
 ebl_backend_name (Ebl *ebl)
 {
-  return ebl != NULL ? ebl->emulation : gettext ("No backend");
+  return ebl != NULL ? ebl->emulation : _("No backend");
 }
diff --git a/libebl/eblcorenotetypename.c b/libebl/eblcorenotetypename.c
index d3a56fa9..0e790d06 100644
--- a/libebl/eblcorenotetypename.c
+++ b/libebl/eblcorenotetypename.c
@@ -97,7 +97,7 @@ ebl_core_note_type_name (Ebl *ebl, uint32_t type, char *buf, 
size_t len)
 #undef KNOWNSTYPE
 
  default:
-   snprintf (buf, len, "%s: %" PRIu32, gettext (""), type);
+   snprintf (buf, len, "%s: %" PRIu32, _(""), type);
 
res = buf;
  }
diff --git a/libebl/ebldynamictagname.c b/libebl/ebldynamictagname.c
index 5622fc31..3f8d8ee4 100644
--- a/libebl/ebldynamictagname.c
+++ b/libebl/ebldynamictagname.c
@@ -100,7 +100,7 @@ ebl_dynamic_tag_name (Ebl *ebl, int64_t tag, char *buf, 
size_t len)
res = "FILTER";
   else
{
- snprintf (buf, len, gettext (": %#" PRIx64), tag);
+ snprintf (buf, len, _(": %#" PRIx64), tag);
 
  res = buf;
 
diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c
index 37cbc499..36efe275 100644
--- a/libebl/eblobjnote.c
+++ b/libebl/eblobjnote.c
@@ -55,7 +55,7 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const char *name, 
uint32_t type,
{
  if (type != 3)
{
- printf (gettext ("unknown SDT version %u\n"), type);
+ printf (_("unknown SDT version %u\n"), type);
  return;
}
 
@@ -73,7 +73,7 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const char *name, 
uint32_t type,
  if (descsz < addrs_size + 3)
{
invalid_sdt:
- printf (gettext ("invalid SDT probe descriptor\n"));
+ printf (_("invalid SDT probe descriptor\n"));
  return;
}
 
@@ -123,17 +123,17 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const char 
*name, uint32_t type,
  sem = addrs.a64[2];
}
 
- printf (gettext ("PC: "));
+ printf (_("PC: "));
  printf ("%#" PRIx64 ",", pc);
- printf (gettext (" Base: "));
+ printf (_(" Base: "));
  printf ("%#" PRIx64 ",", base);
- printf (gettext (" Semaphore: "));
+ printf (_(" Semaphore: "));
  printf ("%#" PRIx64 "\n", sem);
- printf (gettext ("Provider: "));
+ printf (_("Provider: "));
  printf ("%s,", provider);
- printf (gettext (" Name: "));
+ printf (_(" Name: "));
  printf ("%s,", pname);
- printf (gettext (" Args: "));
+ printf (_(" Args: "));
  printf ("'%s'\n", args);
  return;
}
@@ -297,7 +297,7 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const char 
*name, uint32_t type,
case NT_GNU_BUILD_ID:
  if (strcmp (name, "GNU") == 0 && descsz > 0)
{
- printf (gettext ("Build ID:

[Bug libelf/27076] New: heap-buffer-overflow when calling file_read_elf function in elf_begin.c in libelf

2020-12-15 Thread 2060271023 at email dot szu.edu.cn via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=27076

Bug ID: 27076
   Summary: heap-buffer-overflow when calling file_read_elf
function in elf_begin.c in libelf
   Product: elfutils
   Version: unspecified
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: libelf
  Assignee: unassigned at sourceware dot org
  Reporter: 2060271023 at email dot szu.edu.cn
CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Created attachment 13055
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13055&action=edit
the crafted input causing heap-buffer-overflow

Hi, 

A Heap-buffer-overflow problem was discovered in the function file_read_elf in
elf_begin.c in libelf, as distributed in elfutils-0.182. A crafted input can
cause segment faults and I have confirmed them with address sanitizer too.

Here are the POC files. Please use "./eu-stack --core=$POS -abdilmsv" to
reproduce the error.

$ git log

> commit 609290a61d4f900c65b7e0e273981022a826e4c0 (HEAD -> master, 
> origin/master, origin/HEAD)
> Author: Mark Wielaard 
> Date:   Sun Nov 29 01:57:53 2020 +0100
> 
> libdwfl: Use 64bit GElf_Addr instead of size_t to calculate address.
> 
> size_t is too small on 32 bit systems to analyze a 64 bit core file.
> 
> Signed-off-by: Mark Wielaard 

The ASAN dumps the stack trace as follows:

> =
> ==5661==ERROR: AddressSanitizer: heap-buffer-overflow on address 
> 0x606000b0 at pc 0x7f3dda845483 bp 0x7ffcfffb4ad0 sp 0x7ffcfffb4ac0
> READ of size 2 at 0x606000b0 thread T0
> #0 0x7f3dda845482 in file_read_elf /elfutils/libelf/elf_begin.c:453
> #1 0x7f3dda845482 in __libelf_read_mmaped_file 
> /elfutils/libelf/elf_begin.c:552
> #2 0x7f3dda54f44f in dwfl_segment_report_module 
> /elfutils/libdwfl/dwfl_segment_report_module.c:955
> #3 0x7f3dda567165 in dwfl_core_file_report 
> /elfutils/libdwfl/core-file.c:558
> #4 0x5584957f0f15 in parse_opt /elfutils/src/stack.c:595
> #5 0x7f3dd9fe0d4a in argp_parse (/lib/x86_64-linux-gnu/libc.so.6+0x12fd4a)
> #6 0x5584957f01f4 in main /elfutils/src/stack.c:695
> #7 0x7f3dd9ed2bf6 in __libc_start_main 
> (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
> #8 0x5584957f0bc9 in _start (/elfutils/build/bin/eu-stack+0x5bc9)
> 
> 0x606000b1 is located 0 bytes to the right of 49-byte region 
> [0x60600080,0x606000b1)
> allocated by thread T0 here:
> #0 0x7f3ddabc9d28 in __interceptor_calloc 
> (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
> #1 0x7f3dda54f1a6 in dwfl_segment_report_module 
> /elfutils/libdwfl/dwfl_segment_report_module.c:907
> #2 0x7f3dda567165 in dwfl_core_file_report 
> /elfutils/libdwfl/core-file.c:558
> #3 0x5584957f0f15 in parse_opt /elfutils/src/stack.c:595
> #4 0x7f3dd9fe0d4a in argp_parse (/lib/x86_64-linux-gnu/libc.so.6+0x12fd4a)
> #5 0x5584957f01f4 in main /elfutils/src/stack.c:695
> #6 0x7f3dd9ed2bf6 in __libc_start_main 
> (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
> 
> SUMMARY: AddressSanitizer: heap-buffer-overflow 
> /elfutils/libelf/elf_begin.c:453 in file_read_elf
> Shadow bytes around the buggy address:
>   0x0c0c7fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>   0x0c0c7fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>   0x0c0c7fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>   0x0c0c7fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>   0x0c0c7fff8000: fa fa fa fa 00 00 00 00 00 00 00 00 fa fa fa fa
> =>0x0c0c7fff8010: 00 00 00 00 00 00[01]fa fa fa fa fa fa fa fa fa
>   0x0c0c7fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
>   0x0c0c7fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
>   0x0c0c7fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
>   0x0c0c7fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
>   0x0c0c7fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
> Shadow byte legend (one shadow byte represents 8 application bytes):
>   Addressable:   00
>   Partially addressable: 01 02 03 04 05 06 07
>   Heap left redzone:   fa
>   Freed heap region:   fd
>   Stack left redzone:  f1
>   Stack mid redzone:   f2
>   Stack right redzone: f3
>   Stack after return:  f5
>   Stack use after scope:   f8
>   Global redzone:  f9
>   Global init order:   f6
>   Poisoned by user:f7
>   Container overflow:  fc
>   Array cookie:ac
>   Intra object redzone:bb
>   ASan internal:   fe
>   Left alloca redzone: ca
>   Right alloca redzone:cb
> ==5661==ABORTING

-- 
You are receiving this mail because:
You are on the CC list for the bug.