Re: avr-gcc and char strings

Richard Weickelt <[email protected]>
Newsgroups gmane.comp.hardware.avr.gcc
Message-ID <[email protected]>
> I would love to understand the difference between "-j .text" and "-R
> .eeprom". I googled for avr-objcopy and all I found was
> 
> -j sectionname --only-section=sectionname Copy only the named section
> from the input file to the output file. This  option  may  be  given
> more than once.  Note that using this [-R
> sectionname|--remove-section=sectionname This does not really explains it
> to me! :-( Can I always use "-R .eeprom" and am done or should I
> understand what these options mean and use them from case to case? 
> Thanks, Andreas

You might want to read
http://www.nongnu.org/avr-libc/user-manual/mem_sections.html and about the
ELF format, sections and segments in general. I can recommend the book
"Linkers and Loaders" by John Levine but there is various other information
in the web.

Your global string array is not located in the .text section but .data. This
section gets flashed into the AVR as well (hint: PROGBITS, see avr-readelf
-S <EXECUTABLE>) but has to be "loaded" into the RAM during application
startup.

If You throw away the .data section with "objdump -j .text", then Your
program will of course copy data from an empty flash region into the RAM.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.