[PATCH] D15049: [asan] Skip all non-shared objects in FindFirstDSOCallback.
Dimitry Andric via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 4 10:36:01 PST 2015
dim accepted this revision.
dim added a comment.
This revision is now accepted and ready to land.
Ok, this looks good to me. On Linux, however, this might slightly change the first DSO found, as long as it's *not* asan. With the example from `dl_iterate_phdr(3)` (slightly modified to print the type), I get this output on Linux:
$ ./dlip
name= (8 segments), type PT_PHDR
header 0: address= 0x400040
header 1: address= 0x400200
header 2: address= 0x400000
header 3: address= 0x6009a0
header 4: address= 0x6009b8
header 5: address= 0x40021c
header 6: address= 0x400848
header 7: address= (nil)
name=linux-vdso.so.1 (4 segments), type PT_LOAD
header 0: address=0x7ffcbed7f000
header 1: address=0x7ffcbed7f318
header 2: address=0x7ffcbed7f818
header 3: address=0x7ffcbed7f854
name=/lib/x86_64-linux-gnu/libc.so.6 (10 segments), type PT_PHDR
header 0: address=0x7f3ec9f70040
header 1: address=0x7f3eca0dc330
header 2: address=0x7f3ec9f70000
header 3: address=0x7f3eca30f740
header 4: address=0x7f3eca312ba0
header 5: address=0x7f3ec9f70270
header 6: address=0x7f3eca30f740
header 7: address=0x7f3eca0dc34c
header 8: address=0x7f3ec9f70000
header 9: address=0x7f3eca30f740
name=/lib64/ld-linux-x86-64.so.2 (7 segments), type PT_LOAD
header 0: address=0x7f3eca319000
header 1: address=0x7f3eca539c00
header 2: address=0x7f3eca539e70
header 3: address=0x7f3eca3191c8
header 4: address=0x7f3eca336440
header 5: address=0x7f3eca319000
header 6: address=0x7f3eca539c00
So whereas `libc.so.6` would be found earlier, it will now first find `ld-linux-x86-64.so.2`. I'm not sure why `libc.so.6` is identified as `PT_PHDR`, though.
When using `-fsanitize=address`, the output is changed to:
$ ./dlip
name= (8 segments), type PT_PHDR
header 0: address= 0x400040
header 1: address= 0x400200
header 2: address= 0x400000
header 3: address= 0x601478
header 4: address= 0x6014a8
header 5: address= 0x40021c
header 6: address= 0x4012d4
header 7: address= (nil)
name=linux-vdso.so.1 (4 segments), type PT_LOAD
header 0: address=0x7ffebd599000
header 1: address=0x7ffebd599318
header 2: address=0x7ffebd599818
header 3: address=0x7ffebd599854
name=/usr/lib/x86_64-linux-gnu/libasan.so.1 (7 segments), type PT_LOAD
header 0: address=0x7ff8acafc000
header 1: address=0x7ff8acd97a00
header 2: address=0x7ff8acd98848
header 3: address=0x7ff8acafc1c8
header 4: address=0x7ff8acd97a00
header 5: address=0x7ff8acb84d18
header 6: address=0x7ff8acafc000
name=/lib/x86_64-linux-gnu/libc.so.6 (10 segments), type PT_PHDR
header 0: address=0x7ff8ac753040
header 1: address=0x7ff8ac8bf330
header 2: address=0x7ff8ac753000
header 3: address=0x7ff8acaf2740
header 4: address=0x7ff8acaf5ba0
header 5: address=0x7ff8ac753270
header 6: address=0x7ff8acaf2740
header 7: address=0x7ff8ac8bf34c
header 8: address=0x7ff8ac753000
header 9: address=0x7ff8acaf2740
name=/lib/x86_64-linux-gnu/libpthread.so.0 (9 segments), type PT_PHDR
header 0: address=0x7ff8ac536040
header 1: address=0x7ff8ac5481c0
header 2: address=0x7ff8ac536000
header 3: address=0x7ff8ac74db80
header 4: address=0x7ff8ac74dd50
header 5: address=0x7ff8ac536238
header 6: address=0x7ff8ac5481dc
header 7: address=0x7ff8ac536000
header 8: address=0x7ff8ac74db80
name=/lib/x86_64-linux-gnu/libdl.so.2 (9 segments), type PT_PHDR
header 0: address=0x7ff8ac332040
header 1: address=0x7ff8ac333a30
header 2: address=0x7ff8ac332000
header 3: address=0x7ff8ac534d60
header 4: address=0x7ff8ac534d88
header 5: address=0x7ff8ac332238
header 6: address=0x7ff8ac333a4c
header 7: address=0x7ff8ac332000
header 8: address=0x7ff8ac534d60
name=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 (8 segments), type PT_LOAD
header 0: address=0x7ff8ac027000
header 1: address=0x7ff8ac313108
header 2: address=0x7ff8ac31a178
header 3: address=0x7ff8ac027200
header 4: address=0x7ff8ac313108
header 5: address=0x7ff8ac0f13ec
header 6: address=0x7ff8ac027000
header 7: address=0x7ff8ac313108
name=/lib/x86_64-linux-gnu/libm.so.6 (9 segments), type PT_PHDR
header 0: address=0x7ff8abd26040
header 1: address=0x7ff8abe1d1f0
header 2: address=0x7ff8abd26000
header 3: address=0x7ff8ac025d90
header 4: address=0x7ff8ac025da8
header 5: address=0x7ff8abd26238
header 6: address=0x7ff8abe1d20c
header 7: address=0x7ff8abd26000
header 8: address=0x7ff8ac025d90
name=/lib64/ld-linux-x86-64.so.2 (7 segments), type PT_LOAD
header 0: address=0x7ff8ad9d3000
header 1: address=0x7ff8adbf3c00
header 2: address=0x7ff8adbf3e70
header 3: address=0x7ff8ad9d31c8
header 4: address=0x7ff8ad9f0440
header 5: address=0x7ff8ad9d3000
header 6: address=0x7ff8adbf3c00
name=/lib/x86_64-linux-gnu/libgcc_s.so.1 (6 segments), type PT_LOAD
header 0: address=0x7ff8abb10000
header 1: address=0x7ff8abd25450
header 2: address=0x7ff8abd25470
header 3: address=0x7ff8abb10190
header 4: address=0x7ff8abb23490
header 5: address=0x7ff8abb10000
As you can see, `libasan.so.1` is the first PT_LOAD segment.
On FreeBSD, the output is rather different:
$ ./dlip
name=/tmp/dlip (8 segments), type PT_PHDR
header 0: address= 0x8048034
header 1: address= 0x8048134
header 2: address= 0x8048000
header 3: address= 0x8049920
header 4: address= 0x8049934
header 5: address= 0x804814c
header 6: address= 0x80488d4
header 7: address= 0x0
name=/lib/libc.so.7 (6 segments), type PT_LOAD
header 0: address=0x2806e000
header 1: address=0x281ca000
header 2: address=0x281ccad8
header 3: address=0x281ca000
header 4: address=0x281c98e8
header 5: address=0x2806e000
name=/libexec/ld-elf.so.1 (0 segments), type (null phdr)
E.g. here `libc.so.7` will be found as the first `PT_LOAD` segment. (Since I don't have a dynamic asan lib yet, I can't show the output for that case.)
http://reviews.llvm.org/D15049
More information about the llvm-commits
mailing list