[Bug general/29571] Add 'Key to Flags' to eu-readelf output

2025-03-17 Thread samuelzeter at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29571

--- Comment #6 from Sam Zeter  ---
I also noticed in libelf/elf.h that we define these flags but do not print them
in readelf:

#define SHF_MASKOS   0x0ff0 /* OS-specific.  */
#define SHF_MASKPROC 0xf000 /* Processor-specific */

is this intentional?

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

[Bug general/29571] Add 'Key to Flags' to eu-readelf output

2025-03-17 Thread samuelzeter at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29571

Sam Zeter  changed:

   What|Removed |Added

 CC||samuelzeter at gmail dot com

--- Comment #5 from Sam Zeter  ---
I've fixed the outstanding issues, and posted the patch for review here:

https://sourceware.org/pipermail/elfutils-devel/2025q1/007984.html

Along with the other comments posted here, I removed x (unknown), o (OS
specific), l (large), p (processor specific) as I could not see mention of them
in elfutils readelf.

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

[PATCH] Add 'Key to Flags' to eu-readelf output [bz 29571]

2025-03-17 Thread Samuel Zeter
When printing section headers, also include a key to what each flag
is at the end of the section header output.

Signed-off-by: Samuel Zeter 
---
 src/readelf.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/src/readelf.c b/src/readelf.c
index 12d85472..f9c1c742 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -341,6 +341,7 @@ static void print_strings (Ebl *ebl);
 static void dump_archive_index (Elf *, const char *);
 static void print_dwarf_addr (Dwfl_Module *dwflmod, int address_size,
  Dwarf_Addr address, Dwarf_Addr raw);
+static void print_flag_info(void);
 
 enum dyn_idx
 {
@@ -1406,9 +1407,19 @@ There are %zd section headers, starting at offset %#" 
PRIx64 ":\n\
}
 }
 
+  print_flag_info();
   fputc ('\n', stdout);
 }
 
