aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/leb.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-02-08 13:40:54 -0700
committerTom Tromey <tom@tromey.com>2020-02-08 13:43:24 -0700
commit4075cb26687ec6bbd5bab31b6b33f692a3ed3108 (patch)
tree5c02edc5438cc17f80cd73c0bff7c626e2567307 /gdb/dwarf2/leb.h
parent09ba997f323198495bcf6884dd402fa5b9cc8978 (diff)
downloadfsf-binutils-gdb-4075cb26687ec6bbd5bab31b6b33f692a3ed3108.zip
fsf-binutils-gdb-4075cb26687ec6bbd5bab31b6b33f692a3ed3108.tar.gz
fsf-binutils-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.h')
-rw-r--r--gdb/dwarf2/leb.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/gdb/dwarf2/leb.h b/gdb/dwarf2/leb.h
index b17ab88..29fdffe 100644
--- a/gdb/dwarf2/leb.h
+++ b/gdb/dwarf2/leb.h
@@ -89,4 +89,45 @@ extern LONGEST read_signed_leb128 (bfd *, const gdb_byte *, unsigned int *);
extern ULONGEST read_unsigned_leb128 (bfd *, const gdb_byte *, unsigned int *);
+/* Read the initial length from a section. The (draft) DWARF 3
+ specification allows the initial length to take up either 4 bytes
+ or 12 bytes. If the first 4 bytes are 0xffffffff, then the next 8
+ bytes describe the length and all offsets will be 8 bytes in length
+ instead of 4.
+
+ An older, non-standard 64-bit format is also handled by this
+ function. The older format in question stores the initial length
+ as an 8-byte quantity without an escape value. Lengths greater
+ than 2^32 aren't very common which means that the initial 4 bytes
+ is almost always zero. Since a length value of zero doesn't make
+ sense for the 32-bit format, this initial zero can be considered to
+ be an escape value which indicates the presence of the older 64-bit
+ format. As written, the code can't detect (old format) lengths
+ greater than 4GB. If it becomes necessary to handle lengths
+ somewhat larger than 4GB, we could allow other small values (such
+ as the non-sensical values of 1, 2, and 3) to also be used as
+ escape values indicating the presence of the old format.
+
+ The value returned via bytes_read should be used to increment the
+ relevant pointer after calling read_initial_length().
+
+ [ Note: read_initial_length() and read_offset() are based on the
+ document entitled "DWARF Debugging Information Format", revision
+ 3, draft 8, dated November 19, 2001. This document was obtained
+ from:
+
+ http://reality.sgiweb.org/davea/dwarf3-draft8-011125.pdf
+
+ This document is only a draft and is subject to change. (So beware.)
+
+ Details regarding the older, non-standard 64-bit format were
+ determined empirically by examining 64-bit ELF files produced by
+ the SGI toolchain on an IRIX 6.5 machine.
+
+ - Kevin, July 16, 2002
+ ] */
+extern LONGEST read_initial_length (bfd *abfd, const gdb_byte *buf,
+ unsigned int *bytes_read,
+ bool handle_nonstd = true);
+
#endif /* GDB_DWARF2_LEB_H */