Discussion Forums

[SOLVED] "dynalib location not correct" linker error on Arduino build

After incorporating a new library into my project (see https://github.com/kmackay/micro-ecc) I noticed a linker error in the arduino console
“dynalib location not correct”

After looking at the map file I traced the problem down to the check in the linker command file at <User Directory>\AppData\Local\Arduino15\packages\RedBear\hardware\STM32F2\0.2.10\variants\RedBear_Duo\linker_scripts\gcc\shared\stm32f2xx\user.ld

Which contains this check
ASSERT ( link_dynalib_start == expected_dynalib_start, "Dynalib location not correct" );

with the expected_dynalib_start location set like this:
.text: { expected_dynalib_start = ORIGIN (APP_FLASH) + 24 ; . = ALIGN(4); link_dynalib_start = .;

It looks like for some reason, the library code was being placed at the beginning of the .text area and was using an 8 byte alignment expected_dynalib_start was assuming a 4 byte alignment.

To resolve, I added a BLOCK(4) directive to use 4 byte alignment on the .text area like this:

.text BLOCK(4): { expected_dynalib_start = ORIGIN (APP_FLASH) + 24 ; . = ALIGN(4); link_dynalib_start = .;

Hope this helps someone who may notice the “dynalib location not correct” error with their Arduino project build.


I noticed this is still a problem in the 0.3.1 tools release. I was wondering if someone from RedBear could point me to a place I could submit this patch so it will be pulled into the next release of tools? I don’t see the user.ld file hosted anywhere on github today.


1 Like

The user.ld file on the Mac is buried here: