This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: gas --statistics segfault
- From: Dasn Clainst <clainst at fastmail dot cn>
- To: binutils at sourceware dot org, binutils at sources dot redhat dot com
- Date: Tue, 7 Feb 2006 06:43:04 +0800
- Subject: Re: gas --statistics segfault
- References: <20060205130219.GA19544@Compaq>
On Sun, Feb 05, 2006 at 09:02:19PM +0800, Dasn Clainst wrote:
> ===================================================================
> RCS file: /cvs/src/src/gas/as.c,v
> retrieving revision 1.67
> diff -u -p -r1.67 as.c
> --- as.c 30 Oct 2005 18:08:52 -0000 1.67
> +++ as.c 5 Feb 2006 12:41:27 -0000
> @@ -1170,7 +1170,7 @@ main (int argc, char ** argv)
> #endif
>
> #ifndef OBJ_VMS /* Does its own file handling. */
> - output_file_close (out_file_name);
> + /* output_file_close (out_file_name); */
> #endif
>
> if (flag_fatal_warnings && had_warnings () > 0 && had_errors () == 0)
Please forget this patch, it's just an opinion of my own.
-----------------------------------------------------
$ cat test.sh
#!/bin/sh
uname -msr
as --version
count=100;failed=0;i=0
echo "main(){}" > p.c
cc -S p.c -o p.s
while [ $i -lt $count ]
do
as --statistics p.s > /dev/null 2>&1
if [ $? -ne 0 ]; then
let failed=failed+1
fi
let i=i+1
done
echo "$failed/$count failed."
rm -f as.core a.out p.c
$
$ sh test.sh
OpenBSD 3.8 i386
GNU assembler 2.16.91 20060127
Copyright 2005 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
This assembler was configured for a target of `i386-elf-openbsd3.8'.
100/100 failed.
$
$ cat p.s
.file "p.c"
.globl __stack_smash_handler
.section .rodata
.LC0:
.string "main"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
movl $0, %eax
subl %eax, %esp
movl __guard, %eax
movl %eax, -24(%ebp)
movl -24(%ebp), %edx
cmpl __guard, %edx
je .L2
subl $8, %esp
pushl -24(%ebp)
pushl $.LC0
call __stack_smash_handler
addl $16, %esp
.L2:
leave
ret
.size main, .-main
-----------------------------------------------------
After calling 'output_file_close', some pointers to frch_seg in frchain_root
become invalid. I'm not sure whether it is a problem of gas or not,
cause openbsd enables stack smash protection by default. I'll dig it
soon.