This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

Error while using Linker Relaxation


Hi,
    I am facing an issue while using linker relaxation feature in
binutils-2.22.
The testcase works fine with binutils-2.20.1.
 
As a newbie I don't know much what is going wrong but I dig up the issue
and 
found buffer allocated in bfd_get_full_section_contents function in
bfd/compress.c
is overflowed and hence the error is generated (because some other value
is being overwritten).


I see the following difference in the length of the buffer allocated
across the two versions
of binutils.

This is a code snippet in binutils-2.20.1/bfd/section.c

bfd_boolean
bfd_malloc_and_get_section (bfd *abfd, sec_ptr sec, bfd_byte **buf)
{
  ....

  p = (bfd_byte *)

      <<<<<the buffer length here is greater of size and rawsize >>>>
      
       bfd_malloc (sec->rawsize > sec->size ? sec->rawsize : sec->size);


  if (p == NULL)
    return FALSE;
  *buf = p;

  return bfd_get_section_contents (abfd, sec, p, 0, sz);
}


And this is in binutils-2.22/bfd/compress.c

bfd_boolean
bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
{
 ...

if (abfd->direction != write_direction && sec->rawsize != 0)
    sz = sec->rawsize;
  else 
    sz = sec->size;
   ...
  switch (sec->compress_status)
    {
    case COMPRESS_SECTION_NONE:
      if (p == NULL)
        {

       
          <<<<the buffer length here is rawsize(if its not zero), size
otherwise>>>>

          p = (bfd_byte *) bfd_malloc (sz);

          if (p == NULL)
            return FALSE;
        }
   ....
}

I am using avr32 target. Is this change in the buffer length correct?
 
Thanks in advance
Praveen Kaushik



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