Bug#994530: binutils: ld generates corrupted binaries with clang -fsanitize=address -lc

Aurelien Jarno aurel32 at debian.org
Fri Sep 17 11:45:40 BST 2021


Package: binutils
Version: 2.37-5
Severity: serious
Tags: upstream
X-Debbugs-Cc: debian-glibc at lists.debian.org, pkg-llvm-team at lists.alioth.debian.org

When clang is used with both -fsanitize=address and -lc, ld silently generates
binaries contains corrupted symbols as reported by readelf:

$ clang-11 -fsanitize=address test_asan_lc.c -o test_asan_lc -lc
$ readelf -a test_asan_lc | grep '<corrupt>'
   634: 0000000000483090     9 FUNC    WEAK   DEFAULT   15 longjmp@@<corrupt>
  1905: 0000000000483120     9 FUNC    WEAK   DEFAULT   15 siglongjmp@@<corrupt>

This doesn't happen when not using -lc
$ clang-11 -fsanitize=address test_asan_lc.c -o test_asan_lc
$ readelf -a test_asan_lc | grep '<corrupt>'

The issues happens at least on amd64 and arm64. Up to know ld.so has
been able to work despite these broken symbols. Following the move of
the pthread_gettattr_np symbols from libpthread.so to libc.so [1], this
is not longer the case on arm64, where ld.so fails when looking up the
longjmp symbol.

This causes the llvm-toolchain-11 [2] and llvm-toolchain-12 [3] to fail,
blocking the glibc 2.32 transition.

Please find attached the test_asan_lc.c source code, as well as a
reproducer calling ld directly with all the arm64 objects included.

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=07a73d521988a7fdea1bb3c3b5bbb2b23a0da2e1
[2] https://ci.debian.net/data/autopkgtest/testing/arm64/l/llvm-toolchain-11/15302971/log.gz
[3] https://ci.debian.net/data/autopkgtest/unstable/arm64/l/llvm-toolchain-12/15039509/log.gz
-------------- next part --------------
// Test asan with lc https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=876973
//
// REQUIRES: clang
// RUN: %clang -fsanitize=address %s -o %t -lc
// RUN: %t
// XFAIL: i686, i386

#include <stdio.h>
int main(int argc, char **argv)
{
   printf("Hello world!\n");
   return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-clang-asan-lc.tar.xz
Type: application/x-xz
Size: 1508320 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-llvm-team/attachments/20210917/c4cc3a84/attachment-0001.xz>


More information about the Pkg-llvm-team mailing list