Quote an overridden ldscript name on the link line; note the deliberate board-derived --flash_size

The -T script name was the one user-controlled token on the link line
that skipped shell_token, so a space or dollar sign in a
board_build.ldscript override corrupted the emitted linkflags. The
elf2bin comment now records that --flash_size deliberately stays
board-derived, matching PlatformIO (which reads upload.maximum_size,
not the ldscript).
This commit is contained in:
J. Nick Koston
2026-08-22 12:02:33 -05:00
parent 905b056756
commit 10a22d7d74
2 changed files with 16 additions and 2 deletions
@@ -1342,3 +1342,14 @@ def test_flash_ld_name_honors_ldscript_override(tmp_path: Path) -> None:
CORE.platformio_options = {"board_build.ldscript": "../evil.ld"}
with pytest.raises(EsphomeError, match="bare script name"):
arduino8266._flash_ld_name("nodemcuv2")
def test_write_project_quotes_spaced_ldscript_override(tmp_path: Path) -> None:
"""An overridden script name re-quotes on the link line like every other
user token (a space would otherwise split into two argv elements)."""
CORE.platformio_options = {"board_build.ldscript": "my script.ld"}
paths = _make_framework(tmp_path)
_set_flags()
content = _write_ninja(paths)
assert "'my script.ld'" in content or '"my script.ld"' in content
assert "-T my script.ld" not in content