Add ability for objcopy to insert new symbols into a binary.

PR binutils/19104
binutils * objcopy.c (command_line_switch): Add OPTION_ADD_SYMBOL.
	(copy_options): Add add-symbol.
	(copy_usage): Likewise.
	(parse_symflags): New function.
	(need_sym_before): New function.
	(create_new_symbol): New function.
	(filter_symbols): Add code to insert new symbols.
	(copy_main): Process OPTION_ADD_SYMBOL.
	* doc/binutils.texi: Document new feature.
	* NEWS: Add note about the new feature.

tests	* binutils-all/add-symbol.d: New test.
	* binutils-all/objcopy.exp: Run the new test.
This commit is contained in:
Ronald Hoogenbllon
2015-10-21 15:16:35 +01:00
committed by Nick Clifton
parent 1283d92f0e
commit 2b35fb28f3
7 changed files with 356 additions and 100 deletions

View File

@@ -0,0 +1,16 @@
#PROG: objcopy
#name: objcopy add-symbol
#source: symbols.s
#objcopy: --add-symbol NEW=0x1234 --add-symbol NEW_DATA=.data:0x4321,local
#objdump: --syms
# MIPS targets swap the order of the symbols in the output.
#not-target: mips-*-* tx39-*-*
.*: +file format .*
SYMBOL TABLE:
#...
0+04321 l[ ]+.data[ ]+0+00 NEW_DATA
#...
0+01234 g[ ]+\*ABS\*[ ]+0+00 NEW
#pass

View File

@@ -1097,6 +1097,7 @@ if [is_elf_format] {
run_dump_test "testranges-ia64"
run_dump_test "add-section"
run_dump_test "add-symbol"
run_dump_test "add-empty-section"
run_dump_test "exclude-1a"