[PATCH] ld: Add module information substream to PDB files

Mark Harmstone mark@harmstone.com
Thu Nov 3 02:45:05 GMT 2022


On 2/11/22 14:12, Nick Clifton wrote:
> Hi Mark,
>
>> +  *data = xmalloc (*size);
>> +
>> +  ptr = *data;
>> +
>> +  for (bfd *in = coff_data (abfd)->link_info->input_bfds; in;
>> +       in = in->link.next)
>> +    {
>> +      struct module_info *mod = (struct module_info *) ptr;
>> +      uint16_t stream_num;
>> +      bfd *stream;
>> +      uint32_t sym_byte_size;
>> +      uint8_t *start = ptr;
>> +
>> +      stream = add_stream (pdb, NULL, &stream_num);
>> +
>> +      if (!stream)
>> +    {
>> +      free (data);
>> +      return false;
>> +    }
>
> This fails to compile with:
>
>    inlined from 'create_pdb_file' at /work/sources/binutils/upstream/current/ld/pdb.c:1097:8:
> /work/sources/binutils/upstream/current/ld/pdb.c:481:11: error: 'free' called on unallocated object 'mod_info' [-Werror=free-nonheap-object]
>   481 |           free (data);
>       |           ^~~~~~~~~~~
> /work/sources/binutils/upstream/current/ld/pdb.c: In function 'create_pdb_file':
> /work/sources/binutils/upstream/current/ld/pdb.c:604:9: note: declared here
>   604 |   void *mod_info;
>
> Possibly you meant "free (*data)" ?
>
> Cheers
>   Nick
>
Thanks Nick, you're right. I couldn't get the warning to trigger with GCC 12.2.1 though, I'm not sure why...

Mark



More information about the Binutils mailing list