This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: support compressed sections in addr2line, objdump, readelf
- From: Andreas Schwab <schwab at suse dot de>
- To: csilvers at google dot com (Craig Silverstein)
- Cc: binutils at sourceware dot org
- Date: Thu, 10 Jul 2008 18:54:53 +0200
- Subject: Re: PATCH: support compressed sections in addr2line, objdump, readelf
- References: <20080622061003.D279F3F303A@localhost>
csilvers@google.com (Craig Silverstein) writes:
> +/* Read a section into its appropriate place in the dwarf2_debug
> + * struct (indicated by SECTION_BUFFER and SECTION_SIZE). If syms is
> + * not NULL, use bfd_simple_get_relocated_section_contents to read the
> + * section contents, otherwise use bfd_get_section_contents. */
> +
> +static bfd_boolean
> +read_section (bfd *abfd,
> + const char* section_name, const char* compressed_section_name,
> + asymbol** syms, bfd_uint64_t offset,
> + bfd_byte **section_buffer, unsigned long *section_size)
> +{
> + asection *msec;
> + int section_is_compressed = 0;
> +
> + /* read_section is a noop if the section has already been read. */
> + if (*section_buffer)
> + return TRUE;
> +
> + msec = bfd_get_section_by_name (abfd, section_name);
> + if (! msec && compressed_section_name)
> + {
> + msec = bfd_get_section_by_name (abfd, compressed_section_name);
> + section_is_compressed = 1;
> + }
> + if (! msec)
> + {
> + (*_bfd_error_handler) (_("Dwarf Error: Can't find %s section."), section_name);
> + bfd_set_error (bfd_error_bad_value);
> + return FALSE;
> + }
> +
> + if (syms)
> + {
> + *section_size = msec->size;
> + *section_buffer
> + = bfd_simple_get_relocated_section_contents (abfd, msec, NULL, syms);
> + if (! *section_buffer)
> + return FALSE;
> + }
> + else
> + {
> + *section_size = msec->rawsize ? msec->rawsize : msec->size;
> + *section_buffer = bfd_malloc (*section_size);
> + if (! *section_buffer)
> + return FALSE;
> + if (! bfd_get_section_contents (abfd, msec, *section_buffer,
> + 0, *section_size))
> + return FALSE;
> + }
> +
> + if (section_is_compressed)
> + {
> + if (! bfd_uncompress_section_contents (section_buffer, section_size))
/cvs/binutils/bfd/dwarf2.c: In function 'read_section':
/cvs/binutils/bfd/dwarf2.c:444: error: passing argument 2 of 'bfd_uncompress_section_contents' from incompatible pointer type
/cvs/binutils/bfd/dwarf2.c: In function 'find_line':
/cvs/binutils/bfd/dwarf2.c:2918: error: passing argument 7 of 'read_section' from incompatible pointer type
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."