[binutils-gdb] Rewrite leb.h:read_3_bytes

Tom Tromey tromey@sourceware.org
Wed Nov 4 15:22:12 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=93f9561e0fa112bab102dc2c22dd114c84c06a16

commit 93f9561e0fa112bab102dc2c22dd114c84c06a16
Author: Tom Tromey <tromey@adacore.com>
Date:   Wed Nov 4 08:21:36 2020 -0700

    Rewrite leb.h:read_3_bytes
    
    read_3_bytes assumes little-endian data, but in fact it depends on the
    BFD.  This patch rewrites this function to use bfd_get_24 instead.
    
    2020-11-04  Tom Tromey  <tromey@adacore.com>
    
            * dwarf2/leb.h (read_3_bytes): Use bfd_get_24.

Diff:
---
 gdb/ChangeLog    | 4 ++++
 gdb/dwarf2/leb.h | 9 +--------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 373e1527fc7..188bb1e8539 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2020-11-04  Tom Tromey  <tromey@adacore.com>
+
+	* dwarf2/leb.h (read_3_bytes): Use bfd_get_24.
+
 2020-11-02  Tom Tromey  <tromey@adacore.com>
 
 	* Makefile.in (ALL_64_TARGET_OBS): Add amd64-ravenscar-thread.o.
diff --git a/gdb/dwarf2/leb.h b/gdb/dwarf2/leb.h
index f312fc261ee..d76a1f933fc 100644
--- a/gdb/dwarf2/leb.h
+++ b/gdb/dwarf2/leb.h
@@ -57,14 +57,7 @@ read_2_signed_bytes (bfd *abfd, const gdb_byte *buf)
 static inline unsigned int
 read_3_bytes (bfd *abfd, const gdb_byte *buf)
 {
-  unsigned int result = 0;
-  for (int i = 0; i < 3; ++i)
-    {
-      unsigned char byte = bfd_get_8 (abfd, buf);
-      buf++;
-      result |= ((unsigned int) byte << (i * 8));
-    }
-  return result;
+  return bfd_get_24 (abfd, buf);
 }
 
 static inline unsigned int


More information about the Gdb-cvs mailing list