Status: Accepted
Owner: samso...@google.com
Labels: Type-Defect Priority-Medium
New issue 344 by dvyu...@google.com: Clang driver incorrectly handles
-Wl,-r flag
https://code.google.com/p/address-sanitizer/issues/detail?id=344
Moving from Go repo as it seems to be clang issue (and gcc works fine):
https://code.google.com/p/go/issues/detail?id=8788
go version go1.3 linux/amd64
clang version 3.6.0 (217929)
The program is:
package main
// void foo() {}
import "C"
func main() {
C.foo()
}
$ CC="clang -fsanitize=address" go run src.go
/var/tmp/go-link-FimrBB/000000.o:(.data._ZN11__sanitizer15IOCTL_KDGKBSENTE+0x0):
multiple
definition of `__sanitizer::IOCTL_KDGKBSENT'
/ssd/src/llvm/build/bin/../lib/clang/3.6.0/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_platform_limits_posix.cc.o):(.data._ZN11__sanitizer15IOCTL_KDGKBSENTE+0x0):
first
defined here
/var/tmp/go-link-FimrBB/000000.o: In function `__interceptor_xdr_float':
While gcc 4.8.2 works fine.
gcc uses shared asan runtime, and so it tolerates some issues in build
process:
$ ldd src
libasan.so.0 => /usr/lib/x86_64-linux-gnu/libasan.so.0
(0x00007fae89644000)
while clang links asan runtime statically, and some issue in cgo build
process causes multiple symbol errors.
The issue is in clang driver, it incorrectly handles -r linker flag. One of
the objects is build as:
clang -I . -fsanitize=address -fPIC -m64 -pthread -fno-caret-diagnostics
-Qunused-arguments -fmessage-length=0 -o
$WORK/command-line-arguments/_obj/_all.o
$WORK/command-line-arguments/_obj/_cgo_export.o
$WORK/command-line-arguments/_obj/src.cgo2.o -g -O2 -Wl,-r -nostdlib
/usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a
It's kind of linking, but this object is later linked again:
pack r $WORK/command-line-arguments.a
$WORK/command-line-arguments/_obj/_cgo_import.6
$WORK/command-line-arguments/_obj/_cgo_defun.6
$WORK/command-line-arguments/_obj/_all.o # internal
cd .
/usr/lib/google-golang/pkg/tool/linux_amd64/6l -o
$WORK/command-line-arguments/_obj/exe/src -L $WORK -w -extld=clang
-extldflags=-fsanitize=address $WORK/command-line-arguments.a
So one asan runtime comes from _all.o (incorrectly) and another from
implicitly added by driver -lasan.
Driver must not link in asan runtime if -Wl,-r is present.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to address-sanitizer+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.