Add elfedit

binutils/

2010-01-06  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/11131
	* Makefile.am (ELFEDIT_PROG): New.
	(bin_PROGRAMS): Add $(ELFEDIT_PROG).
	(CFILES): Add elfedit.c.
	(elfedit_DEPENDENCIES): New.
	(elfedit_SOURCES): Likewise.
	(elfedit_LDADD): Likewise.
	* Makefile.in: Regenerated.

	* elfedit.c: New.

	* doc/binutils.texi: Document elfedit.

	* doc/Makefile.am (man_MANS): Add elfedit.1.
	(elfedit.1): New.
	* doc/Makefile.in: Regenerated.

binutils/testsuite/

2010-01-06  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/11131
	* binutils-all/elfedit-1.d: New.
	* binutils-all/elfedit.exp: Likewise.

	* config/default.exp (ELFEDIT): New. Set if it doesn't exist.
	(ELFEDITFLAGS): Likewise.

	* lib/utils-lib.exp (run_dump_test): Support elfedit.
This commit is contained in:
H.J. Lu 2010-01-06 16:52:15 +00:00
parent e3e535bc58
commit 30fd33bb93
12 changed files with 1309 additions and 11 deletions

View File

@ -1,3 +1,22 @@
2010-01-06 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/11131
* Makefile.am (ELFEDIT_PROG): New.
(bin_PROGRAMS): Add $(ELFEDIT_PROG).
(CFILES): Add elfedit.c.
(elfedit_DEPENDENCIES): New.
(elfedit_SOURCES): Likewise.
(elfedit_LDADD): Likewise.
* Makefile.in: Regenerated.
* elfedit.c: New.
* doc/binutils.texi: Document elfedit.
* doc/Makefile.am (man_MANS): Add elfedit.1.
(elfedit.1): New.
* doc/Makefile.in: Regenerated.
2010-01-06 Tristan Gingold <gingold@adacore.com>
* nm.c (usage): Remove extra blanks.

View File

