2
0
mirror of git://gcc.gnu.org/git/gcc.git synced 2025-04-09 20:31:36 +08:00

lto-elf.c (is_compatible_architecture): New static function.

* lto-elf.c (is_compatible_architecture): New static function.
	(DEFINE_VALIDATE_EHDR): Use it to validate the architecture.

From-SVN: r157192
This commit is contained in:
Eric Botcazou 2010-03-03 10:29:22 +00:00 committed by Eric Botcazou
parent 7ece48b118
commit bef7d288df
2 changed files with 38 additions and 2 deletions

@ -1,3 +1,8 @@
2010-03-03 Eric Botcazou <ebotcazou@adacore.com>
* lto-elf.c (is_compatible_architecture): New static function.
(DEFINE_VALIDATE_EHDR): Use it to validate the architecture.
2010-02-11 Richard Guenther <rguenther@suse.de>
PR driver/43021

@ -374,6 +374,38 @@ lto_elf_end_section (void)
}
/* Return true if ELF_MACHINE is compatible with the cached value of the
architecture and possibly update the latter. Return false otherwise. */
static bool
is_compatible_architecture (Elf64_Half elf_machine)
{
if (cached_file_attrs.elf_machine == elf_machine)
return true;
switch (cached_file_attrs.elf_machine)
{
case EM_SPARC:
if (elf_machine == EM_SPARC32PLUS)
{
cached_file_attrs.elf_machine = elf_machine;
return true;
}
break;
case EM_SPARC32PLUS:
if (elf_machine == EM_SPARC)
return true;
break;
default:
break;
}
return false;
}
/* Validate's ELF_FILE's executable header and, if cached_file_attrs is
uninitialized, caches the architecture. */
@ -398,8 +430,7 @@ validate_ehdr##BITS (lto_elf_file *elf_file) \
\
if (!cached_file_attrs.initialized) \
cached_file_attrs.elf_machine = elf_header->e_machine; \
\
if (cached_file_attrs.elf_machine != elf_header->e_machine) \
else if (!is_compatible_architecture (elf_header->e_machine)) \
{ \
error ("inconsistent file architecture detected"); \
return false; \