llvm.org GIT mirror llvm / 6eb3e87
Added Mapping Symbols for ARM ELF Before this patch, when you objdump an LLVM-compiled file, objdump tried to decode data-in-code sections as if they were code. This patch adds the missing Mapping Symbols, as defined by "ELF for the ARM Architecture" (ARM IHI 0044D). Patch based on work by Greg Fitzgerald. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169609 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover 7 years ago
20 changed file(s) with 550 addition(s) and 74 deletion(s). Raw diff Collapse all Expand all
0 //===- lib/MC/MCELF.h - ELF MC --------------------------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains some support functions used by the ELF Streamer and
10 // ObjectWriter.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCELF_H
15 #define LLVM_MC_MCELF_H
16
17 #include "llvm/MC/MCExpr.h"
18
19 namespace llvm {
20 class MCSymbolData;
21
22 class MCELF {
23 public:
24 static void SetBinding(MCSymbolData &SD, unsigned Binding);
25 static unsigned GetBinding(const MCSymbolData &SD);
26 static void SetType(MCSymbolData &SD, unsigned Type);
27 static unsigned GetType(const MCSymbolData &SD);
28 static void SetVisibility(MCSymbolData &SD, unsigned Visibility);
29 static unsigned GetVisibility(MCSymbolData &SD);
30 };
31
32 }
33
34 #endif
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/MC/MCELFObjectWriter.h"
14 #include "MCELF.h"
1514 #include "llvm/ADT/OwningPtr.h"
1615 #include "llvm/ADT/STLExtras.h"
1716 #include "llvm/ADT/SmallPtrSet.h"
2120 #include "llvm/MC/MCAsmLayout.h"
2221 #include "llvm/MC/MCAssembler.h"
2322 #include "llvm/MC/MCContext.h"
23 #include "llvm/MC/MCELF.h"
2424 #include "llvm/MC/MCELFSymbolFlags.h"
2525 #include "llvm/MC/MCExpr.h"
2626 #include "llvm/MC/MCFixupKindInfo.h"
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "MCELF.h"
13 #include "llvm/MC/MCELF.h"
1414 #include "llvm/MC/MCAssembler.h"
1515 #include "llvm/MC/MCELFSymbolFlags.h"
1616 #include "llvm/MC/MCFixupKindInfo.h"
+0
-35
lib/MC/MCELF.h less more
None //===- lib/MC/MCELF.h - ELF MC --------------------------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains some support functions used by the ELF Streamer and
10 // ObjectWriter.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCELF_H
15 #define LLVM_MC_MCELF_H
16
17 #include "llvm/MC/MCExpr.h"
18
19 namespace llvm {
20 class MCSymbolData;
21
22 class MCELF {
23 public:
24 static void SetBinding(MCSymbolData &SD, unsigned Binding);
25 static unsigned GetBinding(const MCSymbolData &SD);
26 static void SetType(MCSymbolData &SD, unsigned Type);
27 static unsigned GetType(const MCSymbolData &SD);
28 static void SetVisibility(MCSymbolData &SD, unsigned Visibility);
29 static unsigned GetVisibility(MCSymbolData &SD);
30 };
31
32 }
33
34 #endif
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/MC/MCELFStreamer.h"
14
15 #include "MCELF.h"
1614 #include "llvm/ADT/SmallPtrSet.h"
17 #include "llvm/ADT/StringExtras.h"
18 #include "llvm/ADT/Twine.h"
19 #include "llvm/MC/MCAsmBackend.h"
2015 #include "llvm/MC/MCAssembler.h"
2116 #include "llvm/MC/MCCodeEmitter.h"
2217 #include "llvm/MC/MCContext.h"
18 #include "llvm/MC/MCELF.h"
2319 #include "llvm/MC/MCELFSymbolFlags.h"
2420 #include "llvm/MC/MCExpr.h"
2521 #include "llvm/MC/MCInst.h"
10197 }
10298
10399 llvm_unreachable("invalid assembler flag!");
104 }
105
106 void MCELFStreamer::EmitThumbFunc(MCSymbol *Func) {
107 // FIXME: Anything needed here to flag the function as thumb?
108
109 getAssembler().setIsThumbFunc(Func);
110
111 MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Func);
112 SD.setFlags(SD.getFlags() | ELF_Other_ThumbFunc);
113100 }
114101
115102 void MCELFStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
395382
396383 this->MCObjectStreamer::FinishImpl();
397384 }
398
399 void MCELFStreamer::EmitTCEntry(const MCSymbol &S)
400 {
385 void MCELFStreamer::EmitTCEntry(const MCSymbol &S) {
401386 // Creates a R_PPC64_TOC relocation
402387 MCObjectStreamer::EmitSymbolValue(&S, 8, 0);
403388 }
413398 return S;
414399 }
415400
401 void MCELFStreamer::EmitThumbFunc(MCSymbol *Func) {
402 llvm_unreachable("Generic ELF doesn't support this directive");
403 }
404
416405 void MCELFStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
417406 llvm_unreachable("ELF doesn't support this directive");
418407 }
0 //===- lib/MC/ARMELFStreamer.cpp - ELF Object Output for ARM --------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file assembles .s files and emits ARM ELF .o object files. Different
10 // from generic ELF streamer in emitting mapping symbols ($a, $t and $d) to
11 // delimit regions of data and code.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "llvm/MC/MCELFStreamer.h"
16 #include "llvm/ADT/SmallPtrSet.h"
17 #include "llvm/ADT/StringExtras.h"
18 #include "llvm/MC/MCAssembler.h"
19 #include "llvm/MC/MCCodeEmitter.h"
20 #include "llvm/MC/MCContext.h"
21 #include "llvm/MC/MCSectionELF.h"
22 #include "llvm/MC/MCStreamer.h"
23 #include "llvm/MC/MCELF.h"
24 #include "llvm/MC/MCELFStreamer.h"
25 #include "llvm/MC/MCELFSymbolFlags.h"
26 #include "llvm/MC/MCExpr.h"
27 #include "llvm/MC/MCInst.h"
28 #include "llvm/MC/MCObjectStreamer.h"
29 #include "llvm/MC/MCSection.h"
30 #include "llvm/MC/MCSymbol.h"
31 #include "llvm/MC/MCValue.h"
32 #include "llvm/MC/MCAsmBackend.h"
33 #include "llvm/Support/Debug.h"
34 #include "llvm/Support/ELF.h"
35 #include "llvm/Support/ErrorHandling.h"
36 #include "llvm/Support/raw_ostream.h"
37
38 using namespace llvm;
39
40 namespace {
41
42 /// Extend the generic ELFStreamer class so that it can emit mapping symbols at
43 /// the appropriate points in the object files. These symbols are defined in the
44 /// ARM ELF ABI: infocenter.arm.com/help/topic/com.arm.../IHI0044D_aaelf.pdf.
45 ///
46 /// In brief: $a, $t or $d should be emitted at the start of each contiguous
47 /// region of ARM code, Thumb code or data in a section. In practice, this
48 /// emission does not rely on explicit assembler directives but on inherent
49 /// properties of the directives doing the emission (e.g. ".byte" is data, "add
50 /// r0, r0, r0" an instruction).
51 ///
52 /// As a result this system is orthogonal to the DataRegion infrastructure used
53 /// by MachO. Beware!
54 class ARMELFStreamer : public MCELFStreamer {
55 public:
56 ARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
57 raw_ostream &OS, MCCodeEmitter *Emitter, bool IsThumb)
58 : MCELFStreamer(Context, TAB, OS, Emitter),
59 IsThumb(IsThumb), MappingSymbolCounter(0), LastEMS(EMS_None) {
60 }
61
62 ~ARMELFStreamer() {}
63
64 virtual void ChangeSection(const MCSection *Section) {
65 // We have to keep track of the mapping symbol state of any sections we
66 // use. Each one should start off as EMS_None, which is provided as the
67 // default constructor by DenseMap::lookup.
68 LastMappingSymbols[getPreviousSection()] = LastEMS;
69 LastEMS = LastMappingSymbols.lookup(Section);
70
71 MCELFStreamer::ChangeSection(Section);
72 }
73
74 /// This function is the one used to emit instruction data into the ELF
75 /// streamer. We override it to add the appropriate mapping symbol if
76 /// necessary.
77 virtual void EmitInstruction(const MCInst& Inst) {
78 if (IsThumb)
79 EmitThumbMappingSymbol();
80 else
81 EmitARMMappingSymbol();
82
83 MCELFStreamer::EmitInstruction(Inst);
84 }
85
86 /// This is one of the functions used to emit data into an ELF section, so the
87 /// ARM streamer overrides it to add the appropriate mapping symbol ($d) if
88 /// necessary.
89 virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {
90 EmitDataMappingSymbol();
91 MCELFStreamer::EmitBytes(Data, AddrSpace);
92 }
93
94 /// This is one of the functions used to emit data into an ELF section, so the
95 /// ARM streamer overrides it to add the appropriate mapping symbol ($d) if
96 /// necessary.
97 virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
98 unsigned AddrSpace) {
99 EmitDataMappingSymbol();
100 MCELFStreamer::EmitValueImpl(Value, Size, AddrSpace);
101 }
102
103 virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) {
104 MCELFStreamer::EmitAssemblerFlag(Flag);
105
106 switch (Flag) {
107 case MCAF_SyntaxUnified:
108 return; // no-op here.
109 case MCAF_Code16:
110 IsThumb = true;
111 return; // Change to Thumb mode
112 case MCAF_Code32:
113 IsThumb = false;
114 return; // Change to ARM mode
115 case MCAF_Code64:
116 return;
117 case MCAF_SubsectionsViaSymbols:
118 return;
119 }
120 }
121
122 private:
123 enum ElfMappingSymbol {
124 EMS_None,
125 EMS_ARM,
126 EMS_Thumb,
127 EMS_Data
128 };
129
130 void EmitDataMappingSymbol() {
131 if (LastEMS == EMS_Data) return;
132 EmitMappingSymbol("$d");
133 LastEMS = EMS_Data;
134 }
135
136 void EmitThumbMappingSymbol() {
137 if (LastEMS == EMS_Thumb) return;
138 EmitMappingSymbol("$t");
139 LastEMS = EMS_Thumb;
140 }
141
142 void EmitARMMappingSymbol() {
143 if (LastEMS == EMS_ARM) return;
144 EmitMappingSymbol("$a");
145 LastEMS = EMS_ARM;
146 }
147
148 void EmitMappingSymbol(StringRef Name) {
149 MCSymbol *Start = getContext().CreateTempSymbol();
150 EmitLabel(Start);
151
152 StringRef UniqueName = Name.str() + "." + itostr(MappingSymbolCounter++);
153 MCSymbol *Symbol = getContext().GetOrCreateSymbol(UniqueName);
154
155 MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
156 MCELF::SetType(SD, ELF::STT_NOTYPE);
157 MCELF::SetBinding(SD, ELF::STB_LOCAL);
158 SD.setExternal(false);
159 Symbol->setSection(*getCurrentSection());
160
161 const MCExpr *Value = MCSymbolRefExpr::Create(Start, getContext());
162 Symbol->setVariableValue(Value);
163 }
164
165 void EmitThumbFunc(MCSymbol *Func) {
166 // FIXME: Anything needed here to flag the function as thumb?
167
168 getAssembler().setIsThumbFunc(Func);
169
170 MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Func);
171 SD.setFlags(SD.getFlags() | ELF_Other_ThumbFunc);
172 }
173
174
175 bool IsThumb;
176 int64_t MappingSymbolCounter;
177
178 DenseMap LastMappingSymbols;
179 ElfMappingSymbol LastEMS;
180
181 /// @}
182 };
183 }
184
185 namespace llvm {
186 MCELFStreamer* createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
187 raw_ostream &OS, MCCodeEmitter *Emitter,
188 bool RelaxAll, bool NoExecStack,
189 bool IsThumb) {
190 ARMELFStreamer *S = new ARMELFStreamer(Context, TAB, OS, Emitter, IsThumb);
191 if (RelaxAll)
192 S->getAssembler().setRelaxAll(true);
193 if (NoExecStack)
194 S->getAssembler().setNoExecStack(true);
195 return S;
196 }
197
198 }
199
200
0 //===-- ARMELFStreamer.h - ELF Streamer for ARM ------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements ELF streamer information for the ARM backend.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef ARM_ELF_STREAMER_H
14 #define ARM_ELF_STREAMER_H
15
16 #include "llvm/MC/MCELFStreamer.h"
17
18 namespace llvm {
19
20 MCELFStreamer* createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
21 raw_ostream &OS, MCCodeEmitter *Emitter,
22 bool RelaxAll, bool NoExecStack,
23 bool IsThumb);
24 }
25
26 #endif // ARM_ELF_STREAMER_H
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "ARMMCTargetDesc.h"
14 #include "ARMELFStreamer.h"
15 #include "ARMMCAsmInfo.h"
1416 #include "ARMBaseInfo.h"
1517 #include "ARMMCAsmInfo.h"
1618 #include "InstPrinter/ARMInstPrinter.h"
185187 llvm_unreachable("ARM does not support Windows COFF format");
186188 }
187189
188 return createELFStreamer(Ctx, MAB, OS, Emitter, false, NoExecStack);
190 return createARMELFStreamer(Ctx, MAB, OS, Emitter, false, NoExecStack,
191 TheTriple.getArch() == Triple::thumb);
189192 }
190193
191194 static MCInstPrinter *createARMMCInstPrinter(const Target &T,
0 add_llvm_library(LLVMARMDesc
11 ARMAsmBackend.cpp
22 ARMELFObjectWriter.cpp
3 ARMELFStreamer.cpp
34 ARMMCAsmInfo.cpp
45 ARMMCCodeEmitter.cpp
56 ARMMCExpr.cpp
2222
2323 ; OBJ: Relocation 0
2424 ; OBJ-NEXT: 'r_offset', 0x00000004
25 ; OBJ-NEXT: 'r_sym', 0x000007
25 ; OBJ-NEXT: 'r_sym', 0x000009
2626 ; OBJ-NEXT: 'r_type', 0x2b
2727
2828 ; OBJ: Relocation 1
3232
3333 ; OBJ: # Relocation 2
3434 ; OBJ-NEXT: 'r_offset', 0x0000000c
35 ; OBJ-NEXT: 'r_sym', 0x000008
35 ; OBJ-NEXT: 'r_sym', 0x00000a
3636 ; OBJ-NEXT: 'r_type', 0x1c
3737
3838 }
0 ;; RUN: llc -O0 -mtriple=armv7-linux-gnueabi -filetype=obj %s -o - | \
1 ;; RUN: elf-dump | FileCheck -check-prefix=ARM %s
2
3 ;; RUN: llc -O0 -mtriple=thumbv7-linux-gnueabi -filetype=obj %s -o - | \
4 ;; RUN: elf-dump --dump-section-data | FileCheck -check-prefix=TMB %s
5
6 ;; Ensure that if a jump table is generated that it has Mapping Symbols
7 ;; marking the data-in-code region.
8
9 define void @foo(i32* %ptr) nounwind ssp {
10 %tmp = load i32* %ptr, align 4
11 switch i32 %tmp, label %default [
12 i32 11, label %bb0
13 i32 10, label %bb1
14 i32 8, label %bb2
15 i32 4, label %bb3
16 i32 2, label %bb4
17 i32 6, label %bb5
18 i32 9, label %bb6
19 i32 15, label %bb7
20 i32 1, label %bb8
21 i32 3, label %bb9
22 i32 5, label %bb10
23 i32 30, label %bb11
24 i32 31, label %bb12
25 i32 13, label %bb13
26 i32 14, label %bb14
27 i32 20, label %bb15
28 i32 19, label %bb16
29 i32 17, label %bb17
30 i32 18, label %bb18
31 i32 21, label %bb19
32 i32 22, label %bb20
33 i32 16, label %bb21
34 i32 24, label %bb22
35 i32 25, label %bb23
36 i32 26, label %bb24
37 i32 27, label %bb25
38 i32 28, label %bb26
39 i32 23, label %bb27
40 i32 12, label %bb28
41 ]
42
43 default:
44 br label %exit
45 bb0:
46 br label %exit
47 bb1:
48 br label %exit
49 bb2:
50 br label %exit
51 bb3:
52 br label %exit
53 bb4:
54 br label %exit
55 bb5:
56 br label %exit
57 bb6:
58 br label %exit
59 bb7:
60 br label %exit
61 bb8:
62 br label %exit
63 bb9:
64 br label %exit
65 bb10:
66 br label %exit
67 bb11:
68 br label %exit
69 bb12:
70 br label %exit
71 bb13:
72 br label %exit
73 bb14:
74 br label %exit
75 bb15:
76 br label %exit
77 bb16:
78 br label %exit
79 bb17:
80 br label %exit
81 bb18:
82 br label %exit
83 bb19:
84 br label %exit
85 bb20:
86 br label %exit
87 bb21:
88 br label %exit
89 bb22:
90 br label %exit
91 bb23:
92 br label %exit
93 bb24:
94 br label %exit
95 bb25:
96 br label %exit
97 bb26:
98 br label %exit
99 bb27:
100 br label %exit
101 bb28:
102 br label %exit
103
104
105 exit:
106
107 ret void
108 }
109
110 ;; ARM: # Symbol 2
111 ;; ARM-NEXT: $a
112 ;; ARM-NEXT: 'st_value', 0x00000000
113 ;; ARM-NEXT: 'st_size', 0x00000000
114 ;; ARM-NEXT: 'st_bind', 0x0
115 ;; ARM-NEXT: 'st_type', 0x0
116 ;; ARM-NEXT: 'st_other'
117 ;; ARM-NEXT: 'st_shndx', [[MIXED_SECT:0x[0-9a-f]+]]
118
119 ;; ARM: # Symbol 3
120 ;; ARM-NEXT: $a
121 ;; ARM-NEXT: 'st_value', 0x000000ac
122 ;; ARM-NEXT: 'st_size', 0x00000000
123 ;; ARM-NEXT: 'st_bind', 0x0
124 ;; ARM-NEXT: 'st_type', 0x0
125 ;; ARM-NEXT: 'st_other'
126 ;; ARM-NEXT: 'st_shndx', [[MIXED_SECT]]
127
128 ;; ARM: # Symbol 4
129 ;; ARM-NEXT: $d
130 ;; ARM-NEXT: 'st_value', 0x00000000
131 ;; ARM-NEXT: 'st_size', 0x00000000
132 ;; ARM-NEXT: 'st_bind', 0x0
133 ;; ARM-NEXT: 'st_type', 0x0
134
135 ;; ARM: # Symbol 5
136 ;; ARM-NEXT: $d
137 ;; ARM-NEXT: 'st_value', 0x00000030
138 ;; ARM-NEXT: 'st_size', 0x00000000
139 ;; ARM-NEXT: 'st_bind', 0x0
140 ;; ARM-NEXT: 'st_type', 0x0
141 ;; ARM-NEXT: 'st_other'
142 ;; ARM-NEXT: 'st_shndx', [[MIXED_SECT]]
143
144 ;; ARM-NOT: ${{[atd]}}
145
146 ;; TMB: # Symbol 3
147 ;; TMB-NEXT: $d
148 ;; TMB-NEXT: 'st_value', 0x00000016
149 ;; TMB-NEXT: 'st_size', 0x00000000
150 ;; TMB-NEXT: 'st_bind', 0x0
151 ;; TMB-NEXT: 'st_type', 0x0
152 ;; TMB-NEXT: 'st_other'
153 ;; TMB-NEXT: 'st_shndx', [[MIXED_SECT:0x[0-9a-f]+]]
154
155 ;; TMB: # Symbol 4
156 ;; TMB-NEXT: $t
157 ;; TMB-NEXT: 'st_value', 0x00000000
158 ;; TMB-NEXT: 'st_size', 0x00000000
159 ;; TMB-NEXT: 'st_bind', 0x0
160 ;; TMB-NEXT: 'st_type', 0x0
161 ;; TMB-NEXT: 'st_other'
162 ;; TMB-NEXT: 'st_shndx', [[MIXED_SECT]]
163
164 ;; TMB: # Symbol 5
165 ;; TMB-NEXT: $t
166 ;; TMB-NEXT: 'st_value', 0x00000036
167 ;; TMB-NEXT: 'st_size', 0x00000000
168 ;; TMB-NEXT: 'st_bind', 0x0
169 ;; TMB-NEXT: 'st_type', 0x0
170 ;; TMB-NEXT: 'st_other'
171 ;; TMB-NEXT: 'st_shndx', [[MIXED_SECT]]
172
173
174 ;; TMB-NOT: ${{[atd]}}
175
6161
6262 ;; OBJ: Relocation 1
6363 ;; OBJ-NEXT: 'r_offset',
64 ;; OBJ-NEXT: 'r_sym', 0x000002
64 ;; OBJ-NEXT: 'r_sym', 0x000007
6565 ;; OBJ-NEXT: 'r_type', 0x2b
6666
67 ;; OBJ: Symbol 2
67 ;; OBJ: Symbol 7
6868 ;; OBJ-NEXT: '_MergedGlobals'
6969 ;; OBJ-NEXT: 'st_value', 0x00000010
4141 declare void @exit(i32) noreturn nounwind
4242
4343 ;; OBJ: Relocation 0
44 ;; OBJ-NEXT: 'r_offset',
45 ;; OBJ-NEXT: 'r_sym', 0x000002
44 ;; OBJ-NEXT: 'r_offset',
45 ;; OBJ-NEXT: 'r_sym', 0x000005
4646 ;; OBJ-NEXT: 'r_type', 0x2b
4747
48 ;; OBJ: Symbol 2
48 ;; OBJ: Symbol 5
4949 ;; OBJ-NEXT: '.L.str'
8888 declare void @exit(i32) noreturn nounwind
8989
9090 ;; OBJ: Relocation 1
91 ;; OBJ-NEXT: 'r_offset',
92 ;; OBJ-NEXT: 'r_sym', 0x00000c
91 ;; OBJ-NEXT: 'r_offset',
92 ;; OBJ-NEXT: 'r_sym', 0x000010
9393 ;; OBJ-NEXT: 'r_type', 0x2b
9494
95 ;; OBJ: Symbol 12
95 ;; OBJ: Symbol 16
9696 ;; OBJ-NEXT: 'vtable'
88 // OBJ: .rel.text
99
1010 // OBJ: 'r_offset', 0x00000000
11 // OBJ-NEXT: 'r_sym', 0x000004
11 // OBJ-NEXT: 'r_sym', 0x000005
1212 // OBJ-NEXT: 'r_type', 0x1d
1313
1414 // OBJ: 'r_offset', 0x00000004
15 // OBJ-NEXT: 'r_sym', 0x000004
15 // OBJ-NEXT: 'r_sym', 0x000005
1616 // OBJ-NEXT: 'r_type', 0x1c
1717
1818 // OBJ: 'r_offset', 0x00000008
19 // OBJ-NEXT: 'r_sym', 0x000004
19 // OBJ-NEXT: 'r_sym', 0x000005
2020 // OBJ-NEXT: 'r_type', 0x1c
2121
2222 // OBJ: 'r_offset', 0x0000000c
23 // OBJ-NEXT: 'r_sym', 0x000004
23 // OBJ-NEXT: 'r_sym', 0x000005
2424 // OBJ-NEXT: 'r_type', 0x1d
2525
2626 // OBJ: 'r_offset', 0x00000010
27 // OBJ-NEXT: 'r_sym', 0x000004
27 // OBJ-NEXT: 'r_sym', 0x000005
2828 // OBJ-NEXT: 'r_type', 0x1d
2929
3030 // OBJ: .symtab
31 // OBJ: Symbol 4
31 // OBJ: Symbol 5
3232 // OBJ-NEXT: some_label
2727 ; 00000008 0000070a R_ARM_THM_CALL 00000001 foo
2828 ; CHECK: Relocation 0
2929 ; CHECK-NEXT: 'r_offset', 0x00000008
30 ; CHECK-NEXT: 'r_sym', 0x000007
30 ; CHECK-NEXT: 'r_sym', 0x000009
3131 ; CHECK-NEXT: 'r_type', 0x0a
3232
3333 ; make sure foo is thumb function: bit 0 = 1
34 ; CHECK: Symbol 7
34 ; CHECK: Symbol 9
3535 ; CHECK-NEXT: 'foo'
3636 ; CHECK-NEXT: 'st_value', 0x00000001
1111 bx lr
1212
1313 @@ make sure foo is thumb function: bit 0 = 1 (st_value)
14 @CHECK: Symbol 4
14 @CHECK: Symbol 5
1515 @CHECK-NEXT: 'st_name', 0x00000001
1616 @CHECK-NEXT: 'st_value', 0x00000001
1717 @CHECK-NEXT: 'st_size', 0x00000000
0 @ RUN: llvm-mc -triple=arm-linux-gnueabi -filetype=obj < %s | llvm-objdump -t - | FileCheck %s
1
2 .text
3 @ $a at 0x0000
4 add r0, r0, r0
5 @ $d at 0x0004
6 .word 42
7 .thumb
8 @ $t at 0x0008
9 adds r0, r0, r0
10 adds r0, r0, r0
11 @ $a at 0x000c
12 .arm
13 add r0, r0, r0
14 @ $t at 0x0010
15 .thumb
16 adds r0, r0, r0
17 @ $d at 0x0012
18 .ascii "012"
19 .byte 1
20 .byte 2
21 .byte 3
22 @ $a at 0x0018
23 .arm
24 add r0, r0, r0
25
26 @ CHECK: 00000000 .text 00000000 $a
27 @ CHECK-NEXT: 0000000c .text 00000000 $a
28 @ CHECK-NEXT: 00000018 .text 00000000 $a
29 @ CHECK-NEXT: 00000004 .text 00000000 $d
30 @ CHECK-NEXT: 00000012 .text 00000000 $d
31 @ CHECK-NEXT: 00000008 .text 00000000 $t
32 @ CHECK-NEXT: 00000010 .text 00000000 $t
0 @ RUN: llvm-mc -triple=arm-linux-gnueabi -filetype=obj < %s | llvm-objdump -t - | FileCheck %s
1
2 .text
3 add r0, r0, r0
4
5 @ .wibble should *not* inherit .text's mapping symbol. It's a completely different section.
6 .section .wibble
7 add r0, r0, r0
8
9 @ A section should be able to start with a $t
10 .section .starts_thumb
11 .thumb
12 adds r0, r0, r0
13
14 @ A setion should be able to start with a $d
15 .section .starts_data
16 .word 42
17
18 @ Changing back to .text should not emit a redundant $a
19 .text
20 .arm
21 add r0, r0, r0
22
23 @ With all those constraints, we want:
24 @ + .text to have $a at 0 and no others
25 @ + .wibble to have $a at 0
26 @ + .starts_thumb to have $t at 0
27 @ + .starts_data to have $d at 0
28
29 @ CHECK: 00000000 .text 00000000 $a
30 @ CHECK-NEXT: 00000000 .wibble 00000000 $a
31 @ CHECK-NEXT: 00000000 .starts_data 00000000 $d
32 @ CHECK-NEXT: 00000000 .starts_thumb 00000000 $t
33 @ CHECK-NOT: ${{[adt]}}
34
0 @ RUN: llvm-mc -triple=arm-linux-gnueabi -filetype=obj < %s | llvm-objdump -t - | FileCheck %s
1
2 @ Implementation-detail test (unfortunately): values that are relocated do not
3 @ go via MCStreamer::EmitBytes; make sure they still emit a mapping symbol.
4 add r0, r0, r0
5 .word somewhere
6 add r0, r0, r0
7
8 @ CHECK: 00000000 .text 00000000 $a
9 @ CHECK-NEXT: 00000008 .text 00000000 $a
10 @ CHECK-NEXT: 00000004 .text 00000000 $d