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

Unified Diff: lib/MC/MCNaCl.cpp

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/MC/MCAssembler.cpp ('k') | lib/MC/MCObjectStreamer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/MC/MCNaCl.cpp
diff --git a/lib/MC/MCNaCl.cpp b/lib/MC/MCNaCl.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d2a404721d37052ca68c4d8c650fb7486c1de3ed
--- /dev/null
+++ b/lib/MC/MCNaCl.cpp
@@ -0,0 +1,82 @@
+//===- lib/MC/MCNaCl.cpp - NaCl-specific MC implementation ----------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/MC/MCNaCl.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCSectionELF.h"
+#include "llvm/MC/MCStreamer.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ELF.h"
+
+static const char NoteNamespace[] = "NaCl";
+
+namespace llvm {
+
+void initializeNaClMCStreamer(MCStreamer &Streamer, MCContext &Ctx,
+ const Triple &TheTriple) {
+ assert(TheTriple.isOSNaCl());
+ const char *NoteName;
+ const char *NoteArch;
+ unsigned BundleAlign;
+ switch (TheTriple.getArch()) {
+ case Triple::arm:
+ NoteName = ".note.NaCl.ABI.arm";
+ NoteArch = "arm";
+ BundleAlign = 4;
+ break;
+ case Triple::mipsel:
+ NoteName = ".note.NaCl.ABI.mipsel";
+ NoteArch = "mipsel";
+ BundleAlign = 4;
+ break;
+ case Triple::x86:
+ NoteName = ".note.NaCl.ABI.x86-32";
+ NoteArch = "x86-32";
+ BundleAlign = 5;
+ break;
+ case Triple::x86_64:
+ NoteName = ".note.NaCl.ABI.x86-64";
+ NoteArch = "x86-64";
+ BundleAlign = 5;
+ break;
+ default:
+ report_fatal_error("Unsupported architecture for NaCl");
+ }
+
+ // Set bundle-alignment as required by the NaCl ABI for the target.
+ Streamer.EmitBundleAlignMode(BundleAlign);
+
+ // For gas, override the size of DWARF address values generated by .loc
+ // directives.
+ if (TheTriple.getArch() == Triple::x86_64 &&
+ Streamer.hasRawTextSupport()) {
+ Streamer.EmitRawText("\t.dwarf_addr_size 4\n");
+ }
+ // Emit an ELF Note section in its own COMDAT group which identifies NaCl
+ // object files to the gold linker, so it can use the NaCl layout.
+ const MCSection *Note = Ctx.getELFSection(
+ NoteName, ELF::SHT_NOTE, ELF::SHF_ALLOC | ELF::SHF_GROUP,
+ SectionKind::getReadOnly(), 0, NoteName);
+
+ Streamer.PushSection();
+ Streamer.SwitchSection(Note);
+ Streamer.EmitIntValue(strlen(NoteNamespace) + 1, 4);
+ Streamer.EmitIntValue(strlen(NoteArch) + 1, 4);
+ Streamer.EmitIntValue(ELF::NT_VERSION, 4);
+ Streamer.EmitBytes(NoteNamespace);
+ Streamer.EmitIntValue(0, 1); // NUL terminator
+ Streamer.EmitValueToAlignment(4);
+ Streamer.EmitBytes(NoteArch);
+ Streamer.EmitIntValue(0, 1); // NUL terminator
+ Streamer.EmitValueToAlignment(4);
+ Streamer.PopSection();
+}
+
+} // namespace llvm
« 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