*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;
+}
+
+/* See leb.h. */
+
+LONGEST
+read_offset (bfd *abfd, const gdb_byte *buf, unsigned int offset_size)
+{
+ LONGEST retval = 0;
+
+ switch (offset_size)
+ {
+ case 4:
+ retval = bfd_get_32 (abfd, buf);
+ break;
+ case 8:
+ retval = bfd_get_64 (abfd, buf);
+ break;
+ default:
+ internal_error (__FILE__, __LINE__,
+ _("read_offset_1: bad switch [in module %s]"),
+ bfd_get_filename (abfd));
+ }
+
+ return retval;
+}