Commit ea9fcb21 authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] Work around gcc 3.3 bug on amd64 in binfmt_elf.c

This patch works around a gcc 3.3 bug on AMD64.  On AMD64 the
get_current() function expands to a switch on sizeof which has to be
optimized away by the compiler, finally yielding an inline assembler
statement.  In some cases it seems to get that wrong and forgets to
reference and use the argument.  I have only seen it happen in
binfmt_elf so far.

Work around by just computing "current" once.
parent 450349c0
...@@ -135,6 +135,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr * exec, ...@@ -135,6 +135,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr * exec,
int items; int items;
elf_addr_t elf_info[40]; elf_addr_t elf_info[40];
int ei_index = 0; int ei_index = 0;
struct task_struct *tsk = current;
/* /*
* If this architecture has a platform capability string, copy it * If this architecture has a platform capability string, copy it
...@@ -186,10 +187,10 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr * exec, ...@@ -186,10 +187,10 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr * exec,
NEW_AUX_ENT(AT_BASE, interp_load_addr); NEW_AUX_ENT(AT_BASE, interp_load_addr);
NEW_AUX_ENT(AT_FLAGS, 0); NEW_AUX_ENT(AT_FLAGS, 0);
NEW_AUX_ENT(AT_ENTRY, exec->e_entry); NEW_AUX_ENT(AT_ENTRY, exec->e_entry);
NEW_AUX_ENT(AT_UID, (elf_addr_t) current->uid); NEW_AUX_ENT(AT_UID, (elf_addr_t) tsk->uid);
NEW_AUX_ENT(AT_EUID, (elf_addr_t) current->euid); NEW_AUX_ENT(AT_EUID, (elf_addr_t) tsk->euid);
NEW_AUX_ENT(AT_GID, (elf_addr_t) current->gid); NEW_AUX_ENT(AT_GID, (elf_addr_t) tsk->gid);
NEW_AUX_ENT(AT_EGID, (elf_addr_t) current->egid); NEW_AUX_ENT(AT_EGID, (elf_addr_t) tsk->egid);
if (k_platform) { if (k_platform) {
NEW_AUX_ENT(AT_PLATFORM, (elf_addr_t)(long)u_platform); NEW_AUX_ENT(AT_PLATFORM, (elf_addr_t)(long)u_platform);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment