Re: [PATCH] x86: Clean up stack access code in irq_32.c
From: Chuck Ebbert
Date: Sun Oct 12 2014 - 13:40:22 EST
On Sun, 12 Oct 2014 12:00:03 -0500
Jeff Epler <jepler@xxxxxxxxxxxxxx> wrote:
> It looks like the proposed variant still miscompiles in clang 3.4 and 3.5, the
> two versions I had handy to test.
>
> I extracted your code to a simple standalone C translation unit and
> inspected various compilers' results via objdump.
>
Wow, my little test program below worked with clang by accident. I was
building it with both printf() calls enabled and it printed out the
same results on both output lines. But commenting out the first line
reveals that it simply leaves whatever junk is on the stack there
for the first arg when it calls printf().
#define _GNU_SOURCE
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#define current_stack_pointer ({ \
unsigned long sp; \
asm("mov %%esp,%0" : "=g" (sp)); \
sp; \
})
#define current_stack_pointer2 ({ \
register unsigned long sp asm("esp"); \
sp; \
})
int main(int argc, char **argv)
{
// printf("%X %X\n", current_stack_pointer , __builtin_frame_address(0));
printf("%X %X\n", current_stack_pointer2, __builtin_frame_address(0));
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/