diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/.cvsignore | 1 | ||||
| -rw-r--r-- | src/ChangeLog | 163 | ||||
| -rw-r--r-- | src/Makefile.am | 45 | ||||
| -rw-r--r-- | src/addr2line.c | 32 | ||||
| -rw-r--r-- | src/ar.c | 57 | ||||
| -rw-r--r-- | src/arlib-argp.c | 94 | ||||
| -rw-r--r-- | src/arlib.c | 32 | ||||
| -rw-r--r-- | src/arlib.h | 38 | ||||
| -rw-r--r-- | src/arlib2.c | 29 | ||||
| -rw-r--r-- | src/debugpred.h | 28 | ||||
| -rw-r--r-- | src/elfcmp.c | 36 | ||||
| -rw-r--r-- | src/elflint.c | 42 | ||||
| -rw-r--r-- | src/findtextrel.c | 32 | ||||
| -rw-r--r-- | src/i386_ld.c | 30 | ||||
| -rw-r--r-- | src/ld.c | 40 | ||||
| -rw-r--r-- | src/ld.h | 30 | ||||
| -rw-r--r-- | src/ldgeneric.c | 30 | ||||
| -rw-r--r-- | src/ldlex.l | 30 | ||||
| -rw-r--r-- | src/ldscript.y | 30 | ||||
| -rw-r--r-- | src/nm.c | 326 | ||||
| -rw-r--r-- | src/objdump.c | 103 | ||||
| -rw-r--r-- | src/ranlib.c | 34 | ||||
| -rw-r--r-- | src/readelf.c | 64 | ||||
| -rw-r--r-- | src/sectionhash.c | 30 | ||||
| -rw-r--r-- | src/sectionhash.h | 28 | ||||
| -rw-r--r-- | src/size.c | 32 | ||||
| -rw-r--r-- | src/strings.c | 32 | ||||
| -rw-r--r-- | src/strip.c | 300 | ||||
| -rw-r--r-- | src/symbolhash.c | 30 | ||||
| -rw-r--r-- | src/symbolhash.h | 28 | ||||
| -rw-r--r-- | src/unaligned.h | 30 | ||||
| -rw-r--r-- | src/unstrip.c | 32 | ||||
| -rw-r--r-- | src/versionhash.c | 30 | ||||
| -rw-r--r-- | src/versionhash.h | 28 | ||||
| -rw-r--r-- | src/xelf.h | 30 | ||||
| -rw-r--r-- | src/ylwrap | 154 |
36 files changed, 1256 insertions, 874 deletions
diff --git a/src/.cvsignore b/src/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/src/ChangeLog b/src/ChangeLog index f1333e1d..ba33f1db 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,166 @@ +2012-05-09 Roland McGrath <[email protected]> + + * elflint (check_sections): Allow zero sized sections at (filesz) end + of segment. And make check overflow-proofed. + +2012-04-24 Mark Wielaard <[email protected]> + + * readelf.c (print_ops): Add DW_OP_GNU_push_tls_address, + DW_OP_GNU_uinit and DW_OP_GNU_encoded_addr. + +2012-03-28 Roland McGrath <[email protected]> + + * elflint.c (special_sections): Accept SHF_INFO_LINK for reloc sections. + +2012-03-28 Mark Wielaard <[email protected]> + + * readelf.c (print_debug_abbrev_section): Check there is Dwarf + section data. + (print_debug_str_section): Likewise. + +2012-03-21 Mark Wielaard <[email protected]> + + * readelf.c (print_gdb_index_section): Accept version 6. + +2012-01-31 Mark Wielaard <[email protected]> + + * readelf.c (attr_callback): Don't special case DW_FORM_sec_offset. + +2012-01-21 Ulrich Drepper <[email protected]> + + * addr2line.c: Update copyright year. + * ar.c: Likewise. + * elfcmp.c: Likewise. + * elflint.c: Likewise. + * findtextrel.c: Likewise. + * ld.c: Likewise. + * nm.c: Likewise. + * objdump.c: Likewise. + * ranlib.c: Likewise. + * readelf.c: Likewise. + * size.c: Likewise. + * strings.c: Likewise. + * strip.c: Likewise. + * unstrip.c: Likewise. + + * nm.c (argp_children): Define. + (argp): Hook up argp_children. + (handle_ar): Optimize puts call. + (show_symbols_bsd): Use positional parameters to also print color + codes. Don't print STT_FILE symbols. + * objdump.c (options): Improve help text. + (argp_children): Define. + (argp): Hook up argp_children. + (disasm_info): Add elements for color codes. + (disasm_output): Print color codes as well. + (show_disasm): Set up disasm_info data for callback. + +2012-01-20 Roland McGrath <[email protected]> + + * arlib-argp.c (arlib_deterministic_output): Initialize from + configured value. + (help_filter): New function. + (argp): Use it. + + * ar.c (main): Handle oper_none as usage error. + + * arlib-argp.c (options, parse_opt): Grok -U as inverse of -D. + + * 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 <[email protected]> + + * readelf.c (print_debug): Initialize DUMMY_DBG.elf. + Reported by Karel Klic <[email protected]>. + +2011-11-05 Roland McGrath <[email protected]> + + * ar.c (deterministic_output): New flag variable. + (options, parse_opt): Grok -D to set it. + (do_oper_insert): When set, use zero from mtime, uid, and gid. + + * ar.c (do_oper_insert): Fix check on elf_rawfile return value. + +2011-10-04 Marek Polacek <[email protected]> + + * readelf.c (register_info): Assume the right size of an array. + +2011-10-03 Ulrich Drepper <[email protected]> + + * nm.c: Recognize option --mark-special. Still recognize --mark-weak + but don't show it in help anymore. + (mark_special): Renamed from mark_weak. + (parse_opt): Adjust. + (class_type_char): Take additional parameters for ELF file and ELF + header. Treat TLS symbols like objects. + In case of D symbols, show u for unique symbols, R for symbols in + read-only sections, B for symbols in BSS sections. + (show_symbols_bsd): Take additional parameters for ELF file and ELF + header. Adjust for class_type_char change. Show TLS symbols with + @ after them in case --mark-special is selected. + (show_symbols_posix): Likewise. + (show_symbols): Adjust calls to show_symbols_bsd and + show_symbols_posix. + (show_symbols_sysv): Avoid printing adress and size for undefined + symbols. Don't print initial special entry and section entries. + +2011-10-02 Ulrich Drepper <[email protected]> + + * Makefile.am (demanglelib): Define. + (nm_LDADD): Add demanglelib. + * nm.c (options): Add -C option. + (demangle): Define as global variable. + (parse_opt): Recognize -C. + (show_symbols_sysv): Handle demangling. + (show_symbols_bad): Likewise. + (show_symbols_posix): Likewise. + (show_symbols): Likewise. + +2011-07-09 Roland McGrath <[email protected]> + + * readelf.c (options, parse_opt): Grok -W/--wide and ignore it. + + * ar.c (parse_opt): Grok -u. + +2011-05-30 Mark Wielaard <[email protected]> + + * strip.c (relocate): Make offset check overflow-proof. + +2011-05-23 Mark Wielaard <[email protected]> + + * strip.c (relocate): Take new arguments is_rela to indicate + whether the relocation is from a SHT_REL or SHT_RELA section. + Relocate against any debug section symbol, not just STT_SECTION + symbols. For SHT_REL relocations, fetch addend from offset and + add it to symbol value if not zero. + +2011-05-23 Mark Wielaard <[email protected]> + + * strip.c (OPT_RELOC_DEBUG): New option. + (argp_option): Add new --reloc-debug-sections option. + (main): Check new option. + (parse_opt): Likewise. + (handle_elf): Remove any relocations between debug sections + in ET_REL for the debug file when requested. + +2011-05-18 Mark Wielaard <[email protected]> + + * strip.c (handle_elf): Make sure all sections of a removed group + section are removed too. Don't discard SHT_GROUP sections, copy + section table before it gets modified. Section group signature + symbols don't have to be retained. + 2011-05-16 Jakub Jelinek <[email protected]> * readelf.c (print_ops): Handle DW_OP_GNU_const_type, diff --git a/src/Makefile.am b/src/Makefile.am index f2b22d8d..75b51d97 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,28 +1,20 @@ ## Process this file with automake to create Makefile.in ## -## Copyright (C) 1996-2010 Red Hat, Inc. -## This file is part of Red Hat elfutils. +## Copyright (C) 1996-2012 Red Hat, Inc. +## This file is part of elfutils. ## -## 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. +## This file 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; either version 3 of the License, or +## (at your option) any later version. ## -## Red Hat elfutils is distributed in the hope that it will be useful, but +## 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. +## 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>. +## You should have received a copy of the GNU General Public License +## along with this program. If not, see <http://www.gnu.org/licenses/>. ## include $(top_srcdir)/config/eu.am DEFS += $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \ @@ -69,7 +61,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 dwarfcmp_SOURCES = dwarfcmp.cc @@ -107,6 +99,10 @@ libeu = ../lib/libeu.a # XXX later the C++ stuff will be in libdw.so directly libdwpp = ../libdw/libdwpp.a $(libdw) +if DEMANGLE +demanglelib = -lstdc++ +endif + nm_no_Wformat = yes size_no_Wformat = yes strings_no_Wformat = yes @@ -116,7 +112,8 @@ ldgeneric_no_Wunused = yes dwarfcmp_no_Wformat = yes readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl -nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl +nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl \ + $(demanglelib) size_LDADD = $(libelf) $(libeu) $(libmudflap) strip_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl ld_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl @@ -171,8 +168,8 @@ installcheck-binPROGRAMS: $(bin_PROGRAMS) for opt in --help --version; do \ if LD_LIBRARY_PATH=$(DESTDIR)$(libdir) \ $(DESTDIR)$(bindir)/$$f $$opt > c$${pid}_.out 2> c$${pid}_.err \ - && test -n "`cat c$${pid}_.out`" \ - && test -z "`cat c$${pid}_.err`"; then :; \ + && test -n "`cat c$${pid}_.out`" \ + && test -z "`cat c$${pid}_.err`"; then :; \ else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \ done; \ done; rm -f c$${pid}_.???; exit $$bad @@ -188,6 +185,6 @@ make-debug-archive: $(srcdir)/make-debug-archive.in sed -e "s,@UNSTRIP@,$$UNSTRIP,g" -e "s,@AR@,$$AR,g" \ -e "s%[@]PACKAGE_NAME[@]%$(PACKAGE_NAME)%g" \ -e "s%[@]PACKAGE_VERSION[@]%$(PACKAGE_VERSION)%g" \ - $(srcdir)/make-debug-archive.in > [email protected] + $(srcdir)/make-debug-archive.in > [email protected] chmod +x [email protected] mv -f [email protected] $@ diff --git a/src/addr2line.c b/src/addr2line.c index 2a3efb74..7d241f30 100644 --- a/src/addr2line.c +++ b/src/addr2line.c @@ -1,28 +1,20 @@ /* Locate source files and line information for given addresses - Copyright (C) 2005-2010 Red Hat, Inc. - This file is part of Red Hat elfutils. + Copyright (C) 2005-2010, 2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2005. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -190,7 +182,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } @@ -1,27 +1,20 @@ /* Create, modify, and extract from archives. - Copyright (C) 2005-2010 Red Hat, Inc. + Copyright (C) 2005-2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2005. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -73,7 +66,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 +76,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, @@ -115,7 +108,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 }; @@ -252,6 +245,13 @@ MEMBER parameter required for 'a', 'b', and 'i' modifiers")); int status; switch (operation) { + case oper_none: + error (0, 0, gettext ("command option required")); + argp_help (&argp, stderr, ARGP_HELP_STD_ERR, + program_invocation_short_name); + status = 1; + break; + case oper_list: case oper_print: status = do_oper_extract (operation, arfname, argv, argc, -1); @@ -290,7 +290,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } @@ -380,6 +380,10 @@ parse_opt (int key, char *arg __attribute__ ((unused)), allow_truncate_fname = true; break; + case 'u': + update_newer = true; + break; + case 'v': verbose = true; break; @@ -1291,14 +1295,15 @@ 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 = newst.st_mtime; - found[cnt]->uid = newst.st_uid; - found[cnt]->gid = 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; found[cnt]->mem = elf_rawfile (newelf, &found[cnt]->size); - if (found[cnt] == NULL || elf_cntl (newelf, ELF_C_FDDONE) != 0) + if (found[cnt]->mem == NULL + || elf_cntl (newelf, ELF_C_FDDONE) != 0) error (EXIT_FAILURE, 0, gettext ("cannot read %s: %s"), argv[cnt], elf_errmsg (-1)); diff --git a/src/arlib-argp.c b/src/arlib-argp.c new file mode 100644 index 00000000..1bdd8d0b --- /dev/null +++ b/src/arlib-argp.c @@ -0,0 +1,94 @@ +/* Options common to ar and ranlib. + Copyright (C) 2012 Red Hat, Inc. + This file is part of elfutils. + + This file 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; either version 3 of the License, or + (at your option) any later version. + + 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 this program. If not, see <http://www.gnu.org/licenses/>. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <argp.h> +#include <libintl.h> + +#include "arlib.h" + +bool arlib_deterministic_output = DEFAULT_AR_DETERMINISTIC; + +static const struct argp_option options[] = + { + { NULL, 'D', NULL, 0, + N_("Use zero for uid, gid, and date in archive members."), 0 }, + { NULL, 'U', NULL, 0, + N_("Use actual 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; + + case 'U': + arlib_deterministic_output = false; + break; + + default: + return ARGP_ERR_UNKNOWN; + } + return 0; +} + +static char * +help_filter (int key, const char *text, void *input __attribute__ ((unused))) +{ + inline char *text_for_default (void) + { + char *new_text; + if (unlikely (asprintf (&new_text, gettext ("%s (default)"), text) < 0)) + return (char *) text; + return new_text; + } + + switch (key) + { + case 'D': + if (DEFAULT_AR_DETERMINISTIC) + return text_for_default (); + break; + case 'U': + if (! DEFAULT_AR_DETERMINISTIC) + return text_for_default (); + break; + } + + return (char *) text; +} + +static const struct argp argp = + { + options, parse_opt, NULL, NULL, NULL, help_filter, NULL + }; + +const struct argp_child arlib_argp_children[] = + { + { &argp, 0, "", 2 }, + { NULL, 0, NULL, 0 } + }; diff --git a/src/arlib.c b/src/arlib.c index c69a138f..62c517cc 100644 --- a/src/arlib.c +++ b/src/arlib.c @@ -1,27 +1,20 @@ /* Functions to handle creation of Linux archives. - Copyright (C) 2007 Red Hat, Inc. + Copyright (C) 2007-2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2007. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -69,7 +62,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..e117166e 100644 --- a/src/arlib.h +++ b/src/arlib.h @@ -1,40 +1,42 @@ -/* Copyright (C) 2007 Red Hat, Inc. +/* Copyright (C) 2007-2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2007. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _ARLIB_H #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/arlib2.c b/src/arlib2.c index 7098fec1..7998fc6c 100644 --- a/src/arlib2.c +++ b/src/arlib2.c @@ -1,27 +1,20 @@ /* Functions to handle creation of Linux archives. Copyright (C) 2007 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2007. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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>. */ + 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/src/debugpred.h b/src/debugpred.h index 41d46796..4845a6e2 100644 --- a/src/debugpred.h +++ b/src/debugpred.h @@ -1,28 +1,20 @@ /* Support to debug branch prediction. Copyright (C) 2007 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2007. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> diff --git a/src/elfcmp.c b/src/elfcmp.c index b589dda8..2d85f0b2 100644 --- a/src/elfcmp.c +++ b/src/elfcmp.c @@ -1,28 +1,20 @@ /* Compare relevant content of two ELF files. - Copyright (C) 2005-2011 Red Hat, Inc. - This file is part of Red Hat elfutils. + Copyright (C) 2005-2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2005. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -158,10 +150,10 @@ main (int argc, char *argv[]) /* Comparing the files is done in two phases: 1. compare all sections. Sections which are irrelevant (i.e., if - strip would remove them) are ignored. Some section types are + strip would remove them) are ignored. Some section types are handled special. 2. all parts of the loadable segments which are not parts of any - section is compared according to the rules of the --gaps option. + section is compared according to the rules of the --gaps option. */ int result = 0; elf_version (EV_CURRENT); @@ -671,7 +663,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } diff --git a/src/elflint.c b/src/elflint.c index 5c8d0aaf..1ff28098 100644 --- a/src/elflint.c +++ b/src/elflint.c @@ -1,28 +1,20 @@ /* Pedantic checking of ELF files compliance with gABI/psABI spec. - Copyright (C) 2001-2011 Red Hat, Inc. - This file is part of Red Hat elfutils. + Copyright (C) 2001-2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -240,7 +232,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } @@ -3357,8 +3349,8 @@ static const struct { ".note", 6, SHT_NOTE, atleast, 0, SHF_ALLOC }, { ".plt", 5, SHT_PROGBITS, unused, 0, 0 }, // XXX more tests { ".preinit_array", 15, SHT_PREINIT_ARRAY, exact, SHF_ALLOC | SHF_WRITE, 0 }, - { ".rela", 5, SHT_RELA, atleast, 0, SHF_ALLOC }, // XXX more tests - { ".rel", 4, SHT_REL, atleast, 0, SHF_ALLOC }, // XXX more tests + { ".rela", 5, SHT_RELA, atleast, 0, SHF_ALLOC | SHF_INFO_LINK }, // XXX more tests + { ".rel", 4, SHT_REL, atleast, 0, SHF_ALLOC | SHF_INFO_LINK }, // XXX more tests { ".rodata", 8, SHT_PROGBITS, atleast, SHF_ALLOC, SHF_MERGE | SHF_STRINGS }, { ".rodata1", 9, SHT_PROGBITS, atleast, SHF_ALLOC, SHF_MERGE | SHF_STRINGS }, { ".shstrtab", 10, SHT_STRTAB, exact, 0, 0 }, @@ -3716,8 +3708,10 @@ section [%2zu] '%s' is both executable and writable\n"), || (phdr->p_type == PT_TLS && (shdr->sh_flags & SHF_TLS) != 0)) && phdr->p_offset <= shdr->sh_offset - && (phdr->p_offset + phdr->p_filesz > shdr->sh_offset - || (phdr->p_offset + phdr->p_memsz > shdr->sh_offset + && ((shdr->sh_offset - phdr->p_offset <= phdr->p_filesz + && (shdr->sh_offset - phdr->p_offset < phdr->p_filesz + || shdr->sh_size == 0)) + || (shdr->sh_offset - phdr->p_offset < phdr->p_memsz && shdr->sh_type == SHT_NOBITS))) { /* Found the segment. */ diff --git a/src/findtextrel.c b/src/findtextrel.c index 986c406e..39f7c924 100644 --- a/src/findtextrel.c +++ b/src/findtextrel.c @@ -1,28 +1,20 @@ /* Locate source files or functions which caused text relocations. - Copyright (C) 2005-2010 Red Hat, Inc. - This file is part of Red Hat elfutils. + Copyright (C) 2005-2010, 2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2005. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -171,7 +163,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } diff --git a/src/i386_ld.c b/src/i386_ld.c index 2702ef85..d196177a 100644 --- a/src/i386_ld.c +++ b/src/i386_ld.c @@ -1,27 +1,19 @@ /* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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>. */ + 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -1,27 +1,19 @@ -/* Copyright (C) 2001-2010 Red Hat, Inc. - This file is part of Red Hat elfutils. +/* Copyright (C) 2001-2010, 2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -411,8 +403,8 @@ main (int argc, char *argv[]) load_needed (); /* At this point all object files and DSOs are read. If there - are still undefined symbols left they might have to be - synthesized from the linker script. */ + are still undefined symbols left they might have to be + synthesized from the linker script. */ create_lscript_symbols (); /* Now that we have loaded all the object files we can determine @@ -958,7 +950,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } @@ -1478,7 +1470,7 @@ create_lscript_symbols (void) for (orule = segment->output_rules; orule != NULL; orule = orule->next) if (orule->tag == output_assignment /* The assignments to "." (i.e., the PC) have to be - ignored here. */ + ignored here. */ && strcmp (orule->val.assignment->variable, ".") != 0) { struct symbol *s = ld_state.unresolved; @@ -1519,7 +1511,7 @@ duplicate definition of '%s' in linker script"), } /* If the symbol only has to be provided if it is needed, - ignore it here since it is not undefined. */ + ignore it here since it is not undefined. */ if (orule->val.assignment->provide_flag) continue; @@ -1,27 +1,19 @@ /* Copyright (C) 2001, 2002, 2003, 2005, 2006, 2008, 2009 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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>. */ + 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef LD_H #define LD_H 1 diff --git a/src/ldgeneric.c b/src/ldgeneric.c index 98bdc225..1b5d0f9b 100644 --- a/src/ldgeneric.c +++ b/src/ldgeneric.c @@ -1,27 +1,19 @@ /* Copyright (C) 2001-2011 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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>. */ + 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/src/ldlex.l b/src/ldlex.l index eb15c7be..bfc8bbe5 100644 --- a/src/ldlex.l +++ b/src/ldlex.l @@ -1,28 +1,20 @@ %{ /* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2008 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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>. */ + 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/src/ldscript.y b/src/ldscript.y index c2f1971a..ec58e21a 100644 --- a/src/ldscript.y +++ b/src/ldscript.y @@ -1,29 +1,21 @@ %{ /* Parser for linker scripts. Copyright (C) 2001-2011 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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>. */ + 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -1,28 +1,20 @@ /* Print symbol information from ELF file in human-readable form. - Copyright (C) 2000-2008, 2009 Red Hat, Inc. - This file is part of Red Hat elfutils. + Copyright (C) 2000-2008, 2009, 2011, 2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2000. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -65,8 +57,8 @@ ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT; /* Values for the parameters which have no short form. */ -#define OPT_DEFINED 0x100 -#define OPT_MARK_WEAK 0x101 +#define OPT_DEFINED 0x100 +#define OPT_MARK_SPECIAL 0x101 /* Definitions of arguments for argp functions. */ static const struct argp_option options[] = @@ -92,7 +84,8 @@ static const struct argp_option options[] = { NULL, 'B', NULL, 0, N_("Same as --format=bsd"), 0 }, { "portability", 'P', NULL, 0, N_("Same as --format=posix"), 0 }, { "radix", 't', "RADIX", 0, N_("Use RADIX for printing symbol values"), 0 }, - { "mark-weak", OPT_MARK_WEAK, NULL, 0, N_("Mark weak symbols"), 0 }, + { "mark-special", OPT_MARK_SPECIAL, NULL, 0, N_("Mark special symbols"), 0 }, + { "mark-weak", OPT_MARK_SPECIAL, NULL, OPTION_HIDDEN, "", 0 }, { "print-size", 'S', NULL, 0, N_("Print size of defined symbols"), 0 }, { NULL, 0, NULL, 0, N_("Output options:"), 0 }, @@ -100,6 +93,10 @@ static const struct argp_option options[] = 0 }, { "no-sort", 'p', NULL, 0, N_("Do not sort the symbols"), 0 }, { "reverse-sort", 'r', NULL, 0, N_("Reverse the sense of the sort"), 0 }, +#ifdef USE_DEMANGLE + { "demangle", 'C', NULL, 0, + N_("Decode low-level symbol names into source code names"), 0 }, +#endif { NULL, 0, NULL, 0, N_("Miscellaneous:"), 0 }, { NULL, 0, NULL, 0, NULL, 0 } }; @@ -113,10 +110,17 @@ static const char args_doc[] = N_("[FILE...]"); /* Prototype for option handler. */ static error_t parse_opt (int key, char *arg, struct argp_state *state); +/* Parser children. */ +static struct argp_child argp_children[] = + { + { &color_argp, 0, N_("Output formatting"), 2 }, + { NULL, 0, NULL, 0} + }; + /* 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, argp_children, NULL, NULL }; @@ -175,6 +179,11 @@ static bool print_armap; /* If true reverse sorting. */ static bool reverse_sort; +#ifdef USE_DEMANGLE +/* If true demangle symbols. */ +static bool demangle; +#endif + /* Type of the section we are printing. */ static GElf_Word symsec_type = SHT_SYMTAB; @@ -194,9 +203,12 @@ static enum radix_octal } radix; -/* If nonzero weak symbols are distinguished from global symbols by adding - a `*' after the identifying letter for the symbol class and type. */ -static bool mark_weak; +/* If nonzero mark special symbols: + - weak symbols are distinguished from global symbols by adding + a `*' after the identifying letter for the symbol class and type. + - TLS symbols are distinguished from normal symbols by adding + a '@' after the identifying letter for the symbol class and type. */ +static bool mark_special; int @@ -254,7 +266,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } @@ -270,6 +282,12 @@ parse_opt (int key, char *arg, /* XXX */ break; +#ifdef USE_DEMANGLE + case 'C': + demangle = true; + break; +#endif + case 'f': if (strcmp (arg, "bsd") == 0) format = format_bsd; @@ -329,8 +347,8 @@ parse_opt (int key, char *arg, hide_defined = false; break; - case OPT_MARK_WEAK: - mark_weak = true; + case OPT_MARK_SPECIAL: + mark_special = true; break; case 'S': @@ -439,7 +457,7 @@ handle_ar (int fd, Elf *elf, const char *prefix, const char *fname, Elf_Arhdr *arhdr = NULL; size_t arhdr_off = 0; /* Note: 0 is no valid offset. */ - puts (gettext("\nArchive index:")); + fputs_unlocked (gettext("\nArchive index:\n"), stdout); while (arsym->as_off != 0) { @@ -775,24 +793,48 @@ show_symbols_sysv (Ebl *ebl, GElf_Word strndx, const char *fullname, longest_where, sgettext ("sysv|Line")); /* Which format string to use (different radix for numbers). */ - const char *fmtstr; + const char *number_fmtstr; if (radix == radix_hex) - fmtstr = "%-*s|%0*" PRIx64 "|%-6s|%-8s|%*" PRIx64 "|%*s|%s\n"; + number_fmtstr = "%0*" PRIx64; else if (radix == radix_decimal) - fmtstr = "%-*s|%*" PRId64 "|%-6s|%-8s|%*" PRId64 "|%*s|%s\n"; + number_fmtstr = "%0*" PRId64; else - fmtstr = "%-*s|%0*" PRIo64 "|%-6s|%-8s|%*" PRIo64 "|%*s|%s\n"; + number_fmtstr = "%0*" PRIo64; + +#ifdef USE_DEMANGLE + size_t demangle_buffer_len = 0; + char *demangle_buffer = NULL; +#endif /* Iterate over all symbols. */ - for (cnt = 0; cnt < nsyms; ++cnt) + for (cnt = 1; cnt < nsyms; ++cnt) { + /* In this format SECTION entries are not printed. */ + if (GELF_ST_TYPE (syms[cnt].sym.st_info) == STT_SECTION) + continue; + char symstrbuf[50]; const char *symstr = sym_name (ebl->elf, strndx, syms[cnt].sym.st_name, symstrbuf, sizeof symstrbuf); +#ifdef USE_DEMANGLE + /* Demangle if necessary. */ + if (demangle) + { + int status = -1; + char *dmsymstr = __cxa_demangle (symstr, demangle_buffer, + &demangle_buffer_len, &status); + + if (status == 0) + symstr = dmsymstr; + } +#endif + char symbindbuf[50]; char symtypebuf[50]; char secnamebuf[1024]; + char addressbuf[(64 + 2) / 3 + 1]; + char sizebuf[(64 + 2) / 3 + 1]; /* If we have to precede the line with the file name. */ if (print_file_name) @@ -801,28 +843,42 @@ show_symbols_sysv (Ebl *ebl, GElf_Word strndx, const char *fullname, putchar_unlocked (':'); } + /* Covert the address. */ + if (syms[cnt].sym.st_shndx == SHN_UNDEF) + addressbuf[0] = sizebuf[0] = '\0'; + else + { + snprintf (addressbuf, sizeof (addressbuf), number_fmtstr, + digits, syms[cnt].sym.st_value); + snprintf (sizebuf, sizeof (sizebuf), number_fmtstr, + digits, syms[cnt].sym.st_size); + } + /* Print the actual string. */ - printf (fmtstr, - longest_name, symstr, - digits, syms[cnt].sym.st_value, + printf ("%-*s|%s|%-6s|%-8s|%s|%*s|%s\n", + longest_name, symstr, addressbuf, ebl_symbol_binding_name (ebl, GELF_ST_BIND (syms[cnt].sym.st_info), symbindbuf, sizeof (symbindbuf)), ebl_symbol_type_name (ebl, GELF_ST_TYPE (syms[cnt].sym.st_info), symtypebuf, sizeof (symtypebuf)), - digits, syms[cnt].sym.st_size, longest_where, syms[cnt].where, + sizebuf, longest_where, syms[cnt].where, ebl_section_name (ebl, syms[cnt].sym.st_shndx, syms[cnt].xndx, secnamebuf, sizeof (secnamebuf), scnnames, shnum)); } +#ifdef USE_DEMANGLE + free (demangle_buffer); +#endif + if (scnnames_malloced) free (scnnames); } static char -class_type_char (GElf_Sym *sym) +class_type_char (Elf *elf, const GElf_Ehdr *ehdr, GElf_Sym *sym) { int local_p = GELF_ST_BIND (sym->st_info) == STB_LOCAL; @@ -834,14 +890,35 @@ class_type_char (GElf_Sym *sym) /* Undefined symbols must be global. */ return 'U'; - char result = "NDTSFB "[GELF_ST_TYPE (sym->st_info)]; + char result = "NDTSFBD "[GELF_ST_TYPE (sym->st_info)]; + + if (result == 'D') + { + /* Special handling: unique data symbols. */ + if (ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX + && GELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE) + result = 'u'; + else + { + GElf_Shdr shdr_mem; + GElf_Shdr *shdr = gelf_getshdr (elf_getscn (elf, sym->st_shndx), + &shdr_mem); + if (shdr != NULL) + { + if ((shdr->sh_flags & SHF_WRITE) == 0) + result = 'R'; + else if (shdr->sh_type == SHT_NOBITS) + result = 'B'; + } + } + } return local_p ? tolower (result) : result; } static void -show_symbols_bsd (Elf *elf, GElf_Word strndx, +show_symbols_bsd (Elf *elf, const GElf_Ehdr *ehdr, GElf_Word strndx, const char *prefix, const char *fname, const char *fullname, GElf_SymX *syms, size_t nsyms) { @@ -852,17 +929,22 @@ show_symbols_bsd (Elf *elf, GElf_Word strndx, static const char *const fmtstrs[] = { - [radix_hex] = "%0*" PRIx64 " %c%s %s\n", - [radix_decimal] = "%*" PRId64 " %c%s %s\n", - [radix_octal] = "%0*" PRIo64 " %c%s %s\n" + [radix_hex] = "%8$s%2$0*1$" PRIx64 "%10$s %9$s%3$c%4$s %5$s", + [radix_decimal] = "%8$s%*" PRId64 "%10$s %9$s%3$c%4$s %5$s", + [radix_octal] = "%8$s%2$0*1$" PRIo64 "%10$s %9$s%3$c%4$s %5$s" }; static const char *const sfmtstrs[] = { - [radix_hex] = "%2$0*1$" PRIx64 " %7$0*6$" PRIx64 " %3$c%4$s %5$s\n", - [radix_decimal] = "%2$*1$" PRId64 " %7$*6$" PRId64 " %3$c%4$s %5$s\n", - [radix_octal] = "%2$0*1$" PRIo64 " %7$0*6$" PRIo64 " %3$c%4$s %5$s\n" + [radix_hex] = "%8$s%2$0*1$" PRIx64 "%10$s %7$0*6$" PRIx64 " %9$s%3$c%4$s %5$s", + [radix_decimal] = "%8$s%2$*1$" PRId64 "%10$s %7$*6$" PRId64 " %9$s%3$c%4$s %5$s", + [radix_octal] = "%8$s%2$0*1$" PRIo64 "%10$s %7$0*6$" PRIo64 " %9$s%3$c%4$s %5$s" }; +#ifdef USE_DEMANGLE + size_t demangle_buffer_len = 0; + char *demangle_buffer = NULL; +#endif + /* Iterate over all symbols. */ for (size_t cnt = 0; cnt < nsyms; ++cnt) { @@ -876,6 +958,23 @@ show_symbols_bsd (Elf *elf, GElf_Word strndx, if (symstr[0] == '\0') continue; + /* We do not print the entries for files. */ + if (GELF_ST_TYPE (syms[cnt].sym.st_info) == STT_FILE) + continue; + +#ifdef USE_DEMANGLE + /* Demangle if necessary. */ + if (demangle) + { + int status = -1; + char *dmsymstr = __cxa_demangle (symstr, demangle_buffer, + &demangle_buffer_len, &status); + + if (status == 0) + symstr = dmsymstr; + } +#endif + /* If we have to precede the line with the file name. */ if (print_file_name) { @@ -883,31 +982,65 @@ show_symbols_bsd (Elf *elf, GElf_Word strndx, putchar_unlocked (':'); } + bool is_tls = GELF_ST_TYPE (syms[cnt].sym.st_info) == STT_TLS; + bool is_weak = GELF_ST_BIND (syms[cnt].sym.st_info) == STB_WEAK; + const char *marker = (mark_special + ? (is_tls ? "@" : (is_weak ? "*" : " ")) : ""); + if (syms[cnt].sym.st_shndx == SHN_UNDEF) - printf ("%*s U%s %s\n", - digits, "", - mark_weak - ? (GELF_ST_BIND (syms[cnt].sym.st_info) == STB_WEAK - ? "*" : " ") - : "", - symstr); + { + const char *color = ""; + if (color_mode) + { + if (is_tls) + color = color_undef_tls; + else if (is_weak) + color = color_undef_weak; + else + color = color_undef; + } + + printf ("%*s %sU%s %s", digits, "", color, marker, symstr); + } else - printf (print_size ? sfmtstrs[radix] : fmtstrs[radix], - digits, syms[cnt].sym.st_value, - class_type_char (&syms[cnt].sym), - mark_weak - ? (GELF_ST_BIND (syms[cnt].sym.st_info) == STB_WEAK - ? "*" : " ") - : "", - symstr, - digits, (uint64_t) syms[cnt].sym.st_size); + { + const char *color = ""; + if (color_mode) + { + if (is_tls) + color = color_tls; + else if (is_weak) + color = color_weak; + else + color = color_symbol; + } + + printf (print_size && syms[cnt].sym.st_size != 0 + ? sfmtstrs[radix] : fmtstrs[radix], + digits, syms[cnt].sym.st_value, + class_type_char (elf, ehdr, &syms[cnt].sym), marker, + symstr, + digits, (uint64_t) syms[cnt].sym.st_size, + color_mode ? color_address : "", + color, + color_mode ? color_off : ""); + } + + if (color_mode) + fputs_unlocked (color_off, stdout); + putchar_unlocked ('\n'); } + +#ifdef USE_DEMANGLE + free (demangle_buffer); +#endif } static void -show_symbols_posix (Elf *elf, GElf_Word strndx, const char *prefix, - const char *fullname, GElf_SymX *syms, size_t nsyms) +show_symbols_posix (Elf *elf, const GElf_Ehdr *ehdr, GElf_Word strndx, + const char *prefix, const char *fullname, GElf_SymX *syms, + size_t nsyms) { if (prefix != NULL && ! print_file_name) printf ("%s:\n", fullname); @@ -922,6 +1055,11 @@ show_symbols_posix (Elf *elf, GElf_Word strndx, const char *prefix, int digits = length_map[gelf_getclass (elf) - 1][radix]; +#ifdef USE_DEMANGLE + size_t demangle_buffer_len = 0; + char *demangle_buffer = NULL; +#endif + /* Iterate over all symbols. */ for (size_t cnt = 0; cnt < nsyms; ++cnt) { @@ -935,6 +1073,19 @@ show_symbols_posix (Elf *elf, GElf_Word strndx, const char *prefix, if (symstr[0] == '\0') continue; +#ifdef USE_DEMANGLE + /* Demangle if necessary. */ + if (demangle) + { + int status = -1; + char *dmsymstr = __cxa_demangle (symstr, demangle_buffer, + &demangle_buffer_len, &status); + + if (status == 0) + symstr = dmsymstr; + } +#endif + /* If we have to precede the line with the file name. */ if (print_file_name) { @@ -945,13 +1096,20 @@ show_symbols_posix (Elf *elf, GElf_Word strndx, const char *prefix, printf (fmtstr, symstr, - class_type_char (&syms[cnt].sym), - mark_weak - ? (GELF_ST_BIND (syms[cnt].sym.st_info) == STB_WEAK ? "*" : " ") + class_type_char (elf, ehdr, &syms[cnt].sym), + mark_special + ? (GELF_ST_TYPE (syms[cnt].sym.st_info) == STT_TLS + ? "@" + : (GELF_ST_BIND (syms[cnt].sym.st_info) == STB_WEAK + ? "*" : " ")) : "", digits, syms[cnt].sym.st_value, digits, syms[cnt].sym.st_size); } + +#ifdef USE_DEMANGLE + free (demangle_buffer); +#endif } @@ -1053,6 +1211,10 @@ show_symbols (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, Elf_Scn *xndxscn, INTERNAL_ERROR (fullname); /* Iterate over all symbols. */ +#ifdef USE_DEMANGLE + size_t demangle_buffer_len = 0; + char *demangle_buffer = NULL; +#endif int longest_name = 4; int longest_where = 4; size_t nentries_used = 0; @@ -1065,7 +1227,7 @@ show_symbols (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, Elf_Scn *xndxscn, INTERNAL_ERROR (fullname); /* Filter out administrative symbols without a name and those - deselected by ther user with command line options. */ + deselected by the user with command line options. */ if ((hide_undefined && sym->st_shndx == SHN_UNDEF) || (hide_defined && sym->st_shndx != SHN_UNDEF) || (hide_local && GELF_ST_BIND (sym->st_info) == STB_LOCAL)) @@ -1079,6 +1241,19 @@ show_symbols (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, Elf_Scn *xndxscn, if (symstr == NULL) continue; +#ifdef USE_DEMANGLE + /* Demangle if necessary. */ + if (demangle) + { + int status = -1; + char *dmsymstr = __cxa_demangle (symstr, demangle_buffer, + &demangle_buffer_len, &status); + + if (status == 0) + symstr = dmsymstr; + } +#endif + longest_name = MAX ((size_t) longest_name, strlen (symstr)); if (sym->st_shndx != SHN_UNDEF @@ -1133,7 +1308,7 @@ show_symbols (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, Elf_Scn *xndxscn, } } - /* Try to find the symol among the local symbols. */ + /* Try to find the symbol among the local symbols. */ if (sym_mem[nentries_used].where[0] == '\0') { struct local_name fake = @@ -1164,6 +1339,9 @@ show_symbols (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, Elf_Scn *xndxscn, /* We use this entry. */ ++nentries_used; } +#ifdef USE_DEMANGLE + free (demangle_buffer); +#endif /* Now we know the exact number. */ nentries = nentries_used; @@ -1186,15 +1364,15 @@ show_symbols (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, Elf_Scn *xndxscn, break; case format_bsd: - show_symbols_bsd (ebl->elf, shdr->sh_link, prefix, fname, fullname, + show_symbols_bsd (ebl->elf, ehdr, shdr->sh_link, prefix, fname, fullname, sym_mem, nentries); break; case format_posix: default: assert (format == format_posix); - show_symbols_posix (ebl->elf, shdr->sh_link, prefix, fullname, sym_mem, - nentries); + show_symbols_posix (ebl->elf, ehdr, shdr->sh_link, prefix, fullname, + sym_mem, nentries); break; } diff --git a/src/objdump.c b/src/objdump.c index 1234c794..ebad25d5 100644 --- a/src/objdump.c +++ b/src/objdump.c @@ -1,28 +1,20 @@ /* Print information from ELF file in human-readable form. - Copyright (C) 2005, 2006, 2007, 2009 Red Hat, Inc. - This file is part of Red Hat elfutils. + Copyright (C) 2005, 2006, 2007, 2009, 2011, 2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2005. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -65,7 +57,7 @@ static const struct argp_option options[] = { "disassemble", 'd', NULL, 0, N_("Display assembler code of executable sections"), 0 }, - { NULL, 0, NULL, 0, N_("Output option selection:"), 0 }, + { NULL, 0, NULL, 0, N_("Output content selection:"), 0 }, { "section", 'j', "NAME", 0, N_("Only display information for section NAME."), 0 }, @@ -82,10 +74,17 @@ static const char args_doc[] = N_("[FILE...]"); /* Prototype for option handler. */ static error_t parse_opt (int key, char *arg, struct argp_state *state); +/* Parser children. */ +static struct argp_child argp_children[] = + { + { &color_argp, 0, N_("Output formatting"), 2 }, + { NULL, 0, NULL, 0} + }; + /* Data structure to communicate with argp functions. */ -static struct argp argp = +static const struct argp argp = { - options, parse_opt, args_doc, doc, NULL, NULL, NULL + options, parse_opt, args_doc, doc, argp_children, NULL, NULL }; @@ -128,6 +127,7 @@ static bool print_full_content; /* If true print disassembled output.. */ static bool print_disasm; + int main (int argc, char *argv[]) { @@ -182,7 +182,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "20089"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } @@ -499,7 +499,7 @@ show_relocs (Ebl *ebl, const char *fname, uint32_t shstrndx) if (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA) { - if (! section_match (ebl->elf, elf_ndxscn (scn), shdr, shstrndx)) + if (! section_match (ebl->elf, elf_ndxscn (scn), shdr, shstrndx)) continue; GElf_Shdr destshdr_mem; @@ -570,7 +570,7 @@ show_full_content (Ebl *ebl, const char *fname, uint32_t shstrndx) if (shdr->sh_type == SHT_PROGBITS && shdr->sh_size > 0) { - if (! section_match (ebl->elf, elf_ndxscn (scn), shdr, shstrndx)) + if (! section_match (ebl->elf, elf_ndxscn (scn), shdr, shstrndx)) continue; printf (gettext ("Contents of section %s:\n"), @@ -632,6 +632,8 @@ struct disasm_info GElf_Addr addr; const uint8_t *cur; const uint8_t *last_end; + const char *address_color; + const char *bytes_color; }; @@ -642,10 +644,20 @@ disasm_output (char *buf, size_t buflen, void *arg) { struct disasm_info *info = (struct disasm_info *) arg; - printf ("%8" PRIx64 ": ", (uint64_t) info->addr); + if (info->address_color != NULL) + printf ("%s%8" PRIx64 "%s: ", + info->address_color, (uint64_t) info->addr, color_off); + else + printf ("%8" PRIx64 ": ", (uint64_t) info->addr); + + if (info->bytes_color != NULL) + fputs_unlocked (info->bytes_color, stdout); size_t cnt; for (cnt = 0; cnt < (size_t) MIN (info->cur - info->last_end, 8); ++cnt) printf (" %02" PRIx8, info->last_end[cnt]); + if (info->bytes_color != NULL) + fputs_unlocked (color_off, stdout); + printf ("%*s %.*s\n", (int) (8 - cnt) * 3 + 1, "", (int) buflen, buf); @@ -655,9 +667,18 @@ disasm_output (char *buf, size_t buflen, void *arg) Print the rest on a separate, following line. */ if (info->cur - info->last_end > 8) { - printf ("%8" PRIx64 ": ", (uint64_t) info->addr); + if (info->address_color != NULL) + printf ("%s%8" PRIx64 "%s: ", + info->address_color, (uint64_t) info->addr, color_off); + else + printf ("%8" PRIx64 ": ", (uint64_t) info->addr); + + if (info->bytes_color != NULL) + fputs_unlocked (info->bytes_color, stdout); for (; cnt < (size_t) (info->cur - info->last_end); ++cnt) printf (" %02" PRIx8, info->last_end[cnt]); + if (info->bytes_color != NULL) + fputs_unlocked (color_off, stdout); putchar_unlocked ('\n'); info->addr += info->cur - info->last_end - 8; } @@ -687,7 +708,7 @@ show_disasm (Ebl *ebl, const char *fname, uint32_t shstrndx) if (shdr->sh_type == SHT_PROGBITS && shdr->sh_size > 0 && (shdr->sh_flags & SHF_EXECINSTR) != 0) { - if (! section_match (ebl->elf, elf_ndxscn (scn), shdr, shstrndx)) + if (! section_match (ebl->elf, elf_ndxscn (scn), shdr, shstrndx)) continue; Elf_Data *data = elf_getdata (scn, NULL); @@ -700,10 +721,32 @@ show_disasm (Ebl *ebl, const char *fname, uint32_t shstrndx) struct disasm_info info; info.addr = shdr->sh_addr; info.last_end = info.cur = data->d_buf; + char *fmt; + if (color_mode) + { + info.address_color = color_address; + info.bytes_color = color_bytes; + + if (asprintf (&fmt, "%s%%7m %s%%.1o,%s%%.2o,%s%%.3o%%34a %s%%l", + color_mnemonic ?: "", + color_operand1 ?: "", + color_operand2 ?: "", + color_operand3 ?: "", + color_label ?: "") < 0) + error (EXIT_FAILURE, errno, _("cannot allocate memory")); + } + else + { + info.address_color = info.bytes_color = NULL; + + fmt = "%7m %.1o,%.2o,%.3o%34a %l"; + } disasm_cb (ctx, &info.cur, info.cur + data->d_size, info.addr, - "%7m %.1o,%.2o,%.3o%34a %l", disasm_output, &info, - NULL /* XXX */); + fmt, disasm_output, &info, NULL /* XXX */); + + if (color_mode) + free (fmt); } } diff --git a/src/ranlib.c b/src/ranlib.c index e92dc89b..8435fc1b 100644 --- a/src/ranlib.c +++ b/src/ranlib.c @@ -1,28 +1,20 @@ /* Generate an index to speed access to archives. - Copyright (C) 2005, 2006, 2007, 2009 Red Hat, Inc. - This file is part of Red Hat elfutils. + Copyright (C) 2005-2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2005. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -79,7 +71,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 }; @@ -137,7 +129,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } diff --git a/src/readelf.c b/src/readelf.c index 87513a53..a4b13c86 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -1,28 +1,20 @@ /* Print information from ELF file in human-readable form. - Copyright (C) 1999-2011 Red Hat, Inc. - This file is part of Red Hat elfutils. + Copyright (C) 1999-2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 1999. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -107,7 +99,8 @@ static const struct argp_option options[] = { NULL, 0, NULL, 0, N_("Output control:"), 0 }, { "numeric-addresses", 'N', NULL, 0, N_("Do not find symbol names for addresses in DWARF data"), 0 }, - + { "wide", 'W', NULL, 0, + N_("Ignored for compatibility (lines always wide)"), 0 }, { NULL, 0, NULL, 0, NULL, 0 } }; @@ -445,6 +438,8 @@ parse_opt (int key, char *arg, exit (EXIT_FAILURE); } break; + case 'W': /* Ignored. */ + break; default: return ARGP_ERR_UNKNOWN; } @@ -461,7 +456,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } @@ -3362,6 +3357,9 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest, [DW_OP_bit_piece] = "bit_piece", [DW_OP_implicit_value] = "implicit_value", [DW_OP_stack_value] = "stack_value", + [DW_OP_GNU_push_tls_address] = "GNU_push_tls_address", + [DW_OP_GNU_uninit] = "GNU_uninit", + [DW_OP_GNU_encoded_addr] = "GNU_encoded_addr", [DW_OP_GNU_implicit_pointer] = "GNU_implicit_pointer", [DW_OP_GNU_entry_value] = "GNU_entry_value", [DW_OP_GNU_const_type] = "GNU_const_type", @@ -3863,13 +3861,16 @@ print_debug_abbrev_section (Dwfl_Module *dwflmod __attribute__ ((unused)), Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg) { + const size_t sh_size = (dbg->sectiondata[IDX_debug_abbrev] ? + dbg->sectiondata[IDX_debug_abbrev]->d_size : 0); + printf (gettext ("\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n" " [ Code]\n"), elf_ndxscn (scn), section_name (ebl, ehdr, shdr), (uint64_t) shdr->sh_offset); Dwarf_Off offset = 0; - while (offset < dbg->sectiondata[IDX_debug_abbrev]->d_size) + while (offset < sh_size) { printf (gettext ("\nAbbreviation section at offset %" PRIu64 ":\n"), offset); @@ -4084,7 +4085,7 @@ register_info (Ebl *ebl, unsigned int regno, const Ebl_Register_Location *loc, bits ?: &ignore, type ?: &ignore); if (n <= 0) { - snprintf (name, sizeof name, "reg%u", loc->regno); + snprintf (name, REGNAMESZ, "reg%u", loc->regno); if (bits != NULL) *bits = loc->bits; if (type != NULL) @@ -4909,9 +4910,6 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) break; case DW_FORM_sec_offset: - attrp->form = cbargs->offset_size == 8 ? DW_FORM_data8 : DW_FORM_data4; - /* Fall through. */ - case DW_FORM_udata: case DW_FORM_sdata: case DW_FORM_data8: @@ -6081,7 +6079,8 @@ print_debug_str_section (Dwfl_Module *dwflmod __attribute__ ((unused)), Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg) { - const size_t sh_size = dbg->sectiondata[IDX_debug_str]->d_size; + const size_t sh_size = (dbg->sectiondata[IDX_debug_str] ? + dbg->sectiondata[IDX_debug_str]->d_size : 0); /* Compute floor(log16(shdr->sh_size)). */ GElf_Addr tmp = sh_size; @@ -6418,8 +6417,9 @@ print_gdb_index_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, printf (gettext (" Version: %" PRId32 "\n"), vers); // The only difference between version 4 and version 5 is the - // hash used for generating the table. - if (vers < 4 || vers > 5) + // hash used for generating the table. Version 6 contains symbols + // for inlined functions, older versions didn't. + if (vers < 4 || vers > 6) { printf (gettext (" unknown version, cannot parse section\n")); return; @@ -6585,7 +6585,11 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr) /* Before we start the real work get a debug context descriptor. */ Dwarf_Addr dwbias; Dwarf *dbg = dwfl_module_getdwarf (dwflmod, &dwbias); - Dwarf dummy_dbg = { .other_byte_order = MY_ELFDATA != ehdr->e_ident[EI_DATA] }; + Dwarf dummy_dbg = + { + .elf = ebl->elf, + .other_byte_order = MY_ELFDATA != ehdr->e_ident[EI_DATA] + }; if (dbg == NULL) { if ((print_debug_sections & ~section_exception) != 0) diff --git a/src/sectionhash.c b/src/sectionhash.c index 68d734e1..83a7cca6 100644 --- a/src/sectionhash.c +++ b/src/sectionhash.c @@ -1,28 +1,20 @@ /* Section hash table implementation. Copyright (C) 2001, 2002, 2005 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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>. */ + 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/src/sectionhash.h b/src/sectionhash.h index ba41ee8c..96da3367 100644 --- a/src/sectionhash.h +++ b/src/sectionhash.h @@ -1,27 +1,19 @@ /* Copyright (C) 2001, 2002 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef SECTIONHASH_H #define SECTIONHASH_H 1 @@ -1,28 +1,20 @@ /* Print size information from ELF file. - Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2009 Red Hat, Inc. - This file is part of Red Hat elfutils. + Copyright (C) 2000-2007,2009,2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2000. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -220,7 +212,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } diff --git a/src/strings.c b/src/strings.c index 21380981..084eb999 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1,28 +1,20 @@ /* Print the strings of printable characters in files. - Copyright (C) 2005-2010 Red Hat, Inc. - This file is part of Red Hat elfutils. + Copyright (C) 2005-2010, 2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2005. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -228,7 +220,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } diff --git a/src/strip.c b/src/strip.c index 99374eb3..5e9c8833 100644 --- a/src/strip.c +++ b/src/strip.c @@ -1,28 +1,20 @@ /* Discard section not used at runtime from object files. - Copyright (C) 2000-2011 Red Hat, Inc. - This file is part of Red Hat elfutils. + Copyright (C) 2000-2012 Red Hat, Inc. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2000. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -53,6 +45,7 @@ #include <libebl.h> #include <system.h> +typedef uint8_t GElf_Byte; /* Name and version of program. */ static void print_version (FILE *stream, struct argp_state *state); @@ -66,6 +59,7 @@ ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT; #define OPT_REMOVE_COMMENT 0x100 #define OPT_PERMISSIVE 0x101 #define OPT_STRIP_SECTIONS 0x102 +#define OPT_RELOC_DEBUG 0x103 /* Definitions of arguments for argp functions. */ @@ -85,6 +79,8 @@ static const struct argp_option options[] = N_("Remove section headers (not recommended)"), 0 }, { "preserve-dates", 'p', NULL, 0, N_("Copy modified/access timestamps to the output"), 0 }, + { "reloc-debug-sections", OPT_RELOC_DEBUG, NULL, 0, + N_("Resolve all trivial relocations between debug sections if the removed sections are placed in a debug file (only relevant for ET_REL files, operation is not reversable, needs -f)"), 0 }, { "remove-comment", OPT_REMOVE_COMMENT, NULL, 0, N_("Remove .comment section"), 0 }, { "remove-section", 'R', "SECTION", OPTION_HIDDEN, NULL, 0 }, @@ -149,6 +145,9 @@ static bool remove_shdrs; /* If true relax some ELF rules for input files. */ static bool permissive; +/* If true perform relocations between debug sections. */ +static bool reloc_debug; + int main (int argc, char *argv[]) @@ -177,6 +176,10 @@ main (int argc, char *argv[]) if (argp_parse (&argp, argc, argv, 0, &remaining, NULL) != 0) return EXIT_FAILURE; + if (reloc_debug && debug_fname == NULL) + error (EXIT_FAILURE, 0, + gettext ("--reloc-debug-sections used without -f")); + /* Tell the library which version we are expecting. */ elf_version (EV_CURRENT); @@ -211,7 +214,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } @@ -253,6 +256,10 @@ parse_opt (int key, char *arg, struct argp_state *state) preserve_dates = true; break; + case OPT_RELOC_DEBUG: + reloc_debug = true; + break; + case OPT_REMOVE_COMMENT: remove_comment = true; break; @@ -447,10 +454,12 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, int debug_fd = -1; - /* Get the EBL handling. The -g option is currently the only reason + /* Get the EBL handling. Removing all debugging symbols with the -g + option or resolving all relocations between debug sections with + the --reloc-debug-sections option are currently the only reasons we need EBL so don't open the backend unless necessary. */ Ebl *ebl = NULL; - if (remove_debug) + if (remove_debug || reloc_debug) { ebl = ebl_openbackend (elf); if (ebl == NULL) @@ -726,6 +735,22 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, || shdr_info[cnt].shdr.sh_type == SHT_RELA) && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0) shdr_info[cnt].idx = 1; + + /* If a group section is marked as being removed make + sure all the sections it contains are being removed, too. */ + if (shdr_info[cnt].shdr.sh_type == SHT_GROUP) + { + Elf32_Word *grpref; + grpref = (Elf32_Word *) shdr_info[cnt].data->d_buf; + for (size_t in = 1; + in < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); + ++in) + if (shdr_info[grpref[in]].idx != 0) + { + shdr_info[cnt].idx = 1; + break; + } + } } if (shdr_info[cnt].idx == 1) @@ -883,6 +908,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, bool discard_section = (shdr_info[cnt].idx > 0 && shdr_info[cnt].debug_data == NULL && shdr_info[cnt].shdr.sh_type != SHT_NOTE + && shdr_info[cnt].shdr.sh_type != SHT_GROUP && cnt != ehdr->e_shstrndx); /* Set the section header in the new file. */ @@ -912,7 +938,8 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, *debugdata = *shdr_info[cnt].data; if (discard_section) debugdata->d_buf = NULL; - else if (shdr_info[cnt].debug_data != NULL) + else if (shdr_info[cnt].debug_data != NULL + || shdr_info[cnt].shdr.sh_type == SHT_GROUP) { /* Copy the original data before it gets modified. */ shdr_info[cnt].debug_data = debugdata; @@ -1110,7 +1137,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, shdr_info[shdr_info[cnt].shdr.sh_info].idx; /* Get the data from the old file if necessary. We already - created the data for the section header string table. */ + created the data for the section header string table. */ if (cnt < shnum) { if (shdr_info[cnt].data == NULL) @@ -1261,9 +1288,15 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, } else if (debug_fname == NULL || shdr_info[cnt].debug_data == NULL) - /* This is a section symbol for a section which has - been removed. */ - assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION); + /* This is a section or group signature symbol + for a section which has been removed. */ + { + size_t sidx = (sym->st_shndx != SHN_XINDEX + ? sym->st_shndx : xshndx); + assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION + || (shdr_info[sidx].shdr.sh_type == SHT_GROUP + && shdr_info[sidx].shdr.sh_info == inner)); + } } if (destidx != inner) @@ -1585,6 +1618,219 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, } } + /* Remove any relocations between debug sections in ET_REL + for the debug file when requested. These relocations are always + zero based between the unallocated sections. */ + if (debug_fname != NULL && reloc_debug && ehdr->e_type == ET_REL) + { + scn = NULL; + cnt = 0; + while ((scn = elf_nextscn (debugelf, scn)) != NULL) + { + cnt++; + /* We need the actual section and header from the debugelf + not just the cached original in shdr_info because we + might want to change the size. */ + GElf_Shdr shdr_mem; + GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); + if (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA) + { + /* Make sure that this relocation section points to a + section to relocate with contents, that isn't + allocated and that is a debug section. */ + Elf_Scn *tscn = elf_getscn (debugelf, shdr->sh_info); + GElf_Shdr tshdr_mem; + GElf_Shdr *tshdr = gelf_getshdr (tscn, &tshdr_mem); + if (tshdr->sh_type == SHT_NOBITS + || tshdr->sh_size == 0 + || (tshdr->sh_flags & SHF_ALLOC) != 0) + continue; + + const char *tname = elf_strptr (debugelf, shstrndx, + tshdr->sh_name); + if (! tname || ! ebl_debugscn_p (ebl, tname)) + continue; + + /* OK, lets relocate all trivial cross debug section + relocations. */ + Elf_Data *reldata = elf_getdata (scn, NULL); + /* We actually wanted the rawdata, but since we already + accessed it earlier as elf_getdata () that won't + work. But debug sections are all ELF_T_BYTE, so it + doesn't really matter. */ + Elf_Data *tdata = elf_getdata (tscn, NULL); + if (tdata->d_type != ELF_T_BYTE) + INTERNAL_ERROR (fname); + + /* Pick up the symbol table and shndx table to + resolve relocation symbol indexes. */ + Elf64_Word symt = shdr->sh_link; + Elf_Data *symdata, *xndxdata; + symdata = (shdr_info[symt].debug_data + ?: shdr_info[symt].data); + xndxdata = (shdr_info[shdr_info[symt].symtab_idx].debug_data + ?: shdr_info[shdr_info[symt].symtab_idx].data); + + /* Apply one relocation. Returns true when trivial + relocation actually done. */ + bool relocate (GElf_Addr offset, const GElf_Sxword addend, + bool is_rela, int rtype, int symndx) + { + /* R_*_NONE relocs can always just be removed. */ + if (rtype == 0) + return true; + + /* We only do simple absolute relocations. */ + Elf_Type type = ebl_reloc_simple_type (ebl, rtype); + if (type == ELF_T_NUM) + return false; + + /* These are the types we can relocate. */ +#define TYPES DO_TYPE (BYTE, Byte); DO_TYPE (HALF, Half); \ + DO_TYPE (WORD, Word); DO_TYPE (SWORD, Sword); \ + DO_TYPE (XWORD, Xword); DO_TYPE (SXWORD, Sxword) + + /* And only for relocations against other debug sections. */ + GElf_Sym sym_mem; + Elf32_Word xndx; + GElf_Sym *sym = gelf_getsymshndx (symdata, xndxdata, + symndx, &sym_mem, + &xndx); + Elf32_Word sec = (sym->st_shndx == SHN_XINDEX + ? xndx : sym->st_shndx); + if (ebl_debugscn_p (ebl, shdr_info[sec].name)) + { + size_t size; + +#define DO_TYPE(NAME, Name) GElf_##Name Name; + union { TYPES; } tmpbuf; +#undef DO_TYPE + + switch (type) + { +#define DO_TYPE(NAME, Name) \ + case ELF_T_##NAME: \ + size = sizeof (GElf_##Name); \ + tmpbuf.Name = 0; \ + break; + TYPES; +#undef DO_TYPE + default: + return false; + } + + if (offset > tdata->d_size + || tdata->d_size - offset < size) + error (0, 0, gettext ("bad relocation")); + + /* When the symbol value is zero then for SHT_REL + sections this is all that needs to be checked. + The addend is contained in the original data at + the offset already. So if the (section) symbol + address is zero and the given addend is zero + just remove the relocation, it isn't needed + anymore. */ + if (addend == 0 && sym->st_value == 0) + return true; + + Elf_Data tmpdata = + { + .d_type = type, + .d_buf = &tmpbuf, + .d_size = size, + .d_version = EV_CURRENT, + }; + Elf_Data rdata = + { + .d_type = type, + .d_buf = tdata->d_buf + offset, + .d_size = size, + .d_version = EV_CURRENT, + }; + + GElf_Addr value = sym->st_value; + if (is_rela) + { + /* For SHT_RELA sections we just take the + given addend and add it to the value. */ + value += addend; + } + else + { + /* For SHT_REL sections we have to peek at + what is already in the section at the given + offset to get the addend. */ + Elf_Data *d = gelf_xlatetom (debugelf, &tmpdata, + &rdata, + ehdr->e_ident[EI_DATA]); + if (d == NULL) + INTERNAL_ERROR (fname); + assert (d == &tmpdata); + } + + switch (type) + { +#define DO_TYPE(NAME, Name) \ + case ELF_T_##NAME: \ + tmpbuf.Name += (GElf_##Name) value; \ + break; + TYPES; +#undef DO_TYPE + default: + abort (); + } + + /* Now finally put in the new value. */ + Elf_Data *s = gelf_xlatetof (debugelf, &rdata, + &tmpdata, + ehdr->e_ident[EI_DATA]); + if (s == NULL) + INTERNAL_ERROR (fname); + assert (s == &rdata); + + return true; + } + return false; + } + + size_t nrels = shdr->sh_size / shdr->sh_entsize; + size_t next = 0; + if (shdr->sh_type == SHT_REL) + for (size_t relidx = 0; relidx < nrels; ++relidx) + { + GElf_Rel rel_mem; + GElf_Rel *r = gelf_getrel (reldata, relidx, &rel_mem); + if (! relocate (r->r_offset, 0, false, + GELF_R_TYPE (r->r_info), + GELF_R_SYM (r->r_info))) + { + if (relidx != next) + gelf_update_rel (reldata, next, r); + ++next; + } + } + else + for (size_t relidx = 0; relidx < nrels; ++relidx) + { + GElf_Rela rela_mem; + GElf_Rela *r = gelf_getrela (reldata, relidx, &rela_mem); + if (! relocate (r->r_offset, r->r_addend, true, + GELF_R_TYPE (r->r_info), + GELF_R_SYM (r->r_info))) + { + if (relidx != next) + gelf_update_rela (reldata, next, r); + ++next; + } + } + + nrels = next; + shdr->sh_size = reldata->d_size = nrels * shdr->sh_entsize; + gelf_update_shdr (scn, shdr); + } + } + } + /* Now that we have done all adjustments to the data, we can actually write out the debug file. */ if (debug_fname != NULL) diff --git a/src/symbolhash.c b/src/symbolhash.c index 670cf056..3fd96499 100644 --- a/src/symbolhash.c +++ b/src/symbolhash.c @@ -1,28 +1,20 @@ /* Symbol hash table implementation. Copyright (C) 2001, 2002 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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>. */ + 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/src/symbolhash.h b/src/symbolhash.h index 54b95397..062dadec 100644 --- a/src/symbolhash.h +++ b/src/symbolhash.h @@ -1,27 +1,19 @@ /* Copyright (C) 2001, 2002 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef SYMBOLHASH_H #define SYMBOLHASH_H 1 diff --git a/src/unaligned.h b/src/unaligned.h index ad7c55a5..29166530 100644 --- a/src/unaligned.h +++ b/src/unaligned.h @@ -1,28 +1,20 @@ /* Unaligned memory access functionality. Copyright (C) 2000, 2001, 2002, 2003, 2008 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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>. */ + 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _UNALIGNED_H #define _UNALIGNED_H 1 diff --git a/src/unstrip.c b/src/unstrip.c index 69c37754..f6660a32 100644 --- a/src/unstrip.c +++ b/src/unstrip.c @@ -1,28 +1,20 @@ /* Combine stripped files with separate symbols and debug information. - Copyright (C) 2007-2011 Red Hat, Inc. - This file is part of Red Hat elfutils. + Copyright (C) 2007-2012 Red Hat, Inc. + This file is part of elfutils. Written by Roland McGrath <[email protected]>, 2007. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* TODO: @@ -235,7 +227,7 @@ print_version (FILE *stream, struct argp_state *state __attribute__ ((unused))) Copyright (C) %s Red Hat, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2009"); +"), "2012"); fprintf (stream, gettext ("Written by %s.\n"), "Roland McGrath"); } diff --git a/src/versionhash.c b/src/versionhash.c index 6126eb95..cc4d2833 100644 --- a/src/versionhash.c +++ b/src/versionhash.c @@ -1,28 +1,20 @@ /* Version symbol hash table implementation. Copyright (C) 2001, 2002 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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>. */ + 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/src/versionhash.h b/src/versionhash.h index 63ca1145..4434e055 100644 --- a/src/versionhash.h +++ b/src/versionhash.h @@ -1,27 +1,19 @@ /* Copyright (C) 2001, 2002 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2001. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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. + 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>. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef VERSIONHASH_H #define VERSIONHASH_H 1 @@ -1,28 +1,20 @@ /* Macros to enable writing native and generic ELF access code. Copyright (C) 2003 Red Hat, Inc. - This file is part of Red Hat elfutils. + This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2003. - 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. + This file 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; either version 3 of the License, or + (at your option) any later version. - Red Hat elfutils is distributed in the hope that it will be useful, but + 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>. */ + 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/src/ylwrap b/src/ylwrap deleted file mode 100644 index b77a9ebb..00000000 --- a/src/ylwrap +++ /dev/null @@ -1,154 +0,0 @@ -#! /bin/sh -# ylwrap - wrapper for lex/yacc invocations. -# Copyright 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. -# Written by Tom Tromey <[email protected]>. -# -# This program 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; either version 2, or (at your option) -# any later version. -# -# This program 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 this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Usage: -# ylwrap INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... -# * INPUT is the input file -# * OUTPUT is file PROG generates -# * DESIRED is file we actually want -# * PROGRAM is program to run -# * ARGS are passed to PROG -# Any number of OUTPUT,DESIRED pairs may be used. - -# The input. -input="$1" -shift -case "$input" in - [\\/]* | ?:[\\/]*) - # Absolute path; do nothing. - ;; - *) - # Relative path. Make it absolute. - input="`pwd`/$input" - ;; -esac - -pairlist= -while test "$#" -ne 0; do - if test "$1" = "--"; then - shift - break - fi - pairlist="$pairlist $1" - shift -done - -# The program to run. -prog="$1" -shift -# Make any relative path in $prog absolute. -case "$prog" in - [\\/]* | ?:[\\/]*) ;; - *[\\/]*) prog="`pwd`/$prog" ;; -esac - -# FIXME: add hostname here for parallel makes that run commands on -# other machines. But that might take us over the 14-char limit. -dirname=ylwrap$$ -trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 -mkdir $dirname || exit 1 - -cd $dirname - -$prog ${1+"$@"} "$input" -status=$? - -if test $status -eq 0; then - set X $pairlist - shift - first=yes - # Since DOS filename conventions don't allow two dots, - # the DOS version of Bison writes out y_tab.c instead of y.tab.c - # and y_tab.h instead of y.tab.h. Test to see if this is the case. - y_tab_nodot="no" - if test -f y_tab.c || test -f y_tab.h; then - y_tab_nodot="yes" - fi - - # The directory holding the input. - input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` - # Quote $INPUT_DIR so we can use it in a regexp. - # FIXME: really we should care about more than `.' and `\'. - input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'` - - while test "$#" -ne 0; do - from="$1" - # Handle y_tab.c and y_tab.h output by DOS - if test $y_tab_nodot = "yes"; then - if test $from = "y.tab.c"; then - from="y_tab.c" - else - if test $from = "y.tab.h"; then - from="y_tab.h" - fi - fi - fi - if test -f "$from"; then - # If $2 is an absolute path name, then just use that, - # otherwise prepend `../'. - case "$2" in - [\\/]* | ?:[\\/]*) target="$2";; - *) target="../$2";; - esac - - # Edit out `#line' or `#' directives. - # - # We don't want the resulting debug information to point at - # an absolute srcdir; it is better for it to just mention the - # .y file with no path. - # - # We want to use the real output file name, not yy.lex.c for - # instance. - # - # We want the include guards to be adjusted too. - FROM=`echo "$from" | sed \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ - -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` - TARGET=`echo "$2" | sed \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ - -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` - sed "/^#/{s,$input_rx,,;s,$from,$2,;s,$FORM,$TO,;}" "$from" >"$target" || - status=$? - else - # A missing file is only an error for the first file. This - # is a blatant hack to let us support using "yacc -d". If -d - # is not specified, we don't want an error when the header - # file is "missing". - if test $first = yes; then - status=1 - fi - fi - shift - shift - first=no - done -else - status=$? -fi - -# Remove the directory. -cd .. -rm -rf $dirname - -exit $status |
