Linking the Arduino Bootloader In Atmel Studio I have been trying to get the Arduino bootloader to compile into my firmware binary in Atmel Studio. I got the bootloader project to link and compile. I use ArduinoCore and the bootloader as a dependencies to my main code. The dependency tree looks like:

ArduinoCore
bootloader
Main firmware

The Bootloader
It took me a bit to get the bootloader to accept the rest of ArduinoCore as a dependency but it compiles into a static library. I use the bootloader linker to specify the memory location of the bootloader binary. It should start at 0x0 and provide a jump to the main firmware, located at 0x2000.
Bootloader linker flags:
-Tbootloader_samd21x18.ld -Wl

And here are the contents of the linker script:
  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x2000 /* First 8KB used by bootloader */
  RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000-0x0004 /* 4 bytes used by bootloader to keep data between resets */

This is based off of the .cProj file that comes with the linker. It is compiled as a static library so I can include it into my final binary.
Main Firmware
My code has both the ArduinoCore and the bootloader static libraries as dependencies:
libm
libArduinoCore
libbootloader

And I am using these linker flags:
-Tflash_with_bootloader.ld -Wl,--cref -Os -Wl,--check-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align

The contents of this linker script are moved out by 8KB in order to accommodate the bootloader at the start of the binary:
    FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000  /* First 8KB used by bootloader */
    RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000

And yet, my entry point does not appear to ever hit the bootloader. It jumps straight to &quot;main.cpp&quot; from ArduinoCore. The firmware runs as expected, but the bootloader does not appear to have been included.
Is this some kind of dependency issue? Am I misusing the linkers?
Any help with getting this to compile under a single binary would be very much appreciated. Thank you very much!
This isn't exactly 100% the answer I was looking for, because I still want to know how I can use a static library build, as I mention in my post, and compile everything as a single binary. This method is essentially gluing two binaries together.
I found this great and informative post over here:
https://www.avrfreaks.net/forum/can-you-combine-appbootloader-using-as7
It uses srec_cat to concatenate two binaries after building them:
https://www.keil.com/support/docs/2666.htm
I use the offset specified from the '.ld' file using
srec_cat &lt;firmware1.bin&gt; -Binary &lt;firmware2.bin&gt; -Binary -offset 0x2000 -o &lt;firmwareOut.bin&gt;
As the post suggests, I set this up as a post-build event and set my build dependencies accordingly so that a full clean and make will produce a consolidated binary including the bootloader.
If anyone tries this, make sure you only use the non-bootloader binary generated by your main project build. The bootloader places new firmware at location 0x2000 and your firmware will break if it finds a bootloader at the location where the firmware is supposed to be. When uploading firmware to the bootloader, it does not overwrite the bootloader.