llvm.org GIT mirror llvm / bc9510e
Merging r312905: ------------------------------------------------------------------------ r312905 | dylanmckay | 2017-09-11 22:32:51 +1200 (Mon, 11 Sep 2017) | 10 lines [AVR] Enable the '__do_copy_data' function Also enables '__do_clear_bss'. These functions are automaticalled called by the CRT if they are declared. We need these to be called otherwise RAM will start completely uninitialised, even though we need to copy RAM variables from progmem to RAM. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_50@314356 91177308-0d34-0410-b5e6-96231b3b80d8 Dylan McKay 3 years ago
4 changed file(s) with 32 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1212
1313 #include "AVRTargetStreamer.h"
1414
15 #include "llvm/MC/MCContext.h"
16
1517 namespace llvm {
1618
1719 AVRTargetStreamer::AVRTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
1921 AVRTargetAsmStreamer::AVRTargetAsmStreamer(MCStreamer &S)
2022 : AVRTargetStreamer(S) {}
2123
24 void AVRTargetStreamer::finish() {
25 MCStreamer &OS = getStreamer();
26 MCContext &Context = OS.getContext();
27
28 MCSymbol *DoCopyData = Context.getOrCreateSymbol("__do_copy_data");
29 MCSymbol *DoClearBss = Context.getOrCreateSymbol("__do_clear_bss");
30
31 // FIXME: We can disable __do_copy_data if there are no static RAM variables.
32
33 OS.emitRawComment(" Declaring this symbol tells the CRT that it should");
34 OS.emitRawComment("copy all variables from program memory to RAM on startup");
35 OS.EmitSymbolAttribute(DoCopyData, MCSA_Global);
36
37 OS.emitRawComment(" Declaring this symbol tells the CRT that it should");
38 OS.emitRawComment("clear the zeroed data section on startup");
39 OS.EmitSymbolAttribute(DoClearBss, MCSA_Global);
40 }
41
2242 } // end namespace llvm
2343
1818 class AVRTargetStreamer : public MCTargetStreamer {
1919 public:
2020 explicit AVRTargetStreamer(MCStreamer &S);
21
22 void finish() override;
2123 };
2224
2325 /// A target streamer for textual AVR assembly code.
0 ; RUN: llc < %s -march=avr | FileCheck %s
1
2 ; CHECK: .globl __do_clear_bss
3 @zeroed = internal constant [3 x i8] zeroinitializer
4
0 ; RUN: llc < %s -march=avr | FileCheck %s
1
2 ; CHECK: .globl __do_copy_data
3 @str = internal global [3 x i8] c"foo"
4