@ -39,6 +39,8 @@ STRINGS_PROG=strings
READELF_PROG=readelf
ELFEDIT_PROG=elfedit
# These should all be the same program too.
SIZE_PROG=size
NM_PROG=nm-new
@ -58,7 +60,7 @@ DLLWRAP_PROG=dllwrap
SRCONV_PROG=srconv$(EXEEXT) sysdump$(EXEEXT) coffdump$(EXEEXT)
bin_PROGRAMS = $(SIZE_PROG) $(OBJDUMP_PROG) $(AR_PROG) $(STRINGS_PROG) $(RANLIB_PROG) $(OBJCOPY_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ @BUILD_WINDMC@ $(ADDR2LINE_PROG) $(READELF_PROG) @BUILD_DLLWRAP@ @BUILD_INSTALL_MISC@
bin_PROGRAMS = $(SIZE_PROG) $(OBJDUMP_PROG) $(AR_PROG) $(STRINGS_PROG) $(RANLIB_PROG) $(OBJCOPY_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ @BUILD_WINDMC@ $(ADDR2LINE_PROG) $(READELF_PROG) $(ELFEDIT_PROG) @BUILD_DLLWRAP@ @BUILD_INSTALL_MISC@
## We need a special rule to install the programs which are built with
## -new, and to rename cxxfilt to c++filt.
@ -100,7 +102,7 @@ CFILES = \
rclex.c rdcoff.c rddbg.c readelf.c rename.c \
resbin.c rescoff.c resrc.c resres.c \
size.c srconv.c stabs.c strings.c sysdump.c \
unwind-ia64.c version.c \
unwind-ia64.c elfedit.c version.c \
windres.c winduni.c wrstabs.c \
windmc.c mclex.c
@ -179,6 +181,7 @@ windres_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
windmc_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
addr2line_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
readelf_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
elfedit_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
dllwrap_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL)
@ -192,6 +195,9 @@ strings_SOURCES = strings.c $(BULIBS)
readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c
readelf_LDADD = $(LIBINTL) $(LIBIBERTY)
elfedit_SOURCES = elfedit.c version.c
elfedit_LDADD = $(LIBINTL) $(LIBIBERTY)
strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
nm_new_SOURCES = nm.c $(BULIBS)

View File

@ -39,8 +39,8 @@ bin_PROGRAMS = $(am__EXEEXT_6) $(am__EXEEXT_7) $(am__EXEEXT_8) \
$(am__EXEEXT_9) $(am__EXEEXT_10) $(am__EXEEXT_11) \
@BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ \
@BUILD_WINDMC@ $(am__EXEEXT_12) $(am__EXEEXT_13) \
@BUILD_DLLWRAP@ @BUILD_INSTALL_MISC@ $(am__empty)
noinst_PROGRAMS = $(am__EXEEXT_17) @BUILD_MISC@
$(am__EXEEXT_14) @BUILD_DLLWRAP@ @BUILD_INSTALL_MISC@
noinst_PROGRAMS = $(am__EXEEXT_18) @BUILD_MISC@
EXTRA_PROGRAMS = $(am__EXEEXT_1) srconv$(EXEEXT) sysdump$(EXEEXT) \
coffdump$(EXEEXT) $(am__EXEEXT_2) $(am__EXEEXT_3) \
$(am__EXEEXT_4) $(am__EXEEXT_5)
@ -93,11 +93,12 @@ am__EXEEXT_10 = ranlib$(EXEEXT)
am__EXEEXT_11 = objcopy$(EXEEXT)
am__EXEEXT_12 = addr2line$(EXEEXT)
am__EXEEXT_13 = readelf$(EXEEXT)
am__EXEEXT_14 = elfedit$(EXEEXT)
am__installdirs = "$(DESTDIR)$(bindir)"
am__EXEEXT_14 = nm-new$(EXEEXT)
am__EXEEXT_15 = strip-new$(EXEEXT)
am__EXEEXT_16 = cxxfilt$(EXEEXT)
am__EXEEXT_17 = $(am__EXEEXT_14) $(am__EXEEXT_15) $(am__EXEEXT_16)
am__EXEEXT_15 = nm-new$(EXEEXT)
am__EXEEXT_16 = strip-new$(EXEEXT)
am__EXEEXT_17 = cxxfilt$(EXEEXT)
am__EXEEXT_18 = $(am__EXEEXT_15) $(am__EXEEXT_16) $(am__EXEEXT_17)
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
am__objects_1 = bucomm.$(OBJEXT) version.$(OBJEXT) filemode.$(OBJEXT)
am_addr2line_OBJECTS = addr2line.$(OBJEXT) $(am__objects_1)
@ -161,6 +162,8 @@ strip_new_LDADD = $(LDADD)
am_sysdump_OBJECTS = sysdump.$(OBJEXT) $(am__objects_1)
sysdump_OBJECTS = $(am_sysdump_OBJECTS)
sysdump_LDADD = $(LDADD)
am_elfedit_OBJECTS = elfedit.$(OBJEXT) version.$(OBJEXT)
elfedit_OBJECTS = $(am_elfedit_OBJECTS)
am_windmc_OBJECTS = windmc.$(OBJEXT) mcparse.$(OBJEXT) mclex.$(OBJEXT) \
winduni.$(OBJEXT) $(am__objects_1)
windmc_OBJECTS = $(am_windmc_OBJECTS)
@ -197,7 +200,7 @@ SOURCES = $(addr2line_SOURCES) $(ar_SOURCES) $(EXTRA_ar_SOURCES) \
$(objcopy_SOURCES) $(objdump_SOURCES) $(ranlib_SOURCES) \
$(readelf_SOURCES) $(size_SOURCES) $(srconv_SOURCES) \
$(strings_SOURCES) $(strip_new_SOURCES) $(sysdump_SOURCES) \
$(windmc_SOURCES) $(windres_SOURCES)
$(elfedit_SOURCES) $(windmc_SOURCES) $(windres_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
@ -392,6 +395,7 @@ OBJCOPY_PROG = objcopy
STRIP_PROG = strip-new
STRINGS_PROG = strings
READELF_PROG = readelf
ELFEDIT_PROG = elfedit
# These should all be the same program too.
SIZE_PROG = size
@ -440,7 +444,7 @@ CFILES = \
rclex.c rdcoff.c rddbg.c readelf.c rename.c \
resbin.c rescoff.c resrc.c resres.c \
size.c srconv.c stabs.c strings.c sysdump.c \
unwind-ia64.c version.c \
unwind-ia64.c elfedit.c version.c \
windres.c winduni.c wrstabs.c \
windmc.c mclex.c
@ -496,6 +500,7 @@ windres_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
windmc_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
addr2line_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
readelf_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
elfedit_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
dllwrap_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL)
size_SOURCES = size.c $(BULIBS)
@ -503,6 +508,8 @@ objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
strings_SOURCES = strings.c $(BULIBS)
readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c
readelf_LDADD = $(LIBINTL) $(LIBIBERTY)
elfedit_SOURCES = elfedit.c version.c
elfedit_LDADD = $(LIBINTL) $(LIBIBERTY)
strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
nm_new_SOURCES = nm.c $(BULIBS)
objdump_SOURCES = objdump.c dwarf.c prdbg.c $(DEBUG_SRCS) $(BULIBS)
@ -718,6 +725,9 @@ strip-new$(EXEEXT): $(strip_new_OBJECTS) $(strip_new_DEPENDENCIES)
sysdump$(EXEEXT): $(sysdump_OBJECTS) $(sysdump_DEPENDENCIES)
@rm -f sysdump$(EXEEXT)
$(LINK) $(sysdump_OBJECTS) $(sysdump_LDADD) $(LIBS)
elfedit$(EXEEXT): $(elfedit_OBJECTS) $(elfedit_DEPENDENCIES)
@rm -f elfedit$(EXEEXT)
$(LINK) $(elfedit_OBJECTS) $(elfedit_LDADD) $(LIBS)
mcparse.h: mcparse.c
@if test ! -f $@; then \
rm -f mcparse.c; \
@ -793,6 +803,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strings.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysdump.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unwind-ia64.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfedit.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/windmc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/windres.Po@am__quote@

View File

@ -27,6 +27,7 @@ man_MANS = \
size.1 \
strings.1 \
strip.1 \
elfedit.1 \
windres.1 \
windmc.1 \
$(DEMANGLER_NAME).1
@ -124,6 +125,13 @@ strip.1: $(binutils_TEXI) $(binutils_TEXINFOS)
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
rm -f strip.pod
elfedit.1: $(binutils_TEXI) $(binutils_TEXINFOS)
touch $@
-$(TEXI2POD) $(MANCONF) -Delfedit < $(binutils_TEXI) > elfedit.pod
-($(POD2MAN) elfedit.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
rm -f elfedit.pod
windres.1: $(binutils_TEXI) $(binutils_TEXINFOS)
touch $@
-$(TEXI2POD) $(MANCONF) -Dwindres < $(binutils_TEXI) > windres.pod

View File

@ -286,6 +286,7 @@ man_MANS = \
size.1 \
strings.1 \
strip.1 \
elfedit.1 \
windres.1 \
windmc.1 \
$(DEMANGLER_NAME).1
@ -816,6 +817,13 @@ strip.1: $(binutils_TEXI) $(binutils_TEXINFOS)
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
rm -f strip.pod
elfedit.1: $(binutils_TEXI) $(binutils_TEXINFOS)
touch $@
-$(TEXI2POD) $(MANCONF) -Delfedit < $(binutils_TEXI) > elfedit.pod
-($(POD2MAN) elfedit.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
rm -f elfedit.pod
windres.1: $(binutils_TEXI) $(binutils_TEXINFOS)
touch $@
-$(TEXI2POD) $(MANCONF) -Dwindres < $(binutils_TEXI) > windres.pod

View File

@ -44,6 +44,7 @@ section entitled ``GNU Free Documentation License''.
* size: (binutils)size. List section sizes and total size.
* strings: (binutils)strings. List printable strings from files.
* strip: (binutils)strip. Discard symbols.
* elfedit: (binutils)elfedit. Update the ELF header of ELF files.
* windmc: (binutils)windmc. Generator for Windows message resources.
* windres: (binutils)windres. Manipulate Windows resources.
@end direntry
@ -111,6 +112,9 @@ List printable strings from files
@item strip
Discard symbols
@item elfedit
Update the ELF header of ELF files.
@item c++filt
Demangle encoded C++ symbols (on MS-DOS, this program is named
@code{cxxfilt})
@ -146,6 +150,7 @@ in the section entitled ``GNU Free Documentation License''.
* size:: List section sizes and total size
* strings:: List printable strings from files
* strip:: Discard symbols
* elfedit:: Update the ELF header of ELF files
* c++filt:: Filter to demangle encoded C++ symbols
* cxxfilt: c++filt. MS-DOS name for c++filt
* addr2line:: Convert addresses to file and line
@ -2717,7 +2722,7 @@ the Info entries for @file{binutils}.
@c man end
@end ignore
@node c++filt, addr2line, strip, Top
@node c++filt, addr2line, elfedit, Top
@chapter c++filt
@kindex c++filt
@ -4090,6 +4095,70 @@ objdump(1), and the Info entries for @file{binutils}.
@c man end
@end ignore
@node elfedit
@chapter elfedit
@cindex Update ELF header
@kindex elfedit
@c man title elfedit Update the ELF header of ELF files.
@smallexample
@c man begin SYNOPSIS elfedit
elfedit [@option{--input-mach=}@var{machine}]
@option{--output-machine=}@var{machine}
[@option{-v}|@option{--version}]
[@option{-h}|@option{--help}]
@var{elffile}@dots{}
@c man end
@end smallexample
@c man begin DESCRIPTION elfedit
@command{elfedit} updates the ELF header of ELF files. The
options control how and which fields in the ELF header should be
updated.
@var{elffile}@dots{} are the ELF files to be updated. 32-bit and
64-bit ELF files are supported, as are archives containing ELF files.
@c man end
@c man begin OPTIONS elfedit
The long and short forms of options, shown here as alternatives, are
equivalent. The @option{--output-mach} option must be given.
@table @env
@itemx --input-mach=@var{machine}
Only the input files with ELF machine type, @var{machine}, will be
updated. If @option{--input-mach} isn't specified, any ELF file
will be updated.
The supported ELF machine types are, @var{L1OM} and @var{x86-64}.
@itemx --output-mach=@var{machine}
Change the ELF machine type in the ELF header to @var{machine}. The
supported ELF machine types are the same as @option{--input-mach}.
@item -v
@itemx --version
Display the version number of @command{elfedit}.
@item -h
@itemx --help
Display the command line options understood by @command{elfedit}.
@end table
@c man end
@ignore
@c man begin SEEALSO elfedit
readelf(1), and the Info entries for @file{binutils}.
@c man end
@end ignore
@node Common Options
@chapter Common Options

1110
binutils/elfedit.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,14 @@
2010-01-06 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/11131
* binutils-all/elfedit-1.d: New.
* binutils-all/elfedit.exp: Likewise.
* config/default.exp (ELFEDIT): New. Set if it doesn't exist.
(ELFEDITFLAGS): Likewise.
* lib/utils-lib.exp (run_dump_test): Support elfedit.
2009-10-28 Kai Tietz <kai.tietz@onevision.com>
* binutils-all/dlltool.exp: Add tests for --no-leading-underscore

View File

@ -0,0 +1,16 @@
#PROG: elfedit
#elfedit: --output-mach l1om
#source: empty.s
#readelf: -h
#name: Update ELF header 1
#target: x86_64-*-*
#...
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 \(current\)
#...
Machine: Intel L1OM
#...

View File

@ -0,0 +1,31 @@
# Copyright 2010 Free Software Foundation, Inc.
# 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 3 of the License, 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.
# Exclude non-ELF targets.
if ![is_elf_format] {
verbose "$ELFEDIT is only intended for ELF targets" 2
return
}
if ![is_remote host] {
set tempfile tmpdir/bintest.o
set copyfile tmpdir/bintest
} else {
set tempfile [remote_download host tmpdir/bintest.o]
set copyfile bintest
}
run_dump_test "elfedit-1"

View File

@ -61,6 +61,12 @@ if ![info exists READELF] then {
if ![info exists READELFFLAGS] then {
set READELFFLAGS ""
}
if ![info exists ELFEDIT] then {
set ELFEDIT [findfile $base_dir/elfedit]
}
if ![info exists ELFEDITFLAGS] then {
set ELFEDITFLAGS ""
}
if ![info exists WINDRES] then {
set WINDRES [findfile $base_dir/windres]
}

View File

@ -281,6 +281,7 @@ proc run_dump_test { name {extra_options {}} } {
global subdir srcdir
global OBJDUMP NM OBJCOPY READELF STRIP
global OBJDUMPFLAGS NMFLAGS OBJCOPYFLAGS READELFFLAGS STRIPFLAGS
global ELFEDIT ELFEDITFLAGS
global host_triplet
global env
global copyfile
@ -309,6 +310,7 @@ proc run_dump_test { name {extra_options {}} } {
set opts(size) {}
set opts(strings) {}
set opts(name) {}
set opts(elfedit) {}
set opts(PROG) {}
set opts(DUMPPROG) {}
set opts(source) {}
@ -372,6 +374,7 @@ proc run_dump_test { name {extra_options {}} } {
set destopt "-o"
}
strings { set program strings }
elfedit { set program elfedit }
default {
perror "unrecognized program option $opts(PROG) in $file.d"
unresolved $testname