Skip to contentSkip to conversation

Add a new field `name' to struct linux_binfmt

PATCH In review Jie Zhang 3 participants 4 messages Aug 16, 2007

Subsystems (2)
lore
Share & tools
lore

Jie Zhang

author
#0 lore raw

PATCH 1/2 Add a new field `name' to struct linux_binfmt

Blackfin arch supports two binfmts: flat' and FDPIC ELF'. Sometimes we need deal with them differently. For example, when application crashes, something like below will be dumped:

Undefined instruction
- May be used to emulate instructions that are not defined for a particular processor implementation.

CURRENT PROCESS:

COMM=testmain PID=63
TEXT = 0x01180000-0x011dd258 DATA = 0x01300258-0x013ac4a0
BSS = 0x013ac4a0-0x010a0000 USER-STACK = 0x010bfec0

For flat' binfmt, there is a sperate BSS. But for FDPIC ELF', .bss is usually put into the same segment as .data. So DATA has include .bss section. The BSS for FDPIC ELF' is meaningless and confusing, like the one shown above. So I want to omit BSS for FDPIC ELF' in dumping.

When mapping address to symbol in application, we also need deal with flat' and FDPIC ELF' binfmts differently, since `flat' has a header before the code.

This patch addes a new `name' field to struct linux_binfmt and initialize it in each binfmt type.

A second blackfin arch patch will use this field to distinguish flat' binfmt with FDPIC ELF'.

Is it OK? Any comments?

Thanks,
Jie

---
 fs/binfmt_aout.c        |    3 ++-
 fs/binfmt_elf.c         |    3 ++-
 fs/binfmt_elf_fdpic.c   |    1 +
 fs/binfmt_em86.c        |    1 +
 fs/binfmt_flat.c        |    3 ++-
 fs/binfmt_misc.c        |    1 +
 fs/binfmt_script.c      |    1 +
 fs/binfmt_som.c         |    3 ++-
 include/linux/binfmts.h |    1 +
 9 files changed, 13 insertions(+), 4 deletions(-)
fs/binfmt_aout.c +2 -1
index 813a887..a54a25e 100644
@@ -38,7 +38,8 @@ static struct linux_binfmt aout_format = {
 	.load_binary	= load_aout_binary,
 	.load_shlib	= load_aout_library,
 	.core_dump	= aout_core_dump,
-	.min_coredump	= PAGE_SIZE
+	.min_coredump	= PAGE_SIZE,
+	.name		= "aout"
 };
 
 #define BAD_ADDR(x)	((unsigned long)(x) >= TASK_SIZE)
fs/binfmt_elf.c +2 -1
index 4482a06..5d1e039 100644
@@ -77,7 +77,8 @@ static struct linux_binfmt elf_format = {
 		.load_shlib	= load_elf_library,
 		.core_dump	= elf_core_dump,
 		.min_coredump	= ELF_EXEC_PAGESIZE,
-		.hasvdso	= 1
+		.hasvdso	= 1,
+		.name		= "ELF"
 };
 
 #define BAD_ADDR(x) ((unsigned long)(x) >= TASK_SIZE)
fs/binfmt_elf_fdpic.c +1 -0
index 2f5d8db..3eaa2ec 100644
@@ -85,6 +85,7 @@ static struct linux_binfmt elf_fdpic_format = {
 	.core_dump	= elf_fdpic_core_dump,
 #endif
 	.min_coredump	= ELF_EXEC_PAGESIZE,
+	.name		= "ELF FDPIC"
 };
 
 static int __init init_elf_fdpic_binfmt(void)
fs/binfmt_em86.c +1 -0
index 576dd7d..60036f9 100644
@@ -97,6 +97,7 @@ static int load_em86(struct linux_binprm *bprm,struct pt_regs *regs)
 static struct linux_binfmt em86_format = {
 	.module		= THIS_MODULE,
 	.load_binary	= load_em86,
+	.name		= "em86"
 };
 
 static int __init init_em86_binfmt(void)
fs/binfmt_flat.c +2 -1
index 861141b..b21deee 100644
@@ -81,7 +81,8 @@ static struct linux_binfmt flat_format = {
 	.module		= THIS_MODULE,
 	.load_binary	= load_flat_binary,
 	.core_dump	= flat_core_dump,
-	.min_coredump	= PAGE_SIZE
+	.min_coredump	= PAGE_SIZE,
+	.name		= "flat"
 };
 
 /****************************************************************************/
fs/binfmt_misc.c +1 -0
index 42e94b3..6df9da0 100644
@@ -737,6 +737,7 @@ static int bm_get_sb(struct file_system_type *fs_type,
 static struct linux_binfmt misc_format = {
 	.module = THIS_MODULE,
 	.load_binary = load_misc_binary,
+	.name = "misc"
 };
 
 static struct file_system_type bm_fs_type = {
fs/binfmt_script.c +1 -0
index 4d0e0f6..cdec898 100644
@@ -100,6 +100,7 @@ static int load_script(struct linux_binprm *bprm,struct pt_regs *regs)
 static struct linux_binfmt script_format = {
 	.module		= THIS_MODULE,
 	.load_binary	= load_script,
+	.name		= "script"
 };
 
 static int __init init_script_binfmt(void)
fs/binfmt_som.c +2 -1
index 5bcdaaf..4041d84 100644
@@ -58,7 +58,8 @@ static struct linux_binfmt som_format = {
 	.load_binary	= load_som_binary,
 	.load_shlib	= load_som_library,
 	.core_dump	= som_core_dump,
-	.min_coredump	= SOM_PAGESIZE
+	.min_coredump	= SOM_PAGESIZE,
+	.name		= "SOM"
 };
 
 /*
include/linux/binfmts.h +1 -0
index 91c8c07..b784784 100644
@@ -70,6 +70,7 @@ struct linux_binfmt {
 	int (*core_dump)(long signr, struct pt_regs * regs, struct file * file);
 	unsigned long min_coredump;	/* minimal dump size */
 	int hasvdso;
+	const char *name;
 };
 
 extern int register_binfmt(struct linux_binfmt *);
Signature · 1 line
1.5.2.4
#1 lore raw
Quoted 7 lines · Jie Zhang

This patch addes a new `name' field to struct linux_binfmt and initialize it in each binfmt type.

A second blackfin arch patch will use this field to distinguish flat' binfmt with FDPIC ELF'.

Is it OK? Any comments?

the other possibility would be to not make linux_binfmt definitions static and put appropriate prototypes in the fs.h header ... then you could do:
if (current->binfmt == aout_format) {
... aout stuff ...
}

then again, this goes against the dynamic nature of the binfmt itself ... and the idea that the binfmt should not matter to anything else in the kernel once it's executing ...
-mike

#2 lore raw
In reply to Jie Zhang
Quoted 2 lines · Jie Zhang

A second blackfin arch patch will use this field to distinguish flat' binfmt with FDPIC ELF'.

Please, post it. It a bit hard to see what you're actually trying to do.