hookize the cygwin ".linkonce" directive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93855 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-19 05:08:13 +00:00
parent 619ea855e7
commit 41eb8b4771
4 changed files with 20 additions and 12 deletions

View File

@ -226,6 +226,10 @@ namespace llvm {
/// WeakDefDirective - This directive, if non-null, is used to declare a /// WeakDefDirective - This directive, if non-null, is used to declare a
/// global as being a weak defined symbol. /// global as being a weak defined symbol.
const char *WeakDefDirective; // Defaults to NULL. const char *WeakDefDirective; // Defaults to NULL.
/// LinkOnceDirective - This directive, if non-null is used to declare a
/// global as being a weak defined symbol. This is used on cygwin/mingw.
const char *LinkOnceDirective; // Defaults to NULL.
/// HiddenDirective - This directive, if non-null, is used to declare a /// HiddenDirective - This directive, if non-null, is used to declare a
/// global or function as having hidden visibility. /// global or function as having hidden visibility.
@ -426,12 +430,9 @@ namespace llvm {
const char *getUsedDirective() const { const char *getUsedDirective() const {
return UsedDirective; return UsedDirective;
} }
const char *getWeakRefDirective() const { const char *getWeakRefDirective() const { return WeakRefDirective; }
return WeakRefDirective; const char *getWeakDefDirective() const { return WeakDefDirective; }
} const char *getLinkOnceDirective() const { return LinkOnceDirective; }
const char *getWeakDefDirective() const {
return WeakDefDirective;
}
const char *getHiddenDirective() const { const char *getHiddenDirective() const {
return HiddenDirective; return HiddenDirective;
} }

View File

@ -62,6 +62,7 @@ MCAsmInfo::MCAsmInfo() {
UsedDirective = 0; UsedDirective = 0;
WeakRefDirective = 0; WeakRefDirective = 0;
WeakDefDirective = 0; WeakDefDirective = 0;
LinkOnceDirective = 0;
// FIXME: These are ELFish - move to ELFMAI. // FIXME: These are ELFish - move to ELFMAI.
HiddenDirective = "\t.hidden\t"; HiddenDirective = "\t.hidden\t";
ProtectedDirective = "\t.protected\t"; ProtectedDirective = "\t.protected\t";

View File

@ -25,6 +25,7 @@ MCAsmInfoCOFF::MCAsmInfoCOFF() {
HiddenDirective = NULL; HiddenDirective = NULL;
PrivateGlobalPrefix = "L"; // Prefix for private global symbols PrivateGlobalPrefix = "L"; // Prefix for private global symbols
WeakRefDirective = "\t.weak\t"; WeakRefDirective = "\t.weak\t";
LinkOnceDirective = "\t.linkonce same_size\n";
SetDirective = "\t.set\t"; SetDirective = "\t.set\t";
// Set up DWARF directives // Set up DWARF directives

View File

@ -727,12 +727,16 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
if (Subtarget->isTargetDarwin()) { if (const char *WeakDef = MAI->getWeakDefDirective()) {
// .globl _foo
OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global); OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
O << MAI->getWeakDefDirective() << *GVarSym << '\n'; // .weak_definition _foo
} else if (Subtarget->isTargetCygMing()) { O << WeakDef << *GVarSym << '\n';
} else if (const char *LinkOnce = MAI->getLinkOnceDirective()) {
// .globl _foo
OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global); OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
O << "\t.linkonce same_size\n"; // .linkonce same_size
O << LinkOnce;
} else } else
O << "\t.weak\t" << *GVarSym << '\n'; O << "\t.weak\t" << *GVarSym << '\n';
break; break;
@ -741,7 +745,8 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
// FIXME: appending linkage variables should go into a section of // FIXME: appending linkage variables should go into a section of
// their name or something. For now, just emit them as external. // their name or something. For now, just emit them as external.
case GlobalValue::ExternalLinkage: case GlobalValue::ExternalLinkage:
// If external or appending, declare as a global symbol // If external or appending, declare as a global symbol.
// .globl _foo
OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global); OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
break; break;
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
@ -753,7 +758,7 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
EmitAlignment(AlignLog, GVar); EmitAlignment(AlignLog, GVar);
O << *GVarSym << ":"; O << *GVarSym << ":";
if (VerboseAsm){ if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << ' '; O << MAI->getCommentString() << ' ';
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());