Re: [PATCH] debuginfod-client: Add DEBUGINFOD_HEADERS_FILE.

2022-10-28 Thread Mark Wielaard
Hi Daniel,

On Tue, 2022-10-18 at 14:21 -0700, Daniel Thornburgh via Elfutils-devel wrote:
> This DEBUGINFOD_HEADERS_FILE environment variable names a file to supply
> HTTP headers to outgoing requests. Notably, this allows for
> Authorization headers to be added from a file under OS access control.
> 
> Signed-off-by: Daniel Thornburgh 
> ---
>  NEWS|  3 +++
>  debuginfod/ChangeLog|  5 
>  debuginfod/debuginfod-client.c  | 44 +
>  debuginfod/debuginfod.h.in  |  1 +
>  doc/ChangeLog   |  4 +++
>  doc/debuginfod-client-config.7  |  7 ++
>  doc/debuginfod_find_debuginfo.3 | 12 ++---
>  7 files changed, 73 insertions(+), 3 deletions(-)
> 
> diff --git a/NEWS b/NEWS
> index 6ebd172c..3df652e3 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -2,6 +2,9 @@ Version 0.188 some time after 0.187
>  
>  readelf: Add -D, --use-dynamic option.
>  
> +debuginfod-client: Add $DEBUGINFOD_HEADERS_FILE setting to supply outgoing
> +   HTTP headers.
> +
>  debuginfod: Add --disable-source-scan option.

Thanks for the NEWS entry.

>  libdwfl: Add new function dwfl_get_debuginfod_client.
> diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
> index 59d50df1..1df903fe 100644
> --- a/debuginfod/ChangeLog
> +++ b/debuginfod/ChangeLog
> @@ -1,3 +1,8 @@
> +2022-10-18  Daniel Thornburgh 
> +
> +  * debuginfod-client.c (debuginfod_query_server): Add 
> DEBUGINFOD_HEADERS_FILE
> +  setting to supply outgoing HTTP headers.
> +
>  2022-10-17  Frank Ch. Eigler  
>  
>   * debuginfod.cxx (main): Report libmicrohttpd version.
> diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
> index 2a14d9d9..549520c1 100644
> --- a/debuginfod/debuginfod-client.c
> +++ b/debuginfod/debuginfod-client.c
> @@ -42,6 +42,7 @@
>  #include "config.h"
>  #include "debuginfod.h"
>  #include "system.h"
> +#include 
>  #include 
>  #include 

OK, ctype.h added for isspace.
 
> @@ -447,6 +448,44 @@ add_default_headers(debuginfod_client *client)
>free (utspart);
>  }
>  
> +/* Add HTTP headers found in the given file, one per line. Blank lines or 
> invalid
> + * headers are ignored.
> + */
> +static void
> +add_headers_from_file(debuginfod_client *client, const char* filename)
> +{
> +  int vds = client->verbose_fd;
> +  FILE *f = fopen (filename, "r");
> +  if (f == NULL)
> +{
> +  dprintf(vds, "header file %s: %s\n", filename, strerror(errno));
> +  return;
> +}

Since verbose_fd can be negative it seems better to guard the dprintf
with if (vds >= 0) like other calls that use client->verbose_fd.
dprintf will likely simply silently fail, but better be consistent.

> +  while (1)
> +{
> +  char buf[8192];

OK, 8K should be enough for everybody. It looks like some servers limit
the total header size to 8K. So this seems a fair limit. 

> +  char *s = &buf[0];
> +  if (feof(f))
> +break;
> +  if (fgets (s, sizeof(buf), f) == NULL)
> +break;
> +  for (char *c = s; *c != '\0'; ++c)
> +if (!isspace(*c))
> +  goto nonempty;
> +  continue;
> +nonempty:
> +  ;
> +  size_t last = strlen(s)-1;
> +  if (s[last] == '\n')
> +s[last] = '\0';
> +  int rc = debuginfod_add_http_header(client, s);

OK, this checks there is at least a space between header and value, and
that an ending \n is chopped off. It doesn't check for having a ':',
but debuginfod_add_http_header will do further sanity checks.

> +  if (rc < 0)
> +dprintf(vds, "skipping bad header: %s\n", strerror(-rc));

Like above, guard with if (rc < 0 && vds >= 0).

> +}
> +  fclose (f);
> +}
> +

OK, we will always get here, so f will be closed unless it couldn't be
opened.
 
>  #define xalloc_str(p, fmt, args...)\
>do   \
> @@ -610,6 +649,11 @@ debuginfod_query_server (debuginfod_client *c,
>if (maxtime && vfd >= 0)
>  dprintf(vfd, "using max time %lds\n", maxtime);
>  
> +  const char *headers_file_envvar;
> +  headers_file_envvar = getenv(DEBUGINFOD_HEADERS_FILE_ENV_VAR);
> +  if (headers_file_envvar != NULL)
> +add_headers_from_file(c, headers_file_envvar);
> +
>/* Maxsize is valid*/
>if (maxsize > 0)
>  {

This sets the headers every time debuginfod_query_server is called.
That is correct because at the end of debuginfod_query_server all
headers are cleared. So if the client handle is reused the headers need
to be set again.

> diff --git a/debuginfod/debuginfod.h.in b/debuginfod/debuginfod.h.in
> index 40b1ea00..7d8e4972 100644
> --- a/debuginfod/debuginfod.h.in
> +++ b/debuginfod/debuginfod.h.in
> @@ -38,6 +38,7 @@
>  #define DEBUGINFOD_RETRY_LIMIT_ENV_VAR "DEBUGINFOD_RETRY_LIMIT"
>  #define DEBUGINFOD_MAXSIZE_ENV_VAR "DEBUGINFOD_MAXSIZE"
>  #define DEBUGINFOD_MAXTIME_ENV_VAR "DEBUGINFOD_MAXTIME"
> +#define DEBUGINFOD_HEADERS_FILE_ENV_VAR "DEBUGINFOD_HEADERS_FILE"
>  
>  /* The libdeb

Re: [PATCH 06/25] move platform depended include into system.h of libebl

2022-10-28 Thread Mark Wielaard
On Fri, 2022-10-21 at 02:25 +0800, Yonggang Luo via Elfutils-devel
wrote:
> Because all source in libebl #include , so #include
>  in
> libeblP.h is enough, there is multiple memory-access.h file, so use
> relative path to
> include it properly,

I am not a fan of the relative path trick, especially if there it is
clear only one is every needed. You also use it for other files, why?

Cheers,

Mark


Re: [PATCH 08/25] Use configure to detect HAVE_DECL_MMAP and use it for system doesn't provide sys/mman.h

2022-10-28 Thread Mark Wielaard
Hi,

On Fri, 2022-10-21 at 02:25 +0800, Yonggang Luo via Elfutils-devel
wrote:
> Signed-off-by: Yonggang Luo 
> ---
>  configure.ac  | 1 +
>  lib/crc32_file.c  | 4 ++--
>  lib/system.h  | 2 ++
>  libelf/elf32_updatefile.c | 3 ++-
>  libelf/elf_begin.c| 5 -
>  libelf/elf_end.c  | 2 ++
>  libelf/elf_update.c   | 5 -

Missing commit message and ChangeLog entries.

So this is for a system that doesn't have mmap?
How does the testsuite results look on such a system?

ELF_C_{READ,WRITE,RDWR}_MMAP[_PRIVATE] are elfutils extensions, but
they are used internally in other libraries.

Cheers,

Mark


Re: [PATCH 09/25] include libgen.h in system.h

2022-10-28 Thread Mark Wielaard
On Fri, 2022-10-21 at 02:25 +0800, Yonggang Luo via Elfutils-devel
wrote:
> basename function are accessed multiple place, but used without
> include libgen.h

This is wrong. We use the GNU basename (from string.h with
_GNU_SOURCE), not the POSIX one (from libgen.h).

Cheers,

Mark


Re: [PATCH 07/25] move platform depended include into system.h of libasm, libcpu, libdw, libdwfl and libdwelf

2022-10-28 Thread Mark Wielaard
On Fri, 2022-10-21 at 02:25 +0800, Yonggang Luo via Elfutils-devel
wrote:
> Signed-off-by: Yonggang Luo 
> ---
>  lib/color.c| 1 -
>  libasm/asm_abort.c | 1 -
>  libasm/asm_addint8.c   | 2 --
>  libasm/asm_begin.c | 2 --
>  libasm/asm_end.c   | 2 --
>  libasm/libasmP.h   | 3 +++
>  libcpu/i386_disasm.c   | 1 -
>  libcpu/memory-access.h | 3 +--
>  libdw/dwarf_begin_elf.c| 2 --
>  libdw/dwarf_end.c  | 1 -
>  libdw/dwarf_setalt.c   | 2 --
>  libdw/libdw_find_split_unit.c  | 1 -
>  libdwelf/dwelf_elf_begin.c | 2 --
>  libdwelf/dwelf_strtab.c| 1 -
>  libdwfl/argp-std.c | 1 -
>  libdwfl/core-file.c| 6 --
>  libdwfl/dwfl_build_id_find_debuginfo.c | 2 --
>  libdwfl/dwfl_build_id_find_elf.c   | 1 -
>  libdwfl/dwfl_end.c | 1 -
>  libdwfl/dwfl_frame.c   | 1 -
>  libdwfl/dwfl_module.c  | 1 -
>  libdwfl/dwfl_module_getdwarf.c | 1 -
>  libdwfl/dwfl_report_elf.c  | 2 --
>  libdwfl/dwfl_segment_report_module.c   | 2 --
>  libdwfl/find-debuginfo.c   | 1 -
>  libdwfl/gzip.c | 2 --
>  libdwfl/image-header.c | 4 
>  libdwfl/link_map.c | 2 --
>  libdwfl/linux-pid-attach.c | 1 -
>  libdwfl/offline.c  | 1 -
>  libdwfl/open.c | 2 --
>  31 files changed, 4 insertions(+), 51 deletions(-)

Tweak the commit message to fit on < 72 chars and added ChangeLog
entries.

Pushed,

Mark


[PATCH] Add support for ARCv2

2022-10-28 Thread Shahab Vahedi via Elfutils-devel
This adds support for Synopsys ARCv2 processors. ARC target related
macros has been added to libelf/elf.h. However, there a few changes
on existing ARC macros to correct them and be in sync with binutils.

There are no regressions in tests for an x86_64 build.

==
   elfutils 0.187: tests/test-suite.log
==

.. contents:: :depth: 2

FAIL: run-backtrace-native-core.sh
==

backtrace: No modules recognized in core file
backtrace-child-core.8740: no main
rmdir: failed to remove 'test-8732': Directory not empty
FAIL run-backtrace-native-core.sh (exit status: 1)

FAIL: run-backtrace-native-core-biarch.sh
=

backtrace: No modules recognized in core file
backtrace-child-biarch-core.8763: no main
rmdir: failed to remove 'test-8755': Directory not empty
FAIL run-backtrace-native-core-biarch.sh (exit status: 1)

SKIP: run-lfs-symbols.sh


LFS testing is irrelevant on this system
SKIP run-lfs-symbols.sh (exit status: 77)

Signed-off-by: Shahab Vahedi 
---
 backends/Makefile.am|  7 +++-
 backends/arc_init.c | 55 ++
 backends/arc_reloc.def  | 87 
 backends/arc_symbol.c   | 81 +
 libebl/eblopenbackend.c |  2 +
 libelf/elf.h| 88 +
 src/elflint.c   |  2 +-
 7 files changed, 286 insertions(+), 36 deletions(-)
 create mode 100644 backends/arc_init.c
 create mode 100644 backends/arc_reloc.def
 create mode 100644 backends/arc_symbol.c

diff --git a/backends/Makefile.am b/backends/Makefile.am
index 9566377f..7f8e47a0 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -37,7 +37,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \
 noinst_LIBRARIES = libebl_backends.a libebl_backends_pic.a
 
 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
- m68k bpf riscv csky
+ m68k bpf riscv csky arc
 
 i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \
i386_retval.c i386_regs.c i386_auxv.c \
@@ -96,11 +96,14 @@ riscv_SRCS = riscv_init.c riscv_symbol.c riscv_cfi.c 
riscv_regs.c \
 csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c csky_cfi.c \
csky_regs.c csky_initreg.c csky_corenote.c
 
+arc_SRCS = arc_init.c arc_symbol.c
+
 libebl_backends_a_SOURCES = $(i386_SRCS) $(sh_SRCS) $(x86_64_SRCS) \
$(ia64_SRCS) $(alpha_SRCS) $(arm_SRCS) \
$(aarch64_SRCS) $(sparc_SRCS) $(ppc_SRCS) \
$(ppc64_SRCS) $(s390_SRCS) \
-   $(m68k_SRCS) $(bpf_SRCS) $(riscv_SRCS) $(csky_SRCS)
+   $(m68k_SRCS) $(bpf_SRCS) $(riscv_SRCS) \
+   $(csky_SRCS) $(arc_SRCS)
 
 libebl_backends_pic_a_SOURCES =
 am_libebl_backends_pic_a_OBJECTS = $(libebl_backends_a_SOURCES:.c=.os)
diff --git a/backends/arc_init.c b/backends/arc_init.c
new file mode 100644
index ..a013bc4e
--- /dev/null
+++ b/backends/arc_init.c
@@ -0,0 +1,55 @@
+/* Initialization of ARC specific backend library.
+   Copyright (C) 2022 Synopsys Inc.
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+   Software Foundation; either version 3 of the License, or (at
+   your option) any later version
+
+   or
+
+ * the GNU General Public License as published by the Free
+   Software Foundation; either version 2 of the License, or (at
+   your option) any later version
+
+   or both in parallel, as here.
+
+   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 copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see .  */
+
+#ifdef HAVE_CONFIG_H
+# include 
+#endif
+
+#define BACKENDarc_
+#define RELOC_PREFIX   R_ARC_
+#include "libebl_CPU.h"
+
+/* This defines the common reloc hooks based on arc_reloc.def.  */
+#include "common-reloc.c"
+
+Ebl *
+arc_init (Elf *elf __attribute__ ((unused)),
+ GElf_Half machine __attribute__ ((unused)),
+ Ebl *eh)
+{
+  arc_init_reloc (eh);
+  HOOK (eh, machine_flag_check);
+  HOOK (eh, reloc_simple_type);
+  HOOK (eh, section_type_name);
+
+  /* /bld/gcc-stage2/arc-snps-linux-gnu/libgcc/libgcc.map.in
+ #define __LIBGCC_DWARF_FRAME_REGISTERS__.  */
+  eh->frame_nregs = 146;
+
+  return eh;
+}
diff --git a/backends/arc_reloc.def b/backends/arc_reloc.def
new f

[PATCH] readelf: add binutils-style --syms option

2022-10-28 Thread Arsen Arsenović via Elfutils-devel
This helps people with a lot of built up muscle memory :)

Signed-off-by: Arsen Arsenović 
---
Hi there!

I often use the "medium length" form of --symbols when using readelf, and I've
been trying to switch to eu-readelf lately (for various reasons); this alias
comes in handy for this reason.  I also added the matching tests, though I'm
not sure if they're strictly necessary (but I added them anyway).

Some of the .po files need regenerating, I didn't include that here because it
was a massive diff.

Thanks in advance, and have a great evening!

 doc/ChangeLog  | 4 
 doc/readelf.1  | 5 -
 src/ChangeLog  | 4 
 src/readelf.c  | 1 +
 tests/ChangeLog| 4 
 tests/run-readelf-s.sh | 6 ++
 6 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/doc/ChangeLog b/doc/ChangeLog
index 073023b4..269ed06e 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2022-10-28  Arsen Arsenović  
+
+   * readelf.1: Document the --syms alias.
+
 2022-10-18  Daniel Thornburgh  
 
* debuginfod_find_debuginfo.3: Document DEBUGINFOD_HEADERS_FILE.
diff --git a/doc/readelf.1 b/doc/readelf.1
index 6a843f66..1d182071 100644
--- a/doc/readelf.1
+++ b/doc/readelf.1
@@ -146,7 +146,7 @@ eu-readelf [\fB\-a\fR|\fB\-\-all\fR]
 [\fB\-S\fR|\fB\-\-section\-headers\fR|\fB\-\-sections\fR]
 [\fB\-g\fR|\fB\-\-section\-groups\fR]
 [\fB\-e\fR|\fB\-\-exception\fR]
-[\fB\-s\fR|\fB\-\-symbols\fR] [section name] ]
+[\fB\-\-syms\fR|\fB\-s\fR|\fB\-\-symbols\fR [section name] ]
 [\fB\-\-dyn-syms\fR]
 [\fB\-n\fR|\fB\-\-notes\fR [section name] ]
 [\fB\-r\fR|\fB\-\-relocs\fR]
