Created attachment 5085 [details] ELF file which causes avr-ld to crash The attached ELF file causes avr-ld to crash: $ avr-ld govrout.o Segmentation fault The ELF file is not a valid ELF file, the .e_info field of the .symtab section header has the value 1, though the last local symbol is at index 1 and thus the .e_info should be 2. I think ld should at least print an error message instead of crashing. I am running avr-ld on Linux, see below: $ avr-ld --version GNU ld (GNU Binutils) 2.18.0.20080103 (WinAVR 20080610) (that is the Debian 5.0 package) $ uname -a Linux thecomputer 2.6.26-2-amd64 #1 SMP Thu Sep 16 15:56:38 UTC 2010 x86_64 GNU/Linux
Created attachment 5090 [details] Delete elf32_avr_check_relocs function
Hi, Please could you try out the uploaded patch ? It seems that the bug is in the elf32_avr_check_relocs() function, but since this function does not actually do anything there is no reason to actually keep it in the sources. Cheers Nick
Hi, > Please could you try out the uploaded patch ? I applied it to the 2.18 sources, the problem still persists. I had trouble getting the Debian sources, but I can get that another shot.
Created attachment 5102 [details] Add extra check for bad reloc.
Hi, > I applied it to the 2.18 sources, the problem still persists. My bad - I was using the current mainline binutils sources. The old 2.18 sources have two places that need to be fixed, so please try out the newly uploaded "extra" patch. (Despite its name, this patch should be applied instead of the delete elf32_avr_check_relocs patch). Cheers Nick
(In reply to comment #0) > Created attachment 5085 [details] > ELF file which causes avr-ld to crash > > The attached ELF file causes avr-ld to crash: > > $ avr-ld govrout.o > Segmentation fault Typically, avr-ld is not called directly, but through the driver (avr-gcc). Plus you must also specify the device on the linker command line: -mmcu=<device>. Do you still get a crash when you do this? Eric Weddington Atmel
Hi Guys, I have decided to go ahead and check this patch in. Please reopen this PR if the problem resurfaces. Cheers Nick
(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
Created attachment 6145 [details] Load relocs if necessary
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
(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
CVSROOT: /cvs/src Module name: src Changes by: nickc@sourceware.org 2012-01-05 09:57:18 Modified files: bfd : ChangeLog elf32-avr.c Log message: PR ld/12161 * elf32-avr.c (elf32_avr_relax_delete_bytes): Read in relocs if necessary. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5572&r2=1.5573 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-avr.c.diff?cvsroot=src&r1=1.51&r2=1.52
Patch committed,
*** Bug 13612 has been marked as a duplicate of this bug. ***
(In reply to comment #13) > Patch committed, Hi Nick, I don't quite get it from the ChangeLogs... Is this only a fix for HEAD or will it be backported to 2.22, too?
Hi Georg-Johann, > Is this only a fix for HEAD or will it be backported to 2.22, too? It was only checked in to HEAD, although the patch will work with the 2.22 sources as well. I have now checked it in to the 2.22 branch. so if there is a 2.22 point release then the patch will be included in that. Cheers Nick
(In reply to comment #16) > Hi Georg-Johann, > > > Is this only a fix for HEAD or will it be backported to 2.22, too? > > It was only checked in to HEAD, although the patch will work with the 2.22 > sources as well. I have now checked it in to the 2.22 branch. so if there is a > 2.22 point release then the patch will be included in that. Thanks for taking care of the matter and for the quick response. If there is the decision to have no more 2.22 release and thus your work won't be integrated in any 2.22 release, then the release notes in http://sourceware.org/binutils/ should mention that avr-binutils are broken for target avr and unusable. Even if avr is no "important" target it would be great to have a working 2.22 avr-binutils and not a version that's completely broken...
CVSROOT: /cvs/src Module name: src Branch: binutils-2_22-branch Changes by: nickc@sourceware.org 2012-02-01 17:07:37 Modified files: bfd : ChangeLog elf32-avr.c Log message: * Import this patch from the mainline: 2012-01-05 Nick Clifton <nickc@redhat.com> PR ld/12161 * elf32-avr.c (elf32_avr_relax_delete_bytes): Read in relocs if necessary. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.5473.2.35&r2=1.5473.2.36 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-avr.c.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.51&r2=1.51.2.1
*** Bug 260998 has been marked as a duplicate of this bug. *** Seen from the domain http://volichat.com Page where seen: http://volichat.com/adult-chat-rooms Marked for reference. Resolved as fixed @bugzilla.