Index: lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp |
diff --git a/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp |
index c67bb944b6f5edfd9df0b8faf69f0a13c18c4cd9..03e000c54270f52a8dbd75724ed256288b353fc1 100644 |
--- a/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp |
+++ b/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp |
@@ -17,12 +17,15 @@ |
#include "X86MCAsmInfo.h" |
#include "llvm/ADT/Triple.h" |
#include "llvm/MC/MCCodeGenInfo.h" |
+#include "llvm/MC/MCContext.h" |
#include "llvm/MC/MCInstrAnalysis.h" |
#include "llvm/MC/MCInstrInfo.h" |
#include "llvm/MC/MCRegisterInfo.h" |
+#include "llvm/MC/MCSectionELF.h" |
#include "llvm/MC/MCStreamer.h" |
#include "llvm/MC/MCSubtargetInfo.h" |
#include "llvm/MC/MachineLocation.h" |
+#include "llvm/Support/ELF.h" |
#include "llvm/Support/ErrorHandling.h" |
#include "llvm/Support/Host.h" |
#include "llvm/Support/TargetRegistry.h" |
@@ -369,8 +372,31 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT, |
// @LOCALMOD-BEGIN |
eliben
2013/05/09 21:54:59
I wonder why the LOCALMOD is here, createELFStream
Derek Schuff
2013/05/10 18:35:30
I removed this localmod entirely in the cleanup.
|
MCStreamer *Streamer = createELFStreamer(Ctx, MAB, _OS, _Emitter, |
RelaxAll, NoExecStack); |
- if (TheTriple.isOSNaCl()) |
+ if (TheTriple.isOSNaCl()) { |
eliben
2013/05/09 21:54:59
Move this to a separate function with a descriptiv
Derek Schuff
2013/05/10 18:35:30
That actually doesn't work because registration on
|
Streamer->EmitBundleAlignMode(5); |
+ const char *NoteName = TheTriple.isArch32Bit() ? |
+ ".note.NaCl.ABI.x86-32" : ".note.NaCl.ABI.x86-64"; |
+ const char *NoteNamespace = "NaCl"; |
+ const char *NoteArch = TheTriple.isArch32Bit() ? "x86-32" : "x86-64"; |
+ const MCSection *Note = Ctx.getELFSection( |
+ NoteName, ELF::SHT_NOTE, ELF::SHF_ALLOC | ELF::SHF_GROUP, |
+ SectionKind::getReadOnly(), 0, NoteName); |
+ |
+ Streamer->reset(); |
+ // maybe should use pushSection and popSection but popSection will crash if |
+ // there haven't been any other sections switched to yet. |
+ Streamer->SwitchSection(Note); |
+ Streamer->EmitIntValue(5, 4); // sizeof("NaCl") |
+ Streamer->EmitIntValue(7, 4); // sizeof("x86-xx") |
+ Streamer->EmitIntValue(1, 4); // NT_VERSION |
+ Streamer->EmitValueToAlignment(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); |
+ } |
return Streamer; |
// @LOCALMOD-END |