[PATCH] D39254: On FreeBSD, add -pthread to the flags for dynamic ASan tests

Dimitry Andric via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 14:30:14 PDT 2017


dim added a comment.

So if I *don't* add the -pthread flag, the test case executables have the following needed entries:

  $ readelf -dW /home/dim/obj/llvm-316264-trunk-freebsd12-i386-ninja-rel-1/runtimes/runtimes-bins/compiler-rt/test/asan/I386FreeBSDDynamicConfig/TestCases/Posix/Output/deep_call_stack.cc.tmp
  
  Dynamic section at offset 0xef0 contains 29 entries:
    Tag        Type                         Name/Value
   0x00000001 (NEEDED)                     Shared library: [libclang_rt.asan-i386.so]
   0x00000001 (NEEDED)                     Shared library: [libc++.so.1]
   0x00000001 (NEEDED)                     Shared library: [libcxxrt.so.1]
   0x00000001 (NEEDED)                     Shared library: [libm.so.5]
   0x00000001 (NEEDED)                     Shared library: [libc.so.7]

while the libclang_rt.asan-i386.so has:

  $ readelf -dW ~/obj/llvm-316264-trunk-freebsd12-i386-ninja-rel-1/lib/clang/6.0.0/lib/freebsd/libclang_rt.asan-i386.so
  
  Dynamic section at offset 0xb995c contains 30 entries:
    Tag        Type                         Name/Value
   0x00000001 (NEEDED)                     Shared library: [libstdc++.so.6]
   0x00000001 (NEEDED)                     Shared library: [libgcc_s.so.1]
   0x00000001 (NEEDED)                     Shared library: [libc.so.7]
   0x00000001 (NEEDED)                     Shared library: [librt.so.1]
   0x00000001 (NEEDED)                     Shared library: [libm.so.5]
   0x00000001 (NEEDED)                     Shared library: [libthr.so.3]
   0x0000000e (SONAME)                     Library soname: [libclang_rt.asan-i386.so]

When I run `ldd` on such a test case, the order shown is:

  libclang_rt.asan-i386.so => /home/dim/obj/llvm-316264-trunk-freebsd12-i386-ninja-rel-1/lib/clang/6.0.0/lib/freebsd/libclang_rt.asan-i386.so (0x28071000)
  libc++.so.1 => /usr/lib/libc++.so.1 (0x285c7000)
  libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x28689000)
  libm.so.5 => /lib/libm.so.5 (0x286a3000)
  libc.so.7 => /lib/libc.so.7 (0x286ce000)
  libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x28884000)
  libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x2896f000)
  librt.so.1 => /usr/lib/librt.so.1 (0x28984000)
  libthr.so.3 => /lib/libthr.so.3 (0x2898a000)

E.g. libthr.so.3 is at the end of the list.

However, If I do add the `-pthread` flag, the order in the test case executables becomes a little different:

  readelf -dW /home/dim/obj/llvm-316264-trunk-freebsd12-i386-ninja-rel-1/runtimes/runtimes-bins/compiler-rt/test/asan/I386FreeBSDDynamicConfig/TestCases/Posix/Output/deep_call_stack.cc.tmp
  
  Dynamic section at offset 0xee8 contains 30 entries:
    Tag        Type                         Name/Value
   0x00000001 (NEEDED)                     Shared library: [libclang_rt.asan-i386.so]
   0x00000001 (NEEDED)                     Shared library: [libc++.so.1]
   0x00000001 (NEEDED)                     Shared library: [libcxxrt.so.1]
   0x00000001 (NEEDED)                     Shared library: [libm.so.5]
   0x00000001 (NEEDED)                     Shared library: [libthr.so.3]
   0x00000001 (NEEDED)                     Shared library: [libc.so.7]

and then the `ldd` order becomes:

  libclang_rt.asan-i386.so => /home/dim/obj/llvm-316264-trunk-freebsd12-i386-ninja-rel-1/lib/clang/6.0.0/lib/freebsd/libclang_rt.asan-i386.so (0x28071000)
  libc++.so.1 => /usr/lib/libc++.so.1 (0x285c7000)
  libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x28689000)
  libm.so.5 => /lib/libm.so.5 (0x286a3000)
  libthr.so.3 => /lib/libthr.so.3 (0x286ce000)
  libc.so.7 => /lib/libc.so.7 (0x286f3000)
  libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x288a9000)
  libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x28994000)
  librt.so.1 => /usr/lib/librt.so.1 (0x289a9000)

Here, libthr.so.3 is loaded before libc.so.3, and apparently that works better, somehow.


https://reviews.llvm.org/D39254





More information about the llvm-commits mailing list