Bug 11867 - .quad directive not assembled correctly
Summary: .quad directive not assembled correctly
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.20
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-01 20:35 UTC by Edward Meewis
Modified: 2010-08-02 14:42 UTC (History)
1 user (show)

See Also:
Host: i386-portbld-freebsd8.0
Target: *
Build: i386-portbld-freebsd8.0
Last reconfirmed: 2010-08-02 02:47:34


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Edward Meewis 2010-08-01 20:35:54 UTC
This of for: GNU assembler version 2.20.1 (i386-portbld-freebsd8.0) using BFD
version (GNU Binutils) 2.20.1.20100303

The following assembler file doesn't assemble correctly:

	.file	"quadtest.s"
	.type	globalArray,@object
	.data
	.globl	globalArray
	.align	16
globalArray:
	.quad	542196645677236224
	.quad	-12884901888
	.quad	0
	.quad	542196645677236224
	.size	globalArray, 32


Contents of section .data:
 0000 00000000 fa448607 00000000 fdff0000  .....D..........
 0010 00000000 00000000 00000000 fa448607  .............D..

It should be:

Contents of section .data:
 0000 00000000 fa448607 00000000 fdffffff  .....D..........
 0010 00000000 00000000 00000000 fa448607  .............D..

Presumably, this also occurs on OpenBSD (version unknown)
Comment 1 Alan Modra 2010-08-02 02:47:34 UTC
This is a generic problem that will affect all targets built with a 32-bit
bfd_vma.  It is a bug in bignum handling.
Comment 2 Sourceware Commits 2010-08-02 13:19:58 UTC
Subject: Bug 11867

CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2010-08-02 13:19:44

Modified files:
	gas            : ChangeLog expr.c read.c 

Log message:
	PR gas/11867
	* expr.c (operand <'-' and '~'>): Widen bignums.
	(operand <'!'>): Correct bignum result and convert to O_constant.
	* read.c (emit_expr): Don't assert on .byte bignum.  Don't display
	bignum truncated warning for sign extended bignums.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/ChangeLog.diff?cvsroot=src&r1=1.4217&r2=1.4218
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/expr.c.diff?cvsroot=src&r1=1.83&r2=1.84
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/read.c.diff?cvsroot=src&r1=1.166&r2=1.167

Comment 3 Alan Modra 2010-08-02 13:21:12 UTC
.
Comment 4 Edward Meewis 2010-08-02 14:42:44 UTC
Fix confirmed:

/usr/local/bin/as -o quadtest.o quadtest.asm
objdump -s quadtest.o

Contents of section .data:
 0000 00000000 fa448607 00000000 fdff0000  .....D..........
 0010 00000000 00000000 00000000 fa448607  .............D..

Patched version:
~/obj/binutils-2.20/gas/as-new -o quadtest.o quadtest.asm
[emeewis@jazzed]~/binutils-test>objdump -s quadtest.o

Contents of section .data:
 0000 00000000 fa448607 00000000 fdffffff  .....D..........
 0010 00000000 00000000 00000000 fa448607  .............D..
Comment 5 Sourceware Commits 2010-08-02 20:11:01 UTC
Subject: Bug 11867

CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2010-08-02 20:10:46

Modified files:
	gas/testsuite  : ChangeLog 
	gas/testsuite/gas/elf: elf.exp 
Added files:
	gas/testsuite/gas/elf: data-1.d data-1.s 

Log message:
	Add a testcase for PR gas/11867.
	
	2010-08-02  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR gas/11867
	* gas/elf/data-1.d: New.
	* gas/elf/data-1.s: Likewise.
	
	* elf/elf.exp: Run data-1.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1717&r2=1.1718
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/data-1.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/data-1.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/elf.exp.diff?cvsroot=src&r1=1.61&r2=1.62