@@ -255,6 +255,9 @@ of the symbol tables.
 .IP "\fB\-s\fR" 4
 .IX Item "-s"
 .PD 0
+.IP "\fB\--syms\fR" 4
+.IX Item "--syms"
+.PD 0
 .IP "\fB\-\-symbols\fR [section name]" 4
 .IX Item "--symbols"
 .PD
diff --git a/src/ChangeLog b/src/ChangeLog
index 1f369ef6..d3399a5c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2022-10-28  Arsen Arsenović  
+
+   * readelf.c (options): Add Binutils-style --syms alias.
+
 2022-10-19  Mark Wielaard  
 
* readelf.c (dwarf_loc_list_encoding_string): Handle
diff --git a/src/readelf.c b/src/readelf.c
index 7671a31d..0e0b05c4 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -115,6 +115,7 @@ static const struct argp_option options[] =
   { "sections", 'S', NULL, OPTION_ALIAS | OPTION_HIDDEN, NULL, 0 },
   { "symbols", 's', "SECTION", OPTION_ARG_OPTIONAL,
 N_("Display the symbol table sections"), 0 },
+  { "syms", 's', NULL, OPTION_ALIAS | OPTION_HIDDEN, NULL, 0 },
   { "dyn-syms", PRINT_DYNSYM_TABLE, NULL, 0,
 N_("Display (only) the dynamic symbol table"), 0 },
   { "version-info", 'V', NULL, 0, N_("Display versioning information"), 0 },
