[PATCH] D15049: [asan] Skip all non-shared objects in FindFirstDSOCallback.

Dimitry Andric via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 7 09:41:49 PST 2015


dim added inline comments.

================
Comment at: lib/asan/asan_linux.cc:100
@@ +99,3 @@
+  // not a PT_LOAD type.
+  if (info->dlpi_phdr->p_type != PT_LOAD)
+	  return 0;
----------------
eugenis wrote:
> You are looking at the first segment type. In libc on linux it happens to be PT_PHDR for some reason, and PT_LOAD's are the 3rd and the 4th. You should probably iterate.
> 
You mean iterate through the `info->dlpi_phdr` array?  But as far as I understand, this shows the segments loaded by that particular library.  So do you think that searching recursively will help here?

Also, on FreeBSD, which this change was meant for, this would actually not help, since the executable itself also has PT_LOAD segments.  I.e., if I print the contents of the `dlpi_phdr` array, I see this:

```
name=/tmp/dlip (8 segments), type PT_PHDR
		 header  0: address= 0x8048034, type=PT_PHDR
		 header  1: address= 0x8048134, type=PT_INTERP
		 header  2: address= 0x8048000, type=PT_LOAD
		 header  3: address= 0x8049ab4, type=PT_LOAD
		 header  4: address= 0x8049ac8, type=PT_DYNAMIC
		 header  5: address= 0x804814c, type=PT_NOTE
		 header  6: address= 0x8048a68, type=PT_GNU_EH_FRAME
		 header  7: address=       0x0, type=PT_GNU_STACK
name=/lib/libc.so.7 (6 segments), type PT_LOAD
		 header  0: address=0x2806e000, type=PT_LOAD
		 header  1: address=0x281ca000, type=PT_LOAD
		 header  2: address=0x281ccad8, type=PT_DYNAMIC
		 header  3: address=0x281ca000, type=PT_TLS
		 header  4: address=0x281c98e8, type=PT_GNU_EH_FRAME
		 header  5: address=0x2806e000, type=PT_GNU_STACK
name=/libexec/ld-elf.so.1 (0 segments), type (null phdr)
```
In short, I'm not sure how to distinguish a shared library from the main executable this way.  @dankm, any idea?


http://reviews.llvm.org/D15049





More information about the llvm-commits mailing list