diff options
author | Tom Tromey <tom@tromey.com> | 2020-02-08 13:40:54 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-02-08 13:43:24 -0700 |
commit | 4075cb26687ec6bbd5bab31b6b33f692a3ed3108 (patch) | |
tree | 5c02edc5438cc17f80cd73c0bff7c626e2567307 /gdb/dwarf2/leb.c | |
parent | 09ba997f323198495bcf6884dd402fa5b9cc8978 (diff) | |
download | gdb-4075cb26687ec6bbd5bab31b6b33f692a3ed3108.zip gdb-4075cb26687ec6bbd5bab31b6b33f692a3ed3108.tar.gz gdb-4075cb26687ec6bbd5bab31b6b33f692a3ed3108.tar.bz2 |
Unify read_initial_length implementations
There are two implementations of read_initial_length in gdb. This
merges them and moves the resulting function to leb.c.
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (read_initial_length): Move to leb.c.
* dwarf2/leb.h (read_initial_length): Declare.
* dwarf2/leb.c (read_initial_length): Move from read.c. Add
handle_nonstd parameter.
* dwarf2/frame.c (read_initial_length): Remove.
(decode_frame_entry_1): Update.
Change-Id: I34d37bad0f8a584bfa781432cba25e05e1bd5750
Diffstat (limited to 'gdb/dwarf2/leb.c')
-rw-r--r-- | gdb/dwarf2/leb.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gdb/dwarf2/leb.c b/gdb/dwarf2/leb.c index d26b48b..ef7314e 100644 --- a/gdb/dwarf2/leb.c +++ b/gdb/dwarf2/leb.c @@ -83,3 +83,30 @@ read_signed_leb128 (bfd *abfd, const gdb_byte *buf, *bytes_read_ptr = num_read; return result; } + +/* See leb.h. */ + +LONGEST +read_initial_length (bfd *abfd, const gdb_byte *buf, unsigned int *bytes_read, + bool handle_nonstd) +{ + LONGEST length = bfd_get_32 (abfd, buf); + + if (length == 0xffffffff) + { + length = bfd_get_64 (abfd, buf + 4); + *bytes_read = 12; + } + else if (handle_nonstd && length == 0) + { + /* Handle the (non-standard) 64-bit DWARF2 format used by IRIX. */ + length = bfd_get_64 (abfd, buf); + *bytes_read = 8; + } + else + { + *bytes_read = 4; + } + + return length; +} |