Re: pkg-config not used in configure?

2024-09-10 Thread Mark Wielaard
Hi Paul,

On Mon, Sep 09, 2024 at 06:21:16PM -0400, Paul Smith wrote:
> On Mon, 2024-09-09 at 15:29 -0400, Paul Smith wrote:
> > I'm trying to build the latest elfutils release 0.191.  The configure
> > help says:
> > 
> >   ZSTD_COMPRESS_CFLAGS
> >   C compiler flags for ZSTD_COMPRESS, overriding pkg-
> > config
> >   ZSTD_COMPRESS_LIBS
> >   linker flags for ZSTD_COMPRESS, overriding pkg-config
> 
> Actually, these variables don't seem to work either.
> 
> Looking at the generated configure script, I don't see how to get
> elfutils to use zstd from a non-standard location?

Yeah, this is unfortunate. There are two checks in configure.ac. One
for zstd decompression support (as used in libdw) which uses the
eu_ZIPLIB macro (as defined in m4/zip.m4). This is the main check, it
also creates the --with-zstd=... configure argument to provide an
alternative location.

But then there is this version check that uses pkgconfig to see if
this is zstd version 1.4.0 or higher. Which is then used to see if we
can add decompression support of zstd compressed sections in libelf.

You are right, they are not fully compatible ways to detect zstd
library support. I wonder if it is reasonable now to just check for
some 1.4.0 zstd symbol to get both libdw decompression and libelf
compression support at the same time. Then you only need the eu_ZIPLIB
macro and can forget about the pkgconfig version check.

Cheers,

Mark


Re: pkg-config not used in configure?

2024-09-10 Thread Paul Smith
Hi Mark; thanks for the note.

On Tue, 2024-09-10 at 10:52 +0200, Mark Wielaard wrote:
> On Mon, Sep 09, 2024 at 06:21:16PM -0400, Paul Smith wrote:
> > On Mon, 2024-09-09 at 15:29 -0400, Paul Smith wrote:
> > > I'm trying to build the latest elfutils release 0.191.  The
> > > configure
> > > help says:
> > > 
> > >   ZSTD_COMPRESS_CFLAGS
> > >   C compiler flags for ZSTD_COMPRESS, overriding pkg-
> > > config
> > >   ZSTD_COMPRESS_LIBS
> > >   linker flags for ZSTD_COMPRESS, overriding pkg-
> > > config
> > 
> > Actually, these variables don't seem to work either.
> > 
> > Looking at the generated configure script, I don't see how to get
> > elfutils to use zstd from a non-standard location?
> 
> Yeah, this is unfortunate. There are two checks in configure.ac. One
> for zstd decompression support (as used in libdw) which uses the
> eu_ZIPLIB macro (as defined in m4/zip.m4). This is the main check, it
> also creates the --with-zstd=... configure argument to provide an
> alternative location.

Hm.  Are you saying that if I use --with-zstd=/my/prefix that should
work?  That was the first thing I tried, but it didn't seem to work and
I don't think (from reading the configure script) where this value is
used as part of the path search.  But, the shell output of autoconf is
not easy to read so maybe I missed it.  I can give it another try.

So far the only thing that's worked for me is to set CFLAGS and LDFLAGS
directly on the configure script with the appropriate options to find
zstd in is proper location.

I have similar problems trying to add an alternate location for curl.


[Bug general/32155] elfutils fails to compile with "srcfiles.cxx:354:10: error: use of undeclared identifier 'no_backup'"

2024-09-10 Thread mark at klomp dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32155

