lkml.org 
[lkml]   [2014]   [Oct]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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;
}


\
 
 \ /
  Last update: 2014-10-12 20:21    [W:2.999 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site