$ cc -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ./configure --prefix=/gcc Thread model: posix gcc version 4.3.3 (GCC) $ echo 'void f(void) { char buf[50]; g(buf); }' > 1.c $ echo 'void f(void) { int buf[50]; g(buf); }' > 2.c $ cc -fstack-protector -c 1.c # protects $ cc -fstack-protector -c 2.c # does not protect $ objdump -d 1.o
1.o: file format elf32-i386 Disassembly of section .text: 00000000 <f>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 ec 48 sub $0x48,%esp 6: 65 a1 14 00 00 00 mov %gs:0x14,%eax c: 89 45 fc mov %eax,-0x4(%ebp) f: 31 c0 xor %eax,%eax 11: 8d 45 ca lea -0x36(%ebp),%eax 14: 89 04 24 mov %eax,(%esp) 17: e8 fc ff ff ff call 18 <f+0x18> 1c: 8b 45 fc mov -0x4(%ebp),%eax 1f: 65 33 05 14 00 00 00 xor %gs:0x14,%eax 26: 74 05 je 2d <f+0x2d> 28: e8 fc ff ff ff call 29 <f+0x29> 2d: c9 leave 2e: c3 ret $ objdump -d 2.o 2.o: file format elf32-i386 Disassembly of section .text: 00000000 <f>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 81 ec d8 00 00 00 sub $0xd8,%esp 9: 8d 85 38 ff ff ff lea -0xc8(%ebp),%eax f: 89 04 24 mov %eax,(%esp) 12: e8 fc ff ff ff call 13 <f+0x13> 17: c9 leave 18: c3 ret $ -- Summary: a surprising instance of -fstack-protector not protecting Product: gcc Version: 4.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: paul at g225066096 dot adsl dot alicedsl dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39218