Forcing code location

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using GCC with AVR Studio 4 and the ATmega 324P.

I'm trying to force code to a location in high memory. Within my code, I declare the prototype as:

void foo() __attribute__ ((section ".mysection")));

Then as an added linker option I use:

-Wl,--section-start=.mysection=0x7D00

However when I look at the disassembly while debugging, the program memory at this location is all FFFF.

What could I be doing wrong? I have several other sections in memory that code seems to work fine in.

Thanks for any help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Remember that the Studio debugger shows code space with word addressing while the GCC toolchain handle all addresses using byte addressing. So take a look at 0x3E80 in the debugger.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I know that the linker address is not what is shown during debugging. All other code is in the location I expect it to be in.

When I look at where .mysection should be in disassembly, I can see the C code there and an appropriate amount of space for the associate assembly below it, the assembly is just 0xFFFF on every line.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So what does the .map file have to say about the actual location of .mysection ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The .map file shows all my sections to be at the byte addresses that I defined them to be at. That is, 0x7D00 as opposed to 0x3E80.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Perhaps I should mention that the specific code that is not working for me I have located to 0x7F50. It's only a few instructions that I want placed at the end of memory so I'm not exceeding memory limits. Its size is shown as 0x60.

Code I have located at 0x7D00 works fine.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And the .map file confirms that the 0x7F50 section is located at that address?

Also what does "avr-objdump -h project.elf" show? (IOW did the named section at 0x7F50 actually make it into the .elf and is it positioned at the requested address?)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Running avr-objdump on the .elf file as you described shows that code is positioned as it should be.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Next suspect is the ELF loader in the debugger then. You are using 4.13.557 ?

(I found a previous bug in memory section positioning and Atmel's fix for it went in at the switch from 4.12 to 4.13)