eugenis added a comment. One idea: it looks like we can rely on the fact that the main executable is the first one in dl_iterate_phdr (is it? what about LD_PRELOAD?). If so, you can walk its dynamic section and look for DT_NEEDED records. http://reviews.llvm.org/D15049