From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZJ00o-0006OW-4o for mharc-grub-devel@gnu.org; Sat, 25 Jul 2015 10:01:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJ00l-0006NR-1H for grub-devel@gnu.org; Sat, 25 Jul 2015 10:01:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZJ00h-0008Bi-RK for grub-devel@gnu.org; Sat, 25 Jul 2015 10:01:10 -0400 Received: from mail-lb0-x22f.google.com ([2a00:1450:4010:c04::22f]:34441) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJ00h-0008BP-Jn for grub-devel@gnu.org; Sat, 25 Jul 2015 10:01:07 -0400 Received: by lbbzr7 with SMTP id zr7so29834302lbb.1 for ; Sat, 25 Jul 2015 07:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=sMt3ohRtNR653+aaEh2tp3BzTFJXjs8Y8TxCmphCe5A=; b=cWhyuF8JYI1UwXpmtViWU7VTVsTujPm2HzMSjnqVgHZRImtf7d6beZSOD+dX/9nXR8 kdDHl4+rNZF7Sb7x/3QCjCcitK0spb19jF1tS6Sbi93DlTSJpfhwcYR07TOHk49EsnHf T5RdHfCQSQp0Fl9LQ33v+M0vO9IFA3FiegHuPsX6OtRFv8vrntix04HshCX4Z33M7JSg RUlA+w8bqQgxi8eKPgKvsAR/YdHcEYCur+ZjdLAlRyPNPI52viZ3ILED/SmWJR+dLKjG F1fZYueu0UEi9KiyB9YmgK+6fSl6P2+svCNulUC6lBzFQnSGVQkTVrkRYRDSewGjhmYC C51w== X-Received: by 10.152.22.4 with SMTP id z4mr18699191lae.81.1437832865705; Sat, 25 Jul 2015 07:01:05 -0700 (PDT) Received: from opensuse.site (ppp91-76-6-204.pppoe.mtu-net.ru. [91.76.6.204]) by smtp.gmail.com with ESMTPSA id kc4sm2594343lbc.39.2015.07.25.07.01.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Jul 2015 07:01:05 -0700 (PDT) Date: Sat, 25 Jul 2015 17:01:03 +0300 From: Andrei Borzenkov To: Paulo Flabiano Smorigo Subject: Re: [PATCH v2] Suport for bi-endianess in elf file Message-ID: <20150725170103.34fd9ed8@opensuse.site> In-Reply-To: <20150724214822.391a7814@opensuse.site> References: <1437660636-4027-1-git-send-email-pfsmorigo@linux.vnet.ibm.com> <20150724214822.391a7814@opensuse.site> X-Mailer: Claws Mail 3.11.0 (GTK+ 2.24.28; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22f Cc: The development of GNU GRUB X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Jul 2015 14:01:12 -0000 =D0=92 Fri, 24 Jul 2015 21:48:22 +0300 Andrei Borzenkov =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > =D0=92 Thu, 23 Jul 2015 11:10:36 -0300 > Paulo Flabiano Smorigo =D0=BF=D0=B8=D1=88= =D0=B5=D1=82: >=20 > > Updated version with the suggestions from Andrei Borzenkov. > >=20 > > * grub-core/kern/elf.c: check and switch endianess with grub_{be,le}_to > > cpu functions. > > * grub-core/kern/elfXX.c: Likewise. > >=20 >=20 > Could you add a bit more verbose description that it currently applies > to ppc only when committing. >=20 > > Also-by: Tomohiro B Berry > > --- > > grub-core/kern/elf.c | 51 ++++++++++++++++++++++++++++++--- > > grub-core/kern/elfXX.c | 76 ++++++++++++++++++++++++++++++++++++++++++= ++++++++ > > 2 files changed, 123 insertions(+), 4 deletions(-) > >=20 > > diff --git a/grub-core/kern/elf.c b/grub-core/kern/elf.c > > index 5f99c43..1be9c1c 100644 > > --- a/grub-core/kern/elf.c > > +++ b/grub-core/kern/elf.c > > @@ -28,6 +28,11 @@ > > =20 > > GRUB_MOD_LICENSE ("GPLv3+"); > > =20 > > +#if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275) > > +void grub_elf32_check_endianess (grub_elf_t elf); > > +void grub_elf64_check_endianess (grub_elf_t elf); > > +#endif /* defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275) */ > > + > > /* Check if EHDR is a valid ELF header. */ > > static grub_err_t > > grub_elf_check_header (grub_elf_t elf) > > @@ -38,8 +43,19 @@ grub_elf_check_header (grub_elf_t elf) > > || e->e_ident[EI_MAG1] !=3D ELFMAG1 > > || e->e_ident[EI_MAG2] !=3D ELFMAG2 > > || e->e_ident[EI_MAG3] !=3D ELFMAG3 > > - || e->e_ident[EI_VERSION] !=3D EV_CURRENT > > - || e->e_version !=3D EV_CURRENT) > > + || e->e_ident[EI_VERSION] !=3D EV_CURRENT) > > + return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent E= LF magic")); > > + > > +#if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275) > > + if (grub_elf_is_elf32 (elf)) > > + grub_elf32_check_endianess (elf); > > + else if (grub_elf_is_elf64 (elf)) > > + grub_elf64_check_endianess (elf); > > + else > > + return grub_error (GRUB_ERR_BAD_OS, N_("Uknown ELF class")); >=20 > Other places are using "invalid arch-dependent ELF magic" in this case, > it is better to reuse translation string. Otherwise fine for me.=20 >=20 BTW this duplicates check in grub-core/loader/powerpc/ieee1275/linux.c which probably can then be removed then.