diff options
author | Roland McGrath <roland@hack.frob.com> | 2012-01-20 11:40:59 -0800 |
---|---|---|
committer | Roland McGrath <roland@hack.frob.com> | 2012-01-20 11:40:59 -0800 |
commit | 8592478d3bd1a021c0b51ace768b8ef944b13cf1 (patch) | |
tree | dd51295226734916ae5e3fd295130442b29d62c3 | |
parent | b8ff18e0e8b8631fcc449cbd5a1ceba3f4a73e0d (diff) |
Support -D in ranlib as in ar.
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/ChangeLog | 15 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/ar.c | 19 | ||||
-rw-r--r-- | src/arlib-argp.c | 67 | ||||
-rw-r--r-- | src/arlib.c | 5 | ||||
-rw-r--r-- | src/arlib.h | 11 | ||||
-rw-r--r-- | src/ranlib.c | 4 |
8 files changed, 106 insertions, 20 deletions
@@ -5,6 +5,7 @@ libdw: Support reading .zdebug_* DWARF sections compressed via zlib. nm: Support C++ demangling. ar: Support D modifier for "deterministic output" with no uid/gid/mtime info. +ranlib: Support -D flag with same meaning. Version 0.152 diff --git a/src/ChangeLog b/src/ChangeLog index bef7f943..22212f9b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2012-01-20 Roland McGrath <roland@hack.frob.com> + + * ranlib.c (argp): Use arlib_argp_children. + + * arlib.c (arlib_init): Obey arlib_deterministic_output. + + * arlib-argp.c: New file. + * Makefile.am (libar_a_SOURCES): Add it. + * arlib.h (arlib_deterministic_output, arlib_argp_children): + Declare new variables. + * ar.c (deterministic_output): Variable removed. + (do_oper_insert): Use arlib_deterministic_output instead. + (options, parse_opt): Don't handle -D here. Add group numbers. + (argp): Use arlib_argp_children. + 2011-12-20 Roland McGrath <roland@hack.frob.com> * readelf.c (print_debug): Initialize DUMMY_DBG.elf. diff --git a/src/Makefile.am b/src/Makefile.am index 4d1484c2..dc835cbd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to create Makefile.in ## -## Copyright (C) 1996-2011 Red Hat, Inc. +## Copyright (C) 1996-2012 Red Hat, Inc. ## This file is part of Red Hat elfutils. ## ## Red Hat elfutils is free software; you can redistribute it and/or modify @@ -67,7 +67,7 @@ endif ld_SOURCES = ld.c ldgeneric.c ldlex.l ldscript.y symbolhash.c sectionhash.c \ versionhash.c -libar_a_SOURCES = arlib.c arlib2.c +libar_a_SOURCES = arlib.c arlib2.c arlib-argp.c noinst_HEADERS = ld.h symbolhash.h sectionhash.h versionhash.h \ ldscript.h xelf.h unaligned.h @@ -73,7 +73,7 @@ ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT; /* Definitions of arguments for argp functions. */ static const struct argp_option options[] = { - { NULL, 0, NULL, 0, N_("Commands:"), 0 }, + { NULL, 0, NULL, 0, N_("Commands:"), 1 }, { NULL, 'd', NULL, 0, N_("Delete files from archive."), 0 }, { NULL, 'm', NULL, 0, N_("Move files in archive."), 0 }, { NULL, 'p', NULL, 0, N_("Print files in archive."), 0 }, @@ -83,7 +83,7 @@ static const struct argp_option options[] = { NULL, 't', NULL, 0, N_("Display content of archive."), 0 }, { NULL, 'x', NULL, 0, N_("Extract files from archive."), 0 }, - { NULL, 0, NULL, 0, N_("Command Modifiers:"), 0 }, + { NULL, 0, NULL, 0, N_("Command Modifiers:"), 2 }, { NULL, 'o', NULL, 0, N_("Preserve original dates."), 0 }, { NULL, 'N', NULL, 0, N_("Use instance [COUNT] of name."), 0 }, { NULL, 'C', NULL, 0, @@ -95,8 +95,6 @@ static const struct argp_option options[] = { NULL, 'a', NULL, 0, N_("Insert file after [MEMBER]."), 0 }, { NULL, 'b', NULL, 0, N_("Insert file before [MEMBER]."), 0 }, { NULL, 'i', NULL, 0, N_("Same as -b."), 0 }, - { NULL, 'D', NULL, 0, - N_("Use zero for uid, gid, and date in archive members."), 0 }, { NULL, 'c', NULL, 0, N_("Suppress message when library has to be created."), 0 }, { NULL, 'P', NULL, 0, N_("Use full path for file matching."), 0 }, @@ -117,7 +115,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state); /* Data structure to communicate with argp functions. */ static struct argp argp = { - options, parse_opt, args_doc, doc, NULL, NULL, NULL + options, parse_opt, args_doc, doc, arlib_argp_children, NULL, NULL }; @@ -143,7 +141,6 @@ static bool allow_truncate_fname; static bool force_symtab; static bool suppress_create_msg; static bool full_path; -static bool deterministic_output; static bool update_newer; static enum { ipos_none, ipos_before, ipos_after } ipos; @@ -383,10 +380,6 @@ parse_opt (int key, char *arg __attribute__ ((unused)), allow_truncate_fname = true; break; - case 'D': - deterministic_output = true; - break; - case 'u': update_newer = true; break; @@ -1302,9 +1295,9 @@ do_oper_insert (int oper, const char *arfname, char **argv, int argc, found[cnt]->old_off == -1l ? 'a' : 'r', argv[cnt]); found[cnt]->elf = newelf; - found[cnt]->sec = deterministic_output ? 0 : newst.st_mtime; - found[cnt]->uid = deterministic_output ? 0 : newst.st_uid; - found[cnt]->gid = deterministic_output ? 0 : newst.st_gid; + found[cnt]->sec = arlib_deterministic_output ? 0 : newst.st_mtime; + found[cnt]->uid = arlib_deterministic_output ? 0 : newst.st_uid; + found[cnt]->gid = arlib_deterministic_output ? 0 : newst.st_gid; found[cnt]->mode = newst.st_mode; found[cnt]->name = bname; diff --git a/src/arlib-argp.c b/src/arlib-argp.c new file mode 100644 index 00000000..af19a255 --- /dev/null +++ b/src/arlib-argp.c @@ -0,0 +1,67 @@ +/* Options common to ar and ranlib. + Copyright (C) 2012 Red Hat, Inc. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + <http://www.openinventionnetwork.com>. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <argp.h> +#include "arlib.h" + +bool arlib_deterministic_output; + +static const struct argp_option options[] = + { + { NULL, 'D', NULL, 0, + N_("Use zero for uid, gid, and date in archive members."), 0 }, + + { NULL, 0, NULL, 0, NULL, 0 } + }; + +static error_t +parse_opt (int key, char *arg __attribute__ ((unused)), + struct argp_state *state __attribute__ ((unused))) +{ + switch (key) + { + case 'D': + arlib_deterministic_output = true; + break; + + default: + return ARGP_ERR_UNKNOWN; + } + return 0; +} + +static const struct argp argp = + { + options, parse_opt, NULL, NULL, NULL, NULL, NULL + }; + +const struct argp_child arlib_argp_children[] = + { + { &argp, 0, "", 2 }, + { NULL, } + }; diff --git a/src/arlib.c b/src/arlib.c index c69a138f..bcf9344b 100644 --- a/src/arlib.c +++ b/src/arlib.c @@ -1,5 +1,5 @@ /* Functions to handle creation of Linux archives. - Copyright (C) 2007 Red Hat, Inc. + Copyright (C) 2007-2012 Red Hat, Inc. Written by Ulrich Drepper <drepper@redhat.com>, 2007. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -69,7 +69,8 @@ arlib_init (void) memcpy (ar_hdr.ar_date, tmpbuf, snprintf (tmpbuf, sizeof (tmpbuf), "%-*lld", (int) sizeof (ar_hdr.ar_date), - (long long int) time (NULL))); + (arlib_deterministic_output ? 0 + : (long long int) time (NULL)))); assert ((sizeof (struct ar_hdr) % sizeof (uint32_t)) == 0); /* Note the string for the ar_uid and ar_gid cases is longer than diff --git a/src/arlib.h b/src/arlib.h index fd26d248..ea77b23e 100644 --- a/src/arlib.h +++ b/src/arlib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007 Red Hat, Inc. +/* Copyright (C) 2007-2012 Red Hat, Inc. Written by Ulrich Drepper <drepper@redhat.com>, 2007. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -26,15 +26,24 @@ #define _ARLIB_H 1 #include <ar.h> +#include <argp.h> #include <byteswap.h> #include <endian.h> #include <libelf.h> #include <obstack.h> +#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <sys/types.h> +/* State of -D/-U flags. */ +extern bool arlib_deterministic_output; + +/* For options common to ar and ranlib. */ +extern const struct argp_child arlib_argp_children[]; + + /* Maximum length of a file name that fits directly into the ar header. We cannot use the final byte since a / goes there. */ #define MAX_AR_NAME_LEN (sizeof (((struct ar_hdr *) NULL)->ar_name) - 1) diff --git a/src/ranlib.c b/src/ranlib.c index e92dc89b..cf2f1270 100644 --- a/src/ranlib.c +++ b/src/ranlib.c @@ -1,5 +1,5 @@ /* Generate an index to speed access to archives. - Copyright (C) 2005, 2006, 2007, 2009 Red Hat, Inc. + Copyright (C) 2005-2012 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2005. @@ -79,7 +79,7 @@ static const char args_doc[] = N_("ARCHIVE"); /* Data structure to communicate with argp functions. */ static const struct argp argp = { - options, NULL, args_doc, doc, NULL, NULL, NULL + options, NULL, args_doc, doc, arlib_argp_children, NULL, NULL }; |