Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/binutils/dist/binutils Fix readelf: Error: LEB...



details:   https://anonhg.NetBSD.org/src/rev/a733062c28d7
branches:  trunk
changeset: 366830:a733062c28d7
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jun 17 16:45:22 2022 +0000

description:
Fix readelf: Error: LEB value too large when running:
    readelf --debug-dump /usr/libdata/lib/libc.so.X.Y.debug
Apply patch from:
    https://www.mail-archive.com/bug-binutils%gnu.org@localhost/msg35315.html
affects objdump, readelf.

diffstat:

 external/gpl3/binutils/dist/binutils/dwarf.c |  32 ++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 9 deletions(-)

diffs (47 lines):

diff -r 23e36369fe08 -r a733062c28d7 external/gpl3/binutils/dist/binutils/dwarf.c
--- a/external/gpl3/binutils/dist/binutils/dwarf.c      Fri Jun 17 16:43:52 2022 +0000
+++ b/external/gpl3/binutils/dist/binutils/dwarf.c      Fri Jun 17 16:45:22 2022 +0000
@@ -343,20 +343,34 @@
   while (data < end)
     {
       unsigned char byte = *data++;
+      bfd_boolean cont = (byte & 0x80) ? TRUE : FALSE;
+
+      byte &= 0x7f;
       num_read++;
 
       if (shift < sizeof (result) * 8)
-       {
-         result |= ((dwarf_vma) (byte & 0x7f)) << shift;
-         if ((result >> shift) != (byte & 0x7f))
-           /* Overflow.  */
-           status |= 2;
+        {
+          result |= ((dwarf_vma) byte) << shift;
+          if (sign)
+            {
+              if ((((dwarf_signed_vma) result >> shift) & 0x7f) != byte)
+                /* Overflow.  */
+                status |= 2;
+            }
+          else if ((result >> shift) != byte)
+            {
+              /* Overflow.  */
+              status |= 2;
+            }
+
          shift += 7;
        }
-      else if ((byte & 0x7f) != 0)
-       status |= 2;
-
-      if ((byte & 0x80) == 0)
+      else if (byte != 0)
+        {
+          status |= 2;
+        }
+
+      if (!cont)
        {
          status &= ~1;
          if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40))



Home | Main Index | Thread Index | Old Index