x86: clean up arch/x86/ia32/aout32.c
White space and coding style clenaup. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
committed by
Ingo Molnar
parent
d94448b1fd
commit
8edf8bee88
@@ -40,7 +40,8 @@ static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs);
|
|||||||
static int load_aout_library(struct file *);
|
static int load_aout_library(struct file *);
|
||||||
|
|
||||||
#ifdef CORE_DUMP
|
#ifdef CORE_DUMP
|
||||||
static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit);
|
static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
|
||||||
|
unsigned long limit);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fill in the user structure for a core dump..
|
* fill in the user structure for a core dump..
|
||||||
@@ -54,7 +55,8 @@ static void dump_thread32(struct pt_regs * regs, struct user32 * dump)
|
|||||||
dump->start_code = 0;
|
dump->start_code = 0;
|
||||||
dump->start_stack = regs->rsp & ~(PAGE_SIZE - 1);
|
dump->start_stack = regs->rsp & ~(PAGE_SIZE - 1);
|
||||||
dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
|
dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
|
||||||
dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT;
|
dump->u_dsize = ((unsigned long)
|
||||||
|
(current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT;
|
||||||
dump->u_dsize -= dump->u_tsize;
|
dump->u_dsize -= dump->u_tsize;
|
||||||
dump->u_ssize = 0;
|
dump->u_ssize = 0;
|
||||||
dump->u_debugreg[0] = current->thread.debugreg0;
|
dump->u_debugreg[0] = current->thread.debugreg0;
|
||||||
@@ -66,8 +68,12 @@ static void dump_thread32(struct pt_regs * regs, struct user32 * dump)
|
|||||||
dump->u_debugreg[6] = current->thread.debugreg6;
|
dump->u_debugreg[6] = current->thread.debugreg6;
|
||||||
dump->u_debugreg[7] = current->thread.debugreg7;
|
dump->u_debugreg[7] = current->thread.debugreg7;
|
||||||
|
|
||||||
if (dump->start_stack < 0xc0000000)
|
if (dump->start_stack < 0xc0000000) {
|
||||||
dump->u_ssize = ((unsigned long) (0xc0000000 - dump->start_stack)) >> PAGE_SHIFT;
|
unsigned long tmp;
|
||||||
|
|
||||||
|
tmp = (unsigned long) (0xc0000000 - dump->start_stack);
|
||||||
|
dump->u_ssize = tmp >> PAGE_SHIFT;
|
||||||
|
}
|
||||||
|
|
||||||
dump->regs.ebx = regs->rbx;
|
dump->regs.ebx = regs->rbx;
|
||||||
dump->regs.ecx = regs->rcx;
|
dump->regs.ecx = regs->rcx;
|
||||||
@@ -136,7 +142,11 @@ static int dump_write(struct file *file, const void *addr, int nr)
|
|||||||
if (file->f_op->llseek) { \
|
if (file->f_op->llseek) { \
|
||||||
if (file->f_op->llseek(file, (offset), 0) != (offset)) \
|
if (file->f_op->llseek(file, (offset), 0) != (offset)) \
|
||||||
goto end_coredump; \
|
goto end_coredump; \
|
||||||
} else file->f_pos = (offset)
|
} else \
|
||||||
|
file->f_pos = (offset)
|
||||||
|
|
||||||
|
#define START_DATA() (u.u_tsize << PAGE_SHIFT)
|
||||||
|
#define START_STACK(u) (u.start_stack)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Routine writes a core dump image in the current directory.
|
* Routine writes a core dump image in the current directory.
|
||||||
@@ -148,26 +158,29 @@ if (file->f_op->llseek) { \
|
|||||||
* dumping of the process results in another error..
|
* dumping of the process results in another error..
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit)
|
static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
|
||||||
|
unsigned long limit)
|
||||||
{
|
{
|
||||||
mm_segment_t fs;
|
mm_segment_t fs;
|
||||||
int has_dumped = 0;
|
int has_dumped = 0;
|
||||||
unsigned long dump_start, dump_size;
|
unsigned long dump_start, dump_size;
|
||||||
struct user32 dump;
|
struct user32 dump;
|
||||||
# define START_DATA(u) (u.u_tsize << PAGE_SHIFT)
|
|
||||||
# define START_STACK(u) (u.start_stack)
|
|
||||||
|
|
||||||
fs = get_fs();
|
fs = get_fs();
|
||||||
set_fs(KERNEL_DS);
|
set_fs(KERNEL_DS);
|
||||||
has_dumped = 1;
|
has_dumped = 1;
|
||||||
current->flags |= PF_DUMPCORE;
|
current->flags |= PF_DUMPCORE;
|
||||||
strncpy(dump.u_comm, current->comm, sizeof(current->comm));
|
strncpy(dump.u_comm, current->comm, sizeof(current->comm));
|
||||||
dump.u_ar0 = (u32)(((unsigned long)(&dump.regs)) - ((unsigned long)(&dump)));
|
dump.u_ar0 = (u32)(((unsigned long)(&dump.regs)) -
|
||||||
|
((unsigned long)(&dump)));
|
||||||
dump.signal = signr;
|
dump.signal = signr;
|
||||||
dump_thread32(regs, &dump);
|
dump_thread32(regs, &dump);
|
||||||
|
|
||||||
/* If the size of the dump file exceeds the rlimit, then see what would happen
|
/*
|
||||||
if we wrote the stack, but not the data area. */
|
* If the size of the dump file exceeds the rlimit, then see
|
||||||
|
* what would happen if we wrote the stack, but not the data
|
||||||
|
* area.
|
||||||
|
*/
|
||||||
if ((dump.u_dsize + dump.u_ssize + 1) * PAGE_SIZE > limit)
|
if ((dump.u_dsize + dump.u_ssize + 1) * PAGE_SIZE > limit)
|
||||||
dump.u_dsize = 0;
|
dump.u_dsize = 0;
|
||||||
|
|
||||||
@@ -177,9 +190,11 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, u
|
|||||||
|
|
||||||
/* make sure we actually have a data and stack area to dump */
|
/* make sure we actually have a data and stack area to dump */
|
||||||
set_fs(USER_DS);
|
set_fs(USER_DS);
|
||||||
if (!access_ok(VERIFY_READ, (void *) (unsigned long)START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
|
if (!access_ok(VERIFY_READ, (void *) (unsigned long)START_DATA(dump),
|
||||||
|
dump.u_dsize << PAGE_SHIFT))
|
||||||
dump.u_dsize = 0;
|
dump.u_dsize = 0;
|
||||||
if (!access_ok(VERIFY_READ, (void *) (unsigned long)START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
|
if (!access_ok(VERIFY_READ, (void *) (unsigned long)START_STACK(dump),
|
||||||
|
dump.u_ssize << PAGE_SHIFT))
|
||||||
dump.u_ssize = 0;
|
dump.u_ssize = 0;
|
||||||
|
|
||||||
set_fs(KERNEL_DS);
|
set_fs(KERNEL_DS);
|
||||||
@@ -201,7 +216,10 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, u
|
|||||||
dump_size = dump.u_ssize << PAGE_SHIFT;
|
dump_size = dump.u_ssize << PAGE_SHIFT;
|
||||||
DUMP_WRITE(dump_start, dump_size);
|
DUMP_WRITE(dump_start, dump_size);
|
||||||
}
|
}
|
||||||
/* Finally dump the task struct. Not be used by gdb, but could be useful */
|
/*
|
||||||
|
* Finally dump the task struct. Not be used by gdb, but
|
||||||
|
* could be useful
|
||||||
|
*/
|
||||||
set_fs(KERNEL_DS);
|
set_fs(KERNEL_DS);
|
||||||
DUMP_WRITE(current, sizeof(*current));
|
DUMP_WRITE(current, sizeof(*current));
|
||||||
end_coredump:
|
end_coredump:
|
||||||
@@ -217,11 +235,8 @@ end_coredump:
|
|||||||
*/
|
*/
|
||||||
static u32 __user *create_aout_tables(char __user *p, struct linux_binprm *bprm)
|
static u32 __user *create_aout_tables(char __user *p, struct linux_binprm *bprm)
|
||||||
{
|
{
|
||||||
u32 __user *argv;
|
u32 __user *argv, *envp, *sp;
|
||||||
u32 __user *envp;
|
int argc = bprm->argc, envc = bprm->envc;
|
||||||
u32 __user *sp;
|
|
||||||
int argc = bprm->argc;
|
|
||||||
int envc = bprm->envc;
|
|
||||||
|
|
||||||
sp = (u32 __user *) ((-(unsigned long)sizeof(u32)) & (unsigned long) p);
|
sp = (u32 __user *) ((-(unsigned long)sizeof(u32)) & (unsigned long) p);
|
||||||
sp -= envc+1;
|
sp -= envc+1;
|
||||||
@@ -234,6 +249,7 @@ static u32 __user *create_aout_tables(char __user *p, struct linux_binprm *bprm)
|
|||||||
current->mm->arg_start = (unsigned long) p;
|
current->mm->arg_start = (unsigned long) p;
|
||||||
while (argc-- > 0) {
|
while (argc-- > 0) {
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
put_user((u32)(unsigned long)p, argv++);
|
put_user((u32)(unsigned long)p, argv++);
|
||||||
do {
|
do {
|
||||||
get_user(c, p++);
|
get_user(c, p++);
|
||||||
@@ -243,6 +259,7 @@ static u32 __user *create_aout_tables(char __user *p, struct linux_binprm *bprm)
|
|||||||
current->mm->arg_end = current->mm->env_start = (unsigned long) p;
|
current->mm->arg_end = current->mm->env_start = (unsigned long) p;
|
||||||
while (envc-- > 0) {
|
while (envc-- > 0) {
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
put_user((u32)(unsigned long)p, envp++);
|
put_user((u32)(unsigned long)p, envp++);
|
||||||
do {
|
do {
|
||||||
get_user(c, p++);
|
get_user(c, p++);
|
||||||
@@ -257,20 +274,18 @@ static u32 __user *create_aout_tables(char __user *p, struct linux_binprm *bprm)
|
|||||||
* These are the functions used to load a.out style executables and shared
|
* These are the functions used to load a.out style executables and shared
|
||||||
* libraries. There is no binary dependent code anywhere else.
|
* libraries. There is no binary dependent code anywhere else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int load_aout_binary(struct linux_binprm *bprm, struct pt_regs *regs)
|
static int load_aout_binary(struct linux_binprm *bprm, struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
|
unsigned long error, fd_offset, rlim;
|
||||||
struct exec ex;
|
struct exec ex;
|
||||||
unsigned long error;
|
|
||||||
unsigned long fd_offset;
|
|
||||||
unsigned long rlim;
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
ex = *((struct exec *) bprm->buf); /* exec-header */
|
ex = *((struct exec *) bprm->buf); /* exec-header */
|
||||||
if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != OMAGIC &&
|
if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != OMAGIC &&
|
||||||
N_MAGIC(ex) != QMAGIC && N_MAGIC(ex) != NMAGIC) ||
|
N_MAGIC(ex) != QMAGIC && N_MAGIC(ex) != NMAGIC) ||
|
||||||
N_TRSIZE(ex) || N_DRSIZE(ex) ||
|
N_TRSIZE(ex) || N_DRSIZE(ex) ||
|
||||||
i_size_read(bprm->file->f_path.dentry->d_inode) < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
|
i_size_read(bprm->file->f_path.dentry->d_inode) <
|
||||||
|
ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,24 +359,24 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
|
|||||||
#ifdef WARN_OLD
|
#ifdef WARN_OLD
|
||||||
static unsigned long error_time, error_time2;
|
static unsigned long error_time, error_time2;
|
||||||
if ((ex.a_text & 0xfff || ex.a_data & 0xfff) &&
|
if ((ex.a_text & 0xfff || ex.a_data & 0xfff) &&
|
||||||
(N_MAGIC(ex) != NMAGIC) && (jiffies-error_time2) > 5*HZ)
|
(N_MAGIC(ex) != NMAGIC) && (jiffies-error_time2) > 5*HZ) {
|
||||||
{
|
|
||||||
printk(KERN_NOTICE "executable not page aligned\n");
|
printk(KERN_NOTICE "executable not page aligned\n");
|
||||||
error_time2 = jiffies;
|
error_time2 = jiffies;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fd_offset & ~PAGE_MASK) != 0 &&
|
if ((fd_offset & ~PAGE_MASK) != 0 &&
|
||||||
(jiffies-error_time) > 5*HZ)
|
(jiffies - error_time) > 5*HZ) {
|
||||||
{
|
|
||||||
printk(KERN_WARNING
|
printk(KERN_WARNING
|
||||||
"fd_offset is not page aligned. Please convert program: %s\n",
|
"fd_offset is not page aligned. Please convert "
|
||||||
|
"program: %s\n",
|
||||||
bprm->file->f_path.dentry->d_name.name);
|
bprm->file->f_path.dentry->d_name.name);
|
||||||
error_time = jiffies;
|
error_time = jiffies;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) {
|
if (!bprm->file->f_op->mmap || (fd_offset & ~PAGE_MASK) != 0) {
|
||||||
loff_t pos = fd_offset;
|
loff_t pos = fd_offset;
|
||||||
|
|
||||||
down_write(¤t->mm->mmap_sem);
|
down_write(¤t->mm->mmap_sem);
|
||||||
do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data);
|
do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data);
|
||||||
up_write(¤t->mm->mmap_sem);
|
up_write(¤t->mm->mmap_sem);
|
||||||
@@ -377,7 +392,8 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
|
|||||||
down_write(¤t->mm->mmap_sem);
|
down_write(¤t->mm->mmap_sem);
|
||||||
error = do_mmap(bprm->file, N_TXTADDR(ex), ex.a_text,
|
error = do_mmap(bprm->file, N_TXTADDR(ex), ex.a_text,
|
||||||
PROT_READ | PROT_EXEC,
|
PROT_READ | PROT_EXEC,
|
||||||
MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE | MAP_32BIT,
|
MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE |
|
||||||
|
MAP_EXECUTABLE | MAP_32BIT,
|
||||||
fd_offset);
|
fd_offset);
|
||||||
up_write(¤t->mm->mmap_sem);
|
up_write(¤t->mm->mmap_sem);
|
||||||
|
|
||||||
@@ -389,7 +405,8 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
|
|||||||
down_write(¤t->mm->mmap_sem);
|
down_write(¤t->mm->mmap_sem);
|
||||||
error = do_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
|
error = do_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
|
||||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||||
MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE | MAP_32BIT,
|
MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE |
|
||||||
|
MAP_EXECUTABLE | MAP_32BIT,
|
||||||
fd_offset + ex.a_text);
|
fd_offset + ex.a_text);
|
||||||
up_write(¤t->mm->mmap_sem);
|
up_write(¤t->mm->mmap_sem);
|
||||||
if (error != N_DATADDR(ex)) {
|
if (error != N_DATADDR(ex)) {
|
||||||
@@ -435,8 +452,7 @@ beyond_if:
|
|||||||
static int load_aout_library(struct file *file)
|
static int load_aout_library(struct file *file)
|
||||||
{
|
{
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
unsigned long bss, start_addr, len;
|
unsigned long bss, start_addr, len, error;
|
||||||
unsigned long error;
|
|
||||||
int retval;
|
int retval;
|
||||||
struct exec ex;
|
struct exec ex;
|
||||||
|
|
||||||
@@ -450,7 +466,8 @@ static int load_aout_library(struct file *file)
|
|||||||
/* We come in here for the regular a.out style of shared libraries */
|
/* We come in here for the regular a.out style of shared libraries */
|
||||||
if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != QMAGIC) || N_TRSIZE(ex) ||
|
if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != QMAGIC) || N_TRSIZE(ex) ||
|
||||||
N_DRSIZE(ex) || ((ex.a_entry & 0xfff) && N_MAGIC(ex) == ZMAGIC) ||
|
N_DRSIZE(ex) || ((ex.a_entry & 0xfff) && N_MAGIC(ex) == ZMAGIC) ||
|
||||||
i_size_read(inode) < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
|
i_size_read(inode) <
|
||||||
|
ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,10 +484,10 @@ static int load_aout_library(struct file *file)
|
|||||||
|
|
||||||
#ifdef WARN_OLD
|
#ifdef WARN_OLD
|
||||||
static unsigned long error_time;
|
static unsigned long error_time;
|
||||||
if ((jiffies-error_time) > 5*HZ)
|
if ((jiffies-error_time) > 5*HZ) {
|
||||||
{
|
|
||||||
printk(KERN_WARNING
|
printk(KERN_WARNING
|
||||||
"N_TXTOFF is not page aligned. Please convert library: %s\n",
|
"N_TXTOFF is not page aligned. Please convert "
|
||||||
|
"library: %s\n",
|
||||||
file->f_path.dentry->d_name.name);
|
file->f_path.dentry->d_name.name);
|
||||||
error_time = jiffies;
|
error_time = jiffies;
|
||||||
}
|
}
|
||||||
@@ -482,7 +499,8 @@ static int load_aout_library(struct file *file)
|
|||||||
file->f_op->read(file, (char __user *)start_addr,
|
file->f_op->read(file, (char __user *)start_addr,
|
||||||
ex.a_text + ex.a_data, &pos);
|
ex.a_text + ex.a_data, &pos);
|
||||||
flush_icache_range((unsigned long) start_addr,
|
flush_icache_range((unsigned long) start_addr,
|
||||||
(unsigned long) start_addr + ex.a_text + ex.a_data);
|
(unsigned long) start_addr + ex.a_text +
|
||||||
|
ex.a_data);
|
||||||
|
|
||||||
retval = 0;
|
retval = 0;
|
||||||
goto out;
|
goto out;
|
||||||
|
Reference in New Issue
Block a user