From 00c0eaed8a8a8236e3c0f9740221d97a3c5039de Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Jun 2018 14:50:54 +0300 Subject: [PATCH] Append a main LD script at the beginning --- platformio/builder/tools/platformio.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 6ab49af2..7b6e23ed 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -108,9 +108,10 @@ def BuildProgram(env): # build project with dependencies _build_project_deps(env) - # append specified LD_SCRIPT - if "LDSCRIPT_PATH" in env and not any("-T" in f for f in env['LINKFLAGS']): - env.Append(LINKFLAGS=["-T", "$LDSCRIPT_PATH"]) + # append into the beginning a main LD script + if (env.get("LDSCRIPT_PATH") + and not any("-Wl,-T" in f for f in env['LINKFLAGS'])): + env.Prepend(LINKFLAGS=["-T", "$LDSCRIPT_PATH"]) # enable "cyclic reference" for linker if env.get("LIBS") and env.GetCompilerType() == "gcc":