Bug 9874 - Warning while compiling gas/tc-ia64.c with -Wformat-security
Summary: Warning while compiling gas/tc-ia64.c with -Wformat-security
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-20 00:51 UTC by Marco Schulze
Modified: 2009-03-02 14:48 UTC (History)
2 users (show)

See Also:
Host:
Target: ia64-unknown-linux-gnu
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marco Schulze 2009-02-20 00:51:29 UTC
When I try to build binutils version 2.19.1 as a cross-tool, I get this error:
cc1: warnings being treated as errors
../../binutils-2.19.1/gas/config/tc-ia64.c: In function ‘fix_insn’:
../../binutils-2.19.1/gas/config/tc-ia64.c:11162: error: format not a string
literal and no format arguments
I run configure with the following arguments:
../binutils-2.19.1/configure CC="ccache gcc" CXX="ccache g++"
--prefix=$HOME/Lin/Cross-Tools/ --disable-nls --target=ia64-unknown-linux-gnu
--with-gmp=$HOME/Lin/Cross-Tools/

I'm running a fully patched Ubuntu Intrepid Ibex 32-bits on a Core 2 Duo CPU.
Also, I've searched the for the above bug and it doesn't seem to have been
reported yet.
Comment 1 H.J. Lu 2009-02-20 17:11:31 UTC
Can you try binutils in CVS or Linux binutils 2.19.51.0.2 at

http://www.kernel.org/pub/linux/devel/binutils/
Comment 2 Marco Schulze 2009-02-20 19:19:45 UTC
No good, it's the same error:
cc1: warnings being treated as errors
../../binutils-2.19.51.0.2/gas/config/tc-ia64.c: In function ‘fix_insn’:
../../binutils-2.19.51.0.2/gas/config/tc-ia64.c:11178: error: format not a
string literal and no format arguments

Source:
'http://www.kernel.org/pub/linux/devel/binutils/binutils-2.19.51.0.2.tar.bz2'

This also happens with the cvs version (02/20/09, 19:17 GMT).
Comment 3 H.J. Lu 2009-02-20 19:34:58 UTC
Please show the command line used to compile tc-ia64.c.
Comment 4 Marco Schulze 2009-02-21 19:18:36 UTC
tc-ia64.c is automatically compiled by make. I won't have access to the linux
box this weekend, so it'll only be possible to post how the compiler is run (as
invoked by make) next monday. The configure script is run with the following
arguments (it's incomplete in my first post):

../binutils-2.19.1/configure CC="ccache gcc" CXX="ccache g++"
--prefix=$HOME/Lin/Cross-Tools/ --disable-nls --target=ia64-unknown-linux-gnu
--with-gmp=$HOME/Lin/Cross-Tools/ --with-mpfr=$HOME/Lin/Cross-Tools/
--disable-multilib --enable-shared --enable-64-bit-bfd
--with-lib-path=$HOME/Lin/Cross-Tools/

Then I run 'make configure-host' and 'make -j4'.
Comment 5 H.J. Lu 2009-02-21 19:25:39 UTC
(In reply to comment #4)
> tc-ia64.c is automatically compiled by make. I won't have access to the linux
> box this weekend, so it'll only be possible to post how the compiler is run (as
> invoked by make) next monday. The configure script is run with the following

I can't reproduce it. That is why I want to see the command line used
to compile tc-ia64.c. Also please show the output of "gcc -v".
Comment 6 Marco Schulze 2009-02-23 12:54:04 UTC
ccache gcc -DHAVE_CONFIG_H -I. -I../../binutils-2.19.1/gas -I. -I.
-I../../binutils-2.19.1/gas -I../bfd -I../../binutils-2.19.1/gas/config
-I../../binutils-2.19.1/gas/../include -I../../binutils-2.19.1/gas/..
-I../../binutils-2.19.1/gas/../bfd
-DLOCALEDIR="\"/home/arkdot/Lin/Cross-Tools//share/locale\""   -W -Wall
-Wstrict-prototypes -Wmissing-prototypes -Werror -g -O2 -c
../../binutils-2.19.1/gas/config/tc-ia64.c
Comment 7 Marco Schulze 2009-02-23 13:36:42 UTC
Using built-in specs.
gcc -v
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.2-1ubuntu12'
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3
--program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release
--build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12)
Comment 8 wilson@codesourcery.com 2009-02-23 18:19:21 UTC
Subject: Re:  Error while compiling gas/tc-ia64.c as a cross-tool

hjl dot tools at gmail dot com wrote:
> I can't reproduce it. That is why I want to see the command line used
> to compile tc-ia64.c. Also please show the output of "gcc -v".

He is using Ubuntu.  Ubuntu hard wires on some extra gcc format checking 
options.  The line in question is
    as_bad_where (fix->fx_file, fix->fx_line, err);

This will generate a gcc warning if you use -Wformat-nonliteral, which 
is apparently on by default in Ubuntu.  I saw someone else mention this 
recently, though I don't remember the details.

This could be fixed by changing the line to be instead
     as_bad_where (fix->fx_file, fix->fx_line, "%s", err);

Jim


Comment 9 wilson@codesourcery.com 2009-02-23 18:31:49 UTC
Subject: Re:  Error while compiling gas/tc-ia64.c as a cross-tool

hjl dot tools at gmail dot com wrote:
> I can't reproduce it. That is why I want to see the command line used
> to compile tc-ia64.c. Also please show the output of "gcc -v".

See
     https://wiki.ubuntu.com/CompilerFlags

It is actually -Wformat-security that they are using.

Jim


Comment 10 Marco Schulze 2009-02-24 00:35:05 UTC
Yes, that did the trick! It's compiling now.
Comment 11 H.J. Lu 2009-02-26 00:30:33 UTC
Here is the gcc bug:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39044
Comment 12 Sourceware Commits 2009-03-02 14:47:49 UTC
Subject: Bug 9874

CVSROOT:	/cvs/src
Module name:	src
Changes by:	nickc@sourceware.org	2009-03-02 14:47:38

Modified files:
	gas            : ChangeLog 
	gas/config     : tc-ia64.c 

Log message:
	PR 9874
	* config/tc-ia64.c (fix_insn): Fix warning reported by
	-Wformat-security.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gas/ChangeLog.diff?cvsroot=src&r1=1.3751&r2=1.3752
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gas/config/tc-ia64.c.diff?cvsroot=src&r1=1.204&r2=1.205

Comment 13 Nick Clifton 2009-03-02 14:48:20 UTC
I have checked in Jim's patch.

Cheers
  Nick

gas/ChangeLog

	PR 9874
	* config/tc-ia64.c (fix_insn): Fix warning reported by
	-Wformat-security.