Bug 21248 - GNU BINUTILS 2.28 PPC objdump output error: mtivor35,mtibatl
Summary: GNU BINUTILS 2.28 PPC objdump output error: mtivor35,mtibatl
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.28
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-13 22:52 UTC by James Rodriguez
Modified: 2017-03-17 09:01 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2017-03-17 00:00:00


Attachments
PowerPC Assembly code for gas and then objdump. (64 bytes, text/plain)
2017-03-13 22:52 UTC, James Rodriguez
Details

Note You need to log in before you can comment on or make changes to this bug.
Description James Rodriguez 2017-03-13 22:52:26 UTC
Created attachment 9901 [details]
PowerPC Assembly code for gas and then objdump.

TITLE:
GNU BINUTILS 2.28 PPC objdump output error: mtivor35,mtibatl

SUMMARY:
This GNU Binutils 2.28 software defect report contains seven enumerated sections, labeled:
(#1): ## ORIGINAL_ASM_SOURCE_SIMPLIFIED_EXAMPLE:
(#2): ## ASSEMBLY_OF_ASM_SOURCE_XTERM_SESSION_LOG:
(#3): ## OBJDUMP_INFORMATION_OUTPUT:
(#4): ## OBJDUMP_OUTPUT: --disassembler-options=e6500 --architecture=powerpc:e6500
(#5): ## OBJDUMP_OUTPUT: --disassembler-options=titan --architecture=powerpc:titan
(#6): ## RELATED_BINUTILS_SOURCE_CODE_EXCERPT:
(#7): ## ANALYSIS:


DETAILED_SECTIONS:

(#1):
## ORIGINAL_ASM_SOURCE_SIMPLIFIED_EXAMPLE:
## ATTACHED_FILENAME: showObjdumpIssue1.s
## SOURCE_LIST:
.text
li 3, 0
mtspr 528, 3
mtspr 529, 3
mtspr 530, 3
mtspr 531, 3
mtibatl 1,3
.end



(#2):
## ASSEMBLY_OF_ASM_SOURCE_XTERM_SESSION_LOG:

jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $ ls -l as-new
-rwxr-xr-x 1 jrod users 7514736 Mar 6 13:19 as-new

jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $ file as-new
as-new: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=18a71b03164e039d3e6e1d882e162d1ecfea10b1, not stripped

jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $ ./as-new --version
GNU assembler (GNU Binutils) 2.28
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `powerpc-eabi'.

jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $ ./as-new -a -me6500 showObjdumpIssue1.s
GAS LISTING showObjdumpIssue1.s page 1


   1 .text
   2 0000 38600000 li 3, 0
   3 0004 7C7083A6 mtspr 528, 3
   4 0008 7C7183A6 mtspr 529, 3
   5 000c 7C7283A6 mtspr 530, 3
   6 0010 7C7383A6 mtspr 531, 3
   7 0014 7C7383A6 mtibatl 1,3
   8 .end

GAS LISTING showObjdumpIssue1.s page 2


NO DEFINED SYMBOLS

NO UNDEFINED SYMBOLS
jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $

jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $ ls -l a.out
-rw-r--r-- 1 jrod users 468 Mar 13 11:19 a.out

jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $ file a.out
a.out: ELF 32-bit MSB relocatable, PowerPC or cisco 4500, version 1 (SYSV), not stripped


(#3):
## OBJDUMP_INFORMATION_OUTPUT:

jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $ ls -l /opt/gnu/binutils/binutils-2.28/binutils/objdump
-rwxr-xr-x 1 jrod users 7642172 Mar 6 13:19 /opt/gnu/binutils/binutils-2.28/binutils/objdump

jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $ file /opt/gnu/binutils/binutils-2.28/binutils/objdump
/opt/gnu/binutils/binutils-2.28/binutils/objdump: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=e2b2875e3ecd3db24f6bfa7fcce6bee5930b66cd, not stripped

jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $ /opt/gnu/binutils/binutils-2.28/binutils/objdump -v
GNU objdump (GNU Binutils) 2.28
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $





(#4):
## OBJDUMP_OUTPUT: --disassembler-options=e6500 --architecture=powerpc:e6500

jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $ /opt/gnu/binutils/binutils-2.28/binutils/objdump -l -r -S --disassembler-options=e6500 --architecture=powerpc:e6500 /opt/gnu/binutils/binutils-2.28/gas/a.out

/opt/gnu/binutils/binutils-2.28/gas/a.out: file format elf32-powerpc


Disassembly of section .text:

00000000 <.text>:
   0: 38 60 00 00 li r3,0
   4: 7c 70 83 a6 mtibatu 0,r3
   8: 7c 71 83 a6 mtibatl 0,r3
   c: 7c 72 83 a6 mtibatu 1,r3
  10: 7c 73 83 a6 mtibatl 1,r3
  14: 7c 73 83 a6 mtibatl 1,r3




(#5):
## OBJDUMP_OUTPUT: --disassembler-options=titan --architecture=powerpc:titan

jrod@jrod-lx1$:/opt/gnu/binutils/binutils-2.28/gas $ /opt/gnu/binutils/binutils-2.28/binutils/objdump -l -r -S --disassembler-options=titan --architecture=powerpc:titan /opt/gnu/binutils/binutils-2.28/gas/a.out

/opt/gnu/binutils/binutils-2.28/gas/a.out: file format elf32-powerpc


Disassembly of section .text:

00000000 <.text>:
   0: 38 60 00 00 li r3,0
   4: 7c 70 83 a6 mtspr 528,r3
   8: 7c 71 83 a6 mtspr 529,r3
   c: 7c 72 83 a6 mtspr 530,r3
  10: 7c 73 83 a6 mtivor35 r3
  14: 7c 73 83 a6 mtivor35 r3



(#6):
## RELATED_BINUTILS_SOURCE_CODE_EXCERPT:

/opt/gnu/binutils/binutils-2.28/opcodes/ppc-opc.c
{"mtivor32", XSPR(31,467,528), XSPR_MASK, PPCSPE, 0, {RS}},
{"mtibatu", XSPR(31,467,528), XSPRBAT_MASK, PPC, TITAN, {SPRBAT, RS}},
{"mtivor33", XSPR(31,467,529), XSPR_MASK, PPCSPE, 0, {RS}},
{"mtibatl", XSPR(31,467,529), XSPRBAT_MASK, PPC, TITAN, {SPRBAT, RS}},
{"mtivor34", XSPR(31,467,530), XSPR_MASK, PPCSPE, 0, {RS}},
{"mtivor35", XSPR(31,467,531), XSPR_MASK, PPCPMR, 0, {RS}},



(#7):
## ANALYSIS:

First I tried with a 2.19-base objdump these available options (NXP core e6500 was not available):
--architecture=powerpc:common
--architecture=powerpc:e500
--architecture=powerpc:e500mc

In every case, objdumpppc output the apparently wrong:
b2c: 7c 73 83 a6 mtibatl 1,r3

Instead of the apparently correct value:
b2c: 7c 73 83 a6 mtivor35 r3


But the output of the "apparently wrong" objdump interpretation of the machine code "7c7383a6"
was not initially distinguishable from the alternative: GAS output of the wrong machine code.

After a manual disassembly of machine code "7c7383a6", staff was reasonably certain that
GAS generated the correct machine code from the assembly source. Thus, the conclusion
that "objdump" was the origin of them problem, staff decided to try the binutils 2.28
released 2017-03-02.

It exhibited the same problem. It seems from an examination of the two 2.28 outputs
and a peek at the source code in /opt/gnu/binutils/binutils-2.28/opcodes/ppc-opc.c
that APM/AMCC's "Titan" core has PPC EABI OPcode which overlap with NXP/Freescale:
{"mtivor32", XSPR(31,467,528), XSPR_MASK, PPCSPE, 0, {RS}},
{"mtibatu", XSPR(31,467,528), XSPRBAT_MASK, PPC, TITAN, {SPRBAT, RS}},

{"mtivor33", XSPR(31,467,529), XSPR_MASK, PPCSPE, 0, {RS}},
{"mtibatl", XSPR(31,467,529), XSPRBAT_MASK, PPC, TITAN, {SPRBAT, RS}},

{"mtivor34", XSPR(31,467,530), XSPR_MASK, PPCSPE, 0, {RS}},
{"mtivor35", XSPR(31,467,531), XSPR_MASK, PPCPMR, 0, {RS}},


So to an extent, the objdump-2.28 options that select for NXP/Freescale e6500
are swapped and output the AMCC/APM Titan values:

## OBJDUMP_OUTPUT: --disassembler-options=e6500 --architecture=powerpc:e6500
   4: 7c 70 83 a6 mtibatu 0,r3
   8: 7c 71 83 a6 mtibatl 0,r3
   c: 7c 72 83 a6 mtibatu 1,r3
  10: 7c 73 83 a6 mtibatl 1,r3
  14: 7c 73 83 a6 mtibatl 1,r3

## OBJDUMP_OUTPUT: --disassembler-options=titan --architecture=powerpc:titan
   4: 7c 70 83 a6 mtspr 528,r3
   8: 7c 71 83 a6 mtspr 529,r3
   c: 7c 72 83 a6 mtspr 530,r3
  10: 7c 73 83 a6 mtivor35 r3
  14: 7c 73 83 a6 mtivor35 r3

However, the anomaly seems a little worse than just swapping the two.
This is speculation, but in the case of this swapped objdump line:
  10: 7c 73 83 a6 mtivor35 r3

It is not evident how that could match with this opcodes/ppc-opc.c line:
{"mtivor35", XSPR(31,467,531), XSPR_MASK, PPCPMR, 0, {RS}},

Because XSPR(31,467,531) has no TITAN match, yet the apparent algorithm matched:
  10: 7c 73 83 a6 mtibatl 1,r3

But the match for "mtibatl" (Move to IBAT lower) is: XSPR(31,467,529)
which does not equal: XSPR(31,467,531), since 529 != 531.
Perhaps that is a mismatch feature.

In any case, the objdump is defective in that for these PPC OPcodes,
selecting architecture=powerpc:e6500 outputs Titan, and vice_versa.
The knowledge that the GNU Assembler (gas) is not broken is reassuring.
--------------------------------------------------------------------------


NOTE1:

Support for PPC "mtivor35" was originally inserted by Aldy Hernandez <aldyh@redhat.com>

https://sourceware.org/ml/binutils/2004-02/msg00250.html
patch: ppc-e500 add m*ivor35
From: Aldy Hernandez <aldyh at redhat dot com>
To: binutils at sources dot redhat dot com
Date: Fri, 20 Feb 2004 00:55:57 -0400
Subject: patch: ppc-e500 add m*ivor35
Sigh.  More of the same.  I guess I should do them all at once.
2004-02-20  Aldy Hernandez  <aldyh@redhat.com>
* ppc-opc.c (powerpc_opcodes): Add m*fivor35.
Index: ppc-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/ppc-opc.c,v
retrieving revision 1.61
diff -u -p -r1.61 ppc-opc.c
--- ppc-opc.c	20 Feb 2004 04:45:37 -0000	1.61
+++ ppc-opc.c	20 Feb 2004 04:54:30 -0000
@@ -3686,6 +3686,7 @@ const struct powerpc_opcode powerpc_opco
 { "mfivor32",   XSPR(31,339,528),  XSPR_MASK, PPCSPE,	{ RT } },
 { "mfivor33",   XSPR(31,339,529),  XSPR_MASK, PPCSPE,	{ RT } },
 { "mfivor34",   XSPR(31,339,530),  XSPR_MASK, PPCSPE,	{ RT } },
+{ "mfivor35",   XSPR(31,339,531),  XSPR_MASK, PPCPMR,	{ RT } },
 { "mfibatu",    XSPR(31,339,528),  XSPRBAT_MASK, PPC,	{ RT, SPRBAT } },
 { "mfibatl",    XSPR(31,339,529),  XSPRBAT_MASK, PPC,	{ RT, SPRBAT } },
 { "mfdbatu",    XSPR(31,339,536),  XSPRBAT_MASK, PPC,	{ RT, SPRBAT } },
@@ -3996,6 +3997,7 @@ const struct powerpc_opcode powerpc_opco
 { "mtivor32",  XSPR(31,467,528),  XSPR_MASK, PPCSPE,	{ RS } },
 { "mtivor33",  XSPR(31,467,529),  XSPR_MASK, PPCSPE,	{ RS } },
 { "mtivor34",  XSPR(31,467,530),  XSPR_MASK, PPCSPE,	{ RS } },
+{ "mtivor35",  XSPR(31,467,531),  XSPR_MASK, PPCPMR,	{ RS } },
 { "mtibatu",   XSPR(31,467,528),  XSPRBAT_MASK, PPC,	{ SPRBAT, RS } },
 { "mtibatl",   XSPR(31,467,529),  XSPRBAT_MASK, PPC,	{ SPRBAT, RS } },
 { "mtdbatu",   XSPR(31,467,536),  XSPRBAT_MASK, PPC,	{ SPRBAT, RS } },



NOTE2:

The AMCC Titan core was scrapped in 2010, maybe binutils support could be removed?
https://en.wikipedia.org/wiki/Titan_%28microprocessor%29
Titan was supposed to be a family of 32-bit Power Architecture-based microprocessor cores
designed by Applied Micro Circuits Corporation (AMCC), but was scrapped in 2010 according to reports.
...
Comment 1 Alan Modra 2017-03-17 07:48:57 UTC
Regarding ppc-opc.c, TITAN on those lines *disables* that entry for titan.  So the mtibatu/l are enabled for ppc in general except titan.  The mtivor32..34 are enabled for PPC_OPCODE_SPE and mtivor35 for PPC_OPCODE_PMR.  Only the latter flag is enabled for e6500.

The Freescale reference manual for e6500 that I have mentions IVOR32 and IVOR33, so it would appear that modifying the PPCSPE on those lines (and mfivor32,33) to be PPCSPE|E6500 will fix this for e6500.  I'll commit a patch to do that.

Also, it seems rather a lot of spr related mnemonics should be disabled for e6500.  Please send a patch to binutils@sourceware.org, if you care enough to fix them.
Comment 2 cvs-commit@gcc.gnu.org 2017-03-17 08:40:31 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4b94dd2de12dd0389615700b13b63260e162ccf0

commit 4b94dd2de12dd0389615700b13b63260e162ccf0
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Mar 17 19:06:12 2017 +1030

    E6500 spr mnemonics
    
    	PR 21248
    	* ppc-opc.c (powerpc_opcodes): Enable mfivor32, mfivor33,
    	mtivor32, and mtivor33 for e6500.  Move mfibatl and mfibatu after
    	those spr mnemonics they alias.  Similarly for mtibatl, mtibatu.
Comment 3 Alan Modra 2017-03-17 09:01:06 UTC
Fixed