[PATCH] D70757: [ms] Add @feat.00 magic symbol to COFF object files from AsmParser
Eric Astor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 26 17:58:20 PST 2019
epastor updated this revision to Diff 231159.
epastor added a comment.
- Fix comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70757/new/
https://reviews.llvm.org/D70757
Files:
llvm/lib/MC/MCParser/AsmParser.cpp
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -21,6 +21,7 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/BinaryFormat/COFF.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/MC/MCAsmInfo.h"
@@ -887,6 +888,32 @@
if (!NoInitialTextSection)
Out.InitSections(false);
+ if (Ctx.getObjectFileInfo()->getObjectFileType() ==
+ MCObjectFileInfo::IsCOFF) {
+ // Emit an absolute @feat.00 symbol. This appears to be some kind of
+ // compiler features bitfield read by link.exe.
+ MCSymbol *Feat00Sym = getContext().getOrCreateSymbol("@feat.00");
+ getStreamer().BeginCOFFSymbolDef(Feat00Sym);
+ getStreamer().EmitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC);
+ getStreamer().EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_NULL);
+ getStreamer().EndCOFFSymbolDef();
+ int64_t Feat00Flags = 0;
+
+ if (getContext().getObjectFileInfo()->getTargetTriple().getArch() ==
+ Triple::x86) {
+ // According to the PE-COFF spec, the LSB of this value marks the object
+ // for "registered SEH". This means that all SEH handler entry points
+ // must be registered in .sxdata. Use of any unregistered handlers will
+ // cause the process to terminate immediately. LLVM does not know how to
+ // register any SEH handlers, so its object files should be safe.
+ Feat00Flags |= 1;
+ }
+
+ getStreamer().EmitSymbolAttribute(Feat00Sym, MCSA_Global);
+ getStreamer().EmitAssignment(
+ Feat00Sym, MCConstantExpr::create(Feat00Flags, getContext()));
+ }
+
// Prime the lexer.
Lex();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70757.231159.patch
Type: text/x-patch
Size: 1833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191127/fc4f992a/attachment.bin>
More information about the llvm-commits
mailing list