Bug 14448 - AVR - BFD_RELOC_32 (4bytes) is written as 2 bytes
Summary: AVR - BFD_RELOC_32 (4bytes) is written as 2 bytes
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.20
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-10 11:55 UTC by M.Cerveny
Modified: 2012-08-27 07:29 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
testcase (20.10 KB, text/x-csrc)
2012-08-17 11:42 UTC, M.Cerveny
Details

Note You need to log in before you can comment on or make changes to this bug.
Description M.Cerveny 2012-08-10 11:55:40 UTC
Hello, 

I have problem to debug large avr programs (tinyos/nescc generate one large source file that is passed throught avr-gcc to avr-as). The debug information are getting corrupted if any generated section in elf is larger than 64kB.

Example errors: 
- avr-gdb cannot find source line
- "avr-objdump -Wl" / "avr-readelf -wl" outputs "Warning: The information in section .debug_line appears to be corrupt - the section is too small"

I debugged avr-as. All relloc/fixup are correctly computed in BFD_RELOC_32 format (traced with DEBUG5 in gas/write.c) but there is written only first 2 bytes :-(

I am not expert in code generation.

M.C>

--- gas/config/tc-avr.c.orig	2012-08-05 23:30:56.030369086 +0200
+++ gas/config/tc-avr.c	2012-08-10 13:00:17.610451285 +0200
@@ -1244,7 +1245,7 @@
 	  break;
 
 	case BFD_RELOC_32:
-	  bfd_putl16 ((bfd_vma) value, where);
+	  bfd_putl32 ((bfd_vma) value, where);
 	  break;
 
 	case BFD_RELOC_16:
Comment 1 M.Cerveny 2012-08-17 11:42:27 UTC
Created attachment 6585 [details]
testcase

Testcase:

1) generate large file:
# rm x.c; let i=1; let j=0; while [[ $i -le 2000 ]]; do echo "int fn${i}(int i)\n{\nfn${j}(i+1);\nfn${j}(i+2);\nfn${j}(i+3);\nreturn i+4;\n}\n\n" >> x.c; let
j=i; let i=i+1; done; echo "int fn0(int i) { return i; }; main() { fn${j}(0); }" >> x.c

2) compille

# avr-gcc -o x -g -mmcu=atmega1281 x.c

3) test overflow

# avr-readelf -S x
# avr-objdump -Wl x > /dev/null
avr-objdump: Warning: The information in section .debug_line appears to be corrupt - the section is too small
# avr-readelf -wl x > /dev/null
readelf: Warning: The information in section .debug_line appears to be corrupt - the section is too small
Comment 2 Vidya Praveen 2012-08-27 07:29:31 UTC
This seem to have been fixed already in the mainline:

http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/config/tc-avr.c.diff?r1=1.79&r2=1.80&cvsroot=src&f=h