[lld] r243182 - COFF: Implement Safe SEH support for x86.
Rui Ueyama
ruiu at google.com
Fri Jul 24 16:51:15 PDT 2015
Author: ruiu
Date: Fri Jul 24 18:51:14 2015
New Revision: 243182
URL: http://llvm.org/viewvc/llvm-project?rev=243182&view=rev
Log:
COFF: Implement Safe SEH support for x86.
An object file compatible with Safe SEH contains a .sxdata section.
The section contains a list of symbol table indices, each of which
is an exception handler function. A safe SEH-enabled executable
contains a list of exception handler RVAs. So, what the linker has
to do to support Safe SEH is basically to read the .sxdata section,
interpret the contents as a list of symbol indices, unique-fy and
sort their RVAs, and then emit that list to .rdata. This patch
implements that feature.
Added:
lld/trunk/test/COFF/Inputs/seh.c
lld/trunk/test/COFF/Inputs/seh.obj.yaml
lld/trunk/test/COFF/seh.test
Modified:
lld/trunk/COFF/Chunks.cpp
lld/trunk/COFF/Chunks.h
lld/trunk/COFF/Config.h
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/InputFiles.cpp
lld/trunk/COFF/InputFiles.h
lld/trunk/COFF/SymbolTable.cpp
lld/trunk/COFF/SymbolTable.h
lld/trunk/COFF/Symbols.h
lld/trunk/COFF/Writer.cpp
lld/trunk/COFF/Writer.h
Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=243182&r1=243181&r2=243182&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Fri Jul 24 18:51:14 2015
@@ -23,6 +23,7 @@ using namespace llvm;
using namespace llvm::object;
using namespace llvm::support::endian;
using namespace llvm::COFF;
+using llvm::support::ulittle32_t;
namespace lld {
namespace coff {
@@ -280,6 +281,14 @@ void LocalImportChunk::writeTo(uint8_t *
}
}
+void SEHTableChunk::writeTo(uint8_t *Buf) {
+ ulittle32_t *Begin = reinterpret_cast<ulittle32_t *>(Buf + FileOff);
+ size_t Cnt = 0;
+ for (Defined *D : Syms)
+ Begin[Cnt++] = D->getRVA();
+ std::sort(Begin, Begin + Cnt);
+}
+
// Windows-specific.
// This class represents a block in .reloc section.
BaserelChunk::BaserelChunk(uint32_t Page, uint32_t *Begin, uint32_t *End) {
Modified: lld/trunk/COFF/Chunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.h?rev=243182&r1=243181&r2=243182&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.h (original)
+++ lld/trunk/COFF/Chunks.h Fri Jul 24 18:51:14 2015
@@ -255,6 +255,19 @@ private:
};
// Windows-specific.
+// A chunk for SEH table which contains RVAs of safe exception handler
+// functions. x86-only.
+class SEHTableChunk : public Chunk {
+public:
+ explicit SEHTableChunk(std::set<Defined *> S) : Syms(S) {}
+ size_t getSize() const override { return Syms.size() * 4; }
+ void writeTo(uint8_t *Buf) override;
+
+private:
+ std::set<Defined *> Syms;
+};
+
+// Windows-specific.
// This class represents a block in .reloc section.
// See the PE/COFF spec 5.6 for details.
class BaserelChunk : public Chunk {
Modified: lld/trunk/COFF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?rev=243182&r1=243181&r2=243182&view=diff
==============================================================================
--- lld/trunk/COFF/Config.h (original)
+++ lld/trunk/COFF/Config.h Fri Jul 24 18:51:14 2015
@@ -24,6 +24,8 @@ using llvm::COFF::IMAGE_FILE_MACHINE_AMD
using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
using llvm::COFF::WindowsSubsystem;
using llvm::StringRef;
+class DefinedAbsolute;
+class DefinedRelative;
class Undefined;
// Represents an /export option.
@@ -72,6 +74,10 @@ struct Configuration {
std::set<std::string> DelayLoads;
Undefined *DelayLoadHelper = nullptr;
+ // Used for SafeSEH.
+ DefinedRelative *SEHTable = nullptr;
+ DefinedAbsolute *SEHCount = nullptr;
+
// Used for /opt:icf
bool ICF = false;
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=243182&r1=243181&r2=243182&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Fri Jul 24 18:51:14 2015
@@ -603,6 +603,10 @@ bool LinkerDriver::link(llvm::ArrayRef<c
}
Symtab.addRelative(mangle("__ImageBase"), 0);
+ if (Config->MachineType == IMAGE_FILE_MACHINE_I386) {
+ Config->SEHTable = Symtab.addRelative("___safe_se_handler_table", 0);
+ Config->SEHCount = Symtab.addAbsolute("___safe_se_handler_count", 0);
+ }
// Read as much files as we can from directives sections.
if (auto EC = Symtab.run()) {
@@ -639,6 +643,12 @@ bool LinkerDriver::link(llvm::ArrayRef<c
U->WeakAlias = Symtab.addUndefined(To);
}
+ // Windows specific -- if __load_config_used can be resolved, resolve it.
+ if (Config->MachineType == IMAGE_FILE_MACHINE_I386)
+ if (Symbol *Sym = Symtab.find("__load_config_used"))
+ if (isa<Lazy>(Sym->Body))
+ Symtab.addUndefined("__load_config_used");
+
if (Symtab.queueEmpty())
break;
if (auto EC = Symtab.run()) {
Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=243182&r1=243181&r2=243182&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Fri Jul 24 18:51:14 2015
@@ -25,6 +25,7 @@ using namespace llvm::object;
using namespace llvm::support::endian;
using llvm::RoundUpToAlignment;
using llvm::Triple;
+using llvm::support::ulittle32_t;
using llvm::sys::fs::file_magic;
using llvm::sys::fs::identify_magic;
@@ -112,7 +113,9 @@ std::error_code ObjectFile::parse() {
// Read section and symbol tables.
if (auto EC = initializeChunks())
return EC;
- return initializeSymbols();
+ if (auto EC = initializeSymbols())
+ return EC;
+ return initializeSEH();
}
std::error_code ObjectFile::initializeChunks() {
@@ -132,6 +135,10 @@ std::error_code ObjectFile::initializeCh
<< EC.message() << "\n";
return make_error_code(LLDError::BrokenFile);
}
+ if (Name == ".sxdata") {
+ SXData = Sec;
+ continue;
+ }
if (Name == ".drectve") {
ArrayRef<uint8_t> Data;
COFFObj->getSectionContents(Sec, Data);
@@ -214,8 +221,14 @@ Defined *ObjectFile::createDefined(COFFS
if (Sym.isAbsolute()) {
COFFObj->getSymbolName(Sym, Name);
// Skip special symbols.
- if (Name == "@comp.id" || Name == "@feat.00")
+ if (Name == "@comp.id")
+ return nullptr;
+ // COFF spec 5.10.1. The .sxdata section.
+ if (Name == "@feat.00") {
+ if (Sym.getValue() & 1)
+ SEHCompat = true;
return nullptr;
+ }
return new (Alloc) DefinedAbsolute(Name, Sym);
}
if (Sym.getSectionNumber() == llvm::COFF::IMAGE_SYM_DEBUG)
@@ -242,6 +255,22 @@ Defined *ObjectFile::createDefined(COFFS
return B;
}
+std::error_code ObjectFile::initializeSEH() {
+ if (!SEHCompat || !SXData)
+ return std::error_code();
+ ArrayRef<uint8_t> A;
+ COFFObj->getSectionContents(SXData, A);
+ if (A.size() % 4 != 0) {
+ llvm::errs() << ".sxdata must be an array of symbol table indices\n";
+ return make_error_code(LLDError::BrokenFile);
+ }
+ auto *I = reinterpret_cast<const ulittle32_t *>(A.data());
+ auto *E = reinterpret_cast<const ulittle32_t *>(A.data() + A.size());
+ for (; I != E; ++I)
+ SEHandlers.insert(SparseSymbolBodies[*I]);
+ return std::error_code();
+}
+
MachineTypes ObjectFile::getMachineType() {
if (COFFObj)
return static_cast<MachineTypes>(COFFObj->getMachine());
Modified: lld/trunk/COFF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.h?rev=243182&r1=243181&r2=243182&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.h (original)
+++ lld/trunk/COFF/InputFiles.h Fri Jul 24 18:51:14 2015
@@ -29,6 +29,7 @@ using llvm::COFF::MachineTypes;
using llvm::object::Archive;
using llvm::object::COFFObjectFile;
using llvm::object::COFFSymbolRef;
+using llvm::object::coff_section;
class Chunk;
class Defined;
@@ -130,9 +131,18 @@ public:
// Returns the underying COFF file.
COFFObjectFile *getCOFFObj() { return COFFObj.get(); }
+ // True if this object file is compatible with SEH.
+ // COFF-specific and x86-only.
+ bool SEHCompat = false;
+
+ // The list of safe exception handlers listed in .sxdata section.
+ // COFF-specific and x86-only.
+ std::set<SymbolBody *> SEHandlers;
+
private:
std::error_code initializeChunks();
std::error_code initializeSymbols();
+ std::error_code initializeSEH();
Defined *createDefined(COFFSymbolRef Sym, const void *Aux, bool IsFirst);
Undefined *createUndefined(COFFSymbolRef Sym);
@@ -140,6 +150,7 @@ private:
std::unique_ptr<COFFObjectFile> COFFObj;
llvm::BumpPtrAllocator Alloc;
+ const coff_section *SXData = nullptr;
// List of all chunks defined by this file. This includes both section
// chunks and non-section chunks for common symbols.
Modified: lld/trunk/COFF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.cpp?rev=243182&r1=243181&r2=243182&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.cpp (original)
+++ lld/trunk/COFF/SymbolTable.cpp Fri Jul 24 18:51:14 2015
@@ -317,8 +317,16 @@ Undefined *SymbolTable::addUndefined(Str
return New;
}
-void SymbolTable::addRelative(StringRef Name, uint64_t VA) {
- addSymbol(new (Alloc) DefinedRelative(Name, VA));
+DefinedRelative *SymbolTable::addRelative(StringRef Name, uint64_t VA) {
+ auto *New = new (Alloc) DefinedRelative(Name, VA);
+ addSymbol(New);
+ return New;
+}
+
+DefinedAbsolute *SymbolTable::addAbsolute(StringRef Name, uint64_t VA) {
+ auto *New = new (Alloc) DefinedAbsolute(Name, VA);
+ addSymbol(New);
+ return New;
}
void SymbolTable::printMap(llvm::raw_ostream &OS) {
Modified: lld/trunk/COFF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.h?rev=243182&r1=243181&r2=243182&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.h (original)
+++ lld/trunk/COFF/SymbolTable.h Fri Jul 24 18:51:14 2015
@@ -81,7 +81,8 @@ public:
// Creates an Undefined symbol for a given name.
Undefined *addUndefined(StringRef Name);
- void addRelative(StringRef Name, uint64_t VA);
+ DefinedRelative *addRelative(StringRef Name, uint64_t VA);
+ DefinedAbsolute *addAbsolute(StringRef Name, uint64_t VA);
// A list of chunks which to be added to .rdata.
std::vector<Chunk *> LocalImportChunks;
Modified: lld/trunk/COFF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Symbols.h?rev=243182&r1=243181&r2=243182&view=diff
==============================================================================
--- lld/trunk/COFF/Symbols.h (original)
+++ lld/trunk/COFF/Symbols.h Fri Jul 24 18:51:14 2015
@@ -218,6 +218,7 @@ public:
}
uint64_t getRVA() { return VA - Config->ImageBase; }
+ void setVA(uint64_t V) { VA = V; }
private:
uint64_t VA;
Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=243182&r1=243181&r2=243182&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Fri Jul 24 18:51:14 2015
@@ -58,6 +58,7 @@ std::error_code Writer::write(StringRef
} else {
writeHeader<pe32_header>();
}
+ fixSafeSEHSymbols();
writeSections();
sortExceptionTable();
return Buffer->commit();
@@ -211,11 +212,25 @@ void Writer::createSections() {
}
void Writer::createMiscChunks() {
- if (Symtab->LocalImportChunks.empty())
+ // Create thunks for locally-dllimported symbols.
+ if (!Symtab->LocalImportChunks.empty()) {
+ OutputSection *Sec = createSection(".rdata");
+ for (Chunk *C : Symtab->LocalImportChunks)
+ Sec->addChunk(C);
+ }
+
+ // Create SEH table. x86-only.
+ if (Config->MachineType != IMAGE_FILE_MACHINE_I386)
return;
- OutputSection *Sec = createSection(".rdata");
- for (Chunk *C : Symtab->LocalImportChunks)
- Sec->addChunk(C);
+ std::set<Defined *> Handlers;
+ for (ObjectFile *File : Symtab->ObjectFiles) {
+ if (!File->SEHCompat)
+ return;
+ for (SymbolBody *B : File->SEHandlers)
+ Handlers.insert(cast<Defined>(B->repl()));
+ }
+ SEHTable.reset(new SEHTableChunk(Handlers));
+ createSection(".rdata")->addChunk(SEHTable.get());
}
// Create .idata section for the DLL-imported symbol table.
@@ -524,6 +539,13 @@ std::error_code Writer::openFile(StringR
return std::error_code();
}
+void Writer::fixSafeSEHSymbols() {
+ if (!SEHTable)
+ return;
+ Config->SEHTable->setRVA(SEHTable->getRVA());
+ Config->SEHCount->setVA(SEHTable->getSize() / 4);
+}
+
// Write section contents to a mmap'ed file.
void Writer::writeSections() {
uint8_t *Buf = Buffer->getBufferStart();
Modified: lld/trunk/COFF/Writer.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.h?rev=243182&r1=243181&r2=243182&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.h (original)
+++ lld/trunk/COFF/Writer.h Fri Jul 24 18:51:14 2015
@@ -89,6 +89,7 @@ private:
void createSymbolAndStringTable();
std::error_code openFile(StringRef OutputPath);
template <typename PEHeaderTy> void writeHeader();
+ void fixSafeSEHSymbols();
void writeSections();
void sortExceptionTable();
void applyRelocations();
@@ -114,6 +115,7 @@ private:
IdataContents Idata;
DelayLoadContents DelayIdata;
EdataContents Edata;
+ std::unique_ptr<SEHTableChunk> SEHTable;
bool Is64;
uint64_t FileSize;
Added: lld/trunk/test/COFF/Inputs/seh.c
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/Inputs/seh.c?rev=243182&view=auto
==============================================================================
--- lld/trunk/test/COFF/Inputs/seh.c (added)
+++ lld/trunk/test/COFF/Inputs/seh.c Fri Jul 24 18:51:14 2015
@@ -0,0 +1,13 @@
+__declspec(noinline) void triggerSEH() {
+ volatile int *p = 0;
+ *p = 1;
+}
+
+int main() {
+ __try {
+ triggerSEH();
+ } __except(1) {
+ return 42;
+ }
+ return 0;
+}
Added: lld/trunk/test/COFF/Inputs/seh.obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/Inputs/seh.obj.yaml?rev=243182&view=auto
==============================================================================
--- lld/trunk/test/COFF/Inputs/seh.obj.yaml (added)
+++ lld/trunk/test/COFF/Inputs/seh.obj.yaml Fri Jul 24 18:51:14 2015
@@ -0,0 +1,387 @@
+---
+header:
+ Machine: IMAGE_FILE_MACHINE_I386
+ Characteristics: [ ]
+sections:
+ - Name: .drectve
+ Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]
+ Alignment: 1
+ SectionData: 2020202F44454641554C544C49423A22757569642E6C696222202F44454641554C544C49423A22757569642E6C696222202F4641494C49464D49534D415443483A225F4D53435F5645523D3138303022202F4641494C49464D49534D415443483A225F4954455241544F525F44454255475F4C4556454C3D3022202F4641494C49464D49534D415443483A2252756E74696D654C6962726172793D4D445F44796E616D696352656C6561736522202F44454641554C544C49423A226D73766370727422202F44454641554C544C49423A224D535643525422202F44454641554C544C49423A224F4C444E414D45532220
+ - Name: '.debug$S'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 04000000F1000000600000002200011100000000433A5C63796777696E5C686F6D655C727569755C7365682E6F626A003A003C11012200000700120000000D520100120000000D5201004D6963726F736F667420285229204F7074696D697A696E6720436F6D70696C657200
+ - Name: .rdata
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 00
+ - Name: .rdata
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 01
+ - Name: .rdata
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 4
+ SectionData: 54726967676572696E672053454820657863657074696F6E0D0A0000457865637574696E6720534548205F5F65786365707420626C6F636B20696E20666F6F0D0A000000457865637574696E6720534548205F5F65786365707420626C6F636B0D0A00
+ - Name: '.text$mn'
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 16
+ SectionData: 558BEC516800000000FF150000000083C404C745FC000000008B45FCC700140000008BE55DC3CCCCCCCCCCCCCCCCCCCC558BEC51E8000000008D4DFFE8000000008BE55DC3CCCCCCCCCCCCCCCCCCCCCC558BEC6AFE6800000000680000000064A1000000005083EC08535657A1000000003145F833C5508D45F064A3000000008965E8C745FC00000000E800000000C745FCFEFFFFFFEB1EB801000000C38B65E86800000000FF150000000083C404C745FCFEFFFFFF8B4DF064890D00000000595F5E5B8BE55DC3CCCCCCCCCCCCCCCC558BEC6AFE6800000000680000000064A1000000005083EC08535657A1000000003145F833C5508D45F064A3000000008965E8C745FC00000000E800000000E800000000C745FCFEFFFFFFEB1EB801000000C38B65E86800000000FF150000000083C404C745FCFEFFFFFF33C08B4DF064890D00000000595F5E5B8BE55DC3
+ Relocations:
+ - VirtualAddress: 5
+ SymbolName: '$SG73531'
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 11
+ SymbolName: __imp__printf
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 53
+ SymbolName: '?TestCPPEX@@YAXXZ'
+ Type: IMAGE_REL_I386_REL32
+ - VirtualAddress: 61
+ SymbolName: '??1TestClass@@QAE at XZ'
+ Type: IMAGE_REL_I386_REL32
+ - VirtualAddress: 86
+ SymbolName: '__sehtable$?foo@@YAXXZ'
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 91
+ SymbolName: __except_handler4
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 109
+ SymbolName: ___security_cookie
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 139
+ SymbolName: '?TestExceptions@@YAXXZ'
+ Type: IMAGE_REL_I386_REL32
+ - VirtualAddress: 162
+ SymbolName: '$SG73539'
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 168
+ SymbolName: __imp__printf
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 214
+ SymbolName: '__sehtable$_main'
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 219
+ SymbolName: __except_handler4
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 237
+ SymbolName: ___security_cookie
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 267
+ SymbolName: '?foo@@YAXXZ'
+ Type: IMAGE_REL_I386_REL32
+ - VirtualAddress: 272
+ SymbolName: '?TestExceptions@@YAXXZ'
+ Type: IMAGE_REL_I386_REL32
+ - VirtualAddress: 295
+ SymbolName: '$SG73543'
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 301
+ SymbolName: __imp__printf
+ Type: IMAGE_REL_I386_DIR32
+ - Name: '.text$mn'
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 16
+ SectionData: 558BEC51894DFC6800000000FF150000000083C4048BE55DC3
+ Relocations:
+ - VirtualAddress: 8
+ SymbolName: '??_C at _0BI@BBHGNMOG at Destroying?5TestClass?$CB?$AN?6?$AA@'
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 14
+ SymbolName: __imp__printf
+ Type: IMAGE_REL_I386_DIR32
+ - Name: '.xdata$x'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 8
+ SectionData: FEFFFFFF00000000D8FFFFFF00000000FEFFFFFF000000000000000000000000FEFFFFFF00000000D8FFFFFF00000000FEFFFFFF0000000000000000
+ Relocations:
+ - VirtualAddress: 20
+ SymbolName: '$LN5'
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 24
+ SymbolName: '$LN6'
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 52
+ SymbolName: '$LN5'
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 56
+ SymbolName: '$LN6'
+ Type: IMAGE_REL_I386_DIR32
+ - Name: .rdata
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_READ ]
+ Alignment: 4
+ SectionData: 44657374726F79696E672054657374436C617373210D0A00
+ - Name: .sxdata
+ Characteristics: [ IMAGE_SCN_LNK_INFO ]
+ Alignment: 4
+ SectionData: 1B0000001A000000
+symbols:
+ - Name: '@comp.id'
+ Value: 14766605
+ SectionNumber: 65535
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ - Name: '@feat.00'
+ Value: 2147484049
+ SectionNumber: 65535
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ - Name: .drectve
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 240
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+ - Name: '.debug$S'
+ Value: 0
+ SectionNumber: 2
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 108
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+ - Name: .rdata
+ Value: 0
+ SectionNumber: 3
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 1
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+ Selection: IMAGE_COMDAT_SELECT_ANY
+ - Name: '?value@?$integral_constant at _N$0A@@std@@2_NB'
+ Value: 0
+ SectionNumber: 3
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: .rdata
+ Value: 0
+ SectionNumber: 4
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 1
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 1996959894
+ Number: 0
+ Selection: IMAGE_COMDAT_SELECT_ANY
+ - Name: '?value@?$integral_constant at _N$00 at std@@2_NB'
+ Value: 0
+ SectionNumber: 4
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: .rdata
+ Value: 0
+ SectionNumber: 5
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 99
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 2801625422
+ Number: 0
+ - Name: '$SG73531'
+ Value: 0
+ SectionNumber: 5
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ - Name: '$SG73539'
+ Value: 28
+ SectionNumber: 5
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ - Name: '$SG73543'
+ Value: 68
+ SectionNumber: 5
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ - Name: '.text$mn'
+ Value: 0
+ SectionNumber: 6
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 335
+ NumberOfRelocations: 17
+ NumberOfLinenumbers: 0
+ CheckSum: 2488225337
+ Number: 0
+ - Name: '.text$mn'
+ Value: 0
+ SectionNumber: 7
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 25
+ NumberOfRelocations: 2
+ NumberOfLinenumbers: 0
+ CheckSum: 210566957
+ Number: 0
+ Selection: IMAGE_COMDAT_SELECT_ANY
+ - Name: __imp__printf
+ Value: 0
+ SectionNumber: 0
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: '??1TestClass@@QAE at XZ'
+ Value: 0
+ SectionNumber: 7
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: '?TestCPPEX@@YAXXZ'
+ Value: 0
+ SectionNumber: 6
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: '?TestExceptions@@YAXXZ'
+ Value: 48
+ SectionNumber: 6
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: '?foo@@YAXXZ'
+ Value: 80
+ SectionNumber: 6
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: _main
+ Value: 208
+ SectionNumber: 6
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: __except_handler4
+ Value: 0
+ SectionNumber: 0
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: '$LN5'
+ Value: 152
+ SectionNumber: 6
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_LABEL
+ - Name: '$LN7'
+ Value: 157
+ SectionNumber: 6
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_LABEL
+ - Name: '$LN6'
+ Value: 158
+ SectionNumber: 6
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_LABEL
+ - Name: '$LN5'
+ Value: 285
+ SectionNumber: 6
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_LABEL
+ - Name: '$LN7'
+ Value: 290
+ SectionNumber: 6
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_LABEL
+ - Name: '$LN6'
+ Value: 291
+ SectionNumber: 6
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_LABEL
+ - Name: '.xdata$x'
+ Value: 0
+ SectionNumber: 8
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 60
+ NumberOfRelocations: 4
+ NumberOfLinenumbers: 0
+ CheckSum: 2900129504
+ Number: 0
+ - Name: '__sehtable$?foo@@YAXXZ'
+ Value: 32
+ SectionNumber: 8
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ - Name: '__sehtable$_main'
+ Value: 0
+ SectionNumber: 8
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ - Name: .rdata
+ Value: 0
+ SectionNumber: 9
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 24
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 1296623929
+ Number: 0
+ Selection: IMAGE_COMDAT_SELECT_ANY
+ - Name: '??_C at _0BI@BBHGNMOG at Destroying?5TestClass?$CB?$AN?6?$AA@'
+ Value: 0
+ SectionNumber: 9
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: ___security_cookie
+ Value: 0
+ SectionNumber: 0
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: .sxdata
+ Value: 0
+ SectionNumber: 10
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 4
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+...
Added: lld/trunk/test/COFF/seh.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/seh.test?rev=243182&view=auto
==============================================================================
--- lld/trunk/test/COFF/seh.test (added)
+++ lld/trunk/test/COFF/seh.test Fri Jul 24 18:51:14 2015
@@ -0,0 +1,24 @@
+# RUN: yaml2obj %p/Inputs/seh.obj.yaml > %t.obj
+#
+# RUN: lld -flavor link /out:%t.exe /subsystem:console /force /nodefaultlib %t.obj
+# RUN: llvm-objdump -private-headers %t.exe | FileCheck %s
+
+CHECK: Load configuration:
+CHECK: Timestamp: 0
+CHECK: Major Version: 0
+CHECK: Minor Version: 0
+CHECK: GlobalFlags Clear: 0
+CHECK: GlobalFlags Set: 0
+CHECK: Critical Section Default Timeout: 0
+CHECK: Decommit Free Block Threshold: 0
+CHECK: Decommit Total Free Threshold: 0
+CHECK: Lock Prefix Table: 0
+CHECK: Maximum Allocation Size: 0
+CHECK: Virtual Memory Threshold: 0
+CHECK: Process Affinity Mask: 0
+CHECK: Process Heap Flags: 0
+CHECK: CSD Version: 0
+CHECK: Security Cookie: 0
+CHECK: SEH Table: 4206592
+CHECK: SEH Count: 2
+CHECK: SEH Table: 0x80001b 0x8040ea
More information about the llvm-commits
mailing list