[Bug ld/12161] Unconforming ELF file causes SIGSEGV in avr-ld

2012-01-04 Thread pitchumani.s at atmel dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12161

Pitchumani  changed:

   What|Removed |Added

 CC||pitchumani.s at atmel dot
   ||com

--- Comment #8 from Pitchumani  2012-01-04 
12:49:51 UTC ---
(In reply to comment #7)
> Hi Guys,
> 
>   I have decided to go ahead and check this patch in.  Please reopen this PR 
> if
> the problem resurfaces.
> 
> Cheers
>   Nick

Hi Nick,

Function 'elf32_avr_check_relocs(elf32-avr.c)' is referred in elflink.c:4801

(-- snip from elflink.c --)
 4799   if (! dynamic
 4800   && is_elf_hash_table (htab)
 4801   && bed->check_relocs != NULL
 4802   && elf_object_id (abfd) == elf_hash_table_id (htab)
 4803   && (*bed->relocs_compatible) (abfd->xvec, info->output_bfd->xvec))
(-- snip end --)

As 'bed->check_relocs' is NULL in 2.22, code that follows this check not
executed.
This caused a segmentation fault (NULL pointer access) in elf32-avr.c:1528.

Test case:
-- c source --
void func2(int a) { }

void func1(void)
{
  func2(10);
}

int main(void)
{
  func1();
}
-- c source --

command line options:
avr-gcc segfault.c -ffunction-sections -mmcu=atmega128 -c -o segfault.o
avr-ld segfault.o -m avr51 -relax

Please correct if I am missing something.

Thanks,
Pitchumani

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/12161] Unconforming ELF file causes SIGSEGV in avr-ld

2012-01-04 Thread pitchumani.s at atmel dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12161

--- Comment #11 from Pitchumani  2012-01-05 
07:21:02 UTC ---
(In reply to comment #10)
> Hi Pitchumani,
> 
>   Please try out the uploaded patch ("Load relocs if necessary") and let me
> know if you have any problems with it.
> 
> Cheers
>   Nick

This change solves the issue.

Thanks
Pitchumani

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils