PATCH: Support .quad for x32
H.J. Lu
hjl.tools@gmail.com
Tue Mar 29 12:51:00 GMT 2011
More information about the Binutils mailing list
Tue Mar 29 12:51:00 GMT 2011
- Previous message (by thread): PATCH: Support .quad for x32
- Next message (by thread): PATCH: Support .quad for x32
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Mar 29, 2011 at 1:35 AM, Jan Beulich <JBeulich@novell.com> wrote: >>>> On 29.03.11 at 00:51, "H.J. Lu" <hongjiu.lu@intel.com> wrote: >> Hi, >> >> For this testcase: >> >> --- >> union U >> { >> int *m; >> double d; >> }; >> >> extern int xxxx; >> >> int >> foo (union U u) >> { >> union U v = { &xxxx}; >> return u.d == v.d; >> } >> --- >> >> We can generate >> >> foo: >> .LFB0: >> .cfi_startproc >> movq %rdi, -8(%rsp) >> movsd .LC0(%rip), %xmm1 >> movsd -8(%rsp), %xmm0 >> movl $1, %eax >> ucomisd %xmm1, %xmm0 >> jp .L3 >> jne .L3 >> rep >> ret >> .p2align 4,,10 >> .p2align 3 >> .L3: >> xorl %eax, %eax >> .p2align 4,,9 >> ret >> .cfi_endproc >> .LFE0: >> .size foo, .-foo >> .section .rodata.cst8,"aM",@progbits,8 >> .align 8 >> .LC0: >> .quad xxxx > > Looks more like a compiler bug than something that needs fixing in Reload generates 64bit symbol address in constant pool. I decided it is a nice optimization for x32. Otherwise, we have to do it like ia32. See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47958 > binutils. If programming in assembly, using .quad may be intended handle_quad has if (x86_elf_abi != X86_64_X32_ABI) { cons (nbytes); return; } It only applies to x32. > to generate wider than 32-bit relocs (e.g. when xxxx is a > constant in another translation unit). Yes, with the bogus tying > of the 32-bit ABI to the ELF object bit size (thus causing only > 32-bit relocation forms to be used) that's sort of difficult to > achieve, but not impossible (global constant with less than 32 bits > plus addend with less than 32 bits). > > Additionally, I think the change isn't correct either: > >> I checked in this patch to allow .quad for x32. >> >> ... > > ... but then you zero-extend only the last one? > Thanks for noticing it. I checked in this patch to fix it. -- H.J. ---- diff --git a/gas/ChangeLog b/gas/ChangeLog index 7c5b705..4275767 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2011-03-29 H.J. Lu <hongjiu.lu@intel.com> + + * config/tc-i386.c (handle_quad): Properly handle multiple + operands. + 2011-03-29 Mike Frysinger <vapier@gentoo.org> * config/bfin-parse.y (BYTEUNPACK): Return yyerror when dest diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 624c78a..aa345b5 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -9182,19 +9182,19 @@ handle_quad (int nbytes) if (exp.X_op != O_constant) nbytes = 4; emit_expr (&exp, (unsigned int) nbytes); + /* Zero-extends to 8 bytes if not constant. */ + if (nbytes == 4) + { + memset (&exp, '\0', sizeof (exp)); + exp.X_op = O_constant; + emit_expr (&exp, nbytes); + } + nbytes = 8; } while (*input_line_pointer++ == ','); input_line_pointer--; /* Put terminator back into stream. */ demand_empty_rest_of_line (); - - /* Zero-extends to 8 bytes if not constant. */ - if (nbytes == 4) - { - memset (&exp, '\0', sizeof (exp)); - exp.X_op = O_constant; - emit_expr (&exp, nbytes); - } } #endif /* OBJ_ELF || OBJ_MAYBE_ELF */ diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 2101e9f..51502ee 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-03-29 H.J. Lu <hongjiu.lu@intel.com> + + * gas/i386/ilp32/quad.d: Add tests for multiple operands. + * gas/i386/ilp32/quad.s: Likewise. + 2011-03-29 Mike Frysinger <vapier@gentoo.org> * gas/bfin/expected_errors.s: Add invalid BYTEUNPACK insn tests. diff --git a/gas/testsuite/gas/i386/ilp32/quad.d b/gas/testsuite/gas/i386/ilp32/quad.d index d3e6ff8..6f8a6c6 100644 --- a/gas/testsuite/gas/i386/ilp32/quad.d +++ b/gas/testsuite/gas/i386/ilp32/quad.d @@ -7,8 +7,12 @@ RELOCATION RECORDS FOR \[.data\]: OFFSET +TYPE +VALUE 0+ R_X86_64_32 +foo 0+10 R_X86_64_32 +bar +0+20 R_X86_64_32 +foo +0+30 R_X86_64_32 +bar Contents of section .data: 0000 00000000 00000000 efcdab90 78674512 ............xgE. 0010 00000000 00000000 ffffffff ffffffff ................ + 0020 00000000 00000000 efcdab90 78674512 ............xgE. + 0030 00000000 00000000 ffffffff ffffffff ................ diff --git a/gas/testsuite/gas/i386/ilp32/quad.s b/gas/testsuite/gas/i386/ilp32/quad.s index e96653a..a14304d 100644 --- a/gas/testsuite/gas/i386/ilp32/quad.s +++ b/gas/testsuite/gas/i386/ilp32/quad.s @@ -3,3 +3,4 @@ .quad 0x1245677890abcdef .quad bar .quad -1 + .quad foo, 0x1245677890abcdef, bar, -1
- Previous message (by thread): PATCH: Support .quad for x32
- Next message (by thread): PATCH: Support .quad for x32
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list