[llvm] r185872 - Stop emitting weak symbols into the "coal" sections.

Alexey Samsonov samsonov at google.com
Tue Jul 9 11:53:42 PDT 2013


On Tue, Jul 9, 2013 at 10:22 PM, Bill Wendling <isanbard at gmail.com> wrote:

> Okay. I need more information. I can't seem to run 'check-asan' on my
> machine:
>
> [bitters:llvm.obj] make check-asan
> make: *** No rule to make target `check-asan'.  Stop.
>

"check-asan" works in CMake build only.
This should work if you have LLVM checkout with Clang at tools/clang,
compiler-rt at projects/compiler-rt,
and configure it as, e.g.
$ cmake -DCMAKE_BUILD_TYPE=Release /path/to/llvm/checkout
$ make check-asan


>
> So how does one do that?
>
> Also, what version of Mac OS X and ld are you using?
>

We see the problem on Mac 10.8


>
> -bw
>
> On Jul 9, 2013, at 3:02 AM, Alexander Potapenko <glider at google.com> wrote:
>
> > Reverted in r185923.
> >
> > On Tue, Jul 9, 2013 at 1:28 PM, Alexander Potapenko <glider at google.com>
> wrote:
> >> Hi Bill,
> >>
> >> This patch has totally broken `make check-asan` on Mac.
> >> ld reports numerous warnings like this:
> >> 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.
> >> ld: warning: direct access in __ZL15TestLargeMallocm to global weak
> >> symbol
> __ZTSN7testing8internal15TestFactoryImplI36AddressSanitizer_HugeMallocTest_TestEE
> >> means the weak symbol cannot be overridden at runtime. This was likely
> >> caused by different translation units being compiled with different
> >> visibility settings.
> >>
> >> , after that a huge number of tests die with incorrect ASan reports.
> >>
> >> Reverting your patch locally fixes the problem on my machine.
> >>
> >> On Tue, Jul 9, 2013 at 1:34 AM, Bill Wendling <isanbard at gmail.com>
> wrote:
> >>> Author: void
> >>> Date: Mon Jul  8 16:34:52 2013
> >>> New Revision: 185872
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=185872&view=rev
> >>> Log:
> >>> 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
> >>>
> >>> <rdar://problem/14265330>
> >>>
> >>> Added:
> >>>    llvm/trunk/test/CodeGen/X86/no-coal-sections.ll
> >>> Modified:
> >>>    llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
> >>>    llvm/trunk/test/CodeGen/X86/global-sections.ll
> >>>
> >>> Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
> >>> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=185872&r1=185871&r2=185872&view=diff
> >>>
> ==============================================================================
> >>> --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
> >>> +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Mon Jul  8
> 16:34:52 2013
> >>> @@ -524,14 +524,14 @@ const MCSection *TargetLoweringObjectFil
> >>> 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.
> >>>
> >>> Modified: llvm/trunk/test/CodeGen/X86/global-sections.ll
> >>> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections.ll?rev=185872&r1=185871&r2=185872&view=diff
> >>>
> ==============================================================================
> >>> --- llvm/trunk/test/CodeGen/X86/global-sections.ll (original)
> >>> +++ llvm/trunk/test/CodeGen/X86/global-sections.ll Mon Jul  8 16:34:52
> 2013
> >>> @@ -20,7 +20,7 @@
> >>>
> >>> ; TODO: linux drops this into .rodata, we drop it into
> ".gnu.linkonce.r.G2"
> >>>
> >>> -; DARWIN: .section __TEXT,__const_coal,coalesced
> >>> +; DARWIN: .section __TEXT,__const
> >>> ; DARWIN: _G2:
> >>> ; DARWIN:    .long 42
> >>>
> >>> @@ -70,7 +70,6 @@
> >>> ; LINUX: .weak foo_20_bar
> >>> ; LINUX: foo_20_bar:
> >>>
> >>> -; DARWIN: .section             __DATA,__datacoal_nt,coalesced
> >>> ; DARWIN: .globl       "_foo bar"
> >>> ; DARWIN:      .weak_definition "_foo bar"
> >>> ; DARWIN: "_foo bar":
> >>> @@ -85,7 +84,7 @@
> >>> ; LINUX:   .byte       1
> >>> ; LINUX:   .size       G6, 1
> >>>
> >>> -; DARWIN:  .section __TEXT,__const_coal,coalesced
> >>> +; DARWIN:  .section __TEXT,__const
> >>> ; DARWIN:  .globl _G6
> >>> ; DARWIN:  .weak_definition _G6
> >>> ; DARWIN:_G6:
> >>> @@ -131,7 +130,7 @@
> >>> @G10 = weak global [100 x i32] zeroinitializer, align 32 ; <[100 x
> i32]*> [#uses=0]
> >>>
> >>>
> >>> -; DARWIN:      .section        __DATA,__datacoal_nt,coalesced
> >>> +; DARWIN:      .section        __DATA,__data
> >>> ; DARWIN: .globl _G10
> >>> ; DARWIN:      .weak_definition _G10
> >>> ; DARWIN:      .align  5
> >>>
> >>> Added: llvm/trunk/test/CodeGen/X86/no-coal-sections.ll
> >>> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/no-coal-sections.ll?rev=185872&view=auto
> >>>
> ==============================================================================
> >>> --- llvm/trunk/test/CodeGen/X86/no-coal-sections.ll (added)
> >>> +++ llvm/trunk/test/CodeGen/X86/no-coal-sections.ll Mon Jul  8
> 16:34:52 2013
> >>> @@ -0,0 +1,74 @@
> >>> +; RUN: llc < %s -mtriple x86_64-apple-macosx10 | FileCheck %s
> >>> +; <rdar://problem/14265330>
> >>> +
> >>> +; CHECK:     .section __TEXT,__text
> >>> +; CHECK-NOT: .section __TEXT,__textcoal_nt
> >>> +; CHECK:     .globl __ZN6TrickyIiLi0EEC1Ev
> >>> +
> >>> +; CHECK:     .section __DATA,__data
> >>> +; CHECK-NOT: .section __DATA,__datacoal_nt
> >>> +; CHECK:     .globl __ZTV6TrickyIiLi0EE
> >>> +
> >>> +; CHECK:     .section __TEXT,__const
> >>> +; CHECK-NOT: .section __TEXT,__const_coal
> >>> +; CHECK:     .globl __ZTS6TrickyIiLi0EE
> >>> +
> >>> +; CHECK:     .section __DATA,__data
> >>> +; CHECK-NOT: .section __DATA,__datacoal_nt
> >>> +; CHECK:     .globl __ZTI6TrickyIiLi0EE
> >>> +
> >>> +%class.Tricky = type { i32 (...)**, %union.anon }
> >>> +%union.anon = type { i32 }
> >>> +
> >>> + at _ZTV6TrickyIiLi0EE = linkonce_odr unnamed_addr constant [4 x i8*]
> [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI6TrickyIiLi0EE to i8*), i8*
> bitcast (void (%class.Tricky*)* @_ZN6TrickyIiLi0EED1Ev to i8*), i8* bitcast
> (void (%class.Tricky*)* @_ZN6TrickyIiLi0EED0Ev to i8*)]
> >>> + at _ZTVN10__cxxabiv117__class_type_infoE = external global i8*
> >>> + at _ZTS6TrickyIiLi0EE = linkonce_odr constant [15 x i8]
> c"6TrickyIiLi0EE\00"
> >>> + at _ZTI6TrickyIiLi0EE = linkonce_odr unnamed_addr constant { i8*, i8* }
> { i8* bitcast (i8** getelementptr inbounds (i8**
> @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr
> inbounds ([15 x i8]* @_ZTS6TrickyIiLi0EE, i32 0, i32 0) }
> >>> +
> >>> +; Function Attrs: nounwind ssp uwtable
> >>> +define i32 @main() {
> >>> +entry:
> >>> +  %ok = alloca %class.Tricky, align 8
> >>> +  call void @_ZN6TrickyIiLi0EEC1Ev(%class.Tricky* %ok)
> >>> +  ret i32 0
> >>> +}
> >>> +
> >>> +; Function Attrs: inlinehint nounwind ssp uwtable
> >>> +define linkonce_odr void @_ZN6TrickyIiLi0EEC1Ev(%class.Tricky*
> nocapture %this) unnamed_addr align 2 {
> >>> +entry:
> >>> +  tail call void @_ZN6TrickyIiLi0EEC2Ev(%class.Tricky* %this)
> >>> +  ret void
> >>> +}
> >>> +
> >>> +; Function Attrs: nounwind readnone ssp uwtable
> >>> +define linkonce_odr void @_ZN6TrickyIiLi0EED1Ev(%class.Tricky*
> nocapture %this) unnamed_addr align 2 {
> >>> +entry:
> >>> +  ret void
> >>> +}
> >>> +
> >>> +; Function Attrs: nounwind readnone ssp uwtable
> >>> +define linkonce_odr void @_ZN6TrickyIiLi0EED2Ev(%class.Tricky*
> nocapture %this) unnamed_addr align 2 {
> >>> +entry:
> >>> +  ret void
> >>> +}
> >>> +
> >>> +; Function Attrs: inlinehint nounwind ssp uwtable
> >>> +define linkonce_odr void @_ZN6TrickyIiLi0EEC2Ev(%class.Tricky*
> nocapture %this) unnamed_addr align 2 {
> >>> +entry:
> >>> +  %0 = getelementptr inbounds %class.Tricky* %this, i64 0, i32 0
> >>> +  store i32 (...)** bitcast (i8** getelementptr inbounds ([4 x i8*]*
> @_ZTV6TrickyIiLi0EE, i64 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8
> >>> +  ret void
> >>> +}
> >>> +
> >>> +; Function Attrs: nounwind ssp uwtable
> >>> +define linkonce_odr void @_ZN6TrickyIiLi0EED0Ev(%class.Tricky* %this)
> unnamed_addr align 2 {
> >>> +invoke.cont:
> >>> +  %0 = bitcast %class.Tricky* %this to i8*
> >>> +  tail call void @_ZdlPv(i8* %0)
> >>> +  ret void
> >>> +}
> >>> +
> >>> +declare i32 @__gxx_personality_v0(...)
> >>> +
> >>> +; Function Attrs: nounwind
> >>> +declare void @_ZdlPv(i8*)
> >>>
> >>>
> >>> _______________________________________________
> >>> llvm-commits mailing list
> >>> llvm-commits at cs.uiuc.edu
> >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >>
> >>
> >>
> >> --
> >> Alexander Potapenko
> >> Software Engineer
> >> Google Moscow
> >
> >
> >
> > --
> > Alexander Potapenko
> > Software Engineer
> > Google Moscow
>
>


-- 
Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130709/3d8829d2/attachment.html>


More information about the llvm-commits mailing list