[Bug debuginfod/28583] FAIL run-debuginfod-response-headers.sh (exit status: 1) with 0.186

2022-04-25 Thread mliska at suse dot cz via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28583

Martin Liska  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |WORKSFORME

--- Comment #4 from Martin Liska  ---
Works for me now.

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

Re: RFC patch: generated AUTHORS

2022-04-25 Thread Mark Wielaard
Hi Frank,

On Sun, Apr 24, 2022 at 07:42:05PM -0400, Frank Ch. Eigler via Elfutils-devel 
wrote:
> The following patch adds a tool AUTHORS.sh to compute a complete
> AUTHORS list to cover the entire git history.  We do this in systemtap
> and it's a nice way of showing off the large list of contributors over
> time.

Nice!  So when preparing a release we just run
./AUTHORS.sh > AUTHORS
to get it up to date.

Thanks for adding this.

Cheers,

Mark


[Bug general/29089] New: riscv64 test failures

2022-04-25 Thread mliska at suse dot cz via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29089

Bug ID: 29089
   Summary: riscv64 test failures
   Product: elfutils
   Version: unspecified
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: general
  Assignee: unassigned at sourceware dot org
  Reporter: mliska at suse dot cz
CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

I noticed the following test failures for elfutils-0.186.tar.bz2 release:

...
[ 8641s] FAIL: run-strip-strmerge.sh
[ 8641s] ===
[ 8641s] 
[ 8641s] elflint /home/abuild/rpmbuild/BUILD/elfutils-0.186/tests/elfstrmerge
[ 8641s] program header entry 2: unknown program header entry type 0x7003
[ 8641s] program header entry 2: file size greater than memory size
[ 8641s] section [25] '.riscv.attributes' has unsupported type 1879048195
[ 8641s] FAIL run-strip-strmerge.sh (exit status: 1)
[ 8641s] 
[ 8641s] FAIL: run-elflint-self.sh
[ 8641s] =
[ 8641s] 
[ 8641s] program header entry 2: unknown program header entry type 0x7003
[ 8641s] program header entry 2: file size greater than memory size
[ 8641s] section [26] '.riscv.attributes' has unsupported type 1879048195
[ 8641s] *** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.186/src/elflint
--quiet --gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.186/src/addr2line
[ 8641s] program header entry 2: unknown program header entry type 0x7003
[ 8641s] program header entry 2: file size greater than memory size
[ 8641s] section [26] '.riscv.attributes' has unsupported type 1879048195
[ 8641s] *** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.186/src/elflint
--quiet --gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.186/src/elfclassify
[ 8641s] program header entry 2: unknown program header entry type 0x7003
[ 8641s] program header entry 2: file size greater than memory size
...

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

[Bug general/29089] riscv64 test failures

2022-04-25 Thread mliska at suse dot cz via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29089

Martin Liska  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|UNCONFIRMED |RESOLVED

--- Comment #1 from Martin Liska  ---
Dup.

*** This bug has been marked as a duplicate of bug 29073 ***

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

[Bug tools/29073] program header entry 2: unknown program header entry type 0x70000003

2022-04-25 Thread mliska at suse dot cz via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29073

Martin Liska  changed:

   What|Removed |Added

 CC||mliska at suse dot cz

--- Comment #2 from Martin Liska  ---
*** Bug 29089 has been marked as a duplicate of this bug. ***

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

[PATCH 0/4] Add AARCH64 pointer authentication support

2022-04-25 Thread German Gomez via Elfutils-devel
Hi,

I've included a set of patches in order to demangle return addresses in
aarch64 platforms with pointer authentication.

Besides adding the implementation of the negate_ra_state opcode, there
is a new function in the libdwfl.h header to feed the PAC masks to the
library.

Let me know if there are any concerns with the current version.

Thanks,
German

German Gomez (4):
  aarch64: Create definitions for AARCH64_RA_SIGN_STATE register
  libdw,aarch64: Implement DW_CFA_AARCH64_negate_ra_state CFI
instruction
  libdwfl,aarch64: Demangle return addresses using a PAC mask
  libdwfl,eu-stack,aarch64: Add API for setting AARCH64 PAC mask.

 backends/aarch64_init.c|  6 +++---
 backends/aarch64_initreg.c |  2 ++
 backends/aarch64_regs.c|  5 -
 libdw/cfi.c| 14 +-
 libdw/dwarf.h  |  5 +
 libdw/libdw.map|  5 +
 libdwfl/dwfl_frame.c   |  3 +++
 libdwfl/dwfl_frame_regs.c  | 10 ++
 libdwfl/frame_unwind.c | 14 +-
 libdwfl/libdwfl.h  |  6 ++
 libdwfl/libdwflP.h |  7 +++
 libdwfl/linux-pid-attach.c | 34 --
 tests/run-addrcfi.sh   |  1 +
 tests/run-allregs.sh   |  1 +
 14 files changed, 105 insertions(+), 8 deletions(-)

