Skip to contentSkip to conversation

vmcore: replace Elf64_Ehdr/Elf32_Ehdr with elfhdr

PATCH New [email protected] 3 participants 7 messages Sep 16, 2015 – Sep 18, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vmcore: replace Elf64_Ehdr/Elf32_Ehdr with elfhdr

From: Yanjiang Jin <[email protected]>

Already verified this patch on a MIPS64 cavium octeon board: CN78XX.

This patch is to eliminate the compile warning only, has no side effect in run-time.

Yanjiang Jin (1):
vmcore: replace Elf64_Ehdr/Elf32_Ehdr with elfhdr

 fs/proc/vmcore.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 vmcore: replace Elf64_Ehdr/Elf32_Ehdr with elfhdr

From: Yanjiang Jin <[email protected]>

Function parse_crash_elf_headers() reads e_ident[EI_CLASS] then decides to call parse_crash_elf64_headers() or parse_crash_elf32_headers(). But this happens in run time, not compile time. So compiler will report the below warning:

In file included from include/linux/elf.h:4:0,

                 from fs/proc/vmcore.c:13:
fs/proc/vmcore.c: In function 'parse_crash_elf32_headers':
arch/mips/include/asm/elf.h:258:23: warning: initializatio
n from incompatible pointer type
  struct elfhdr *__h = (hdr);     \
                       ^
fs/proc/vmcore.c:1071:4: note: in expansion of macro 'elf_
check_arch'
   !elf_check_arch(&ehdr) ||
    ^
---
 fs/proc/vmcore.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/vmcore.c +2 -2