diff --git a/tests/ChangeLog b/tests/ChangeLog
index be90832a..949dab8a 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2022-10-28  Arsen Arsenović  
+
+   * run-readelf-s.sh: Add tests for the --syms alias.
+
 2022-10-27  Mark Wielaard  
 
* backtrace-subr.sh: Use grep -E instead of egrep, use grep -F
diff --git a/tests/run-readelf-s.sh b/tests/run-readelf-s.sh
index 527c436c..ee1c0e82 100755
--- a/tests/run-readelf-s.sh
+++ b/tests/run-readelf-s.sh
@@ -277,10 +277,16 @@ EOF
 cat testfile.dynsym.in testfile.symtab.in \
   | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebaztab
 
+cat testfile.dynsym.in testfile.symtab.in \
+  | testrun_compare ${abs_top_builddir}/src/readelf --syms testfilebaztab
+
 # Display just .dynsym
 cat testfile.dynsym.in \
   | testrun_compare ${abs_top_builddir}/src/readelf \
 --symbols=.dynsym testfilebaztab
+cat testfile.dynsym.in \
+  | testrun_compare ${abs_top_builddir}/src/readelf \
+--syms=.dynsym testfilebaztab
 cat testfile.dynsym.in \
   | testrun_compare ${abs_top_builddir}/src/readelf \
 --dyn-syms testfilebaztab
