From ede6005e7092ddae454e4d365d8adefeaec1f5e3 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Mon, 18 May 2020 02:18:54 +1200 Subject: [PATCH] [AVR] Explicitly set the address of the data section when invoking the linker This is required to get avr-gdb correctly showing values at the right addresses. This problem was discovered by using debug symbols in an external program to lookup values in an AVR simulator. --- clang/lib/Driver/ToolChains/AVR.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/clang/lib/Driver/ToolChains/AVR.cpp b/clang/lib/Driver/ToolChains/AVR.cpp index 6405db1a11a..04655d5b188 100644 --- a/clang/lib/Driver/ToolChains/AVR.cpp +++ b/clang/lib/Driver/ToolChains/AVR.cpp @@ -120,6 +120,13 @@ void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA, Args.AddAllArgs(CmdArgs, options::OPT_L); getToolChain().AddFilePathLibArgs(Args, CmdArgs); + // "Not [sic] that addr must be offset by adding 0x800000 the to + // real SRAM address so that the linker knows that the address + // is in the SRAM memory space." + // + // - https://www.nongnu.org/avr-libc/user-manual/mem_sections.html + CmdArgs.push_back("-Tdata=0x800100"); + // If the family name is known, we can link with the device-specific libgcc. // Without it, libgcc will simply not be linked. This matches avr-gcc // behavior. -- 2.11.0