Mark Wielaard  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Mark Wielaard  ---
(In reply to Evgeny Vereshchagin from comment #5)
> I applied the patch locally and as far as I can see elfutils no longer fails
> to compile. Thank you!

Thanks for testing. Pushed as:

commit 1ccbd384375d4c84aecc6dc382d372f5979a1f0c (HEAD -> main)
Author: Mark Wielaard 
Date:   Mon Sep 9 10:24:07 2024 +0200

srcfiles: Fix compile with --disable-libdebuginfod

The eu-srcfiles --no-backup option is only valid when build with
libdebuginfod support. Adjust the ENABLE_LIBDEBUGINFOD conditional
to not use no_backup anywhere. Also only run the run-srcfiles-self.sh
test when debuginfod is enabled.

 * src/srcfiles.cxx (zip_files): Move endif ENABLE_LIBDEBUGINFOD
 after no_backup check.
 * tests/Makefile.am (TESTS): Only add run-srcfiles-self.sh
 if DEBUGINFOD and !DUMMY_LIBDEBUGINFOD.
 * tests/run-srcfiles.self.sh: Use local DEBUGINFOD_CACHE_PATH.

https://sourceware.org/bugzilla/show_bug.cgi?id=32155

Signed-off-by: Mark Wielaard 

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

Re: [PATCH] libdwelf: provide a public debug section relocation function

2024-09-10 Thread Aaron Merey
Hi Di,

Thanks for working on this.

On Tue, Sep 3, 2024 at 7:48 AM Di Chen  wrote:
>
> When opening an ET_REL file through libdwfl, we do resolve all
> cross-debug-section relocations using __libdwfl_relocate().
>
> This commit provide a public function for the above feature, so users
> can make sure that ET_REL files can be handled by libdw.
>
> Here is an example:
>
> int main(int argc, char **argv) {
>   const char *fname = argv[1];
>
>   Elf *elf;
>   elf_version(EV_CURRENT);
>   int fd = open(argv[1], O_RDWR);
>
>   elf = elf_begin(fd, ELF_C_RDWR, NULL);
>
>   dwelf_relocation_debug_sections(elf, fname);

libdwelf.h mentions the following re. naming:

  Functions starting with dwelf_elf will take a (libelf) Elf object as
  first argument and might set elf_errno on error.  Functions starting
  with dwelf_dwarf will take a (libdw) Dwarf object as first argument
  and might set dwarf_errno on error.

The new function takes an Elf object, its name should start with
dwelf_elf.  And since the original eu-strip function is called
remove_debug_relocations I would name the new function
dwelf_elf_remove_debug_relocations.

>   elf_update(elf, ELF_C_WRITE);
>
>   return 0;
> }
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=31447
>
> Signed-off-by: Di Chen 
> ---
>  libdw/libdw.map|   5 +
>  libdwelf/Makefile.am   |   5 +-
>  libdwelf/dwelf_relocation_debug_sections.c | 389 +
>  libdwelf/libdwelf.h|   3 +
>  src/strip.c| 348 +-
>  tests/Makefile.am  |   5 +-
>  tests/dwelf_reloc_dbg_scn.c|  25 ++
>  tests/run-dwelf-reloc-dbg-scn.sh   |  48 +++
>  tests/testfile-dwelf-reloc-dbg-scn.o.bz2   | Bin 0 -> 1088 bytes
>  9 files changed, 481 insertions(+), 347 deletions(-)
>  create mode 100644 libdwelf/dwelf_relocation_debug_sections.c
>  create mode 100644 tests/dwelf_reloc_dbg_scn.c
>  create mode 100755 tests/run-dwelf-reloc-dbg-scn.sh
>  create mode 100644 tests/testfile-dwelf-reloc-dbg-scn.o.bz2
>
> diff --git a/libdw/libdw.map b/libdw/libdw.map
> index 552588a9..529036f8 100644
> --- a/libdw/libdw.map
> +++ b/libdw/libdw.map
> @@ -383,3 +383,8 @@ ELFUTILS_0.192 {
>global:
>  dwfl_set_sysroot;
>  } ELFUTILS_0.191;
> +
> +ELFUTILS_0.193 {
> +  global:
> +dwelf_relocation_debug_sections;
> +} ELFUTILS_0.192;
> diff --git a/libdwelf/Makefile.am b/libdwelf/Makefile.am
> index a35a2873..a3d9cdd4 100644
> --- a/libdwelf/Makefile.am
> +++ b/libdwelf/Makefile.am
> @@ -42,13 +42,14 @@ noinst_HEADERS = libdwelfP.h
>  libdwelf_a_SOURCES = dwelf_elf_gnu_debuglink.c 
> dwelf_dwarf_gnu_debugaltlink.c \
>   dwelf_elf_gnu_build_id.c dwelf_scn_gnu_compressed_size.c \
>   dwelf_strtab.c dwelf_elf_begin.c \
> - dwelf_elf_e_machine_string.c
> + dwelf_elf_e_machine_string.c \
> + dwelf_relocation_debug_sections.c
>
>  libdwelf = $(libdw)
>
>  libdw = ../libdw/libdw.so
>  libelf = ../libelf/libelf.so
> -libebl = ../libebl/libebl.a
> +libebl = ../libebl/libebl.a ../backends/libebl_backends.a
>  libeu = ../lib/libeu.a
>
>  libdwelf_pic_a_SOURCES =
> diff --git a/libdwelf/dwelf_relocation_debug_sections.c 
> b/libdwelf/dwelf_relocation_debug_sections.c
> new file mode 100644
> index ..b2949124
> --- /dev/null
> +++ b/libdwelf/dwelf_relocation_debug_sections.c
> @@ -0,0 +1,389 @@
> +#ifdef HAVE_CONFIG_H
> +# include 
> +#endif
> +
> +#include 
> +#include "libdwP.h"
> +#include "libebl.h"
> +
> +#define INTERNAL_ERROR(fname)
>   \
> +  error_exit(0, _("%s: INTERNAL ERROR %d (%s): %s"), fname, __LINE__,
>   \
> + PACKAGE_VERSION, elf_errmsg(-1))

Since this is a library function we don't want to exit the program when
there is an error.  It's better to instead set elf_errno and return early.

> +
> +typedef uint8_t GElf_Byte;

This typedef is unused.

> +static int debug_fd = -1;
> +static char *tmp_debug_fname = NULL;

This was copied over from eu-strip.  It's needed there because
eu-strip writes to files, but this function only acts on an Elf
object.  It should not write to any files.

> +
> +
> +const char *
> +secndx_name (Elf *elf, size_t ndx)
> +{
> +  size_t shstrndx;
> +  GElf_Shdr mem;
> +  Elf_Scn *sec = elf_getscn (elf, ndx);
> +  GElf_Shdr *shdr = gelf_getshdr (sec, &mem);
> +  if (shdr == NULL || elf_getshdrstrndx (elf, &shstrndx) < 0)
> +return "???";
> +  return elf_strptr (elf, shstrndx, shdr->sh_name) ?: "???";
> +}
> +
> +
> +Elf_Data *
> +get_xndxdata (Elf *elf, Elf_Scn *symscn)
> +{
> +  Elf_Data *xndxdata = NULL;
> +  GElf_Shdr shdr_mem;
> +  GElf_Shdr *shdr = gelf_getshdr (symscn, &shdr_mem);
> +  if (shdr != NULL && shdr->sh_type == SHT_SYMTAB)
> +{
> +  size_t scnndx = elf_ndxscn (symscn);
> +  Elf_Scn *xndxscn = NULL;
> +  

☠ Buildbot (Sourceware): elfutils - failed test (failure) (main)

2024-09-10 Thread builder
A new failure has been detected on builder elfutils-fedora-ppc64le while 
building elfutils.

Full details are available at:
https://builder.sourceware.org/buildbot/#/builders/55/builds/342

Build state: failed test (failure)
Revision: 1ccbd384375d4c84aecc6dc382d372f5979a1f0c
Worker: fedora-ppc64le
Build Reason: (unknown)
Blamelist: Mark Wielaard 

Steps:

- 0: worker_preparation ( success )

- 1: set package name ( success )

- 2: git checkout ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/2/logs/stdio

- 3: autoreconf ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/3/logs/stdio

- 4: configure ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/4/logs/stdio
- config.log: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/4/logs/config_log

- 5: get version ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/5/logs/stdio
- property changes: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/5/logs/property_changes

- 6: make ( warnings )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/6/logs/stdio
- warnings (3): 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/6/logs/warnings__3_

- 7: make check ( failure )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/7/logs/stdio
- test-suite.log: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/7/logs/test-suite_log

- 8: prep ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/8/logs/stdio

- 9: build bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/9/logs/stdio

- 10: fetch bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/10/logs/stdio

- 11: unpack bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/11/logs/stdio

- 12: pass .bunsen.source.* ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/12/logs/stdio

- 13: upload to bunsen ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/13/logs/stdio

- 14: clean up ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/14/logs/stdio

- 15: make distclean ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/15/logs/stdio



Re: [PATCH] readelf: Allow .gdb_index const table to be empty

2024-09-10 Thread Mark Wielaard
Hi,

On Sun, 2024-09-08 at 00:00 +0200, Mark Wielaard wrote:
> The .gdb_index const table can be empty, if no symbol table entry
> refers to a name or CU. Which technically means the symbol table is
> empty or has only zero members.
> 
>   * src/readelf.c (print_gdb_index_section): Check const_off is
>   not past the end of the data section, it can be at the end.

Very briefly discussed with Aaron on irc.

Pushed,

Mark


☺ Buildbot (Sourceware): elfutils - build successful (main)

2024-09-10 Thread builder
A restored build has been detected on builder elfutils-fedora-ppc64le while 
building elfutils.

Full details are available at:
https://builder.sourceware.org/buildbot/#/builders/55/builds/343

Build state: build successful
Revision: 90973df78628a5aefa973d676a4402285e93c9cf
Worker: fedora-ppc64le
Build Reason: (unknown)
Blamelist: Mark Wielaard 

Steps:

- 0: worker_preparation ( success )

- 1: set package name ( success )

- 2: git checkout ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/2/logs/stdio

- 3: autoreconf ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/3/logs/stdio

- 4: configure ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/4/logs/stdio
- config.log: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/4/logs/config_log

- 5: get version ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/5/logs/stdio
- property changes: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/5/logs/property_changes

- 6: make ( warnings )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/6/logs/stdio
- warnings (3): 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/6/logs/warnings__3_

- 7: make check ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/7/logs/stdio
- test-suite.log: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/7/logs/test-suite_log

- 8: prep ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/8/logs/stdio

- 9: build bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/9/logs/stdio

- 10: fetch bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/10/logs/stdio

- 11: unpack bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/11/logs/stdio

- 12: pass .bunsen.source.* ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/12/logs/stdio

- 13: upload to bunsen ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/13/logs/stdio

- 14: clean up ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/14/logs/stdio

- 15: make distclean ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/343/steps/15/logs/stdio



Re: ☠ Buildbot (Sourceware): elfutils - failed test (failure) (main)

2024-09-10 Thread Mark Wielaard
Hi,

On Tue, Sep 10, 2024 at 03:42:38PM +, buil...@sourceware.org wrote:
> A new failure has been detected on builder elfutils-fedora-ppc64le while 
> building elfutils.
> 
> Full details are available at:
> https://builder.sourceware.org/buildbot/#/builders/55/builds/342
> 
> Build state: failed test (failure)
> Revision: 1ccbd384375d4c84aecc6dc382d372f5979a1f0c
> Worker: fedora-ppc64le
> Build Reason: (unknown)
> Blamelist: Mark Wielaard 
> 
> [...]
> 
> - 7: make check ( failure )
> Logs:
> - stdio: 
> https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/7/logs/stdio
> - test-suite.log: 
> https://builder.sourceware.org/buildbot/#/builders/55/builds/342/steps/7/logs/test-suite_log

FAIL: run-backtrace-native-core.sh
==
/usr/bin/coredumpctl
0x7fffbd78  0x7fffbd79  linux-vdso64.so.1
0x7fffbd79  0x7fffbd811310  ld64.so.2
0x7fffbd6a  0x7fffbd6f01a8  libgcc_s.so.1
0x7fffbceb  0x7fffbcff0018  libm.so.6
0x7fffbc80  0x7fffbcb744c0  libstdc++.so.6
0x7fffbcc0  0x7fffbce79110  libc.so.6
0x7fffbd00  0x7fffbd654af0  libubsan.so.1
0x7fffbd70  0x7fffbd740c08  libbz2.so.1
0x13ec3 0x13ec701f0 backtrace-child
TID 2198171:
# 0 0x7fffbccb8b6c  __pthread_kill_implementation
# 1 0x7fffbcc503ac - 1  raise
# 2 0x13ec409b4 - 1  sigusr2
# 3 0x13ec40adc - 1  stdarg
# 4 0x13ec40b2c - 1  backtracegen
# 5 0x13ec40b58 - 1  start
# 6 0x7fffbccb623c - 1  start_thread
# 7 0x7fffbcd6282c - 1  __clone3
TID 2198168:
# 0 0x7fffbcd627f8  __clone3
# 1 0x7fffbcd627f8 - 1  __clone3
# 2 0x7fffbccb5ebc - 1  create_thread.constprop.0
# 3 0x7fffe92ff370 - 1  
/home/mjw/wildebeest/buildbot/elfutils-fedora-ppc64le/build/tests/backtrace: 
dwfl_thread_getframes: address out of range
/home/mjw/wildebeest/buildbot/elfutils-fedora-ppc64le/build/tests/backtrace: 
dwfl_thread_getframes: No DWARF information found
backtrace: backtrace.c:81: callback_verify: Assertion `seen_main' failed.
./test-subr.sh: line 84: 2198174 Aborted (core dumped) 
LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" 
$VALGRIND_CMD "$@"
backtrace-child-core.2198168: no main
rmdir: failed to remove 'test-2198148': Directory not empty
FAIL run-backtrace-native-core.sh (exit status: 1)

Odd, somehow we failed to properly unwind here.  But the next build
seems fine. And neither of the last two commits seem related to
unwinding at all.

Cheers,

Mark