From 59eaa3874663f80ce111a4781b8f1db82995210c Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 28 Jun 2013 20:05:11 +0000 Subject: DebugInfo: PR14728: TLS support Based on GCC's output for TLS variables (OP_constNu, x@dtpoff, OP_lo_user), this implements debug info support for TLS in ELF. Verified that this output is correct/sufficient on Linux (using gold - if you're using binutils-ld, you'll need something with the fix for http://sourceware.org/bugzilla/show_bug.cgi?id=15685 in it). Support on non-ELF is sort of "arbitrary" at the moment - if Apple folks want to discuss (or just go ahead & implement) how this should work in MachO, etc, I'm open. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185203 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/CodeGen/TargetLoweringObjectFileImpl.cpp') diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 7e7359a..69d5591 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -401,6 +401,10 @@ TargetLoweringObjectFileELF::InitializeELF(bool UseInitArray_) { SectionKind::getDataRel()); } +const MCSymbolRefExpr *TargetLoweringObjectFileELF::getDebugThreadLocalSymbol(const MCSymbol *Sym) const { + return MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_DTPOFF, getContext()); +} + //===----------------------------------------------------------------------===// // MachO //===----------------------------------------------------------------------===// -- cgit v1.1 From a35ae962918258207f9092ccbdf4fffa1f2c70f1 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 1 Jul 2013 21:45:25 +0000 Subject: PR16493: DebugInfo with TLS on PPC crashing due to invalid relocation Restrict the current TLS support to X86 ELF for now. Test that we don't produce it on PPC & we can flesh that test case out with the right thing once someone implements it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185389 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/CodeGen/TargetLoweringObjectFileImpl.cpp') diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 69d5591..7e7359a 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -401,10 +401,6 @@ TargetLoweringObjectFileELF::InitializeELF(bool UseInitArray_) { SectionKind::getDataRel()); } -const MCSymbolRefExpr *TargetLoweringObjectFileELF::getDebugThreadLocalSymbol(const MCSymbol *Sym) const { - return MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_DTPOFF, getContext()); -} - //===----------------------------------------------------------------------===// // MachO //===----------------------------------------------------------------------===// -- cgit v1.1 From 80646283796b20c6a1b7d8eb69ce6f0478d54383 Mon Sep 17 00:00:00 2001 From: Nico Rieck Date: Sat, 6 Jul 2013 12:13:10 +0000 Subject: MC: Implement COFF .linkonce directive git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185753 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/CodeGen/TargetLoweringObjectFileImpl.cpp') diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 7e7359a..3e1afc0 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -732,8 +732,8 @@ getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, } return getContext().getCOFFSection(Name, Characteristics, - Selection, - Kind); + Kind, + Selection); } static const char *getCOFFSectionPrefixForUniqueGlobal(SectionKind Kind) { @@ -769,7 +769,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT; return getContext().getCOFFSection(Name.str(), Characteristics, - COFF::IMAGE_COMDAT_SELECT_ANY, Kind); + Kind, COFF::IMAGE_COMDAT_SELECT_ANY); } if (Kind.isText()) -- cgit v1.1 From 8722e25715f9c56a1f2a03587211f2b0d98b330d Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 8 Jul 2013 21:34:52 +0000 Subject: Stop emitting weak symbols into the "coal" sections. The Mach-O linker has been able to support the weak-def bit on any symbol for quite a while now. The compiler however continued to place these symbols into a "coal" section, which required the linker to map them back to the base section name. Replace the sections like this: __TEXT/__textcoal_nt instead use __TEXT/__text __TEXT/__const_coal instead use __TEXT/__const __DATA/__datacoal_nt instead use __DATA/__data git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185872 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/CodeGen/TargetLoweringObjectFileImpl.cpp') diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 3e1afc0..c928945 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -524,14 +524,14 @@ const MCSection *TargetLoweringObjectFileMachO:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const { if (Kind.isText()) - return GV->isWeakForLinker() ? TextCoalSection : TextSection; - - // If this is weak/linkonce, put this in a coalescable section, either in text - // or data depending on if it is writable. + return TextSection; + + // If this is weak/linkonce, put this in a read only or data section depending + // on whether or not it's writable. if (GV->isWeakForLinker()) { if (Kind.isReadOnly()) - return ConstTextCoalSection; - return DataCoalSection; + return ReadOnlySection; + return DataSection; } // FIXME: Alignment check should be handled by section classifier. -- cgit v1.1 From 9467b3e0ac593571a205041c129ed5ae11bf9d1f Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Tue, 9 Jul 2013 10:00:16 +0000 Subject: Revert r185872 - "Stop emitting weak symbols into the "coal" sections" This patch broke `make check-asan` on Mac, causing ld warnings like the following one: ld: warning: direct access in __GLOBAL__I_a to global weak symbol ___asan_mapping_scale means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings. The resulting test binaries crashed with incorrect ASan warnings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185923 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/CodeGen/TargetLoweringObjectFileImpl.cpp') diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index c928945..3e1afc0 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -524,14 +524,14 @@ const MCSection *TargetLoweringObjectFileMachO:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const { if (Kind.isText()) - return TextSection; - - // If this is weak/linkonce, put this in a read only or data section depending - // on whether or not it's writable. + return GV->isWeakForLinker() ? TextCoalSection : TextSection; + + // If this is weak/linkonce, put this in a coalescable section, either in text + // or data depending on if it is writable. if (GV->isWeakForLinker()) { if (Kind.isReadOnly()) - return ReadOnlySection; - return DataSection; + return ConstTextCoalSection; + return DataCoalSection; } // FIXME: Alignment check should be handled by section classifier. -- cgit v1.1 From fdbea5107b5a8249421fd5e603a31f40f05ea25f Mon Sep 17 00:00:00 2001 From: Nico Rieck Date: Mon, 29 Jul 2013 13:58:39 +0000 Subject: Use proper section suffix for COFF weak symbols 32-bit symbols have "_" as global prefix, but when forming the name of COMDAT sections this prefix is ignored. The current behavior assumes that this prefix is always present which is not the case for 64-bit and names are truncated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187356 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/CodeGen/TargetLoweringObjectFileImpl.cpp') diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 3e1afc0..07cf871 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -726,9 +726,8 @@ getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, if (GV->isWeakForLinker()) { Selection = COFF::IMAGE_COMDAT_SELECT_ANY; Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT; - MCSymbol *Sym = Mang->getSymbol(GV); Name.append("$"); - Name.append(Sym->getName().begin() + 1, Sym->getName().end()); + Mang->getNameWithPrefix(Name, GV, false, false); } return getContext().getCOFFSection(Name, Characteristics, @@ -761,8 +760,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, if (GV->isWeakForLinker()) { const char *Prefix = getCOFFSectionPrefixForUniqueGlobal(Kind); SmallString<128> Name(Prefix, Prefix+strlen(Prefix)); - MCSymbol *Sym = Mang->getSymbol(GV); - Name.append(Sym->getName().begin() + 1, Sym->getName().end()); + Mang->getNameWithPrefix(Name, GV, false, false); unsigned Characteristics = getCOFFSectionFlags(Kind); -- cgit v1.1