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

Side by Side Diff: lib/MC/MCNaCl.cpp

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 9 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
« no previous file with comments | « lib/MC/MCAssembler.cpp ('k') | lib/MC/MCObjectStreamer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //===- lib/MC/MCNaCl.cpp - NaCl-specific MC implementation ----------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/MC/MCNaCl.h"
11 #include "llvm/ADT/Triple.h"
12 #include "llvm/MC/MCContext.h"
13 #include "llvm/MC/MCSectionELF.h"
14 #include "llvm/MC/MCStreamer.h"
15 #include "llvm/Support/CommandLine.h"
16 #include "llvm/Support/ELF.h"
17
18 static const char NoteNamespace[] = "NaCl";
19
20 namespace llvm {
21
22 void initializeNaClMCStreamer(MCStreamer &Streamer, MCContext &Ctx,
23 const Triple &TheTriple) {
24 assert(TheTriple.isOSNaCl());
25 const char *NoteName;
26 const char *NoteArch;
27 unsigned BundleAlign;
28 switch (TheTriple.getArch()) {
29 case Triple::arm:
30 NoteName = ".note.NaCl.ABI.arm";
31 NoteArch = "arm";
32 BundleAlign = 4;
33 break;
34 case Triple::mipsel:
35 NoteName = ".note.NaCl.ABI.mipsel";
36 NoteArch = "mipsel";
37 BundleAlign = 4;
38 break;
39 case Triple::x86:
40 NoteName = ".note.NaCl.ABI.x86-32";
41 NoteArch = "x86-32";
42 BundleAlign = 5;
43 break;
44 case Triple::x86_64:
45 NoteName = ".note.NaCl.ABI.x86-64";
46 NoteArch = "x86-64";
47 BundleAlign = 5;
48 break;
49 default:
50 report_fatal_error("Unsupported architecture for NaCl");
51 }
52
53 // Set bundle-alignment as required by the NaCl ABI for the target.
54 Streamer.EmitBundleAlignMode(BundleAlign);
55
56 // For gas, override the size of DWARF address values generated by .loc
57 // directives.
58 if (TheTriple.getArch() == Triple::x86_64 &&
59 Streamer.hasRawTextSupport()) {
60 Streamer.EmitRawText("\t.dwarf_addr_size 4\n");
61 }
62 // Emit an ELF Note section in its own COMDAT group which identifies NaCl
63 // object files to the gold linker, so it can use the NaCl layout.
64 const MCSection *Note = Ctx.getELFSection(
65 NoteName, ELF::SHT_NOTE, ELF::SHF_ALLOC | ELF::SHF_GROUP,
66 SectionKind::getReadOnly(), 0, NoteName);
67
68 Streamer.PushSection();
69 Streamer.SwitchSection(Note);
70 Streamer.EmitIntValue(strlen(NoteNamespace) + 1, 4);
71 Streamer.EmitIntValue(strlen(NoteArch) + 1, 4);
72 Streamer.EmitIntValue(ELF::NT_VERSION, 4);
73 Streamer.EmitBytes(NoteNamespace);
74 Streamer.EmitIntValue(0, 1); // NUL terminator
75 Streamer.EmitValueToAlignment(4);
76 Streamer.EmitBytes(NoteArch);
77 Streamer.EmitIntValue(0, 1); // NUL terminator
78 Streamer.EmitValueToAlignment(4);
79 Streamer.PopSection();
80 }
81
82 } // namespace llvm
OLDNEW
« no previous file with comments | « lib/MC/MCAssembler.cpp ('k') | lib/MC/MCObjectStreamer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698