diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2010-03-03 10:29:22 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2010-03-03 10:29:22 +0000 |
commit | bef7d288df865ca1b76d20b56f2883b1338ea285 (patch) | |
tree | 6805e654c85670ebc42d596cd83da2367d72cbfc /gcc | |
parent | 7ece48b1187e63a238d97028937afa311943e436 (diff) | |
download | gcc-bef7d288df865ca1b76d20b56f2883b1338ea285.zip gcc-bef7d288df865ca1b76d20b56f2883b1338ea285.tar.gz gcc-bef7d288df865ca1b76d20b56f2883b1338ea285.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/lto/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/lto/lto-elf.c | 35 |
2 files changed, 38 insertions, 2 deletions
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 58e5123..560539d 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -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 diff --git a/gcc/lto/lto-elf.c b/gcc/lto/lto-elf.c index 356e513..0135284 100644 --- a/gcc/lto/lto-elf.c +++ b/gcc/lto/lto-elf.c @@ -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; \ |