aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2010-01-08 15:58:08 +0000
committerH.J. Lu <hjl.tools@gmail.com>2010-01-08 15:58:08 +0000
commit2dc654c3e9b8515e5ef1f2042d6f21fd6f2e77bc (patch)
tree96d07260b20780f9475210c78e3b4ba9253a0a6a /binutils
parentf91e5ac34e150aeb5030c1005a510a231449c33c (diff)
downloadgdb-2dc654c3e9b8515e5ef1f2042d6f21fd6f2e77bc.zip
gdb-2dc654c3e9b8515e5ef1f2042d6f21fd6f2e77bc.tar.gz
gdb-2dc654c3e9b8515e5ef1f2042d6f21fd6f2e77bc.tar.bz2
Don't change input_elf_XXX if they are -1
2010-01-08 H.J. Lu <hongjiu.lu@intel.com> * elfedit.c (update_elf_header): Don't change input_elf_class nor input_elf_machine if they are -1.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog5
-rw-r--r--binutils/elfedit.c27
2 files changed, 18 insertions, 14 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index ebdc1a2..fb7adc1 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2010-01-08 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elfedit.c (update_elf_header): Don't change input_elf_class
+ nor input_elf_machine if they are -1.
+
2010-01-08 Tristan Gingold <gingold@adacore.com>
* ar.c: Remove bfd_special_undocumented_glue prototype.
diff --git a/binutils/elfedit.c b/binutils/elfedit.c
index 6e2f8db4..410d89a 100644
--- a/binutils/elfedit.c
+++ b/binutils/elfedit.c
@@ -228,7 +228,7 @@ byte_put_big_endian (unsigned char * field, bfd_vma value, int size)
static int
update_elf_header (const char *file_name, FILE *file)
{
- int status;
+ int class, machine, status;
if (elf_header.e_ident[EI_MAG0] != ELFMAG0
|| elf_header.e_ident[EI_MAG1] != ELFMAG1
@@ -250,35 +250,34 @@ update_elf_header (const char *file_name, FILE *file)
return 0;
}
+ /* Return if e_machine is the same as output_elf_machine. */
+ if (output_elf_machine == elf_header.e_machine)
+ return 1;
+
+ class = elf_header.e_ident[EI_CLASS];
+
/* Skip if class doesn't match. */
- if (input_elf_class == -1)
- input_elf_class = elf_header.e_ident[EI_CLASS];
- else if (elf_header.e_ident[EI_CLASS] != input_elf_class)
+ if (input_elf_class != -1 && class != input_elf_class)
{
non_fatal
(_("%s: Unmatched EI_CLASS: %d is not %d\n"),
- file_name, elf_header.e_ident[EI_CLASS],
- input_elf_class);
+ file_name, class, input_elf_class);
return 0;
}
- /* Return if e_machine is the same as output_elf_machine. */
- if (output_elf_machine == elf_header.e_machine)
- return 1;
+ machine = elf_header.e_machine;
/* Skip if e_machine doesn't match. */
- if (input_elf_machine == -1)
- input_elf_machine = elf_header.e_machine;
- else if (elf_header.e_machine != input_elf_machine)
+ if (input_elf_machine != -1 && machine != input_elf_machine)
{
non_fatal
(_("%s: Unmatched e_machine: %d is not %d\n"),
- file_name, elf_header.e_machine, input_elf_machine);
+ file_name, machine, input_elf_machine);
return 0;
}
/* Update e_machine. */
- switch (input_elf_class)
+ switch (class)
{
default:
/* We should never get here. */