This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [lto] PATCH: map/unmap LTO sections, + bug fixes


Sandra Loosemore wrote:
Here's the patch to implement the map/unmap functions for the LTO information. I've also attempted to fix some bugs in the DIE readers for parameters and subroutines, so that it can read a file containing the identity function without croaking.

Looks good. Thanks for fixing my dumbnesses!


! const void *
! lto_elf_map_fn_body (lto_file *file,
! const char *fn)
{
! /* Look in the ELF file to find the actual data, which should be
in the section named LTO_SECTION_NAME_PREFIX || "the function name". */
! const char *name = concat (LTO_SECTION_NAME_PREFIX, fn, NULL);
! Elf_Data *data = lto_elf_find_section_data ((lto_elf_file *)file, name);
! ! if (! data)
! return NULL;
! else
! return (const void *)(data->d_buf);
}

I think you have a memory leak here: "name" will be allocated with malloc, but you never free it. I think you should call free before returning, independent of the value returned by lto_elf_find_section_data.


Thanks,

--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]