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

Unified Diff: lib/Target/X86/MCTargetDesc/X86MCTargetDesc.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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698