This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: bfd_get_full_section_contents memory leak, plus
On Sat, Oct 20, 2012 at 5:21 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sat, Oct 20, 2012 at 3:17 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Sat, Oct 20, 2012 at 1:28 AM, Alan Modra <amodra@gmail.com> wrote:
>>> On Sat, Oct 20, 2012 at 10:42:21AM +1030, Alan Modra wrote:
>>>> This on top of Tom's patch ought to cure the failures. Testing
>>>> in progress.
>>>>
>>>> * compress.c: Reinstate 2012-10-19 change.
>>>> (bfd_get_full_section_contents): Don't free unless we alloc.
>>>> Use proper decompress size. Delete some vars, rename others.
>>>
>>> Testing successful. Committed.
>>>
>>
>> It breaks objdump. I checked in this tectase to show the
>> error.
>>
>> --
>> H.J.
>> ---
>> 2012-10-20 H.J. Lu <hongjiu.lu@intel.com>
>>
>> * binutils-all/compress.exp: Add an objdump test.
>> * binutils-all/dw2-1.W: New file.
>>
>
> This patch works for me:
>
>
> diff --git a/binutils/objdump.c b/binutils/objdump.c
> index 44e857a..b1a5be6 100644
> --- a/binutils/objdump.c
> +++ b/binutils/objdump.c
> @@ -2277,6 +2277,7 @@ load_specific_debug_section (enum
> dwarf_section_display_enum debug,
> the bfd_section, and tell it that the contents are
> already in memory. */
> sec->contents = section->start;
> + sec->compress_status = COMPRESS_SECTION_NONE;
> sec->flags |= SEC_IN_MEMORY;
> sec->size = section->size;
>
>
This one may be better,
--
H.J.
---
diff --git a/bfd/compress.c b/bfd/compress.c
index 294bfd3..2ffa6f0 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -166,6 +166,9 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr
sec, bfd_byte **ptr)
bfd_byte *compressed_buffer;
#endif
+ if (p != NULL && p == sec->contents)
+ return TRUE;
+
if (abfd->direction != write_direction && sec->rawsize != 0)
sz = sec->rawsize;
else
- References:
- Re: bfd_get_full_section_contents memory leak, plus
- Re: bfd_get_full_section_contents memory leak, plus
- Re: bfd_get_full_section_contents memory leak, plus
- Re: bfd_get_full_section_contents memory leak, plus
- Re: bfd_get_full_section_contents memory leak, plus
- Re: bfd_get_full_section_contents memory leak, plus
- Re: bfd_get_full_section_contents memory leak, plus
- Re: bfd_get_full_section_contents memory leak, plus
- Re: bfd_get_full_section_contents memory leak, plus
- Re: bfd_get_full_section_contents memory leak, plus
- Re: bfd_get_full_section_contents memory leak, plus
- Re: bfd_get_full_section_contents memory leak, plus
- Re: bfd_get_full_section_contents memory leak, plus