diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-11-21 05:38:58 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-11-21 05:38:58 +0000 |
commit | ac6d271cf95d6994c88ff8dcc096b98f33c50644 (patch) | |
tree | 5d7ca7984884ac7303aa6dcf36ba265dc6370779 /ldso | |
parent | e75a596ed9002cd24508e822b6e989ff05373334 (diff) |
Act more like the GNU version. Accept multiple args. Accept/ignore
the "--" option since we always do that anyways.
-Erik
Diffstat (limited to 'ldso')
-rw-r--r-- | ldso/util/ldd.c | 92 |
1 files changed, 62 insertions, 30 deletions
diff --git a/ldso/util/ldd.c b/ldso/util/ldd.c index 29c520c60..951c839fb 100644 --- a/ldso/util/ldd.c +++ b/ldso/util/ldd.c @@ -282,10 +282,6 @@ static int add_library(Elf32_Ehdr* ehdr, Elf32_Dyn* dynamic, char *strtab, int i if (!s || !strlen(s)) return 1; - /* We add libc.so.0 elsewhere */ - if (strcmp(s, UCLIBC_LDSO)==0) - return 1; - tmp = s; while (*tmp) { if (*tmp == '/') @@ -293,6 +289,14 @@ static int add_library(Elf32_Ehdr* ehdr, Elf32_Dyn* dynamic, char *strtab, int i tmp++; } + /* We add libc.so.0 elsewhere */ + if ((tmp=strrchr(interp, '/')) != NULL) + { + int len = strlen(interp_dir); + if (strcmp(s, interp+1+len)==0) + return 1; + } + for (cur = lib_list; cur; cur=cur->next) { /* Check if this library is already in the list */ tmp1 = tmp2 = cur->name; @@ -474,42 +478,70 @@ foo: int main( int argc, char** argv) { + int multi=0; int got_em_all=1; - char *filename = argv[1]; + char *filename = NULL; struct library *cur; - - if (!filename) { - fprintf(stderr, "No filename specified.\n"); + if (argc < 2) { + fprintf(stderr, "ldd: missing file arguments\n"); + fprintf(stderr, "Try `ldd --help' for more information.\n"); exit(EXIT_FAILURE); } + if (argc > 2) { + multi++; + } - find_dependancies(filename); - - while(got_em_all) { - got_em_all=0; - /* Keep walking the list till everybody is resolved */ - for (cur = lib_list; cur; cur=cur->next) { - if (cur->resolved == 0 && cur->path) { - got_em_all=1; - //printf("checking sub-depends for '%s\n", cur->path); - find_dependancies(cur->path); - cur->resolved = 1; + while (--argc > 0) { + ++argv; + + if(strcmp(*argv, "--")==0) { + /* Ignore "--" */ + continue; + } + + if(strcmp(*argv, "--help")==0) { + fprintf(stderr, "Usage: ldd [OPTION]... FILE...\n"); + fprintf(stderr, "\t--help\t\tprint this help and exit\n"); + exit(EXIT_FAILURE); + } + + filename=*argv; + if (!filename) { + fprintf(stderr, "No filename specified.\n"); + exit(EXIT_FAILURE); + } + + find_dependancies(filename); + + while(got_em_all) { + got_em_all=0; + /* Keep walking the list till everybody is resolved */ + for (cur = lib_list; cur; cur=cur->next) { + if (cur->resolved == 0 && cur->path) { + got_em_all=1; + //printf("checking sub-depends for '%s\n", cur->path); + find_dependancies(cur->path); + cur->resolved = 1; + } } } - } - - /* Print the list */ - got_em_all=0; - for (cur = lib_list; cur; cur=cur->next) { - got_em_all=1; - printf("\t%s => %s\n", cur->name, cur->path); + + /* Print the list */ + got_em_all=0; + if (multi) { + printf("%s:\n", *argv); + } + for (cur = lib_list; cur; cur=cur->next) { + got_em_all=1; + printf("\t%s => %s\n", cur->name, cur->path); + } + if (interp_dir && got_em_all==1) + printf("\t%s => %s\n", interp, interp); + if (got_em_all==0) + printf("\tnot a dynamic executable\n"); } - if (interp_dir && got_em_all==1) - printf("\t%s => %s\n", interp, interp); - if (got_em_all==0) - printf("\tnot a dynamic executable\n"); return 0; } |