-- 
2.38.1



Re: [PATCH][RFC] readelf: partial support of ZSTD compression

2022-10-28 Thread Mark Wielaard
Hi Martin,

On Mon, Oct 24, 2022 at 08:16:09PM +0200, Martin Liška wrote:
> Anyway, I'm sending V2 that works fine --with-zstd and --without-zstd as 
> expected.
> 
> Ready for master?

The decompression part looks good. Few small nitpicks below.

Although I like to also have compression working.  Then we can also
add support to src/elfcompress, which makes for a good testcase. See
tests/run-compress.sh (which has found some subtle memory issues when
run under valgrind).

> From 4aea412783b9b0dcaf0f887947bf2e8ee6c5368b Mon Sep 17 00:00:00 2001
> From: Martin Liska 
> Date: Mon, 24 Oct 2022 11:53:13 +0200
> Subject: [PATCH] readelf: partial support of ZSTD compression
> 
> Support decompression of ZSTD sections and add support
> for it when -SWz is used:
> 
> ...
> [30] .debug_abbrevPROGBITS  1f9d 0168  0 
> C  0   0  1
>  [ELF ZSTD (2) 02fc  1]
> ...

And for this it would be nice to have a tests/run-readelf-z.sh testcase.

> ChangeLog:
> 
>   * configure.ac: Add zstd_LIBS.
> 
> libelf/ChangeLog:
> 
>   * Makefile.am: Use zstd_LIBS.
>   * elf.h (ELFCOMPRESS_ZSTD): Add new value.
>   * elf_compress.c (__libelf_decompress): Dispatch based
>   on the compression algorithm.
>   (__libelf_decompress_zlib): New.
>   (__libelf_decompress_zstd): New.
>   (__libelf_decompress_elf): Pass type of compression to
>   __libelf_decompress.
>   * elf_compress_gnu.c (elf_compress_gnu): Use ELFCOMPRESS_ZLIB
>   as .z* sections can be only compressed with ZLIB.
>   * libelfP.h (__libelf_decompress): Change signature.
> 
> src/ChangeLog:
> 
>   * readelf.c (elf_ch_type_name): Use switch and support ZSTD.

