Messages in this thread | | | Date | Sun, 12 Oct 2014 12:40:13 -0500 | From | Chuck Ebbert <> | Subject | Re: [PATCH] x86: Clean up stack access code in irq_32.c |
| |
On Sun, 12 Oct 2014 12:00:03 -0500 Jeff Epler <jepler@unpythonic.net> 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; }
| |