1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

Dllexport stuff cleanup:

1. Emit external function type information for all COFF targets since it's
a feature of object format
2. Emit linker directives only for cygming (since this is ld-specific stuff)

llvm-svn: 84214
This commit is contained in:
Anton Korobeynikov 2009-10-15 22:36:18 +00:00
parent c0762ba283
commit 7d6c12de5b

View File

@ -874,24 +874,9 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
}
if (Subtarget->isTargetCOFF()) {
// Necessary for dllexport support
std::vector<std::string> DLLExportedFns, DLLExportedGlobals;
X86COFFMachineModuleInfo &COFFMMI =
MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
TargetLoweringObjectFileCOFF &TLOFCOFF =
static_cast<TargetLoweringObjectFileCOFF&>(getObjFileLowering());
for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
if (I->hasDLLExportLinkage())
DLLExportedFns.push_back(Mang->getMangledName(I));
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I)
if (I->hasDLLExportLinkage())
DLLExportedGlobals.push_back(Mang->getMangledName(I));
if (Subtarget->isTargetCygMing()) {
// Emit type information for external functions
for (X86COFFMachineModuleInfo::stub_iterator I = COFFMMI.stub_begin(),
E = COFFMMI.stub_end(); I != E; ++I) {
@ -900,6 +885,27 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
<< ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
<< ";\t.endef\n";
}
if (Subtarget->isTargetCygMing()) {
// Necessary for dllexport support
std::vector<std::string> DLLExportedFns, DLLExportedGlobals;
TargetLoweringObjectFileCOFF &TLOFCOFF =
static_cast<TargetLoweringObjectFileCOFF&>(getObjFileLowering());
for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
if (I->hasDLLExportLinkage()) {
std::string Name = Mang->getMangledName(I);
COFFMMI.DecorateCygMingName(Name, I, *TM.getTargetData());
DLLExportedFns.push_back(Name);
}
for (Module::const_global_iterator I = M.global_begin(),
E = M.global_end(); I != E; ++I)
if (I->hasDLLExportLinkage()) {
std::string Name = Mang->getMangledName(I);
COFFMMI.DecorateCygMingName(Name, I, *TM.getTargetData());
DLLExportedGlobals.push_back(Mang->getMangledName(I));
}
// Output linker support code for dllexported globals on windows.
@ -907,7 +913,6 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve",
true,
SectionKind::getMetadata()));
for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i)
O << "\t.ascii \" -export:" << DLLExportedGlobals[i] << ",data\"\n";
@ -915,6 +920,7 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
O << "\t.ascii \" -export:" << DLLExportedFns[i] << "\"\n";
}
}
}
}