diff options
Diffstat (limited to 'elfutils/src')
-rw-r--r-- | elfutils/src/ChangeLog | 23 | ||||
-rw-r--r-- | elfutils/src/Makefile.am | 45 | ||||
-rw-r--r-- | elfutils/src/Makefile.in | 80 | ||||
-rw-r--r-- | elfutils/src/ar.c | 3 | ||||
-rw-r--r-- | elfutils/src/elflint.c | 1 | ||||
-rw-r--r-- | elfutils/src/readelf.c | 59 | ||||
-rw-r--r-- | elfutils/src/strip.c | 3 | ||||
-rw-r--r-- | elfutils/src/unstrip.c | 3 |
8 files changed, 102 insertions, 115 deletions
diff --git a/elfutils/src/ChangeLog b/elfutils/src/ChangeLog index c4b5b053..0b7c51a6 100644 --- a/elfutils/src/ChangeLog +++ b/elfutils/src/ChangeLog @@ -1,3 +1,26 @@ +2010-02-15 Roland McGrath <roland@redhat.com> + + * Makefile.am: Use config/eu.am for common stuff. + + * readelf.c (print_debug_frame_section): Add a cast to avoid sign + mismatch in comparison. + +2010-02-02 Roland McGrath <roland@redhat.com> + + * readelf.c (print_encoding_base): Handle DW_EH_PE_absptr (zero). + (read_encoded): Likewise. + (print_debug_frame_section): Check for bogus augmentation length. + For P augmentation, use read_encoded, print the encoding description, + and use hex for unsigned values. + +2010-01-15 Roland McGrath <roland@redhat.com> + + * ar.c: Include <sys/stat.h>. + * elflint.c: Likewise. + * readelf.c: Likewise. + * strip.c: Likewise. + * unstrip.c: Likewise + 2010-01-07 Roland McGrath <roland@redhat.com> * readelf.c (print_ehdr): Handle PN_XNUM. diff --git a/elfutils/src/Makefile.am b/elfutils/src/Makefile.am index 9b7d7f0f..afd3bd3a 100644 --- a/elfutils/src/Makefile.am +++ b/elfutils/src/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to create Makefile.in ## -## Copyright (C) 1996-2002, 2003, 2004, 2005, 2006, 2007, 2009 Red Hat, Inc. +## Copyright (C) 1996-2010 Red Hat, Inc. ## This file is part of Red Hat elfutils. ## ## Red Hat elfutils is free software; you can redistribute it and/or modify @@ -24,24 +24,17 @@ ## Network licensing program, please visit www.openinventionnetwork.com ## <http://www.openinventionnetwork.com>. ## -DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \ - -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\" -if MUDFLAP -AM_CFLAGS = -fmudflap -else -AM_CFLAGS = -endif -AM_CFLAGS += -Wall -Wshadow -std=gnu99 $(native_ld_cflags) \ - $(if $($(*F)_no_Werror),,-Werror) \ - $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ - $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $(CFLAGS_$(*F)) - -INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ - -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \ - -I$(srcdir)/../libasm -I$(srcdir)/../lib -I.. +include $(top_srcdir)/config/eu.am +DEFS += $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \ + -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\" +INCLUDES += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ + -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \ + -I$(srcdir)/../libasm AM_LDFLAGS = -Wl,-rpath-link,../libelf:../libdw +no_mudflap.os = -fmudflap + YACC = @YACC@ -d AM_YFLAGS = -pld AM_LFLAGS = -Pld -olex.yy.c @@ -70,8 +63,6 @@ noinst_LIBRARIES += libdummy.a libdummy_a_SOURCES = i386_ld.c endif -textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi - ld_SOURCES = ld.c ldgeneric.c ldlex.l ldscript.y symbolhash.c sectionhash.c \ versionhash.c @@ -87,11 +78,7 @@ ld_modules = i386_ld.c bin_SCRIPTS = make-debug-archive EXTRA_DIST += make-debug-archive.in -CLEANFILES = make-debug-archive - -if MUDFLAP -libmudflap = -lmudflap -endif +CLEANFILES += make-debug-archive if BUILD_STATIC libasm = ../libasm/libasm.a @@ -151,16 +138,6 @@ libld_elf_i386.so: libld_elf_i386_pic.a libld_elf_i386.map $(textrel_check) endif - -%.os: %.c %.o - if $(filter-out -fmudflap,$(COMPILE)) -c -o $@ -fpic -DPIC -DSHARED \ - -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ - `test -f '$<' || echo '$(srcdir)/'`$<; \ - then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \ - rm -f "$(DEPDIR)/$*.Tpo"; \ - else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ - fi - # Special rule to make it possible to define libld_elf_a_SOURCES as we do. # Otherwise make would complain. .deps/none_ld.Po: none_ld.os @@ -183,7 +160,7 @@ installcheck-binPROGRAMS: $(bin_PROGRAMS) done; \ done; rm -f c$${pid}_.???; exit $$bad -CLEANFILES += none_ld.os $(ld_modules:.c=.os) *.gcno *.gcda *.gconv +CLEANFILES += none_ld.os $(ld_modules:.c=.os) *.gconv MAINTAINERCLEANFILES = ldlex.c ldscript.c ldscript.h diff --git a/elfutils/src/Makefile.in b/elfutils/src/Makefile.in index 3f829e96..86d1b64b 100644 --- a/elfutils/src/Makefile.in +++ b/elfutils/src/Makefile.in @@ -37,6 +37,10 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/config/eu.am ChangeLog \ + ldlex.c ldscript.c ylwrap +@MUDFLAP_TRUE@am__append_1 = -fmudflap bin_PROGRAMS = readelf$(EXEEXT) nm$(EXEEXT) size$(EXEEXT) \ strip$(EXEEXT) ld$(EXEEXT) elflint$(EXEEXT) \ findtextrel$(EXEEXT) addr2line$(EXEEXT) elfcmp$(EXEEXT) \ @@ -45,13 +49,11 @@ bin_PROGRAMS = readelf$(EXEEXT) nm$(EXEEXT) size$(EXEEXT) \ @NATIVE_LD_FALSE@noinst_PROGRAMS = $(am__EXEEXT_1) # We never build this library but we need to get the dependency files # of all the linker backends that might be used in a non-generic linker. -@NEVER_TRUE@am__append_1 = libdummy.a +@NEVER_TRUE@am__append_2 = libdummy.a # -ldl is always needed for libebl. -@NATIVE_LD_TRUE@am__append_2 = libld_elf.a +@NATIVE_LD_TRUE@am__append_3 = libld_elf.a @NATIVE_LD_TRUE@am_libld_elf_i386_pic_a_OBJECTS = subdir = src -DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in ChangeLog ldlex.c ldscript.c ylwrap ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/zip.m4 \ @@ -112,7 +114,7 @@ am_ld_OBJECTS = ld.$(OBJEXT) ldgeneric.$(OBJEXT) ldlex.$(OBJEXT) \ versionhash.$(OBJEXT) ld_OBJECTS = $(am_ld_OBJECTS) ld_DEPENDENCIES = $(libebl) $(libelf) $(libeu) $(am__DEPENDENCIES_1) \ - $(am__append_2) + $(am__append_3) ld_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(ld_LDFLAGS) $(LDFLAGS) -o \ $@ am_libld_elf_i386_so_OBJECTS = @@ -210,9 +212,9 @@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEBUGPRED = @DEBUGPRED@ -DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \ - -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\" - +DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) \ + -DDEBUGPRED=@DEBUGPRED@ -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" \ + -DOBJDIR=\"$(shell pwd)\" DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ @@ -312,33 +314,34 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ zip_LIBS = @zip_LIBS@ -@MUDFLAP_FALSE@AM_CFLAGS = -Wall -Wshadow -std=gnu99 \ -@MUDFLAP_FALSE@ $(native_ld_cflags) $(if \ -@MUDFLAP_FALSE@ $($(*F)_no_Werror),,-Werror) $(if \ -@MUDFLAP_FALSE@ $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ -@MUDFLAP_FALSE@ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) \ -@MUDFLAP_FALSE@ $(CFLAGS_$(*F)) -@MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -Wall -Wshadow -std=gnu99 \ -@MUDFLAP_TRUE@ $(native_ld_cflags) $(if \ -@MUDFLAP_TRUE@ $($(*F)_no_Werror),,-Werror) $(if \ -@MUDFLAP_TRUE@ $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ -@MUDFLAP_TRUE@ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) \ -@MUDFLAP_TRUE@ $(CFLAGS_$(*F)) -INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ - -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \ - -I$(srcdir)/../libasm -I$(srcdir)/../lib -I.. +INCLUDES = -I. -I$(srcdir) -I$(top_srcdir)/lib -I.. \ + -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ + -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \ + -I$(srcdir)/../libasm +AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ + $($(*F)_no_Werror),,-Werror) $(if \ + $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ + $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ + $(am__append_1) +@MUDFLAP_FALSE@libmudflap = +@MUDFLAP_TRUE@libmudflap = -lmudflap +COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage $(no_mudflap.os),\ + $(COMPILE)) +CLEANFILES = *.gcno *.gcda make-debug-archive none_ld.os \ + $(ld_modules:.c=.os) *.gconv +textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi AM_LDFLAGS = -Wl,-rpath-link,../libelf:../libdw +no_mudflap.os = -fmudflap AM_YFLAGS = -pld AM_LFLAGS = -Pld -olex.yy.c native_ld = @native_ld@ ld_dsos = libld_elf_i386_pic.a @NATIVE_LD_FALSE@noinst_LIBRARIES = libld_elf.a libar.a $(ld_dsos) \ -@NATIVE_LD_FALSE@ $(am__append_1) -@NATIVE_LD_TRUE@noinst_LIBRARIES = libld_elf.a libar.a $(am__append_1) +@NATIVE_LD_FALSE@ $(am__append_2) +@NATIVE_LD_TRUE@noinst_LIBRARIES = libld_elf.a libar.a $(am__append_2) @NATIVE_LD_TRUE@native_ld_cflags = -DBASE_ELF_NAME=elf_$(base_cpu) @NEVER_TRUE@libdummy_a_SOURCES = i386_ld.c -textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi ld_SOURCES = ld.c ldgeneric.c ldlex.l ldscript.y symbolhash.c sectionhash.c \ versionhash.c @@ -350,9 +353,6 @@ EXTRA_DIST = elf32-i386.script libld_elf_i386.map $(ld_modules) \ arlib.h debugpred.h make-debug-archive.in ld_modules = i386_ld.c bin_SCRIPTS = make-debug-archive -CLEANFILES = make-debug-archive none_ld.os $(ld_modules:.c=.os) *.gcno \ - *.gcda *.gconv -@MUDFLAP_TRUE@libmudflap = -lmudflap @BUILD_STATIC_FALSE@libasm = ../libasm/libasm.so @BUILD_STATIC_TRUE@libasm = ../libasm/libasm.a @BUILD_STATIC_FALSE@libdw = ../libdw/libdw.so @@ -372,7 +372,7 @@ nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl size_LDADD = $(libelf) $(libeu) $(libmudflap) strip_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl ld_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl \ - $(am__append_2) + $(am__append_3) ld_LDFLAGS = -rdynamic elflint_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl findtextrel_LDADD = $(libdw) $(libelf) $(libmudflap) @@ -395,7 +395,7 @@ all: all-am .SUFFIXES: .SUFFIXES: .c .l .o .obj .y -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/eu.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -836,6 +836,15 @@ uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS uninstall-am uninstall-binPROGRAMS uninstall-binSCRIPTS +%.os: %.c %.o +@AMDEP_TRUE@ if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \ +@AMDEP_TRUE@ -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \ +@AMDEP_TRUE@ then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \ +@AMDEP_TRUE@ rm -f "$(DEPDIR)/$*.Tpo"; \ +@AMDEP_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@AMDEP_TRUE@ fi +@AMDEP_FALSE@ $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED $< + ldlex.o: ldscript.c ldscript.h: ldscript.c @NATIVE_LD_FALSE@libld_elf_i386.so: libld_elf_i386_pic.a libld_elf_i386.map @@ -844,15 +853,6 @@ ldscript.h: ldscript.c @NATIVE_LD_FALSE@ -Wl,--version-script,$(srcdir)/libld_elf_i386.map @NATIVE_LD_FALSE@ $(textrel_check) -%.os: %.c %.o - if $(filter-out -fmudflap,$(COMPILE)) -c -o $@ -fpic -DPIC -DSHARED \ - -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ - `test -f '$<' || echo '$(srcdir)/'`$<; \ - then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \ - rm -f "$(DEPDIR)/$*.Tpo"; \ - else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ - fi - # Special rule to make it possible to define libld_elf_a_SOURCES as we do. # Otherwise make would complain. .deps/none_ld.Po: none_ld.os diff --git a/elfutils/src/ar.c b/elfutils/src/ar.c index 5d7a6e76..149d116d 100644 --- a/elfutils/src/ar.c +++ b/elfutils/src/ar.c @@ -1,5 +1,5 @@ /* Create, modify, and extract from archives. - Copyright (C) 2005, 2007, 2009 Red Hat, Inc. + Copyright (C) 2005-2010 Red Hat, Inc. Written by Ulrich Drepper <drepper@redhat.com>, 2005. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -45,6 +45,7 @@ #include <time.h> #include <unistd.h> #include <sys/mman.h> +#include <sys/stat.h> #include <sys/time.h> #include <system.h> diff --git a/elfutils/src/elflint.c b/elfutils/src/elflint.c index 63d8389e..531122bf 100644 --- a/elfutils/src/elflint.c +++ b/elfutils/src/elflint.c @@ -42,6 +42,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <sys/stat.h> #include <sys/param.h> #include <elf-knowledge.h> diff --git a/elfutils/src/readelf.c b/elfutils/src/readelf.c index 44648669..7b3c4f8b 100644 --- a/elfutils/src/readelf.c +++ b/elfutils/src/readelf.c @@ -49,6 +49,7 @@ #include <time.h> #include <unistd.h> #include <sys/param.h> +#include <sys/stat.h> #include <system.h> #include "../libelf/libelfP.h" @@ -4704,8 +4705,7 @@ print_encoding_base (const char *pfx, unsigned int fde_encoding) { unsigned int w = fde_encoding; - if (w & 0xf) - w = print_encoding (w); + w = print_encoding (w); if (w & 0x70) { @@ -4727,6 +4727,10 @@ static const unsigned char * read_encoded (unsigned int encoding, const unsigned char *readp, const unsigned char *const endp, uint64_t *res, Dwarf *dbg) { + if ((encoding & 0xf) == DW_EH_PE_absptr) + encoding = gelf_getclass (dbg->elf) == ELFCLASS32 + ? DW_EH_PE_udata4 : DW_EH_PE_udata8; + switch (encoding & 0xf) { case DW_EH_PE_uleb128: @@ -4914,6 +4918,9 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, unsigned int augmentationlen; get_uleb128 (augmentationlen, readp); + if (augmentationlen > (size_t) (dataend - readp)) + error (1, 0, gettext ("invalid augmentation length")); + const char *hdr = "Augmentation data:"; const char *cp = augmentation + 1; while (*cp != '\0') @@ -4940,51 +4947,27 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, const unsigned char *startp = readp; unsigned int encoding = *readp++; uint64_t val = 0; - int64_t sval = 0; - bool is_signed = false; + readp = read_encoded (encoding, readp, + readp - 1 + augmentationlen, + &val, dbg); + + while (++startp < readp) + printf ("%#x ", *startp); + putchar ('('); + print_encoding (encoding); + putchar (' '); switch (encoding & 0xf) { - case DW_EH_PE_uleb128: - get_uleb128 (val, readp); - break; case DW_EH_PE_sleb128: - get_sleb128 (sval, readp); - is_signed = true; - break; - case DW_EH_PE_udata2: - val = read_2ubyte_unaligned_inc (dbg, readp); - break; - case DW_EH_PE_udata4: - val = read_4ubyte_unaligned_inc (dbg, readp); - break; - case DW_EH_PE_udata8: - val = read_8ubyte_unaligned_inc (dbg, readp); - break; case DW_EH_PE_sdata2: - val = read_2sbyte_unaligned_inc (dbg, readp); - is_signed = true; - break; case DW_EH_PE_sdata4: - val = read_4sbyte_unaligned_inc (dbg, readp); - is_signed = true; - break; - case DW_EH_PE_sdata8: - val = read_8sbyte_unaligned_inc (dbg, readp); - is_signed = true; + printf ("%" PRId64 ")\n", val); break; default: - error (1, 0, - gettext ("invalid augmentation encoding")); + printf ("%#" PRIx64 ")\n", val); + break; } - - while (++startp < readp) - printf ("%#x ", *startp); - - if (is_signed) - printf ("(%" PRId64 ")\n", sval); - else - printf ("(%" PRIu64 ")\n", val); } else printf ("(%x)\n", *readp++); diff --git a/elfutils/src/strip.c b/elfutils/src/strip.c index 32cf0d70..7b2b889a 100644 --- a/elfutils/src/strip.c +++ b/elfutils/src/strip.c @@ -1,5 +1,5 @@ /* Discard section not used at runtime from object files. - Copyright (C) 2000-2008, 2009 Red Hat, Inc. + Copyright (C) 2000-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2000. @@ -46,6 +46,7 @@ #include <string.h> #include <unistd.h> #include <sys/param.h> +#include <sys/stat.h> #include <sys/time.h> #include <elf-knowledge.h> diff --git a/elfutils/src/unstrip.c b/elfutils/src/unstrip.c index 284607b3..0984e6bc 100644 --- a/elfutils/src/unstrip.c +++ b/elfutils/src/unstrip.c @@ -1,5 +1,5 @@ /* Combine stripped files with separate symbols and debug information. - Copyright (C) 2007, 2009 Red Hat, Inc. + Copyright (C) 2007-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Roland McGrath <roland@redhat.com>, 2007. @@ -52,6 +52,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <sys/stat.h> #include <gelf.h> #include <libebl.h> |