diff options
-rw-r--r-- | trunk/ChangeLog | 15 | ||||
-rw-r--r-- | trunk/src/cxx.c | 5 | ||||
-rw-r--r-- | trunk/src/gather.c | 111 | ||||
-rw-r--r-- | trunk/src/main.c | 9 | ||||
-rw-r--r-- | trunk/src/prelink.h | 7 | ||||
-rw-r--r-- | trunk/src/verify.c | 7 | ||||
-rwxr-xr-x | trunk/testsuite/quick2.sh | 8 |
7 files changed, 112 insertions, 50 deletions
diff --git a/trunk/ChangeLog b/trunk/ChangeLog index 75baac9..2f854bd 100644 --- a/trunk/ChangeLog +++ b/trunk/ChangeLog @@ -1,3 +1,18 @@ +2007-10-04 Jakub Jelinek <jakub@redhat.com> + + * src/prelink.h (read_config): New prototype. + (gather_config, blacklist_from_config): Remove argument. + * src/gather.c (struct config_line): New type. + (config_lines, config_end): New variables. + (read_config): New function. + (gather_config, blacklist_from_config): Walk config_lines + chain instead of reading the config file. + * src/verify.c (prelink_verify): Call read_config. Don't + pass any argument to gather_config. + * src/main.c (main): Likewise. Also for blacklist_from_config. + * testsuite/quick2.sh: Use new -c etc/prelink.conf.d/*.conf + feature in prelink.conf and multiple config snippets. + 2007-06-27 Jakub Jelinek <jakub@redhat.com> * testsuite/reloc2.sh: If libs aren't built with -fpic, diff --git a/trunk/src/cxx.c b/trunk/src/cxx.c index b3530f0..738431b 100644 --- a/trunk/src/cxx.c +++ b/trunk/src/cxx.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002, 2003 Red Hat, Inc. +/* Copyright (C) 2001, 2002, 2003, 2007 Red Hat, Inc. Written by Jakub Jelinek <jakub@redhat.com>, 2001. This program is free software; you can redistribute it and/or modify @@ -187,7 +187,6 @@ remove_redundant_cxx_conflicts (struct prelink_info *info) n = find_cxx_sym (info, info->conflict_rela[i].r_offset, &fcs1, reloc_size); - name = (const char *) fcs1.strtab->d_buf + fcs1.sym.st_name; state = 0; if (n == -1) continue; @@ -200,6 +199,8 @@ remove_redundant_cxx_conflicts (struct prelink_info *info) if (secname == NULL) continue; + name = (const char *) fcs1.strtab->d_buf + fcs1.sym.st_name; + for (k = 0; specials[k].prefix; ++k) if (ELF32_ST_VISIBILITY (fcs1.sym.st_other) == STV_DEFAULT && fcs1.sym.st_info == specials[k].st_info diff --git a/trunk/src/gather.c b/trunk/src/gather.c index a3d0870..72d2e41 100644 --- a/trunk/src/gather.c +++ b/trunk/src/gather.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc. +/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc. Written by Jakub Jelinek <jakub@redhat.com>, 2001. This program is free software; you can redistribute it and/or modify @@ -1014,13 +1014,20 @@ gather_object (const char *name, int deref, int onefs) return gather_binlib (name, &st); } +static struct config_line +{ + struct config_line *next; + char line[1]; +} *config_lines, **config_end = &config_lines; + int -gather_config (const char *config) +read_config (const char *config) { FILE *file = fopen (config, "r"); char *line = NULL; - size_t len; + size_t len, llen; int ret = 0; + struct config_line *c; if (file == NULL) { @@ -1028,12 +1035,9 @@ gather_config (const char *config) return 1; } - implicit = 1; do { ssize_t i = getline (&line, &len, file); - int deref = 0; - int onefs = 0; char *p; if (i < 0) @@ -1047,6 +1051,62 @@ gather_config (const char *config) *p = '\0'; p = line + strspn (line, " \t"); + if (p[0] == '-' && p[1] == 'c' && (p[2] == ' ' || p[2] == '\t')) + { + glob_t g; + p += 2 + strspn (p + 2, " \t"); + + if (!glob (p, GLOB_BRACE, NULL, &g)) + { + size_t n; + + for (n = 0; n < g.gl_pathc; ++n) + if (read_config (g.gl_pathv[n])) + { + ret = 1; + break; + } + + globfree (&g); + if (ret) + break; + } + continue; + } + + llen = strlen (p); + c = malloc (sizeof (*c) + llen); + if (c == NULL) + { + error (0, ENOMEM, "Could not cache config file"); + ret = 1; + break; + } + + c->next = NULL; + memcpy (c->line, p, llen + 1); + *config_end = c; + config_end = &c->next; + } + while (!feof (file)); + + free (line); + fclose (file); + return ret; +} + +int +gather_config (void) +{ + struct config_line *c; + int ret = 0; + + implicit = 1; + for (c = config_lines; c; c = c->next) + { + int deref = 0; + int onefs = 0; + char *p = c->line; while (*p == '-') { @@ -1054,7 +1114,7 @@ gather_config (const char *config) { case 'h': deref = 1; break; case 'l': onefs = 1; break; - case 'b': *p = '\0'; continue; + case 'b': p = ""; continue; default: error (0, 0, "Unknown directory option `%s'\n", p); break; @@ -1097,10 +1157,8 @@ gather_config (const char *config) break; } } - } while (!feof (file)); + } - free (line); - fclose (file); implicit = 0; return ret; } @@ -1278,39 +1336,18 @@ add_blacklist_ext (const char *ext) } int -blacklist_from_config (const char *config) +blacklist_from_config (void) { - FILE *file = fopen (config, "r"); - char *line = NULL; - size_t len; + struct config_line *c; int ret = 0; - if (file == NULL) - { - error (0, errno, "Can't open configuration file %s", config); - return 1; - } - implicit = 1; - do + for (c = config_lines; c; c = c->next) { - ssize_t i = getline (&line, &len, file); int deref = 0; int onefs = 0; int blacklist = 0; - char *p; - - if (i < 0) - break; - - if (line[i - 1] == '\n') - line[i - 1] = '\0'; - - p = strchr (line, '#'); - if (p != NULL) - *p = '\0'; - - p = line + strspn (line, " \t"); + char *p = c->line; while (*p == '-') { @@ -1364,10 +1401,8 @@ blacklist_from_config (const char *config) break; } } - } while (!feof (file)); + } - free (line); - fclose (file); implicit = 0; return ret; } diff --git a/trunk/src/main.c b/trunk/src/main.c index 9c8b082..144ce84 100644 --- a/trunk/src/main.c +++ b/trunk/src/main.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002, 2003, 2004, 2005 Red Hat, Inc. +/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 Red Hat, Inc. Written by Jakub Jelinek <jakub@redhat.com>, 2001. This program is free software; you can redistribute it and/or modify @@ -383,13 +383,16 @@ main (int argc, char *argv[]) return failures; } - if (blacklist_from_config (prelink_conf)) + if (read_config (prelink_conf)) + return EXIT_FAILURE; + + if (blacklist_from_config ()) return EXIT_FAILURE; if (quick) prelink_load_cache (); - if (gather_config (prelink_conf)) + if (gather_config ()) return EXIT_FAILURE; while (remaining < argc) diff --git a/trunk/src/prelink.h b/trunk/src/prelink.h index 5aedaf6..8dc39e1 100644 --- a/trunk/src/prelink.h +++ b/trunk/src/prelink.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc. +/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc. Written by Jakub Jelinek <jakub@redhat.com>, 2001. This program is free software; you can redistribute it and/or modify @@ -461,10 +461,11 @@ int prelink_undo (DSO *dso); int prelink_verify (const char *filename); int gather_object (const char *dir, int deref, int onefs); -int gather_config (const char *config); +int read_config (const char *config); +int gather_config (void); int gather_check_libs (void); int add_to_blacklist (const char *name, int deref, int onefs); -int blacklist_from_config (const char *config); +int blacklist_from_config (void); FILE *execve_open (const char *path, char *const argv[], char *const envp[]); int execve_close (FILE *f); diff --git a/trunk/src/verify.c b/trunk/src/verify.c index 7945ced..7abc945 100644 --- a/trunk/src/verify.c +++ b/trunk/src/verify.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2006 Red Hat, Inc. +/* Copyright (C) 2002, 2003, 2006, 2007 Red Hat, Inc. Written by Jakub Jelinek <jakub@redhat.com>, 2002. This program is free software; you can redistribute it and/or modify @@ -227,7 +227,10 @@ prelink_verify (const char *filename) goto failure; } - if (gather_config (prelink_conf)) + if (read_config (prelink_conf)) + goto failure; + + if (gather_config ()) goto failure; if (gather_object (filename, 0, 0)) diff --git a/trunk/testsuite/quick2.sh b/trunk/testsuite/quick2.sh index 131795e..b999786 100755 --- a/trunk/testsuite/quick2.sh +++ b/trunk/testsuite/quick2.sh @@ -116,8 +116,12 @@ echo 'int main () { return 0; }' \ | $CCLINK -o quick2.tree/usr/bin/bin12 -pie -fPIE -xc - -xnone cat > quick2.tree/etc/prelink.conf <<EOF -b *.sh --b *.py --b b*11*r[hijk]*t +-c quick2.tree/etc/prelink.conf.d/*.conf +EOF +mkdir quick2.tree/etc/prelink.conf.d +echo '-b *.py' > quick2.tree/etc/prelink.conf.d/py.conf +echo '-b b*11*r[hijk]*t' > quick2.tree/etc/prelink.conf.d/script.conf +cat > quick2.tree/etc/prelink.conf.d/rest.conf <<EOF quick2.tree/usr/bin quick2.tree/lib quick2.tree/usr/lib |