readelf.c (get_note_type): Handle notes not in core files.

(process_note_sections): New function.
  (process_corefile_contents): Rename to ...
  (process_notes): ... this.
  (process_object): Call process_notes, not process_corefile_contents.
doc/binutils.texi: Update readelf -n documentation.
This commit is contained in:
Nick Clifton 2004-10-26 16:05:42 +00:00
parent e7d6a6d283
commit 1ec5cd3721
4 changed files with 126 additions and 148 deletions

View File

@ -1,3 +1,13 @@
2004-10-26 Mark Mitchell <mark@codesourcery.com>
* readelf.c (get_note_type): Handle notes not in core files.
(process_note_sections): New function.
(process_corefile_contents): Rename to ...
(process_notes): ... this.
(process_object): Call process_notes, not
process_corefile_contents.
* doc/binutils.texi: Update readelf -n documentation.
2004-10-26 Jakub Jelinek <jakub@redhat.com>
* ar.c (extract_file): Set atime to mtime for ar xo.

View File

@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -64,68 +64,23 @@ host_triplet = @host@
target_alias = @target_alias@
target_triplet = @target@
AR = @AR@
AS = @AS@
BUILD_DLLTOOL = @BUILD_DLLTOOL@
BUILD_DLLWRAP = @BUILD_DLLWRAP@
BUILD_MISC = @BUILD_MISC@
BUILD_NLMCONV = @BUILD_NLMCONV@
BUILD_SRCONV = @BUILD_SRCONV@
BUILD_WINDRES = @BUILD_WINDRES@
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DATADIRNAME = @DATADIRNAME@
DEMANGLER_NAME = @DEMANGLER_NAME@
DLLTOOL = @DLLTOOL@
DLLTOOL_DEFS = @DLLTOOL_DEFS@
EMULATION = @EMULATION@
EMULATION_VECTOR = @EMULATION_VECTOR@
EXEEXT = @EXEEXT@
GCJ = @GCJ@
GCJFLAGS = @GCJFLAGS@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
GNATBIND = @GNATBIND@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
HDEFINES = @HDEFINES@
INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
INSTOBJEXT = @INSTOBJEXT@
INTLDEPS = @INTLDEPS@
INTLOBJS = @INTLOBJS@
LIBTOOL = @LIBTOOL@
LN = @LN@
LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKINSTALLDIRS = @MKINSTALLDIRS@
MSGFMT = @MSGFMT@
NLMCONV_DEFS = @NLMCONV_DEFS@
OBJDUMP = @OBJDUMP@
OBJDUMP_DEFS = @OBJDUMP_DEFS@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
POFILES = @POFILES@
POSUB = @POSUB@
RANLIB = @RANLIB@
STRIP = @STRIP@
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
bfdincludedir = @bfdincludedir@
bfdlibdir = @bfdlibdir@
build_noncanonical = @build_noncanonical@
build_subdir = @build_subdir@
do_compare = @do_compare@
host_noncanonical = @host_noncanonical@
host_subdir = @host_subdir@
l = @l@
ncn_cv_ = @ncn_cv_@
target_noncanonical = @target_noncanonical@
target_subdir = @target_subdir@
INTLLIBS = @INTLLIBS@
@ -329,7 +284,6 @@ DISTCLEANFILES = sysinfo sysroff.c sysroff.h \
MOSTLYCLEANFILES = sysinfo binutils.log binutils.sum abcdefgh*
CLEANFILES = dep.sed DEP DEPA DEP1 DEP2
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
@ -345,96 +299,77 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I.
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
nlmconv_OBJECTS = nlmconv.$(OBJEXT) nlmheader.$(OBJEXT) \
bucomm.$(OBJEXT) version.$(OBJEXT) filemode.$(OBJEXT)
nlmconv_OBJECTS = nlmconv.o nlmheader.o bucomm.o version.o filemode.o
nlmconv_LDADD = $(LDADD)
nlmconv_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
nlmconv_LDFLAGS =
srconv_OBJECTS = srconv.$(OBJEXT) coffgrok.$(OBJEXT) bucomm.$(OBJEXT) \
version.$(OBJEXT) filemode.$(OBJEXT)
srconv_OBJECTS = srconv.o coffgrok.o bucomm.o version.o filemode.o
srconv_LDADD = $(LDADD)
srconv_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
srconv_LDFLAGS =
sysdump_OBJECTS = sysdump.$(OBJEXT) bucomm.$(OBJEXT) version.$(OBJEXT) \
filemode.$(OBJEXT)
sysdump_OBJECTS = sysdump.o bucomm.o version.o filemode.o
sysdump_LDADD = $(LDADD)
sysdump_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
sysdump_LDFLAGS =
coffdump_OBJECTS = coffdump.$(OBJEXT) coffgrok.$(OBJEXT) \
bucomm.$(OBJEXT) version.$(OBJEXT) filemode.$(OBJEXT)
coffdump_OBJECTS = coffdump.o coffgrok.o bucomm.o version.o filemode.o
coffdump_LDADD = $(LDADD)
coffdump_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
coffdump_LDFLAGS =
dlltool_OBJECTS = dlltool.$(OBJEXT) defparse.$(OBJEXT) deflex.$(OBJEXT) \
bucomm.$(OBJEXT) version.$(OBJEXT) filemode.$(OBJEXT)
dlltool_OBJECTS = dlltool.o defparse.o deflex.o bucomm.o version.o \
filemode.o
dlltool_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
dlltool_LDFLAGS =
windres_OBJECTS = windres.$(OBJEXT) resrc.$(OBJEXT) rescoff.$(OBJEXT) \
resbin.$(OBJEXT) rcparse.$(OBJEXT) rclex.$(OBJEXT) winduni.$(OBJEXT) \
resres.$(OBJEXT) bucomm.$(OBJEXT) version.$(OBJEXT) filemode.$(OBJEXT)
windres_OBJECTS = windres.o resrc.o rescoff.o resbin.o rcparse.o \
rclex.o winduni.o resres.o bucomm.o version.o filemode.o
windres_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
windres_LDFLAGS =
dllwrap_OBJECTS = dllwrap.$(OBJEXT) version.$(OBJEXT)
dllwrap_OBJECTS = dllwrap.o version.o
dllwrap_DEPENDENCIES = ../libiberty/libiberty.a
dllwrap_LDFLAGS =
size_OBJECTS = size.$(OBJEXT) bucomm.$(OBJEXT) version.$(OBJEXT) \
filemode.$(OBJEXT)
size_OBJECTS = size.o bucomm.o version.o filemode.o
size_LDADD = $(LDADD)
size_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
size_LDFLAGS =
objdump_OBJECTS = objdump.$(OBJEXT) budemang.$(OBJEXT) prdbg.$(OBJEXT) \
rddbg.$(OBJEXT) debug.$(OBJEXT) stabs.$(OBJEXT) ieee.$(OBJEXT) \
rdcoff.$(OBJEXT) bucomm.$(OBJEXT) version.$(OBJEXT) filemode.$(OBJEXT)
objdump_OBJECTS = objdump.o budemang.o prdbg.o rddbg.o debug.o stabs.o \
ieee.o rdcoff.o bucomm.o version.o filemode.o
objdump_DEPENDENCIES = ../opcodes/libopcodes.la ../bfd/libbfd.la \
../libiberty/libiberty.a
objdump_LDFLAGS =
ar_OBJECTS = arparse.$(OBJEXT) arlex.$(OBJEXT) ar.$(OBJEXT) \
not-ranlib.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) binemul.$(OBJEXT) \
emul_$(EMULATION).$(OBJEXT) bucomm.$(OBJEXT) version.$(OBJEXT) \
filemode.$(OBJEXT)
ar_OBJECTS = arparse.o arlex.o ar.o not-ranlib.o arsup.o rename.o \
binemul.o emul_$(EMULATION).o bucomm.o version.o filemode.o
ar_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
ar_LDFLAGS =
strings_OBJECTS = strings.$(OBJEXT) bucomm.$(OBJEXT) version.$(OBJEXT) \
filemode.$(OBJEXT)
strings_OBJECTS = strings.o bucomm.o version.o filemode.o
strings_LDADD = $(LDADD)
strings_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
strings_LDFLAGS =
ranlib_OBJECTS = ar.$(OBJEXT) is-ranlib.$(OBJEXT) arparse.$(OBJEXT) \
arlex.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) binemul.$(OBJEXT) \
emul_$(EMULATION).$(OBJEXT) bucomm.$(OBJEXT) version.$(OBJEXT) \
filemode.$(OBJEXT)
ranlib_OBJECTS = ar.o is-ranlib.o arparse.o arlex.o arsup.o rename.o \
binemul.o emul_$(EMULATION).o bucomm.o version.o filemode.o
ranlib_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
ranlib_LDFLAGS =
objcopy_OBJECTS = objcopy.$(OBJEXT) not-strip.$(OBJEXT) \
rename.$(OBJEXT) rddbg.$(OBJEXT) debug.$(OBJEXT) stabs.$(OBJEXT) \
ieee.$(OBJEXT) rdcoff.$(OBJEXT) wrstabs.$(OBJEXT) bucomm.$(OBJEXT) \
version.$(OBJEXT) filemode.$(OBJEXT)
objcopy_OBJECTS = objcopy.o not-strip.o rename.o rddbg.o debug.o \
stabs.o ieee.o rdcoff.o wrstabs.o bucomm.o version.o filemode.o
objcopy_LDADD = $(LDADD)
objcopy_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
objcopy_LDFLAGS =
addr2line_OBJECTS = addr2line.$(OBJEXT) budemang.$(OBJEXT) \
bucomm.$(OBJEXT) version.$(OBJEXT) filemode.$(OBJEXT)
addr2line_OBJECTS = addr2line.o budemang.o bucomm.o version.o \
filemode.o
addr2line_LDADD = $(LDADD)
addr2line_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
addr2line_LDFLAGS =
readelf_OBJECTS = readelf.$(OBJEXT) version.$(OBJEXT) \
unwind-ia64.$(OBJEXT)
readelf_OBJECTS = readelf.o version.o unwind-ia64.o
readelf_DEPENDENCIES = ../libiberty/libiberty.a
readelf_LDFLAGS =
nm_new_OBJECTS = nm.$(OBJEXT) budemang.$(OBJEXT) bucomm.$(OBJEXT) \
version.$(OBJEXT) filemode.$(OBJEXT)
nm_new_OBJECTS = nm.o budemang.o bucomm.o version.o filemode.o
nm_new_LDADD = $(LDADD)
nm_new_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
nm_new_LDFLAGS =
strip_new_OBJECTS = objcopy.$(OBJEXT) is-strip.$(OBJEXT) \
rename.$(OBJEXT) rddbg.$(OBJEXT) debug.$(OBJEXT) stabs.$(OBJEXT) \
ieee.$(OBJEXT) rdcoff.$(OBJEXT) wrstabs.$(OBJEXT) bucomm.$(OBJEXT) \
version.$(OBJEXT) filemode.$(OBJEXT)
strip_new_OBJECTS = objcopy.o is-strip.o rename.o rddbg.o debug.o \
stabs.o ieee.o rdcoff.o wrstabs.o bucomm.o version.o filemode.o
strip_new_LDADD = $(LDADD)
strip_new_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
strip_new_LDFLAGS =
cxxfilt_OBJECTS = cxxfilt.$(OBJEXT) bucomm.$(OBJEXT) version.$(OBJEXT) \
filemode.$(OBJEXT)
cxxfilt_OBJECTS = cxxfilt.o bucomm.o version.o filemode.o
cxxfilt_LDADD = $(LDADD)
cxxfilt_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
cxxfilt_LDFLAGS =
@ -447,20 +382,23 @@ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
DIST_COMMON = README ./stamp-h.in ChangeLog Makefile.am Makefile.in \
NEWS acinclude.m4 aclocal.m4 arlex.c arparse.c config.in configure \
configure.in deflex.c defparse.c nlmheader.c rclex.c rcparse.c
NEWS acinclude.m4 arlex.c arparse.c config.in configure configure.in \
deflex.c defparse.c nlmheader.c rclex.c rcparse.c
PACKAGE = @PACKAGE@
VERSION = @VERSION@
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
SOURCES = $(nlmconv_SOURCES) $(srconv_SOURCES) $(sysdump_SOURCES) $(coffdump_SOURCES) $(dlltool_SOURCES) $(windres_SOURCES) $(dllwrap_SOURCES) $(size_SOURCES) $(objdump_SOURCES) $(ar_SOURCES) $(strings_SOURCES) $(ranlib_SOURCES) $(objcopy_SOURCES) $(addr2line_SOURCES) $(readelf_SOURCES) $(nm_new_SOURCES) $(strip_new_SOURCES) $(cxxfilt_SOURCES)
OBJECTS = $(nlmconv_OBJECTS) $(srconv_OBJECTS) $(sysdump_OBJECTS) $(coffdump_OBJECTS) $(dlltool_OBJECTS) $(windres_OBJECTS) $(dllwrap_OBJECTS) $(size_OBJECTS) $(objdump_OBJECTS) $(ar_OBJECTS) $(strings_OBJECTS) $(ranlib_OBJECTS) $(objcopy_OBJECTS) $(addr2line_OBJECTS) $(readelf_OBJECTS) $(nm_new_OBJECTS) $(strip_new_OBJECTS) $(cxxfilt_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .l .lo .o .obj .s .y
.SUFFIXES: .S .c .l .lo .o .s .y
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --cygnus Makefile
@ -541,11 +479,6 @@ maintainer-clean-noinstPROGRAMS:
.c.o:
$(COMPILE) -c $<
# FIXME: We should only use cygpath when building on Windows,
# and only if it is available.
.c.obj:
$(COMPILE) -c `cygpath -w $<`
.s.o:
$(COMPILE) -c $<
@ -554,7 +487,6 @@ maintainer-clean-noinstPROGRAMS:
mostlyclean-compile:
-rm -f *.o core *.core
-rm -f *.$(OBJEXT)
clean-compile:
@ -699,7 +631,7 @@ maintainer-clean-recursive:
dot_seen=no; \
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
rev="$$subdir $$rev"; \
test "$$subdir" != "." || dot_seen=yes; \
test "$$subdir" = "." && dot_seen=yes; \
done; \
test "$$dot_seen" = "no" && rev=". $$rev"; \
target=`echo $@ | sed s/-recursive//`; \
@ -881,7 +813,7 @@ distclean-generic:
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
-test -z "arlex.cdeflex.crclex.carparse.harparse.cdefparse.hdefparse.cnlmheader.hnlmheader.crcparse.hrcparse.c" || rm -f arlex.c deflex.c rclex.c arparse.h arparse.c defparse.h defparse.c nlmheader.h nlmheader.c rcparse.h rcparse.c
-test -z "arlexldeflexlrclexlarparseharparsecdefparsehdefparsecnlmheaderhnlmheadercrcparsehrcparsec" || rm -f arlexl deflexl rclexl arparseh arparsec defparseh defparsec nlmheaderh nlmheaderc rcparseh rcparsec
mostlyclean-am: mostlyclean-hdr mostlyclean-binPROGRAMS \
mostlyclean-noinstPROGRAMS mostlyclean-compile \
mostlyclean-libtool mostlyclean-tags \

View File

@ -3225,8 +3225,8 @@ Display all the headers in the file. Equivalent to @option{-h -l -S}.
@item -n
@itemx --notes
@cindex ELF core notes
Displays the contents of the NOTE segment, if it exists.
@cindex ELF notes
Displays the contents of the NOTE segments and/or sections, if any.
@item -r
@itemx --relocs

View File

@ -10348,24 +10348,49 @@ get_note_type (unsigned e_type)
{
static char buff[64];
switch (e_type)
{
case NT_AUXV: return _("NT_AUXV (auxiliary vector)");
case NT_PRSTATUS: return _("NT_PRSTATUS (prstatus structure)");
case NT_FPREGSET: return _("NT_FPREGSET (floating point registers)");
case NT_PRPSINFO: return _("NT_PRPSINFO (prpsinfo structure)");
case NT_TASKSTRUCT: return _("NT_TASKSTRUCT (task structure)");
case NT_PRXFPREG: return _("NT_PRXFPREG (user_xfpregs structure)");
case NT_PSTATUS: return _("NT_PSTATUS (pstatus structure)");
case NT_FPREGS: return _("NT_FPREGS (floating point registers)");
case NT_PSINFO: return _("NT_PSINFO (psinfo structure)");
case NT_LWPSTATUS: return _("NT_LWPSTATUS (lwpstatus_t structure)");
case NT_LWPSINFO: return _("NT_LWPSINFO (lwpsinfo_t structure)");
case NT_WIN32PSTATUS: return _("NT_WIN32PSTATUS (win32_pstatus structure)");
default:
sprintf (buff, _("Unknown note type: (0x%08x)"), e_type);
return buff;
}
if (elf_header.e_type == ET_CORE)
switch (e_type)
{
case NT_AUXV:
return _("NT_AUXV (auxiliary vector)");
case NT_PRSTATUS:
return _("NT_PRSTATUS (prstatus structure)");
case NT_FPREGSET:
return _("NT_FPREGSET (floating point registers)");
case NT_PRPSINFO:
return _("NT_PRPSINFO (prpsinfo structure)");
case NT_TASKSTRUCT:
return _("NT_TASKSTRUCT (task structure)");
case NT_PRXFPREG:
return _("NT_PRXFPREG (user_xfpregs structure)");
case NT_PSTATUS:
return _("NT_PSTATUS (pstatus structure)");
case NT_FPREGS:
return _("NT_FPREGS (floating point registers)");
case NT_PSINFO:
return _("NT_PSINFO (psinfo structure)");
case NT_LWPSTATUS:
return _("NT_LWPSTATUS (lwpstatus_t structure)");
case NT_LWPSINFO:
return _("NT_LWPSINFO (lwpsinfo_t structure)");
case NT_WIN32PSTATUS:
return _("NT_WIN32PSTATUS (win32_pstatus structure)");
default:
break;
}
else
switch (e_type)
{
case NT_VERSION:
return _("NT_VERSION (version)");
case NT_ARCH:
return _("NT_ARCH (architecture)");
default:
break;
}
sprintf (buff, _("Unknown note type: (0x%08x)"), e_type);
return buff;
}
static const char *
@ -10440,22 +10465,18 @@ process_note (Elf_Internal_Note *pnote)
const char *nt;
if (pnote->namesz == 0)
{
/* If there is no note name, then use the default set of
note type strings. */
nt = get_note_type (pnote->type);
}
/* If there is no note name, then use the default set of
note type strings. */
nt = get_note_type (pnote->type);
else if (strncmp (pnote->namedata, "NetBSD-CORE", 11) == 0)
{
/* NetBSD-specific core file notes. */
nt = get_netbsd_elfcore_note_type (pnote->type);
}
/* NetBSD-specific core file notes. */
nt = get_netbsd_elfcore_note_type (pnote->type);
else
{
/* Don't recognize this note name; just use the default set of
note type strings. */
/* Don't recognize this note name; just use the default set of
note type strings. */
nt = get_note_type (pnote->type);
}
printf (" %s\t\t0x%08lx\t%s\n",
pnote->namesz ? pnote->namedata : "(NONE)",
@ -10570,24 +10591,39 @@ process_corefile_note_segments (FILE *file)
}
static int
process_corefile_contents (FILE *file)
process_note_sections (FILE *file)
{
Elf_Internal_Shdr *section;
unsigned long i;
int res = 1;
for (i = 0, section = section_headers;
i < elf_header.e_shnum;
i++, section++)
if (section->sh_type == SHT_NOTE)
res &= process_corefile_note_segment (file,
(bfd_vma) section->sh_offset,
(bfd_vma) section->sh_size);
return res;
}
static int
process_notes (FILE *file)
{
/* If we have not been asked to display the notes then do nothing. */
if (! do_notes)
return 1;
/* If file is not a core file then exit. */
if (elf_header.e_type != ET_CORE)
return 1;
return process_note_sections (file);
/* No program headers means no NOTE segment. */
if (elf_header.e_phnum == 0)
{
printf (_("No note segments present in the core file.\n"));
return 1;
}
if (elf_header.e_phnum > 0)
return process_corefile_note_segments (file);
return process_corefile_note_segments (file);
printf (_("No note segments present in the core file.\n"));
return 1;
}
static int
@ -10756,7 +10792,7 @@ process_object (char *file_name, FILE *file)
process_section_contents (file);
process_corefile_contents (file);
process_notes (file);
process_gnu_liblist (file);