From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 6/8] arm: allow passing an ELF64 header to elf_check_arch()
Date: Mon, 10 May 2010 12:20:36 +0100 [thread overview]
Message-ID: <20100510112036.GC14337@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <3c8da055f0a84cfd1c6659d9fda24e4eb97ab9fb.1273041358.git.ext-mika.1.westerberg@nokia.com>
On Wed, May 05, 2010 at 09:54:18AM +0300, Mika Westerberg wrote:
> This is needed to shut following compiler warning when CONFIG_PROC_VMCORE is
> enabled:
>
> fs/proc/vmcore.c: In function 'parse_crash_elf64_headers':
> fs/proc/vmcore.c:500: warning: passing argument 1 of 'elf_check_arch' from
> incompatible pointer type
>
> ELF32 and ELF64 headers have common fields of same size (namely e_ident and
> e_machine) which are checked in arm_elf_check_arch().
This patch is bogus - and shows the dangers of throwing casts into C code
to shut up warnings without first analysing the code.
Our elf_check_arch() uses:
e_machine
e_entry
e_flags
thusly:
if (x->e_machine != EM_ARM)
if (x->e_entry & 1) {
} else if (x->e_entry & 3)
eflags = x->e_flags;
Now, the Elf32 header looks like this:
typedef struct elf32_hdr{
unsigned char e_ident[EI_NIDENT]; /* 0x00 - 0x0F */
Elf32_Half e_type; /* 0x10 - 0x11 */
Elf32_Half e_machine; /* 0x12 - 0x13 */
Elf32_Word e_version; /* 0x14 - 0x17 */
Elf32_Addr e_entry; /* 0x18 - 0x1b */
Elf32_Off e_phoff; /* 0x1c - 0x1f */
Elf32_Off e_shoff; /* 0x20 - 0x23 */
Elf32_Word e_flags; /* 0x24 - 0x27 */
and Elf64 header:
typedef struct elf64_hdr {
unsigned char e_ident[EI_NIDENT]; /* 0x00 - 0x0F */
Elf64_Half e_type; /* 0x10 - 0x11 */
Elf64_Half e_machine; /* 0x12 - 0x13 */
Elf64_Word e_version; /* 0x14 - 0x17 */
Elf64_Addr e_entry; /* 0x18 - 0x1f */
Elf64_Off e_phoff; /* 0x20 - 0x27 */
Elf64_Off e_shoff; /* 0x28 - 0x2f */
Elf64_Word e_flags; /* 0x30 - 0x33 */
Notice that e_entry and e_flags are different sizes and/or different
offsets, so ARMs elf_check_arch can not work with elf64 headers. So
with an ELF64 header, accessing e_flags will result in actually
accessing the top half of the 64-bit e_phoff, and accessing 32-bit
e_entry will get us the lower half of the 64-bit e_entry.
Now, here's the question: why does this crashkernel stuff want to
parse a 64-bit ELF header on a 32-bit only platform where the crashing
kernel will never generate a 64-bit ELF core file?
next prev parent reply other threads:[~2010-05-10 11:20 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-05 6:54 [PATCH v2 0/8] Initial implementation of kdump for ARM Mika Westerberg
2010-05-05 6:54 ` [PATCH v2 1/8] arm: kdump: reserve memory for crashkernel Mika Westerberg
2010-05-05 6:54 ` [PATCH v2 2/8] arm: kdump: implement crash_setup_regs() Mika Westerberg
2010-05-05 6:54 ` [PATCH v2 3/8] arm: kdump: implement machine_crash_shutdown() Mika Westerberg
2010-05-05 6:54 ` [PATCH v2 4/8] arm: kdump: skip indirection page when crashing Mika Westerberg
2010-05-05 6:54 ` [PATCH v2 5/8] arm: kdump: implement copy_oldmem_page() Mika Westerberg
2010-05-05 6:54 ` [PATCH v2 6/8] arm: allow passing an ELF64 header to elf_check_arch() Mika Westerberg
2010-05-10 11:20 ` Russell King - ARM Linux [this message]
2010-05-10 12:09 ` Mika Westerberg
2010-05-10 12:21 ` Russell King - ARM Linux
2010-05-11 7:17 ` Mika Westerberg
2010-07-16 8:14 ` Mika Westerberg
2010-08-25 2:40 ` Lei Wen
2010-08-25 12:29 ` Mika Westerberg
2010-05-05 6:54 ` [PATCH v2 7/8] arm: kdump: add support for elfcorehdr= parameter Mika Westerberg
2010-05-05 6:54 ` [PATCH v2 8/8] arm: kdump: add CONFIG_CRASH_DUMP Kconfig option Mika Westerberg
2010-05-25 8:19 ` [PATCH v2 0/8] Initial implementation of kdump for ARM Mika Westerberg
2010-06-11 6:36 ` Mika Westerberg
2010-07-02 12:48 ` Per Fransson
2010-07-05 8:28 ` Mika Westerberg
2010-07-05 10:01 ` Per Fransson
2010-07-05 10:18 ` Russell King - ARM Linux
2010-07-05 10:34 ` Per Fransson
2010-07-05 11:31 ` Mika Westerberg
2010-07-05 12:04 ` Per Fransson
2010-07-05 13:55 ` Russell King - ARM Linux
2010-07-05 14:05 ` Per Fransson
2010-07-05 14:19 ` Russell King - ARM Linux
2010-07-05 15:37 ` Per Fransson
2010-07-05 16:08 ` Nicolas Pitre
2010-07-05 18:14 ` Russell King - ARM Linux
2010-07-06 8:30 ` Per Fransson
2010-07-07 7:29 ` Mika Westerberg
2010-07-08 8:52 ` Per Fransson
2010-07-12 8:20 ` Mika Westerberg
2010-07-09 3:38 ` Simon Horman
2010-07-09 8:19 ` Per Fransson
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=20100510112036.GC14337@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).