From: Sascha Hauer <s.hauer@pengutronix.de>
To: Antony Pavlov <antonynpavlov@gmail.com>
Cc: barebox@lists.infradead.org, Peter Mamonov <pmamonov@gmail.com>
Subject: Re: [RFC v2 4/8] import initial kexec stuff
Date: Wed, 7 Dec 2016 20:47:55 +0100 [thread overview]
Message-ID: <20161207194755.54yayeuzdf3s2576@pengutronix.de> (raw)
In-Reply-To: <20161205094033.31569-5-antonynpavlov@gmail.com>
On Mon, Dec 05, 2016 at 12:40:29PM +0300, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
The commit message could be a bit more verbose and at least mention
where this code is derived from and from which version.
> +
> +static int build_mem_ehdr(const char *buf, off_t len, struct mem_ehdr *ehdr)
> +{
> + unsigned char e_ident[EI_NIDENT];
> + int result;
> +
> + memset(ehdr, 0, sizeof(*ehdr));
> +
> + if ((size_t)len < sizeof(e_ident)) {
> + printf("Buffer is too small to hold ELF e_ident\n");
> +
> + return -1;
> + }
> +
> + memcpy(e_ident, buf, sizeof(e_ident));
> +
> + ehdr->ei_class = e_ident[EI_CLASS];
> + ehdr->ei_data = e_ident[EI_DATA];
> + if ( (ehdr->ei_class != ELFCLASS32) &&
> + (ehdr->ei_class != ELFCLASS64))
> + {
> + printf("Not a supported ELF class\n");
> + return -1;
> + }
> +
> + if ( (ehdr->ei_data != ELFDATA2LSB) &&
> + (ehdr->ei_data != ELFDATA2MSB))
> + {
> + printf("Not a supported ELF data format\n");
> + return -1;
> + }
> +
> + result = -1;
> + if (ehdr->ei_class == ELFCLASS32) {
> + result = build_mem_elf32_ehdr(buf, len, ehdr);
> + }
The opening braces are sometimes on the same line and sometimees on a
new line. Is this from the original code?
> +
> + /* Now walk and normalize the notes */
> + ehdr->e_note = xmalloc(sizeof(*ehdr->e_note) * ehdr->e_notenum);
> + for (i = 0, note = note_start; note < note_end;
> + note += note_size, i++) {
> + const unsigned char *name, *desc;
> + ElfNN_Nhdr hdr;
> + read_nhdr(ehdr, &hdr, note);
> + note_size = sizeof(hdr);
> + name = note + note_size;
> + note_size += (hdr.n_namesz + 3) & ~3;
> + desc = note + note_size;
> + note_size += (hdr.n_descsz + 3) & ~3;
> +
> + if ((hdr.n_namesz != 0) && (name[hdr.n_namesz -1] != '\0')) {
> + /* If note name string is not null terminated, just
> + * warn user about it and continue processing. This
> + * allows us to parse /proc/kcore on older kernels
> + * where /proc/kcore elf notes were not null
> + * terminated. It has been fixed in 2.6.19.
> + */
> + printf("Warning: Elf Note name is not null "
> + "terminated\n");
> + }
Is this relevant for barebox? We do not parse /proc/kcore.
> + ehdr->e_note[i].n_type = hdr.n_type;
> + ehdr->e_note[i].n_name = (char *)name;
> + ehdr->e_note[i].n_desc = desc;
> + ehdr->e_note[i].n_descsz = hdr.n_descsz;
> +
> + }
> +
> + return 0;
> +}
> +
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2016-12-07 19:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-05 9:40 [RFC v2 0/8] MIPS: use kexec to load ELF linux images Antony Pavlov
2016-12-05 9:40 ` [RFC v2 1/8] MIPS: add virt_to_phys() and phys_to_virt() Antony Pavlov
2016-12-05 9:40 ` [RFC v2 2/8] MIPS: c-r4k: add support for secondary cache Antony Pavlov
2016-12-05 9:40 ` [RFC v2 3/8] resource: add create_resource() helper function Antony Pavlov
2016-12-05 9:40 ` [RFC v2 4/8] import initial kexec stuff Antony Pavlov
2016-12-07 19:47 ` Sascha Hauer [this message]
2016-12-08 7:24 ` Antony Pavlov
2016-12-05 9:40 ` [RFC v2 5/8] filetype: add ELF type Antony Pavlov
2016-12-05 9:40 ` [RFC v2 6/8] bootm: add kexec ELF support Antony Pavlov
2016-12-07 19:59 ` Sascha Hauer
2016-12-08 7:29 ` Antony Pavlov
2016-12-05 9:40 ` [RFC v2 7/8] MIPS: add kexec ELF loading support Antony Pavlov
2016-12-05 9:40 ` [RFC v2 8/8] MIPS: malta: enable kexec Antony Pavlov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161207194755.54yayeuzdf3s2576@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=antonynpavlov@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=pmamonov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox