Compiling code to specific memory address

Hi,

Is there any method in Arduino IDE to specify to where in the program memory the code should be compiled to?
(Something like "org" directive when writing in assembler)

I don't know. Maybe avrdude supports doing that.
https://learn.sparkfun.com/tutorials/pocket-avr-programmer-hookup-guide/using-avrdude
http://www.ladyada.net/learn/avr/avrdude.html
https://www.nongnu.org/avrdude/

Why do you want to put the code in a specific address instead going where the bootloader is expecting it to be? Or address 0 if there is no bootloader?

@RamNadler, tell us why you want to do that.
Have you heard about the XY-Problem ?

There is a special bootloader that is able to write to flash in runtime. That makes it possible (for example for an Arduino Mega 2560) to store a lot of data in flash. Could that be what you want ? It is to store data, not program code.

Do you want to jump to different sketches ? That can be solved in software in a normal way.

The gcc compiler/linker supports a locator of course, but I have never used it. I don't know how to do that whithout messing up the Arduino way to create a binary file.

This is indeed for writing my own bootloader.
I need it since I am including libraries which needs to sit in the bootloader program memory area.

No, not in the arduino ide.
You can do it with the core tools. For example, see the optiboot github page.

westfw:
No, not in the arduino ide.
You can do it with the core tools. For example, see the optiboot github page.

By core tools, do you mean avrdude?
I looked at optiboot page already. I was wondering if there is a more straightforward method.

By core tools, do you mean avrdude?

Either the linker, or objcopy. AFAIK, the only way to put code at specific addresses (and still have library functions callable) is to put it in a specific section, and then relocate it with the linker using "--section-start" That's because the internal jumps for loops and what not may need to be relocated as well.

For bootloaders containg "system support" code, you usually end up putting some "vectors" at known addresses (like optiboot's version number), and then letting the linker (with --section-start) relocate the actual code to wherever it needs to.

Thanks