[PATCH] unwind: add simple test case for testing -k
Masatake YAMATO
yamato at redhat.com
Thu May 15 04:25:05 UTC 2014
Hi,
> > stack_fcall_CFLAGS = $(AM_CFLAGS) -O0
I tried 'stack_fcall_CFLAGS = $(AM_CFLAGS) -O0' before posting.
However, it seemed that is was not enough.
Next lines are the output of make with Makefile.am in which
'stack_fcall_CFLAGS = $(AM_CFLAGS) -O0' line is added:
$ gcc -DHAVE_CONFIG_H -I. -I.. -O0 -g -O2 -MT stack_fcall-stack-fcall.o ...
mv -f .deps/stack_fcall-stack-fcall.Tpo .deps/stack_fcall-stack-fcall.Po
$ gcc -O0 -g -O2 -o stack-fcall stack_fcall-stack-fcall.o
Both -O0 and -O2 are specified. -O2 may come from CFLAGS.
What happens if both -O0 and -O2 are specified.
I wrote smaller program.
[yamato at localhost]/tmp% cat foo.c
cat foo.c
int foo(void) {return 3;}
int main(void) {return foo();}
[yamato at localhost]/tmp% PATH=/usr/bin gcc -c -O0 -O2 foo.c; /usr/bin/objdump -d foo.o
...
Disassembly of section .text:
0000000000000000 <foo>:
0: b8 03 00 00 00 mov $0x3,%eax
5: c3 retq
Disassembly of section .text.startup:
0000000000000000 <main>:
0: b8 03 00 00 00 mov $0x3,%eax
5: c3 retq
[yamato at localhost]/tmp% PATH=/usr/bin gcc -c -O0 foo.c; /usr/bin/objdump -d foo.o
...
Disassembly of section .text:
0000000000000000 <foo>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: b8 03 00 00 00 mov $0x3,%eax
9: 5d pop %rbp
a: c3 retq
000000000000000b <main>:
b: 55 push %rbp
c: 48 89 e5 mov %rsp,%rbp
f: e8 00 00 00 00 callq 14 <main+0x9>
14: 5d pop %rbp
15: c3 retq
The generated codes are different between "-O0 -O2" and "-O0".
The order of -O0 and -O2 in a command line is important?
I don't want to inspect anymore:(
info doc of automake shows the way to how to define per object
CFLAGS. It looks tricky for me.
(I'm using Fedora 20.)
Masatake YAMATO
On Thu, 15 May 2014 00:43:19 +0400, "Dmitry V. Levin" <ldv at altlinux.org> wrote:
> On Wed, May 14, 2014 at 01:16:29PM +0900, Masatake YAMATO wrote:
> [...]
>> diff --git a/tests/stack-fcall.c b/tests/stack-fcall.c
>> new file mode 100644
>> index 0000000..3e6ffd4
>> --- /dev/null
>> +++ b/tests/stack-fcall.c
>> @@ -0,0 +1,27 @@
>> +#include <unistd.h>
>> +#include <sys/types.h>
>> +
>> +/* volatile is used to protect 'call' is converted to 'jump'
>> + by gcc.
>> +
>> + I cannot find the way not to apply -O0 to this program
>> + in info doc of automake. */
>
> stack_fcall_CFLAGS = $(AM_CFLAGS) -O0
>
>
> --
> ldv
More information about the Strace-devel
mailing list