* dwarf2.c (dwarf2_debug): Move info_ptr_unit to ...
(comp_unit): Here.
(read_unsigned_leb128): Removed.
(read_signed_leb128): Removed.
(find_abstract_instance_name): Updated.
(parse_comp_unit): Accept info_ptr_unit.
(_bfd_dwarf2_find_nearest_line): Set info_ptr_unit for each
comp unit and pass it to parse_comp_unit.
* elf-eh-frame.c (read_unsigned_leb128): Moved to ...
(read_signed_leb128): Moved to ...
* libbfd.c: Here.
* libbfd-in.h (read_unsigned_leb128): New prototype.
(read_signed_leb128): Likewise.
* libbfd.h: Regenerated.
+2005-01-17 H.J. Lu <hongjiu.lu@intel.com>
+
+ * dwarf2.c (dwarf2_debug): Move info_ptr_unit to ...
+ (comp_unit): Here.
+ (read_unsigned_leb128): Removed.
+ (read_signed_leb128): Removed.
+ (find_abstract_instance_name): Updated.
+ (parse_comp_unit): Accept info_ptr_unit.
+ (_bfd_dwarf2_find_nearest_line): Set info_ptr_unit for each
+ comp unit and pass it to parse_comp_unit.
+
+ * elf-eh-frame.c (read_unsigned_leb128): Moved to ...
+ (read_signed_leb128): Moved to ...
+ * libbfd.c: Here.
+
+ * libbfd-in.h (read_unsigned_leb128): New prototype.
+ (read_signed_leb128): Likewise.
+ * libbfd.h: Regenerated.
+
2005-01-17 Andrew Stubbs <andrew.stubbs@st.com>
Nick Clifton <nickc@redhat.com>
into a buffer yet. */
char* info_ptr;
- /* Preserve the original value of info_ptr for the current
- comp_unit so we can find a given entry by its reference. */
- char* info_ptr_unit;
-
/* Pointer to the end of the .debug_info section memory buffer. */
char* info_ptr_end;
/* TRUE if there is a line number table associated with this comp. unit. */
int stmtlist;
+ /* Pointer to the current comp_unit so that we can find a given entry
+ by its reference. */
+ char *info_ptr_unit;
+
/* The offset into .debug_line of the line number table. */
unsigned long line_offset;
return buf;
}
-static unsigned int
-read_unsigned_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
- char *buf,
- unsigned int *bytes_read_ptr)
-{
- unsigned int result;
- unsigned int num_read;
- int shift;
- unsigned char byte;
-
- result = 0;
- shift = 0;
- num_read = 0;
-
- do
- {
- byte = bfd_get_8 (abfd, buf);
- buf ++;
- num_read ++;
- result |= ((byte & 0x7f) << shift);
- shift += 7;
- }
- while (byte & 0x80);
-
- * bytes_read_ptr = num_read;
-
- return result;
-}
-
-static int
-read_signed_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
- char *buf,
- unsigned int * bytes_read_ptr)
-{
- int result;
- int shift;
- int num_read;
- unsigned char byte;
-
- result = 0;
- shift = 0;
- num_read = 0;
-
- do
- {
- byte = bfd_get_8 (abfd, buf);
- buf ++;
- num_read ++;
- result |= ((byte & 0x7f) << shift);
- shift += 7;
- }
- while (byte & 0x80);
-
- if ((shift < 32) && (byte & 0x40))
- result |= -(1 << shift);
-
- * bytes_read_ptr = num_read;
-
- return result;
-}
-
/* END VERBATIM */
static bfd_uint64_t
struct attribute attr;
char *name = 0;
- info_ptr = unit->stash->info_ptr_unit + die_ref;
+ info_ptr = unit->info_ptr_unit + die_ref;
abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
info_ptr += bytes_read;
parse_comp_unit (bfd *abfd,
struct dwarf2_debug *stash,
bfd_vma unit_length,
+ char *info_ptr_unit,
unsigned int offset_size)
{
struct comp_unit* unit;
unit->abbrevs = abbrevs;
unit->end_ptr = end_ptr;
unit->stash = stash;
+ unit->info_ptr_unit = info_ptr_unit;
for (i = 0; i < abbrev->num_attrs; ++i)
{
if (stash->info_ptr == NULL)
return FALSE;
- stash->info_ptr_unit = stash->info_ptr;
stash->info_ptr_end = stash->info_ptr;
for (msec = find_debug_info (abfd, NULL);
bfd_vma length;
bfd_boolean found;
unsigned int offset_size = addr_size;
+ char *info_ptr_unit = stash->info_ptr;
length = read_4_bytes (abfd, stash->info_ptr);
/* A 0xffffff length is the DWARF3 way of indicating we use
if (length > 0)
{
- each = parse_comp_unit (abfd, stash, length, offset_size);
+ each = parse_comp_unit (abfd, stash, length, info_ptr_unit,
+ offset_size);
stash->info_ptr += length;
if ((bfd_vma) (stash->info_ptr - stash->sec_info_ptr)
#define EH_FRAME_HDR_SIZE 8
-/* Helper function for reading uleb128 encoded data. */
-
-static bfd_vma
-read_unsigned_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
- char *buf,
- unsigned int *bytes_read_ptr)
-{
- bfd_vma result;
- unsigned int num_read;
- int shift;
- unsigned char byte;
-
- result = 0;
- shift = 0;
- num_read = 0;
- do
- {
- byte = bfd_get_8 (abfd, (bfd_byte *) buf);
- buf++;
- num_read++;
- result |= (((bfd_vma) byte & 0x7f) << shift);
- shift += 7;
- }
- while (byte & 0x80);
- *bytes_read_ptr = num_read;
- return result;
-}
-
-/* Helper function for reading sleb128 encoded data. */
-
-static bfd_signed_vma
-read_signed_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
- char *buf,
- unsigned int * bytes_read_ptr)
-{
- bfd_vma result;
- int shift;
- int num_read;
- unsigned char byte;
-
- result = 0;
- shift = 0;
- num_read = 0;
- do
- {
- byte = bfd_get_8 (abfd, (bfd_byte *) buf);
- buf ++;
- num_read ++;
- result |= (((bfd_vma) byte & 0x7f) << shift);
- shift += 7;
- }
- while (byte & 0x80);
- if (byte & 0x40)
- result |= (((bfd_vma) -1) << (shift - 7)) << 7;
- *bytes_read_ptr = num_read;
- return result;
-}
-
#define read_uleb128(VAR, BUF) \
do \
{ \
(bfd_boolean (*) (struct bfd_section_already_linked_hash_entry *,
void *), void *);
+extern bfd_vma read_unsigned_leb128 (bfd *, char *, unsigned int *);
+extern bfd_signed_vma read_signed_leb128 (bfd *, char *, unsigned int *);
+
mask |= ~(size_t) func;
}
}
+
+/* Helper function for reading uleb128 encoded data. */
+
+bfd_vma
+read_unsigned_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
+ char *buf,
+ unsigned int *bytes_read_ptr)
+{
+ bfd_vma result;
+ unsigned int num_read;
+ int shift;
+ unsigned char byte;
+
+ result = 0;
+ shift = 0;
+ num_read = 0;
+ do
+ {
+ byte = bfd_get_8 (abfd, (bfd_byte *) buf);
+ buf++;
+ num_read++;
+ result |= (((bfd_vma) byte & 0x7f) << shift);
+ shift += 7;
+ }
+ while (byte & 0x80);
+ *bytes_read_ptr = num_read;
+ return result;
+}
+
+/* Helper function for reading sleb128 encoded data. */
+
+bfd_signed_vma
+read_signed_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
+ char *buf,
+ unsigned int * bytes_read_ptr)
+{
+ bfd_vma result;
+ int shift;
+ int num_read;
+ unsigned char byte;
+
+ result = 0;
+ shift = 0;
+ num_read = 0;
+ do
+ {
+ byte = bfd_get_8 (abfd, (bfd_byte *) buf);
+ buf ++;
+ num_read ++;
+ result |= (((bfd_vma) byte & 0x7f) << shift);
+ shift += 7;
+ }
+ while (byte & 0x80);
+ if ((shift < 8 * sizeof (result)) && (byte & 0x40))
+ result |= (((bfd_vma) -1) << shift);
+ *bytes_read_ptr = num_read;
+ return result;
+}
(bfd_boolean (*) (struct bfd_section_already_linked_hash_entry *,
void *), void *);
+extern bfd_vma read_unsigned_leb128 (bfd *, char *, unsigned int *);
+extern bfd_signed_vma read_signed_leb128 (bfd *, char *, unsigned int *);
+
/* Extracted from init.c. */
/* Extracted from libbfd.c. */
bfd_boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);