-- 
2.25.1



[PATCH 1/4] aarch64: Create definitions for AARCH64_RA_SIGN_STATE register

2022-04-25 Thread German Gomez via Elfutils-devel
This register will be used to indicate whether a return address is
mangled with a PAC or not, in accordance with the DWARF AARCH64 ABI [1].

[1] 
https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#41dwarf-register-names

Signed-off-by: German Gomez 
---
 backends/aarch64_init.c| 6 +++---
 backends/aarch64_initreg.c | 2 ++
 backends/aarch64_regs.c| 5 -
 libdw/dwarf.h  | 5 +
 tests/run-addrcfi.sh   | 1 +
 tests/run-allregs.sh   | 1 +
 6 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/backends/aarch64_init.c b/backends/aarch64_init.c
index bed92954..0a3a2c79 100644
--- a/backends/aarch64_init.c
+++ b/backends/aarch64_init.c
@@ -55,10 +55,10 @@ aarch64_init (Elf *elf __attribute__ ((unused)),
   HOOK (eh, data_marker_symbol);
   HOOK (eh, abi_cfi);
 
-  /* X0-X30 (31 regs) + SP + 1 Reserved + ELR, 30 Reserved regs (34-43)
+  /* X0-X30 (31 regs) + SP + 1 Reserved + ELR + RA_SIGN_STATE, 30 Reserved 
regs (34-43)
  + V0-V31 (32 regs, least significant 64 bits only)
- + ALT_FRAME_RETURN_COLUMN (used when LR isn't used) = 97 DWARF regs. */
-  eh->frame_nregs = 97;
+ + ALT_FRAME_RETURN_COLUMN (used when LR isn't used) = 98 DWARF regs. */
+  eh->frame_nregs = 98;
   HOOK (eh, set_initial_registers_tid);
   HOOK (eh, unwind);
 
diff --git a/backends/aarch64_initreg.c b/backends/aarch64_initreg.c
index daf6f375..4661068a 100644
--- a/backends/aarch64_initreg.c
+++ b/backends/aarch64_initreg.c
@@ -73,6 +73,8 @@ aarch64_set_initial_registers_tid (pid_t tid __attribute__ 
((unused)),
 
   /* ELR cannot be found.  */
 
+  /* RA_SIGN_STATE cannot be found */
+
   /* FP registers (only 64bits are used).  */
   struct user_fpsimd_struct fregs;
   iovec.iov_base = &fregs;
diff --git a/backends/aarch64_regs.c b/backends/aarch64_regs.c
index 23014bfc..e95ece37 100644
--- a/backends/aarch64_regs.c
+++ b/backends/aarch64_regs.c
@@ -87,7 +87,10 @@ aarch64_register_info (Ebl *ebl __attribute__ ((unused)),
 case 33:
   return regtype ("integer", DW_ATE_address, "elr");
 
-case 34 ... 63:
+case 34:
+  return regtype ("integer", DW_ATE_unsigned, "ra_sign_state");
+
+case 35 ... 63:
   return 0;
 
 case 64 ... 95:
diff --git a/libdw/dwarf.h b/libdw/dwarf.h
index 3ce7f236..f234c411 100644
--- a/libdw/dwarf.h
+++ b/libdw/dwarf.h
@@ -1011,6 +1011,11 @@ enum
 DW_EH_PE_indirect = 0x80
   };
 
+/* AARCH64 DWARF registers. */
+enum
+  {
+DW_AARCH64_RA_SIGN_STATE = 34
+  };
 
 /* DWARF XXX.  */
 #define DW_ADDR_none   0
diff --git a/tests/run-addrcfi.sh b/tests/run-addrcfi.sh
index 64fa24d7..ce9e753e 100755
--- a/tests/run-addrcfi.sh
+++ b/tests/run-addrcfi.sh
@@ -3639,6 +3639,7 @@ dwarf_cfi_addrframe (.eh_frame): no matching address range
integer reg30 (x30): same_value
integer reg31 (sp): location expression: call_frame_cfa stack_value
integer reg33 (elr): undefined
+   integer reg34 (ra_sign_state): undefined
FP/SIMD reg64 (v0): undefined
FP/SIMD reg65 (v1): undefined
FP/SIMD reg66 (v2): undefined
diff --git a/tests/run-allregs.sh b/tests/run-allregs.sh
index 87b16c95..ed086651 100755
--- a/tests/run-allregs.sh
+++ b/tests/run-allregs.sh
@@ -2693,6 +2693,7 @@ integer registers:
 30: x30 (x30), signed 64 bits
 31: sp (sp), address 64 bits
 33: elr (elr), address 64 bits
+34: ra_sign_state (ra_sign_state), unsigned 64 bits
 FP/SIMD registers:
 64: v0 (v0), unsigned 128 bits
 65: v1 (v1), unsigned 128 bits
-- 
2.25.1



[PATCH 2/4] libdw, aarch64: Implement DW_CFA_AARCH64_negate_ra_state CFI instruction

2022-04-25 Thread German Gomez via Elfutils-devel
Implement DW_CFA_AARCH64_negate_ra_state in accordance with the DWARF
AARCH64 ABI [1].

Followup commits will use the value of this register to remove the PAC
from return addresses.

[1] 
https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#44call-frame-instructions

Signed-off-by: German Gomez 
---
 libdw/cfi.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libdw/cfi.c b/libdw/cfi.c
index a73fb03f..f985b4d8 100644
--- a/libdw/cfi.c
+++ b/libdw/cfi.c
@@ -125,6 +125,15 @@ execute_cfi (Dwarf_CFI *cache,
 fs->regs[regno].value = (r_value); \
   } while (0)
 
+  /* The AARCH64 DWARF ABI states that register 34 (ra_sign_state) must
+ be initialized to 0. So do it before executing the CFI. */
+  if (cache->e_machine == EM_AARCH64)
+{
+  if (unlikely (! enough_registers (DW_AARCH64_RA_SIGN_STATE, &fs, 
&result)))
+   goto out;
+  fs->regs[DW_AARCH64_RA_SIGN_STATE].value = 0;
+}
+
   while (program < end)
 {
   uint8_t opcode = *program++;
@@ -355,7 +364,10 @@ execute_cfi (Dwarf_CFI *cache,
{
  /* Toggles the return address state, indicating whether
 the return address is encrypted or not on
-aarch64. XXX not handled yet.  */
+aarch64. */
+ if (unlikely (! enough_registers (DW_AARCH64_RA_SIGN_STATE, &fs, 
&result)))
+   goto out;
+ fs->regs[DW_AARCH64_RA_SIGN_STATE].value ^= 0x1;
}
  else
{
-- 
2.25.1



[PATCH 3/4] libdwfl, aarch64: Demangle return addresses using a PAC mask

2022-04-25 Thread German Gomez via Elfutils-devel
Demangle mangled return addresses on AARCH64. The value of the masks is
stored in the struct Dwfl_Thread.

Signed-off-by: German Gomez 
---
 libdwfl/dwfl_frame.c   |  3 +++
 libdwfl/frame_unwind.c | 14 +-
 libdwfl/libdwflP.h |  7 +++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/libdwfl/dwfl_frame.c b/libdwfl/dwfl_frame.c
index 77e0c5cb..88972d8e 100644
--- a/libdwfl/dwfl_frame.c
+++ b/libdwfl/dwfl_frame.c
@@ -270,6 +270,8 @@ dwfl_getthreads (Dwfl *dwfl, int (*callback) (Dwfl_Thread 
*thread, void *arg),
   thread.process = process;
   thread.unwound = NULL;
   thread.callbacks_arg = NULL;
+  thread.aarch64.pauth_insn_mask = 0;
+
   for (;;)
 {
   thread.tid = process->callbacks->next_thread (dwfl,
@@ -340,6 +342,7 @@ getthread (Dwfl *dwfl, pid_t tid,
   thread.process = process;
   thread.unwound = NULL;
   thread.callbacks_arg = NULL;
+  thread.aarch64.pauth_insn_mask = 0;
 
   if (process->callbacks->get_thread (dwfl, tid, process->callbacks_arg,
  &thread.callbacks_arg))
diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c
index 9ac33833..839d1eff 100644
--- a/libdwfl/frame_unwind.c
+++ b/libdwfl/frame_unwind.c
@@ -610,7 +610,19 @@ handle_cfi (Dwfl_Frame *state, Dwarf_Addr pc, Dwarf_CFI 
*cfi, Dwarf_Addr bias)
 
   /* Some architectures encode some extra info in the return address.  */
   if (regno == frame->fde->cie->return_address_register)
-   regval &= ebl_func_addr_mask (ebl);
+   {
+ regval &= ebl_func_addr_mask (ebl);
+
+ /* In aarch64, pseudo-register RA_SIGN_STATE indicates whether the 
+return address needs demangling using the PAC mask from the
+thread. */
+ if (cfi->e_machine == EM_AARCH64 &&
+ frame->nregs > DW_AARCH64_RA_SIGN_STATE &&
+ frame->regs[DW_AARCH64_RA_SIGN_STATE].value & 0x1)
+   {
+ regval &= ~(state->thread->aarch64.pauth_insn_mask);
+   }
+   }
 
   /* This is another strange PPC[64] case.  There are two
 registers numbers that can represent the same DWARF return
diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h
index 7503a627..d3fe8118 100644
--- a/libdwfl/libdwflP.h
+++ b/libdwfl/libdwflP.h
@@ -244,6 +244,12 @@ struct Dwfl_Thread
   /* Bottom (innermost) frame while we're initializing, NULL afterwards.  */
   Dwfl_Frame *unwound;
   void *callbacks_arg;
+
+  /* Data for handling AARCH64 (currently limited to demangling PAC from
+ return addresses). */
+  struct {
+Dwarf_Addr pauth_insn_mask;
+  } aarch64;
 };
 
 /* See its typedef in libdwfl.h.  */
@@ -782,6 +788,7 @@ INTDECL (dwfl_thread_tid)
 INTDECL (dwfl_frame_thread)
 INTDECL (dwfl_thread_state_registers)
 INTDECL (dwfl_thread_state_register_pc)
+INTDECL (dwfl_thread_state_aarch64_pauth)
 INTDECL (dwfl_getthread_frames)
 INTDECL (dwfl_getthreads)
 INTDECL (dwfl_thread_getframes)
-- 
2.25.1



[PATCH 4/4] libdwfl, eu-stack, aarch64: Add API for setting AARCH64 PAC mask.

2022-04-25 Thread German Gomez via Elfutils-devel
Add user API for setting the PAC mask.
The function is intended to be called in 
Dwfl_Thread_Callbacks.set_initial_registers.

Testing notes:

 ... consider the following program.c

 | int a = 0;
 | void leaf(void) {
 |   for (;;)
 | a += a;
 | }
 | void parent(void) {
 |   leaf();
 | }
 | int main(void) {
 |   parent();
 |   return 0;
 | }

 ... compiled with "gcc-10 -O0 -g -mbranch-protection=pac-ret+leaf program.c"
 ... should yield the correct call stack, without mangled addresses:

 | $ eu-stack -p 
 |
 | PID 760267 - process
 | TID 760267:
 | #0  0xaebd0804 leaf
 | #1  0xaebd0818 parent
 | #2  0xaebd0838 main
 | #3  0xbd52ad50 __libc_start_main
 | #4  0xaebd0694 $x

Signed-off-by: German Gomez 
---
 libdw/libdw.map|  5 +
 libdwfl/dwfl_frame_regs.c  | 10 ++
 libdwfl/libdwfl.h  |  6 ++
 libdwfl/linux-pid-attach.c | 34 --
 4 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/libdw/libdw.map b/libdw/libdw.map
index 4f530378..469c72ab 100644
--- a/libdw/libdw.map
+++ b/libdw/libdw.map
@@ -366,3 +366,8 @@ ELFUTILS_0.186 {
 dwarf_linecontext;
 dwarf_linefunctionname;
 } ELFUTILS_0.177;
+
+ELFUTILS_0.188 {
+  global:
+dwfl_thread_state_aarch64_pauth;
+} ELFUTILS_0.186;
diff --git a/libdwfl/dwfl_frame_regs.c b/libdwfl/dwfl_frame_regs.c
index 83b1abef..f8baf6d3 100644
--- a/libdwfl/dwfl_frame_regs.c
+++ b/libdwfl/dwfl_frame_regs.c
@@ -59,3 +59,13 @@ dwfl_thread_state_register_pc (Dwfl_Thread *thread, 
Dwarf_Word pc)
   state->pc_state = DWFL_FRAME_STATE_PC_SET;
 }
 INTDEF(dwfl_thread_state_register_pc)
+
+void
+dwfl_thread_state_aarch64_pauth(Dwfl_Thread *thread, Dwarf_Word insn_mask)
+{
+  Dwfl_Frame *state = thread->unwound;
+  assert (state && state->unwound == NULL);
+  assert (state->initial_frame);
+  thread->aarch64.pauth_insn_mask = insn_mask;
+}
+INTDEF(dwfl_thread_state_aarch64_pauth)
diff --git a/libdwfl/libdwfl.h b/libdwfl/libdwfl.h
index f98f1d52..9eef703c 100644
--- a/libdwfl/libdwfl.h
+++ b/libdwfl/libdwfl.h
@@ -753,6 +753,12 @@ bool dwfl_thread_state_registers (Dwfl_Thread *thread, int 
firstreg,
 void dwfl_thread_state_register_pc (Dwfl_Thread *thread, Dwarf_Word pc)
   __nonnull_attribute__ (1);
 
+/* Called by Dwfl_Thread_Callbacks.set_initial_registers implementation.
+   On AARCH64 platforms with Pointer Authentication, the bits from this mask
+   indicate the position of the PAC bits in return addresses. */
+void dwfl_thread_state_aarch64_pauth (Dwfl_Thread *thread, Dwarf_Word 
insn_mask)
+  __nonnull_attribute__ (1);
+
 /* Iterate through the threads for a process.  Returns zero if all threads have
been processed by the callback, returns -1 on error, or the value of the
callback when not DWARF_CB_OK.  -1 returned on error will set dwfl_errno ().
diff --git a/libdwfl/linux-pid-attach.c b/libdwfl/linux-pid-attach.c
index 09cba07b..bf50a5bc 100644
--- a/libdwfl/linux-pid-attach.c
+++ b/libdwfl/linux-pid-attach.c
@@ -321,6 +321,28 @@ pid_thread_state_registers_cb (int firstreg, unsigned 
nregs,
   return INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
 }
 
+#if defined(__aarch64__)
+
+#include  /* struct user_pac_mask */
+
+static void
+pid_set_aarch64_pauth(Dwfl_Thread *thread, pid_t tid)
+{
+  struct user_pac_mask pac_mask;
+  struct iovec iovec;
+
+  iovec.iov_base = &pac_mask;
+  iovec.iov_len = sizeof (pac_mask);
+
+  /* If the ptrace returns an error, the system may not support pointer
+ authentication. In that case, set the masks to 0 (no PAC bits). */
+  if (ptrace(PTRACE_GETREGSET, tid, NT_ARM_PAC_MASK, &iovec))
+pac_mask.insn_mask = 0;
+
+  INTUSE(dwfl_thread_state_aarch64_pauth) (thread, pac_mask.insn_mask);
+}
+#endif /* __aarch64__ */
+
 static bool
 pid_set_initial_registers (Dwfl_Thread *thread, void *thread_arg)
 {
@@ -333,8 +355,16 @@ pid_set_initial_registers (Dwfl_Thread *thread, void 
*thread_arg)
   pid_arg->tid_attached = tid;
   Dwfl_Process *process = thread->process;
   Ebl *ebl = process->ebl;
-  return ebl_set_initial_registers_tid (ebl, tid,
-   pid_thread_state_registers_cb, thread);
+  if (!ebl_set_initial_registers_tid (ebl, tid,
+ pid_thread_state_registers_cb, thread))
+return false;
+
+#if defined(__aarch64__)
+  /* Set aarch64 pointer authentication data. */
+  pid_set_aarch64_pauth(thread, tid);
+#endif
+
+  return true;
 }
 
 static void
-- 
2.25.1



Re: [PATCH] debuginfod, libdwfl: Initialize libcurl and dlopen debuginfod-client lazily

2022-04-25 Thread Mark Wielaard
On Fri, Apr 22, 2022 at 11:53:43PM +0200, Mark Wielaard wrote:
> We used to go out of our way to initialize libcurl early before any other
> thread/code was running. But this meant that we might pay startup cost,
> which under FIPS is significant, even for code that never uses libdebuginfod
> or TLS libcurl connections. Although curl_global_init itself isn't thread-safe
> we can use pthread_once to make sure we don't race against ourselves. This
> still means we might race against any application code that might use
> libcurl. But we can assume they will have called curl_global_init before
> calling dwfl_begin or debuginfod_begin.

Pushed.

Mark


Re: [PATCH] debuginfod: Use the debuginfod-size response header

2022-04-25 Thread Aaron Merey via Elfutils-devel
On Sun, Apr 24, 2022 at 11:05 AM Mark Wielaard  wrote:
> Looks good. Pleas commit.

Thanks, pushed as:

commit 55fee962676fbff60c6b0469305bcb077910d64f
Author: Aaron Merey 
Date:   Tue Jan 11 22:07:55 2022 -0500

debuginfod: Use the debuginfod-size response header

In some cases the content-length header may not be available in order
to pass to a progressfn.  If content-length isn't available then attempt
to get the size of the download from the debuginfod-size header instead.

It should be mentioned that if a compressed file (ex. gzip) is being
transferred, the actual transfer length will be less than debuginfod-size.
In this case debuginfod-size is a best-guess upper bound on the size of
the transfer.

Signed-off-by: Aaron Merey 



[PATCH] debuginfod: ensure X-DEBUGINFOD-SIZE contains file size

2022-04-25 Thread Aaron Merey via Elfutils-devel
Hi Frank,

On Fri, Apr 22, 2022 at 7:27 PM Frank Ch. Eigler  wrote:
> > -  add_mhd_response_header (r, "X-DEBUGINFOD-SIZE",
> > -   to_string(fs.st_size).c_str());
>
> > +  rc = fstat (fd, &fs);
> > +  if (rc == 0)
> > +add_mhd_response_header (r, "X-DEBUGINFOD-SIZE",
> > + to_string(fs.st_size).c_str());
> > +  else
> > +{
> > +  close (fd);
> > +  throw libc_exception (errno, string("stat ") + b_source1 + " 
> > archive " + b_source0);
> > +}
>
> It shouldn't require a new fstat -- the archive component file's size
> should be available from libarchive already: archive_entry_size(e);

Fixed.

Aaron

>From 08e448456e27339aeb326828d44069028518038a Mon Sep 17 00:00:00 2001
From: Aaron Merey 
Date: Mon, 25 Apr 2022 11:10:46 -0400

For archived files X-DEBUGINFOD-SIZE currently contains the size of the
archive instead of the size of the uncompressed file.  Fix this.

Also add testcases to verify X-DEBUGINFOD-SIZE contains uncompressed
file sizes.

Signed-off-by: Aaron Merey 
---
 debuginfod/debuginfod.cxx| 2 +-
 tests/run-debuginfod-response-headers.sh | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index adca8208..4aaf41c0 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -1790,7 +1790,7 @@ handle_buildid_r_match (bool internal_req_p,
   add_mhd_response_header (r, "Content-Type",
"application/octet-stream");
   add_mhd_response_header (r, "X-DEBUGINFOD-SIZE",
-   to_string(fs.st_size).c_str());
+   to_string(archive_entry_size(e)).c_str());
   add_mhd_response_header (r, "X-DEBUGINFOD-ARCHIVE",
b_source0.c_str());
   add_mhd_response_header (r, "X-DEBUGINFOD-FILE", file.c_str());
diff --git a/tests/run-debuginfod-response-headers.sh 
b/tests/run-debuginfod-response-headers.sh
index 10b2ab49..62c43887 100755
--- a/tests/run-debuginfod-response-headers.sh
+++ b/tests/run-debuginfod-response-headers.sh
@@ -86,6 +86,14 @@ grep 'X-DEBUGINFOD-FILE: ' vlog-find$PORT1.2
 grep 'X-DEBUGINFOD-SIZE: ' vlog-find$PORT1.2
 grep 'X-DEBUGINFOD-ARCHIVE: ' vlog-find$PORT1.2
 
+# Check that X-DEBUGINFOD-SIZE matches the size of each file
+for file in vlog-find$PORT1.1 vlog-find$PORT1.2
+do
+st_size=$(stat -c%s $(tail -n 1 $file))
+x_debuginfod_size=$(grep 'X-DEBUGINFOD-SIZE' $file | egrep -o '[0-9]+')
+test $st_size -eq $x_debuginfod_size
+done
+
 kill $PID1
 wait $PID1
 PID1=0
-- 
2.35.1



[COMMITTED] Prepare for 0.187

2022-04-25 Thread Mark Wielaard
Set version to 0.187
Update NEWS and elfutils.spec.in
Set copyright year in configure.ac and printversion.
Regenerate po/*.po files.

Signed-off-by: Mark Wielaard 
---
 ChangeLog   |5 +
 NEWS|   13 +-
 config/ChangeLog|4 +
 config/elfutils.spec.in |   14 +
 configure.ac|4 +-
 lib/ChangeLog   |4 +
 lib/printversion.c  |2 +-
 po/ChangeLog|4 +
 po/de.po| 1123 +++---
 po/es.po| 1128 +++
 po/ja.po| 1120 +++---
 po/pl.po| 1120 +++---
 po/uk.po| 1121 +++---
 13 files changed, 2823 insertions(+), 2839 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5ad93a16..77173d91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2022-04-25  Mark Wielaard  
+
+   * configure.ac (AC_INIT): Set version to 0.187.
+   * NEWS: Add some more 0.187 items.
+
 2022-04-24  Frank Ch. Eigler  
 
* AUTHORS.sh, .mailmap: New files.
diff --git a/NEWS b/NEWS
index ea74c019..c74fe3f1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,22 @@
-Version 0.187 after 0.186
+Version 0.187
 
 debuginfod: Support -C option for connection thread pooling.
 
+debuginfod-client: Negative cache file are now zero sized instead of
+   no-permission files.
+
 addr2line: The -A, --absolute option, which shows file names including
the full compilation directory is now the default.  To get the
old behavior use the new option --relative.
 
+readelf, elflint: Recognize FDO Packaging Metadata ELF notes
+
+libdw, debuginfo-client: Load libcurl lazily only when files need to
+ be fetched remotely. libcurl is now never
+ loaded when DEBUGINFOD_URLS is unset. And when
+ DEBUGINFOD_URLS is set, libcurl is only loaded
+ when the debuginfod_begin function is called.
+
 Version 0.186
 
 debuginfod-client: Default $DEBUGINFOD_URLS is computed from drop-in files
diff --git a/config/ChangeLog b/config/ChangeLog
index b9b1c44e..51415258 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,7 @@
+2022-04-25  Mark Wielaard  
+
+   * elfutils.spec.in: Update for 0.187.
+
 2022-01-19  Ahelenia Ziemiańska 
 
* profile.csh.in: Set DEBUGINFOD_URLS directly. Use "$0" and :
diff --git a/config/elfutils.spec.in b/config/elfutils.spec.in
index 49e5a016..54599159 100644
--- a/config/elfutils.spec.in
+++ b/config/elfutils.spec.in
@@ -340,6 +340,20 @@ exit 0
 %systemd_postun_with_restart debuginfod.service
 
 %changelog
+* Mon Apr 25 2022 Mark Wielaard  0.187-1
+- debuginfod: Support -C option for connection thread pooling.
+- debuginfod-client: Negative cache file are now zero sized instead
+  of no-permission files.
+- addr2line: The -A, --absolute option, which shows file names
+  includingthe full compilation directory is now the
+  default.  To get theold behavior use the new option --relative.
+- readelf, elflint: Recognize FDO Packaging Metadata ELF notes
+- libdw, debuginfo-client: Load libcurl lazily only when files need
+  to be fetched remotely. libcurl is now never loaded when
+  DEBUGINFOD_URLS is unset. And whenDEBUGINFOD_URLS is set,
+  libcurl is only loaded when the debuginfod_begin function is
+  called.
+
 * Wed Nov 10 2021 Mark Wielaard  0.186-1
 - debuginfod-client: Default $DEBUGINFOD_URLS is computed from
   drop-in files /etc/debuginfod/*.urls rather than
diff --git a/configure.ac b/configure.ac
index 33c4b5e5..11d1cf82 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,7 @@ dnl  GNU General Public License for more details.
 dnl
 dnl  You should have received a copy of the GNU General Public License
 dnl  along with this program.  If not, see .
-AC_INIT([elfutils],[0.186],[https://sourceware.org/bugzilla],[elfutils],[http://elfutils.org/])
+AC_INIT([elfutils],[0.187],[https://sourceware.org/bugzilla],[elfutils],[http://elfutils.org/])
 
 dnl Workaround for older autoconf < 2.64
 m4_ifndef([AC_PACKAGE_URL],
@@ -45,7 +45,7 @@ fi
 AC_CONFIG_AUX_DIR([config])
 AC_CONFIG_FILES([config/Makefile])
 
-AC_COPYRIGHT([Copyright (C) 1996-2021 The elfutils developers.])
+AC_COPYRIGHT([Copyright (C) 1996-2022 The elfutils developers.])
 AC_PREREQ(2.63)dnl Minimum Autoconf version required.
 
 dnl We use GNU make extensions; automake 1.10 defaults to -Wportability.
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 6b76f647..32dda566 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,7 @@
+2022-04-25  Mark Wielaard  
+
+   * printversion.c (print_version): Update copyright year.
+
 2022-03-27  Mark Wielaard  
 
* system.h: define error_exit.
diff --git a/lib/printversion.c b/lib/printversion.c
ind

elfutils 0.187 released

2022-04-25 Thread Mark Wielaard
ELFUTILS 0.187 - http://elfutils.org/

A new release of elfutils is available at:
ftp://sourceware.org/pub/elfutils/0.187/
or https://sourceware.org/elfutils/ftp/0.187/

Visit us on the Libera.Chat irc channel #elfutils

* NEWS *

debuginfod: Support -C option for connection thread pooling.

debuginfod-client: Negative cache file are now zero sized instead of
   no-permission files.

addr2line: The -A, --absolute option, which shows file names including
   the full compilation directory is now the default.  To get the
   old behavior use the new option --relative.

readelf, elflint: Recognize FDO Packaging Metadata ELF notes

libdw, debuginfo-client: Load libcurl lazily only when files need to
 be fetched remotely. libcurl is now never
 loaded when DEBUGINFOD_URLS is unset. And when
 DEBUGINFOD_URLS is set, libcurl is only loaded
 when the debuginfod_begin function is called.

* GIT SHORTLOG *

Aaron Merey (4):
  debuginfod: Include "IPv4 IPv6" in server startup message
  PR29022: 000-permissions files cause problems for backups
  debuginfod: Use the debuginfod-size response header
  debuginfod: ensure X-DEBUGINFOD-SIZE contains file size

Ahelenia Ziemiańska (1):
  config: simplify profile.*sh.in

Alexander Kanavin (1):
  debuginfod/debuginfod-client.c: use long for cache time configurations

Di Chen (1):
  readelf: Don't consider padding DT_NULL as dynamic section entry

Frank Ch. Eigler (6):
  debuginfod: correct concurrency bug in fdcache metrics
  PR28661: debuginfo connection thread pool support
  man debuginfod-client-config.7: Elaborate $DEBUGINFOD_URLS
  PR28708: debuginfod: use MHD_USE_EPOLL for microhttpd threads
  debuginfod: use single ipv4+ipv6 microhttpd daemon configuration
  AUTHORS: Use generator script & git mailmap

Luca Boccassi (1):
  libebl: recognize FDO Packaging Metadata ELF note

Mark Wielaard (71):
  tests: Don't set DEBUGINFOD_TIMEOUT
  tests: Add -rdynamic to dwfl_proc_attach_LDFLAGS
  debuginfod: Use gmtime_r instead of gmtime to avoid data race
  debuginfod: sqlite3_sharedprefix_fn should not compare past end of string
  debuginfod: Fix some memory leaks on debuginfod-client error paths.
  debuginfod: Clear and reset debuginfod_client winning_headers on reuse
  libdwfl: Don't read beyond end of file in dwfl_segment_report_module
  debuginfod: Check result of calling MHD_add_response_header.
  readelf: Workaround stringop-truncation error
  tests: varlocs workaround format-overflow errors
  debuginfod: Fix debuginfod_pool leak
  configure: Add --enable-sanitize-address
  debuginfod: Don't format clog using 'right' or 'setw(20)'.
  libdwfl: Don't try to convert too many bytes in dwfl_link_map_report
  libdwfl: Make sure we know the phdr entry size before searching phdrs.
  libdwfl: Don't trust e_shentsize in dwfl_segment_report_module
  libdwfl: Don't install an Elf handle in a Dwfl_Module twice
  libdwfl: Don't try to convert too many dyns in dwfl_link_map_report
  libdwfl: Don't allocate more than SIZE_MAX in dwfl_segment_report_module.
  libelf: Use offsetof to get field of unaligned
  libdwfl: Make sure phent is sane and there is at least one phdr
  libdwfl: Add overflow check while iterating in dwfl_segment_report_module
  tests: Use /bin/sh instead of /bin/ls as always there binary
  libdwfl: Make sure there is at least one dynamic entry
  libdwfl: Make sure there is at least one phdr
  libdwfl: Make sure note data is properly aligned.
  libdwfl: Make dwfl_segment_report_module aware of maximum Elf size
  libdwfl: Make sure the note len increases each iteration
  libelf: Only set shdr state when there is at least one shdr
  libdwfl: Make sure that ph_buffer_size has room for at least one phdr
  libdwfl: Make sure dyn_filesz has a sane size
  libdwfl: Rewrite GElf_Nhdr reading in dwfl_segment_report_module
  libdwfl: Handle unaligned Ehdr in dwfl_segment_report_module
  libdwfl: Handle unaligned Phdr in dwfl_segment_report_module
  libdwfl: Handle unaligned Nhdr in dwfl_segment_report_module
  libdwfl: Always clean up build_id.memory
  libdwfl: Make sure dwfl_elf_phdr_memory_callback returns at least minread
  libdwfl: Call xlatetom on aligned buffers in dwfl_link_map_report
  libdwfl: Calculate addr to read by hand in link_map.c read_addrs.
  libdwfl: Fix overflow check in link_map.c read_addrs
  libdwfl: Handle unaligned Dyns in dwfl_segment_report_module
  libdwfl: Declare possible zero sized arrays only when non-zero
  backends: Use PTRACE_GETREGSET for ppc_set_initial_registers_tid
  configure: Test for _FORTIFY_SOURCE=3 support.
  addr2line: Make --absolute the default, add --relative option.
  configure: Use AS_HELP_STRING instead of AC_HELP_STRING.
  libelf: Take map offset into account for Shdr alignment check in elf_begin
  libelf: Make sure ar_size starts with a digit before calling atol.
  libelf: Check alignment of Verdef, Verdaux, V