[PATCH] readelf: Support showing view pairs in loclists as GNU extension.

2020-09-28 Thread Mark Wielaard
View pairs are encoded in .debug_loclists as they are encoded in
.debug_locs sections by the GCC compiler. Scan for DW_AT_GNU_locviews
attributes that point to the view pairs just in front of the actual
location lists.

Signed-off-by: Mark Wielaard 
---
 src/ChangeLog |  9 ++
 src/readelf.c | 78 +--
 2 files changed, 79 insertions(+), 8 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 0313d2a2..112b2242 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2020-09-28  Mark Wielaard  
+
+   * readelf.c (next_listptr_offset): Take idx as pointer, to be updated
+   and use new Dwarf_Off as offset to match.
+   (listptr_attr): New function.
+   (print_debug_loclists_section): Check for DW_AT_GNU_locviews to show
+   view pairs.
+   (print_debug_loc_section): Adjust next_listptr_offset call.
+
 2020-09-03  Mark Wielaard  
 
* readelf.c (print_cfa_program): Take ehdr as argument. Use it to
diff --git a/src/readelf.c b/src/readelf.c
index 64067a57..f6d13afa 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -4993,17 +4993,19 @@ skip_listptr_hole (struct listptr_table *table, size_t 
*idxp,
 }
 
 static Dwarf_Off
-next_listptr_offset (struct listptr_table *table, size_t idx)
+next_listptr_offset (struct listptr_table *table, size_t *idxp, Dwarf_Off off)
 {
   /* Note that multiple attributes could in theory point to the same loclist
  offset, so make sure we pick one that is bigger than the current one.
  The table is sorted on offset.  */
-  Dwarf_Off offset = table->table[idx].offset;
-  while (++idx < table->n)
+  if (*idxp < table->n)
 {
-  Dwarf_Off next = table->table[idx].offset;
-  if (next > offset)
-   return next;
+  while (++*idxp < table->n)
+   {
+ Dwarf_Off next = table->table[*idxp].offset;
+ if (next > off)
+   return next;
+   }
 }
   return 0;
 }
@@ -5036,13 +5038,36 @@ listptr_cu (struct listptr_table *table, size_t *idxp,
   struct listptr *p = &table->table[*idxp];
   *base = listptr_base (p);
   *cu = p->cu;
-  ++*idxp;
   return true;
 }
 
   return false;
 }
 
+/* Returns the next index with the current CU for the given attribute.
+   If there is none false is returned, otherwise true.  Assumes the
+   table has been sorted.  */
+static bool
+listptr_attr (struct listptr_table *table, size_t idxp,
+ Dwarf_Off offset, unsigned int attr)
+{
+  struct listptr *listptr;
+  do
+{
+  listptr = get_listptr (table, idxp);
+  if (listptr == NULL)
+   return false;
+
+  if (listptr->offset == offset && listptr->attr == attr)
+   return true;
+
+  idxp++;
+}
+  while (listptr->offset <= offset);
+
+  return false;
+}
+
 static void
 print_debug_abbrev_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
Ebl *ebl, GElf_Ehdr *ehdr __attribute__ ((unused)),
@@ -9171,6 +9196,43 @@ print_debug_loclists_section (Dwfl_Module *dwflmod,
   bool start_of_list = true;
   while (readp < nexthdr)
{
+ Dwarf_Off off = (Dwarf_Off) (readp - (unsigned char *) data->d_buf);
+ if (listptr_attr (&known_loclistsptr, listptr_idx, off,
+   DW_AT_GNU_locviews))
+   {
+ Dwarf_Off next_off = next_listptr_offset (&known_loclistsptr,
+   &listptr_idx, off);
+ const unsigned char *locp = readp;
+ const unsigned char *locendp;
+ if (next_off == 0
+ || next_off > (size_t) (nexthdr - ((const unsigned char *)
+data->d_buf)))
+   locendp = nexthdr;
+ else
+   locendp = (const unsigned char *) data->d_buf + next_off;
+
+ printf ("  Offset: %" PRIx64 ", Index: %" PRIx64 "\n",
+ (uint64_t) (readp - (unsigned char *) data->d_buf),
+ (uint64_t) (readp - offset_array_start));
+
+ while (locp < locendp)
+   {
+ uint64_t v1, v2;
+ get_uleb128 (v1, locp, locendp);
+ if (locp >= locendp)
+   {
+ printf (gettext ("\n"));
+ break;
+   }
+ get_uleb128 (v2, locp, locendp);
+ printf ("view pair %" PRId64 ", %" PRId64 "\n", v1, v2);
+   }
+
+ printf ("\n");
+ readp = (unsigned char *) locendp;
+ continue;
+   }
+
  uint8_t kind = *readp++;
  uint64_t op1, op2, len;
 
@@ -9502,7 +9564,7 @@ print_debug_loc_section (Dwfl_Module *dwflmod,
   if (attr == DW_AT_GNU_locviews)
{
  Dwarf_Off next_off = next_listptr_offset (&known_locsptr,
-   listptr_idx);
+

[Bug tools/23787] eu-size: Bad handling of ar files inside are files

2020-09-28 Thread shahidanwar8359 at gmail dot com via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=23787

shahid anwar  changed:

   What|Removed |Added

 CC||shahidanwar8359 at gmail dot 
com

--- Comment #35 from shahid anwar  ---
thank you for posting this it is really nice i hope that will see more in
future. https://www.mierepair.ae/services/home-appliances-repair-dubai.html

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

[Bug tools/23787] eu-size: Bad handling of ar files inside are files

2020-09-28 Thread shahidanwar8359 at gmail dot com via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=23787

--- Comment #36 from shahid anwar  ---
i found your website over the web, actually my friend suggest about this so i
am here. https://www.a2zappliancerepairs.ae/refrigerator-repair.php

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

[Bug tools/23787] eu-size: Bad handling of ar files inside are files

2020-09-28 Thread zarakhan8359 at gmail dot com via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=23787

zara khan  changed:

   What|Removed |Added

 CC||zarakhan8359 at gmail dot com

--- Comment #37 from zara khan  ---
i'm very happy that i'm here at your website you maintain your website really
nicely, no bugs no errors everything is good.
https://tvrepairdubai.com/philips-tv-repair-dubai/

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