index 4e61388..576bb26 100644
@@ -999,7 +999,7 @@ static void free_elfcorebuf(void)
 static int __init parse_crash_elf64_headers(void)
 {
 	int rc=0;
-	Elf64_Ehdr ehdr;
+	struct elfhdr ehdr;
 	u64 addr;
 
 	addr = elfcorehdr_addr;
@@ -1055,7 +1055,7 @@ fail:
 static int __init parse_crash_elf32_headers(void)
 {
 	int rc=0;
-	Elf32_Ehdr ehdr;
+	struct elfhdr ehdr;
 	u64 addr;
 
 	addr = elfcorehdr_addr;
Signature · 1 line
1.9.1
#2 lore raw

Cc kexec list.

Quoted 50 lines · On 09/16/15 at 10:58am, [email protected] wrote:

From: Yanjiang Jin <[email protected]>

Function parse_crash_elf_headers() reads e_ident[EI_CLASS] then decides to call parse_crash_elf64_headers() or parse_crash_elf32_headers(). But this happens in run time, not compile time. So compiler will report the below warning:

In file included from include/linux/elf.h:4:0,

                 from fs/proc/vmcore.c:13:
fs/proc/vmcore.c: In function 'parse_crash_elf32_headers':
arch/mips/include/asm/elf.h:258:23: warning: initializatio
n from incompatible pointer type
  struct elfhdr *__h = (hdr);     \
                       ^
fs/proc/vmcore.c:1071:4: note: in expansion of macro 'elf_
check_arch'
   !elf_check_arch(&ehdr) ||
    ^
---
 fs/proc/vmcore.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/vmcore.c +2 -2
index 4e61388..576bb26 100644
@@ -999,7 +999,7 @@ static void free_elfcorebuf(void)
 static int __init parse_crash_elf64_headers(void)
 {
 	int rc=0;
-	Elf64_Ehdr ehdr;
+	struct elfhdr ehdr;
 	u64 addr;
 
 	addr = elfcorehdr_addr;
@@ -1055,7 +1055,7 @@ fail:
 static int __init parse_crash_elf32_headers(void)
 {
 	int rc=0;
-	Elf32_Ehdr ehdr;
+	struct elfhdr ehdr;
 	u64 addr;
 
 	addr = elfcorehdr_addr;
Signature · 1 line
1.9.1
#3 lore raw
In reply to [email protected]
Quoted 7 lines · On 09/16/15 at 10:58am, [email protected] wrote:

From: Yanjiang Jin <[email protected]>

Function parse_crash_elf_headers() reads e_ident[EI_CLASS] then decides to call parse_crash_elf64_headers() or parse_crash_elf32_headers(). But this happens in run time, not compile time. So compiler will report the below warning:

Quoted 7 lines

In file included from include/linux/elf.h:4:0,

                 from fs/proc/vmcore.c:13:
fs/proc/vmcore.c: In function 'parse_crash_elf32_headers':
arch/mips/include/asm/elf.h:258:23: warning: initializatio
n from incompatible pointer type
  struct elfhdr *__h = (hdr);     \
                       ^

How about converting the hdr to type elfhdr in above sentence, like following.

struct elfhdr *__h = (struct elfhdr *)(hdr);

Thanks
Minfei

Quoted 32 lines

fs/proc/vmcore.c:1071:4: note: in expansion of macro 'elf_ check_arch'
!elf_check_arch(&ehdr) ||

    ^
---
 fs/proc/vmcore.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/vmcore.c +2 -2
index 4e61388..576bb26 100644
@@ -999,7 +999,7 @@ static void free_elfcorebuf(void)
 static int __init parse_crash_elf64_headers(void)
 {
 	int rc=0;
-	Elf64_Ehdr ehdr;
+	struct elfhdr ehdr;
 	u64 addr;
 
 	addr = elfcorehdr_addr;
@@ -1055,7 +1055,7 @@ fail:
 static int __init parse_crash_elf32_headers(void)
 {
 	int rc=0;
-	Elf32_Ehdr ehdr;
+	struct elfhdr ehdr;
 	u64 addr;
 
 	addr = elfcorehdr_addr;
#4 lore raw

Ccing kexec maillist.

Quoted 56 lines · Minfei Huang
Quoted 7 lines · On 09/16/15 at 10:58am, [email protected] wrote:

From: Yanjiang Jin <[email protected]>

Function parse_crash_elf_headers() reads e_ident[EI_CLASS] then decides to call parse_crash_elf64_headers() or parse_crash_elf32_headers(). But this happens in run time, not compile time. So compiler will report the below warning:

Quoted 7 lines

In file included from include/linux/elf.h:4:0,

                 from fs/proc/vmcore.c:13:
fs/proc/vmcore.c: In function 'parse_crash_elf32_headers':
arch/mips/include/asm/elf.h:258:23: warning: initializatio
n from incompatible pointer type
  struct elfhdr *__h = (hdr);     \
                       ^

How about converting the hdr to type elfhdr in above sentence, like following.

struct elfhdr *__h = (struct elfhdr *)(hdr);

Thanks
Minfei

Quoted 32 lines

fs/proc/vmcore.c:1071:4: note: in expansion of macro 'elf_ check_arch'
!elf_check_arch(&ehdr) ||

    ^
---
 fs/proc/vmcore.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/vmcore.c +2 -2
index 4e61388..576bb26 100644
@@ -999,7 +999,7 @@ static void free_elfcorebuf(void)
 static int __init parse_crash_elf64_headers(void)
 {
 	int rc=0;
-	Elf64_Ehdr ehdr;
+	struct elfhdr ehdr;
 	u64 addr;
 
 	addr = elfcorehdr_addr;
@@ -1055,7 +1055,7 @@ fail:
 static int __init parse_crash_elf32_headers(void)
 {
 	int rc=0;
-	Elf32_Ehdr ehdr;
+	struct elfhdr ehdr;
 	u64 addr;
 
 	addr = elfcorehdr_addr;
author
#5 lore raw
In reply to Minfei Huang
Quoted 15 lines · Minfei Huang
Quoted 7 lines · On 09/16/15 at 10:58am, [email protected] wrote:

From: Yanjiang Jin <[email protected]>

Function parse_crash_elf_headers() reads e_ident[EI_CLASS] then decides to call parse_crash_elf64_headers() or parse_crash_elf32_headers(). But this happens in run time, not compile time. So compiler will report the below warning:

Quoted 7 lines

In file included from include/linux/elf.h:4:0,

                  from fs/proc/vmcore.c:13:
fs/proc/vmcore.c: In function 'parse_crash_elf32_headers':
arch/mips/include/asm/elf.h:258:23: warning: initializatio
n from incompatible pointer type
   struct elfhdr *__h = (hdr);     \
                        ^
Quoted 4 lines

How about converting the hdr to type elfhdr in above sentence, like following.

struct elfhdr *__h = (struct elfhdr *)(hdr);

Yes, this is a replacement, and it seems more safe because it just affects MIPS arch. But I also can't see any obvious impact if modifying common vmcore.c:-)
Anyway, if you stick to your opinion, I can send a V2 patch to update mips' elf.h rather than vmcore.c.

Thanks!
Yanjiang

Quoted 35 lines

Thanks
Minfei

Quoted 31 lines

fs/proc/vmcore.c:1071:4: note: in expansion of macro 'elf_ check_arch'

    !elf_check_arch(&ehdr) ||
     ^
---
  fs/proc/vmcore.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/vmcore.c +2 -2
index 4e61388..576bb26 100644
@@ -999,7 +999,7 @@ static void free_elfcorebuf(void)
  static int __init parse_crash_elf64_headers(void)
  {
  	int rc=0;
-	Elf64_Ehdr ehdr;
+	struct elfhdr ehdr;
  	u64 addr;
 
  	addr = elfcorehdr_addr;
@@ -1055,7 +1055,7 @@ fail:
  static int __init parse_crash_elf32_headers(void)
  {
  	int rc=0;
-	Elf32_Ehdr ehdr;
+	struct elfhdr ehdr;
  	u64 addr;
 
Quoted 1 line

fs/proc/vmcore.c fail: · line 1061

Quoted 1 line
fs/proc/vmcore.c +0 -0
  	addr = elfcorehdr_addr;

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw
Quoted 17 lines · yjin
Quoted 15 lines · Minfei Huang
Quoted 14 lines · On 09/16/15 at 10:58am, [email protected] wrote:

From: Yanjiang Jin <[email protected]>

Function parse_crash_elf_headers() reads e_ident[EI_CLASS] then decides to call parse_crash_elf64_headers() or parse_crash_elf32_headers(). But this happens in run time, not compile time. So compiler will report the below warning:

In file included from include/linux/elf.h:4:0,

                 from fs/proc/vmcore.c:13:
fs/proc/vmcore.c: In function 'parse_crash_elf32_headers':
arch/mips/include/asm/elf.h:258:23: warning: initializatio
n from incompatible pointer type
  struct elfhdr *__h = (hdr);     \
                       ^
Quoted 8 lines
Quoted 4 lines

How about converting the hdr to type elfhdr in above sentence, like following.

struct elfhdr *__h = (struct elfhdr *)(hdr);

Yes, this is a replacement, and it seems more safe because it just affects MIPS arch.
But I also can't see any obvious impact if modifying common vmcore.c:-)

Without the Maro define, elfhdr is not the struct in the code source. Thus there is some unconvenience for people to read the code, if there is another thought to fix this issue.

Please do the converting in the Maro, and repost the new version.

Thanks
Minfei

Quoted 45 lines

Anyway, if you stick to your opinion, I can send a V2 patch to update mips' elf.h rather than vmcore.c.

Thanks!
Yanjiang

Quoted 26 lines

Thanks
Minfei

Quoted 22 lines

fs/proc/vmcore.c:1071:4: note: in expansion of macro 'elf_ check_arch'
!elf_check_arch(&ehdr) ||

    ^
---
 fs/proc/vmcore.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/vmcore.c +1 -1
index 4e61388..576bb26 100644
@@ -999,7 +999,7 @@ static void free_elfcorebuf(void)
 static int __init parse_crash_elf64_headers(void)
 {
 	int rc=0;
-	Elf64_Ehdr ehdr;
+	struct elfhdr ehdr;
 	u64 addr;
 	addr = elfcorehdr_addr;
Quoted 8 lines

fs/proc/vmcore.c fail: · line 1060

Quoted 8 lines
fs/proc/vmcore.c +1 -1
@@ -1055,7 +1055,7 @@ fail:
 static int __init parse_crash_elf32_headers(void)
 {
 	int rc=0;
-	Elf32_Ehdr ehdr;
+	struct elfhdr ehdr;
 	u64 addr;
 	addr = elfcorehdr_addr;

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec