Bug 506417

Summary: nop instruction requires operand
Product: [Fedora] Fedora Reporter: Dan Horák <dan>
Component: binutilsAssignee: Nick Clifton <nickc>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 11CC: jakub, jan.kratochvil, nickc
Target Milestone: ---   
Target Release: ---   
Hardware: s390x   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-06-30 09:31:41 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 467765    
Description Flags
Allow NOP instruction without any operands none

Description Dan Horák 2009-06-17 04:45:38 EDT
When assembler source contains "nop" (no-operation) instruction without an operand, gas on s390x produces an error

a.s: Assembler messages:
a.s:2: Error: missing operand

In my opinion "nop" should translate into a no-operation machine instruction without requiring any operand in the assembler sources.

Version-Release number of selected component (if applicable):

also present in RHEL-4 and RHEL-5
binutils- (EL4)

Reproducer is:
as << EOF
  .section code

and it results into:
{standard input}: Assembler messages:
{standard input}:2: Error: missing operand

Aditional info:

Real world example of breakage is build of postgresql (https://s390.koji.fedoraproject.org/koji/taskinfo?taskID=82106) with static probes where the probe (from sys/sdt.h) translates into

# 1551 "xact.c" 1
        .section .probes
        .align 8
        .asciz "transaction__start"
        .align 4
        .int 0x31425250
        .align 8
        .long 1b
        .align 8
        .long 2f

# 0 "" 2
        l       %r1,164(%r15)
# 1551 "xact.c" 1
        nop /* %r1 */
# 0 "" 2

xact.c: Assembler messages:
xact.c:2089: Error: missing operand
xact.c:1552: Error: missing operand
xact.c:1679: Error: missing operand

These lines from opcodes/s390-opc.txt are related to "nop":
0700 nopr RR_0R "no operation" g5 esa,zarch
0700 b*8r RR_0R "conditional branch" g5 esa,zarch
4700 nop RX_0RRD "no operation" g5 esa,zarch
4700 b*8 RX_0RRD "conditional branch" g5 esa,zarch

Even the Linux kernel defines a nop in /arch/s390/include/asm/system.h as
#define nop() asm volatile("nop")
but it's not probably used, otherwise it would break the build.
Comment 1 Nick Clifton 2009-06-17 12:01:12 EDT
Created attachment 348283 [details]
Allow NOP instruction without any operands
Comment 2 Nick Clifton 2009-06-17 12:01:58 EDT
Hi Dan,

  Please could you try out the uploaded patch and let me know if this fixes the problem for you.

Comment 3 Dan Horák 2009-06-23 08:09:22 EDT
(In reply to comment #2)
>   Please could you try out the uploaded patch and let me know if this fixes the
> problem for you.

I have used a cross-assembler on the file and it compiles without error. I have only a question whether this "hack" guarantees that the proper "no-operation" opcode will be generated?
Comment 4 Nick Clifton 2009-06-30 09:31:41 EDT
Hi Dan,

  The patch will generate a proper nop instruction.  But as it turns out the patch is unnecessary.  The s390x maintainer for the binutils port has recently installed a different patch into the FSF sources (which makes the arguments to the NOP instruction opional) and this has now been imported into rawhide.

Comment 5 Dan Horák 2009-06-30 09:47:22 EDT
Hi Nick,

it looks like there's a parallel channel directly into IBM from our bugzilla :-) 2 days from a report to a fix. Thanks anyway.