> diff --git a/libelf/elf.h b/libelf/elf.h
> index 02a1b3f5..f0f0ec7d 100644
> --- a/libelf/elf.h
> +++ b/libelf/elf.h

We normally sync elf.h from glibc. I'll do that in a second.

> +#ifdef USE_ZSTD
> +void *
> +internal_function
> +__libelf_decompress_zstd (void *buf_in, size_t size_in, size_t size_out)
> +{
> +  /* Malloc might return NULL when requestion zero size.  This is highly

requesting

> + unlikely, it would only happen when the compression was forced.
> + But we do need a non-NULL buffer to return and set as result.
> + Just make sure to always allocate at least 1 byte.  */

> +void *
> +internal_function
> +__libelf_decompress (int chtype, void *buf_in, size_t size_in, size_t 
> size_out)
> +{
> +  if (chtype == ELFCOMPRESS_ZLIB)
> +return __libelf_decompress_zlib (buf_in, size_in, size_out);
> +  else
> +{
> +#ifdef USE_ZSTD
> +return __libelf_decompress_zstd (buf_in, size_in, size_out);
> +#else
> +return 0;
> +#endif

return NULL for consistency?

> +}
> +}
> +
>  void *
>  internal_function
>  __libelf_decompress_elf (Elf_Scn *scn, size_t *size_out, size_t *addralign)
> @@ -268,7 +316,7 @@ __libelf_decompress_elf (Elf_Scn *scn, size_t *size_out, 
> size_t *addralign)
>if (gelf_getchdr (scn, &chdr) == NULL)
>  return NULL;
>  
> -  if (chdr.ch_type != ELFCOMPRESS_ZLIB)
> +  if (chdr.ch_type != ELFCOMPRESS_ZLIB && chdr.ch_type != ELFCOMPRESS_ZSTD)
>  {

What about the ifndef USE_ZSTD case? Should this then not recognize
ELFCOMPRESS_ZSTD?

Thanks,

Mark



[COMMITTED] libelf: Sync elf.h from glibc

2022-10-28 Thread Mark Wielaard
Adds ELFCOMPRESS_ZSTD, NT_S390_PV_CPU_DATA and NT_LOONGARCH_*.

Signed-off-by: Mark Wielaard 
---
 libelf/ChangeLog |  4 
 libelf/elf.h | 18 +-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index aefb31b3..8107c71e 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2022-10-28  Mark Wielaard  
+
+   * elf.h: Update from glibc.
+
 2022-10-21  Yonggang Luo  
 
* libelf_crc32.c: Remove LIB_SYSTEM_H define.
diff --git a/libelf/elf.h b/libelf/elf.h
index 02a1b3f5..f51300bc 100644
--- a/libelf/elf.h
+++ b/libelf/elf.h
@@ -506,6 +506,7 @@ typedef struct
 
 /* Legal values for ch_type (compression algorithm).  */
 #define ELFCOMPRESS_ZLIB   1  /* ZLIB/DEFLATE algorithm.  */
+#define ELFCOMPRESS_ZSTD   2  /* Zstandard algorithm.  */
 #define ELFCOMPRESS_LOOS   0x6000 /* Start of OS-specific.  */
 #define ELFCOMPRESS_HIOS   0x6fff /* End of OS-specific.  */
 #define ELFCOMPRESS_LOPROC 0x7000 /* Start of processor-specific.  */
@@ -808,6 +809,7 @@ typedef struct
 #define NT_S390_GS_BC  0x30c   /* s390 guarded storage
   broadcast control block.  */
 #define NT_S390_RI_CB  0x30d   /* s390 runtime instrumentation.  */
+#define NT_S390_PV_CPU_DATA0x30e   /* s390 protvirt cpu dump data.  */
 #define NT_ARM_VFP 0x400   /* ARM VFP/NEON registers */
 #define NT_ARM_TLS 0x401   /* ARM TLS register */
 #define NT_ARM_HW_BREAK0x402   /* ARM hardware breakpoint 
registers */
@@ -829,6 +831,15 @@ typedef struct
 #define NT_MIPS_DSP0x800   /* MIPS DSP ASE registers.  */
 #define NT_MIPS_FP_MODE0x801   /* MIPS floating-point mode.  */
 #define NT_MIPS_MSA0x802   /* MIPS SIMD registers.  */
+#define NT_LOONGARCH_CPUCFG0xa00   /* LoongArch CPU config registers.  */
+#define NT_LOONGARCH_CSR   0xa01   /* LoongArch control and
+  status registers.  */
+#define NT_LOONGARCH_LSX   0xa02   /* LoongArch Loongson SIMD
+  Extension registers.  */
+#define NT_LOONGARCH_LASX  0xa03   /* LoongArch Loongson Advanced
+  SIMD Extension registers.  */
+#define NT_LOONGARCH_LBT   0xa04   /* LoongArch Loongson Binary
+  Translation registers.  */
 
 /* Legal values for the note segment descriptor types for object files.  */
 
@@ -1054,7 +1065,8 @@ typedef struct
 
 /* Legal values for vd_flags (version information flags).  */
 #define VER_FLG_BASE   0x1 /* Version definition of file itself */
-#define VER_FLG_WEAK   0x2 /* Weak version identifier */
+#define VER_FLG_WEAK   0x2 /* Weak version identifier.  Also
+  used by vna_flags below.  */
 
 /* Versym symbol index values.  */
 #defineVER_NDX_LOCAL   0   /* Symbol is local.  */
@@ -1132,10 +1144,6 @@ typedef struct
 } Elf64_Vernaux;
 
 
-/* Legal values for vna_flags.  */
-#define VER_FLG_WEAK   0x2 /* Weak version identifier */
-
-
 /* Auxiliary vector.  */
 
 /* This vector is normally only used by the program interpreter.  The
-- 
2.30.2



[Bug tools/29498] Is it expected that eu-strip strips .note.GNU-stack

2022-10-28 Thread jpalus at fastmail dot com via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29498

--- Comment #3 from Jan Palus  ---
If I understand it correctly in binutils primary criteria for removing section
is whether it is marked with SEC_DEBUGGING flag:

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/objcopy.c;h=d20aaef9f4f2e2a910bd7bf666dab6e3c158fc1b;hb=HEAD#l1366

and the flag for ELF seems to be set here:

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elf.c;h=81825b748d75f2b68a6cca1c54b126df53c36dc2;hb=HEAD#l1093

  if (startswith (name, ".debug")
  || startswith (name, ".gnu.debuglto_.debug_")
  || startswith (name, ".gnu.linkonce.wi.")
  || startswith (name, ".zdebug"))
flags |= SEC_DEBUGGING | SEC_ELF_OCTETS;
  else if (startswith (name, GNU_BUILD_ATTRS_SECTION_NAME)
   || startswith (name, ".note.gnu"))
{
  flags |= SEC_ELF_OCTETS;
  opb = 1;
}
  else if (startswith (name, ".line")
   || startswith (name, ".stab")
   || strcmp (name, ".gdb_index") == 0)
flags |= SEC_DEBUGGING;

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