+/* Print flag information.  */
+static void
+print_flag_info (void)
+{
+   puts ("Key to Flags:");
+   puts ("  W (write), A (alloc), X (execute), M (merge), S (strings), I 
(info),");
+   puts ("  L (link order), N (extra OS processing required), G (group), T 
(TLS),");
+   puts ("  C (compressed), O (ordered), R (GNU retain), E (exclude)");
+}
 
 /* Print the program header.  */
 static void
-- 
2.48.1



[PATCH 3/9 v4] libdwP.h: Add locking to str_offsets_base_off

2025-03-17 Thread Aaron Merey
* libdw/dwarf_end.c (cu_free): Free str_off_base_lock.
* libdw/libdwP.h (struct Dwarf_CU): Add str_off_base_lock member.
(str_offsets_base_off): Add locking.
* libdw/libdw_findcu.c (__libdw_intern_next_unit): Initialize
str_off_base_lock.

Signed-off-by: Aaron Merey 
---
v3: 
https://patchwork.sourceware.org/project/elfutils/patch/20250220043644.2058519-3-ame...@redhat.com/

v4: simplify unlocking in str_offsets_base_off.

 libdw/dwarf_end.c|  1 +
 libdw/libdwP.h   | 17 +++--
 libdw/libdw_findcu.c |  1 +
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/libdw/dwarf_end.c b/libdw/dwarf_end.c
index c12815e1..1628e448 100644
--- a/libdw/dwarf_end.c
+++ b/libdw/dwarf_end.c
@@ -71,6 +71,7 @@ cu_free (void *arg)
   rwlock_fini (p->abbrev_lock);
   rwlock_fini (p->split_lock);
   mutex_fini (p->src_lock);
+  mutex_fini (p->str_off_base_lock);
 
   /* Free split dwarf one way (from skeleton to split).  */
   if (p->unit_type == DW_UT_skeleton
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 974d6a50..383a26b4 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -467,6 +467,10 @@ struct Dwarf_CU
  Covers dwarf_getsrclines and dwarf_getsrcfiles.  */
   mutex_define(, src_lock);
 
+  /* Synchronize access to the str_off_base of this Dwarf_CU.
+ Covers __libdw_str_offsets_base_off.  */
+  mutex_define(, str_off_base_lock);
+
   /* Memory boundaries of this CU.  */
   void *startp;
   void *endp;
@@ -1208,6 +1212,7 @@ str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
   Dwarf_Off off = 0;
   if (cu != NULL)
 {
+  mutex_lock (cu->str_off_base_lock);
   if (cu->str_off_base == (Dwarf_Off) -1)
{
  Dwarf_Off dwp_offset;
@@ -1222,6 +1227,7 @@ str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
  if (dwarf_formudata (&attr, &base) == 0)
{
  cu->str_off_base = off + base;
+ mutex_unlock (cu->str_off_base_lock);
  return cu->str_off_base;
}
}
@@ -1229,6 +1235,7 @@ str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
  if (cu->version < 5)
{
  cu->str_off_base = off;
+ mutex_unlock (cu->str_off_base_lock);
  return cu->str_off_base;
}
 
@@ -1236,7 +1243,10 @@ str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
dbg = cu->dbg;
}
   else
-   return cu->str_off_base;
+   {
+ mutex_unlock (cu->str_off_base_lock);
+ return cu->str_off_base;
+   }
 }
 
   /* No str_offsets_base attribute, we have to assume "zero".
@@ -1286,7 +1296,10 @@ str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
 
  no_header:
   if (cu != NULL)
-cu->str_off_base = off;
+{
+  cu->str_off_base = off;
+  mutex_unlock (cu->str_off_base_lock);
+}
 
   return off;
 }
diff --git a/libdw/libdw_findcu.c b/libdw/libdw_findcu.c
index f0243643..8805af9b 100644
--- a/libdw/libdw_findcu.c
+++ b/libdw/libdw_findcu.c
@@ -180,6 +180,7 @@ __libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
   rwlock_init (newp->abbrev_lock);
   rwlock_init (newp->split_lock);
   mutex_init (newp->src_lock);
+  mutex_init (newp->str_off_base_lock);
 
   /* v4 debug type units have version == 4 and unit_type == DW_UT_type.  */
   if (debug_types)
-- 
2.48.1



Re: [PATCH 01/13] libebl [1/13]: api for perf register handling, start with x86_64

2025-03-17 Thread Serhei Makarov



On Sun, Mar 16, 2025, at 7:12 PM, Serhei Makarov wrote:
> +bool
> +x86_64_set_initial_registers_sample (const Dwarf_Word *regs, uint32_t 
> n_regs,
> +  uint64_t regs_mask, uint32_t abi,
> +  ebl_tid_registers_t *setfunc,
> +  void *arg)
> +{
> +#if !defined(__x86_64__) || !defined(__linux__)
> +  return false;
> +#else /* __x86_64__ */
Found that coding like this triggers -Werror=unused-parameter on non-x86. I 
plan to fix this in the next version of the patch.

-- 
All the best,
Serhei
http://serhei.io


Re: [PATCH] Take latest of archive and file mtime

2025-03-17 Thread Lluís Batlle i Rossell
On Thu, Mar 13, 2025 at 01:43:25PM -0400, Frank Ch. Eigler wrote:
> Hi -
> 
> > [...]
> > Every time you rebuild some packages, the package files are rebuilt with the
> > new contents. When this happens, the new package files will have a newer
> > mtime, but the files inside the archive (elf, source) will have the same
> > fixed timestamp as before. 
> 
> Do I understand this part correctly: that yocto package-file
> filestamps are normal (reflect their actual unique-ish creation time),
> but the timestamps of constituent files are synthetic (and may be
> backdated / duplicate)?

Exactly. Correct. The "rpm" file has a good mtime timestamp of it
creation, but the mtimes of the files inside are fake.

> > And when debuginfod will traverse them (without the patch I
> > propose), it will not update the database because it will find
> > consider that the files inside the packages were not modified. [...]
> 
> That's not how debuginfod works though.  It decides to reanalyze
> archives based on the archive mtime, not the constituent file mtime.
> Your patch only affects the "_r_seekable.mtime" column, which I
> believe is not used for any sort of caching/invalidation type logic.

Uhm I agree now that I review.
I see the _r_seekable_mtime though is sent through HTTP as Last-Modified.
Maybe it is the client that is confused? I had the impression the patch
fixed all my problems for me.
I will have to review this again in detail. I simply wanted to avoid
trusting the file-in-archive timestamp for anything, in my patch.

> Maybe we could make this discussion more concrete by having you show
> us an actual example.  Two different yocto package versions, with
> detailed timestamp/content listings, ingested into an otherwise empty
> debuginfod database one at a time, and doing a database dump after
> both completed scan operations.

Here is an example:
$ ls -l less-600-r0.cortexa78ae.rpm
-rw-r--r-- 1 lbatlle 1000 121980 Mar 14 02:04 less-600-r0.cortexa78ae.rpm
$ rpm2cpio less-600-r0.cortexa78ae.rpm |cpio -v -t
drwxr-xr-x   1 root root0 Jan  7  2022 ./usr
drwxr-xr-x   1 root root0 Jan  7  2022 ./usr/bin
-rwxr-xr-x   1 root root   223592 Jan  7  2022 ./usr/bin/less.less
-rwxr-xr-x   1 root root10232 Jan  7  2022 ./usr/bin/lessecho
-rwxr-xr-x   1 root root19840 Jan  7  2022 ./usr/bin/lesskey
497 blocks

If I modify the recipe and build again, I get the same timestamps inside.
For example, I removed one of the patches to 'less' and rebuilt it.

$ ls -l less-600-r0.cortexa78ae.rpm
-rw-r--r-- 1 lbatlle 1000 121837 Mar 17 17:24 less-600-r0.cortexa78ae.rpm
$ rpm2cpio less-600-r0.cortexa78ae.rpm |cpio -v -t
drwxr-xr-x   1 root root0 Jan  7  2022 ./usr
drwxr-xr-x   1 root root0 Jan  7  2022 ./usr/bin
-rwxr-xr-x   1 root root   223592 Jan  7  2022 ./usr/bin/less.less
-rwxr-xr-x   1 root root10232 Jan  7  2022 ./usr/bin/lessecho
-rwxr-xr-x   1 root root19840 Jan  7  2022 ./usr/bin/lesskey
497 blocks

Regards,
Lluís.