----- Original Message -----
From: "Rolf Ebert" <[EMAIL PROTECTED]>
To: "Dean" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Wednesday, November 14, 2007 5:13 PM
Subject: Re: [avr-libc-dev] PROGMEM section variables throw away
by --gc-sections?
Dean schrieb:
Hi guys,
I've been noticing some strange behaviour with my makefile arguments.
Firstly, LD.exe crashes when I use -mshort-calls with the --relax linker
option, but *only* if I *don't* use -ffunction-sections
and --gc-sections. With the latter two options enabled both -mshort-calls
and --relax work just fine.
Secondly, -ffunction-sections and --gc-sections seems to throw away some
of my PROGMEM variables. I rely on a few PROGMEM variables being embedded
into the binary so I can later distinguish which version it was compiled
from, similar to:
char PROGMEM buildtime[] = __TIME__;
--gc-sections seems to remove this, although I thought it was only
designed to remove unused functions and not PROGMEM data. Is there a
workaround to this?
--gc_sections removes all sections, that the linker thinks are unused. Did
you compile also with the -fdata-sections compiler switch?
No, didn't try that. I was under the hazy impression that -fdata-sections
didn't work for the AVR target? I'll give it a try.
The assembler symbol of buildtime is not modified by -ffunction-sections,
only by -fdata-sections.
I can also imagine a missing KEEP instruction in the linker script
Rolf
This is all getting wierder. It's only triggered by --relax, --gc-sections
and -mshort-calls on my large projects - test cases don't work.
Incidentally, removing -ffunction-sections causes my USB demo apps to
misbehave, even when --gc-sections isn't enabled. I though
that -ffunction-sections essentially does nothing without --gc-sections? I
tried to compare the listings and found some very minor differences, but
nothing to indicate why the firmware screwed up when -ffunction-sections was
turned off. Removing --relax fixes the problem and allows me to freely
turn -ffunction-sections on and off without faulty firmware.
I've no idea what's going on, but there's obviously some sort of confict (if
not multiple ones) between -mshort-calls, -ffunction-sections, --relax
and --gc-sections. It only seems to affect my large complex project, not
simple ones I've tested it on. Wierd.
_______________________________________________
AVR-libc-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev