Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp

Issue 15067009: LLVM: Add ELF Note section to NaCl object files identifying them as such to gold (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: retry upload Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===-- ARMMCTargetDesc.cpp - ARM Target Descriptions ---------------------===// 1 //===-- ARMMCTargetDesc.cpp - ARM Target Descriptions ---------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file provides ARM specific target descriptions. 10 // This file provides ARM specific target descriptions.
11 // 11 //
12 //===----------------------------------------------------------------------===// 12 //===----------------------------------------------------------------------===//
13 13
14 #include "ARMMCTargetDesc.h" 14 #include "ARMMCTargetDesc.h"
15 #include "ARMBaseInfo.h" 15 #include "ARMBaseInfo.h"
16 #include "ARMELFStreamer.h" 16 #include "ARMELFStreamer.h"
17 #include "ARMMCAsmInfo.h" 17 #include "ARMMCAsmInfo.h"
18 #include "ARMMCTargetDesc.h" 18 #include "ARMMCTargetDesc.h"
19 #include "InstPrinter/ARMInstPrinter.h" 19 #include "InstPrinter/ARMInstPrinter.h"
20 #include "llvm/ADT/Triple.h" 20 #include "llvm/ADT/Triple.h"
21 #include "llvm/MC/MCCodeGenInfo.h" 21 #include "llvm/MC/MCCodeGenInfo.h"
22 #include "llvm/MC/MCContext.h"
22 #include "llvm/MC/MCInstrAnalysis.h" 23 #include "llvm/MC/MCInstrAnalysis.h"
23 #include "llvm/MC/MCInstrInfo.h" 24 #include "llvm/MC/MCInstrInfo.h"
24 #include "llvm/MC/MCRegisterInfo.h" 25 #include "llvm/MC/MCRegisterInfo.h"
26 #include "llvm/MC/MCSectionELF.h"
25 #include "llvm/MC/MCStreamer.h" 27 #include "llvm/MC/MCStreamer.h"
26 #include "llvm/MC/MCSubtargetInfo.h" 28 #include "llvm/MC/MCSubtargetInfo.h"
29 #include "llvm/Support/ELF.h"
27 #include "llvm/Support/ErrorHandling.h" 30 #include "llvm/Support/ErrorHandling.h"
28 #include "llvm/Support/TargetRegistry.h" 31 #include "llvm/Support/TargetRegistry.h"
29 32
30 #define GET_REGINFO_MC_DESC 33 #define GET_REGINFO_MC_DESC
31 #include "ARMGenRegisterInfo.inc" 34 #include "ARMGenRegisterInfo.inc"
32 35
33 #define GET_INSTRINFO_MC_DESC 36 #define GET_INSTRINFO_MC_DESC
34 #include "ARMGenInstrInfo.inc" 37 #include "ARMGenInstrInfo.inc"
35 38
36 #define GET_SUBTARGETINFO_MC_DESC 39 #define GET_SUBTARGETINFO_MC_DESC
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 207
205 if (TheTriple.isOSDarwin()) 208 if (TheTriple.isOSDarwin())
206 return createMachOStreamer(Ctx, MAB, OS, Emitter, false); 209 return createMachOStreamer(Ctx, MAB, OS, Emitter, false);
207 210
208 if (TheTriple.isOSWindows()) { 211 if (TheTriple.isOSWindows()) {
209 llvm_unreachable("ARM does not support Windows COFF format"); 212 llvm_unreachable("ARM does not support Windows COFF format");
210 } 213 }
211 // @LOCALMOD-BEGIN 214 // @LOCALMOD-BEGIN
212 MCStreamer *Streamer = createARMELFStreamer(Ctx, MAB, OS, Emitter, false, 215 MCStreamer *Streamer = createARMELFStreamer(Ctx, MAB, OS, Emitter, false,
213 NoExecStack, TheTriple.getArch() == Triple::thumb); 216 NoExecStack, TheTriple.getArch() == Triple::thumb);
214 if (TheTriple.isOSNaCl()) 217 if (TheTriple.isOSNaCl()) {
215 Streamer->EmitBundleAlignMode(4); 218 Streamer->EmitBundleAlignMode(4);
219 const char *NoteName = ".note.NaCl.ABI.arm";
Mark Seaborn 2013/05/09 21:54:11 Since this is duplicated between ARM/x86 (and does
eliben 2013/05/09 21:54:59 Why not: const char NoteName[] = "...." And then
Derek Schuff 2013/05/10 18:35:30 I didn't end up with a named const char array for
220 const char *NoteNamespace = "NaCl";
221 const char *NoteArch = "arm";
222 const MCSection *Note = Ctx.getELFSection(
223 NoteName, ELF::SHT_NOTE, ELF::SHF_ALLOC | ELF::SHF_GROUP,
224 SectionKind::getReadOnly(), 0, NoteName);
225
226 Streamer->reset();
227 // maybe should use pushSection and popSection but popSection will crash if
Mark Seaborn 2013/05/09 21:54:11 'maybe' -> 'Maybe'. Make this a TODO?
Derek Schuff 2013/05/10 18:35:30 Done.
228 // there haven't been any other sections switched to yet.
229 Streamer->SwitchSection(Note);
230 Streamer->EmitIntValue(5, 4); // sizeof("NaCl")
Mark Seaborn 2013/05/09 21:54:11 Use strlen(NoteNamespace)
Derek Schuff 2013/05/10 18:35:30 Done.
231 Streamer->EmitIntValue(4, 4); // sizeof("arm")
Mark Seaborn 2013/05/09 21:54:11 ditto
Derek Schuff 2013/05/10 18:35:30 Done.
232 Streamer->EmitIntValue(1, 4); // NT_VERSION
Mark Seaborn 2013/05/09 21:54:11 Can you #define this in Support/ELF.h?
Derek Schuff 2013/05/10 18:35:30 I could. I'm actually not sure if this is 1 becaus
Mark Seaborn 2013/05/10 19:52:45 It's NT_VERSION. See gold/nacl.h in binutils:
Derek Schuff 2013/05/10 22:59:26 Done.
233 Streamer->EmitValueToAlignment(4);
234 Streamer->EmitBytes(NoteNamespace);
235 Streamer->EmitIntValue(0, 1); // NUL terminator
236 Streamer->EmitValueToAlignment(4);
237 Streamer->EmitBytes(NoteArch);
238 Streamer->EmitIntValue(0, 1); // NUL terminator
239 Streamer->EmitValueToAlignment(4);
240 }
216 return Streamer; 241 return Streamer;
217 // @LOCALMOD-END 242 // @LOCALMOD-END
218 } 243 }
219 244
220 static MCInstPrinter *createARMMCInstPrinter(const Target &T, 245 static MCInstPrinter *createARMMCInstPrinter(const Target &T,
221 unsigned SyntaxVariant, 246 unsigned SyntaxVariant,
222 const MCAsmInfo &MAI, 247 const MCAsmInfo &MAI,
223 const MCInstrInfo &MII, 248 const MCInstrInfo &MII,
224 const MCRegisterInfo &MRI, 249 const MCRegisterInfo &MRI,
225 const MCSubtargetInfo &STI) { 250 const MCSubtargetInfo &STI) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 TargetRegistry::RegisterMCAsmBackend(TheThumbTarget, createARMAsmBackend); 330 TargetRegistry::RegisterMCAsmBackend(TheThumbTarget, createARMAsmBackend);
306 331
307 // Register the object streamer. 332 // Register the object streamer.
308 TargetRegistry::RegisterMCObjectStreamer(TheARMTarget, createMCStreamer); 333 TargetRegistry::RegisterMCObjectStreamer(TheARMTarget, createMCStreamer);
309 TargetRegistry::RegisterMCObjectStreamer(TheThumbTarget, createMCStreamer); 334 TargetRegistry::RegisterMCObjectStreamer(TheThumbTarget, createMCStreamer);
310 335
311 // Register the MCInstPrinter. 336 // Register the MCInstPrinter.
312 TargetRegistry::RegisterMCInstPrinter(TheARMTarget, createARMMCInstPrinter); 337 TargetRegistry::RegisterMCInstPrinter(TheARMTarget, createARMMCInstPrinter);
313 TargetRegistry::RegisterMCInstPrinter(TheThumbTarget, createARMMCInstPrinter); 338 TargetRegistry::RegisterMCInstPrinter(TheThumbTarget, createARMMCInstPrinter);
314 } 339 }
OLDNEW
« no previous file with comments | « no previous file | lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp » ('j') | lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698