malformed symbol
Hiroki Sato
hrs at FreeBSD.org
Wed Dec 14 22:53:42 UTC 2016
Hi,
I noticed that a simple USDT definition caused an odd error. The
source files in question are as follows (a complete tarball is
attached to this email):
sample.c:
| #include <sys/param.h>
| #include <stdlib.h>
| #include <unistd.h>
|
| #include "sample_probes.h"
|
| int
| main(void)
| {
| ssize_t i;
| char buf[80];
|
| i = read(STDIN_FILENO, buf, sizeof(buf));
| SAMPLE_FIRST_READ(i, buf);
|
| return (0);
| }
sample_probes.d:
| provider sample {
| probe first__read(ssize_t, char *);
| };
Makefile:
| PROG= sample
| MAN=
| SRCS= sample.c sample_probes.d
|
|.include <bsd.prog.mk>
Note that the program itself is useless because this is a minimal
working example to reproduce the symptom. It causes the following
error:
| dtrace -C -x nolibs -h -s sample_probes.d
| rm -f .depend
| echo sample.full: /usr/lib/libc.a >> .depend
| cc -O2 -pipe -g -I/var/home/hrs/sample -MD -MF.depend.sample.o -MTsample.o -std=gnu99 -fstack-protector-strong -Qunused-arguments -c sample.c -o sample.o
| dtrace -C -x nolibs -G -o sample_probes.o -s sample_probes.d sample.o
| cc -O2 -pipe -g -I/var/home/hrs/sample -std=gnu99 -fstack-protector-strong -Qunused-arguments -o sample.full sample.o sample_probes.o
| sample.o: In function `main':
| /var/home/hrs/sample/sample.c:13: undefined reference to `ead'
| cc: error: linker command failed with exit code 1 (use -v to see invocation)
| *** Error code 1
A symbol "read" in sample.o seems to be rewritten in the "dtrace -G"
line. Sample.o just after compilation of sample.c had the correct
symbol name like the following:
% nm sample.o
U __dtrace_sample___first__read
U __stack_chk_fail
U __stack_chk_guard
0000000000000000 T main
U read
% dtrace -C -x nolibs -G -o sample_probes.o -s sample_probes.d sample.o
% nm sample.o
0000000000000000 A __dtrace_sample___first-read
U __stack_chk_fail
U __stack_chk_guard
U ead
0000000000000000 T main
And it worked when I changed the probe name with "first__readx".
This was reproducible on 11.x and 12.x, not on 10.x. Could anyone
try this and let me know if this is reproducible on your 11.x or 12.x
box? I guess this is a regression of symbol rewrite routine such as
s/__/-/ in the dtrace utility while I have not investigated the
details yet. Or am I missing something here?
-- Hiroki
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sample-20161215-1.tar.gz
Type: application/octet-stream
Size: 436 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-dtrace/attachments/20161215/9d690bc5/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-dtrace/attachments/20161215/9d690bc5/attachment.sig>
More information about the freebsd-dtrace
mailing list