Summary: | [avr] Wrong symbol values with --gc-sections | ||
---|---|---|---|
Product: | binutils | Reporter: | Georg-Johann Lay <gjl> |
Component: | ld | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | amodra, childbear0, eric.weddington, matthieu.lemerre |
Priority: | P2 | ||
Version: | 2.24 | ||
Target Milestone: | --- | ||
Host: | Target: | avr | |
Build: | Last reconfirmed: | ||
Attachments: |
heap-start.s
heap-start.map Console Output with -v -Wl,-v heal-start.elf: Disassembly from avr-objdump -d Tentative patch: Keep .data |
Description
Georg-Johann Lay
2012-02-16 10:18:16 UTC
Created attachment 6217 [details]
heap-start.s
avr-gcc's assembler output
Created attachment 6218 [details]
heap-start.map
Created attachment 6219 [details]
Console Output with -v -Wl,-v
Console output for the following command:
avr-gcc heap-start.c -mmcu=atmega168 -o heal-start.elf -Os -save-temps -Wl,-Map,heap-start.map -Wl,--gc-sections -v -Wl,-v
Created attachment 6220 [details]
heal-start.elf: Disassembly from avr-objdump -d
avr-objdump -d heal-start.elf | grep -A 3 '<main>:'
00000080 <main>:
80: 80 e6 ldi r24, 0x60 ; 96
82: 90 e0 ldi r25, 0x00 ; 0
84: 08 95 ret
I think this pain is self-inflicted. You're using -m avr5 -Tdata 0x800100 instead of -m avr51. So you get the avr5 ld script with the data section fudged to be at 0x800100. However, the data section is stripped by -gc-sections. So the address change doesn't affect following sections. They stay at the avr5 data memory region of 0x800060. (In reply to comment #5) > I think this pain is self-inflicted. > > You're using -m avr5 -Tdata 0x800100 instead of -m avr51. So you get the avr5 > ld script with the data section fudged to be at 0x800100. However, the data > section is stripped by -gc-sections. So the address change doesn't affect > following sections. They stay at the avr5 data memory region of 0x800060. atmega168 is element of avr5 and not element of avr51 (avr51 has ELPM instruction for example. ATmega168 has no ELPM). avr-gcc mixes devices with different RAM-start in the same core architecture, see mcu-devices.def: http://gcc.gnu.org/viewcvs/trunk/gcc/config/avr/avr-mcus.def?revision=184276&content-type=text%2Fplain&view=co Created attachment 6417 [details] Tentative patch: Keep .data This is a tentative patch to fix the issue by KEEPing .data. Lightly tested with a small program. Johann ld/ PR 13697 * scripttempl/avr.sc (.data): Keep it. CVSROOT: /cvs/src Module name: src Changes by: nickc@sourceware.org 2012-06-07 16:53:11 Modified files: ld : ChangeLog ld/scripttempl : avr.sc Log message: PR 13697 * scripttempl/avr.sc (.data): Keep it. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2454&r2=1.2455 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/scripttempl/avr.sc.diff?cvsroot=src&r1=1.12&r2=1.13 Fixed |