This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/30622] New: char *p; p = "str"; puts "str" into rodata
- From: "vda dot linux at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Jan 2007 16:03:52 -0000
- Subject: [Bug c/30622] New: char *p; p = "str"; puts "str" into rodata
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
char p;
int main() {
p = "str";
return 0;
}
If anyone will try to assign something to p[0] and if rodata is write
protected,
we'll segfault. Assembly:
.file "t.c"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "str"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
movl $.LC0, %eax
movb %al, p
xorl %eax, %eax
leave
ret
.size main, .-main
.comm p,1,1
.ident "GCC: (GNU) 4.1.1"
.section .note.GNU-stack,"",@progbits
--
Summary: char *p; p = "str"; puts "str" into rodata
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: vda dot linux at googlemail dot com
GCC build triplet: i386-pc-linux-gnu
GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30622