Bug 10767 - opcodes/i386-dis.c exceeds 256 levels of nested macros
Summary: opcodes/i386-dis.c exceeds 256 levels of nested macros
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: unassigned
Depends on:
Reported: 2009-10-13 11:56 UTC by Jerker Bäck
Modified: 2009-10-16 17:57 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-interix6.1
Target: x86_64-unknown-interix6.1
Build: x86_64-unknown-interix6.1
Last reconfirmed:

enum.sed (480 bytes, text/plain)
2009-10-15 16:03 UTC, Ineiev

Note You need to log in before you can comment on or make changes to this bug.
Description Jerker Bäck 2009-10-13 11:56:39 UTC
This is not a bug, rather to inform that the current solution breaks the
MS x64 compiler <= 15.00.30729.01. There is a limit of max 256 levels
of nested macros. The Intel compiler v11.1 do not have this limit,
neither do gcc.

As there are no functional 64bit gcc for PE targets and the Intel
compiler is not fully compatible with NT POSIX, the only current
possible choice is the MS compiler to get 64bit binaries.

Here is a simple solution to get it working:
Preprocess opcodes/i386-dis.c with the Intel compiler. 
Extract "struct dis386 vex_table" to opcodes/i386-dis_tables.c
Apply the following patch:

RCS file: /cvs/src/src/opcodes/i386-dis.c,v
retrieving revision 1.200
diff -w -b -B -u -p -r1.200 i386-dis.c
--- i386-dis.c	15 Sep 2009 17:53:40 -0000	1.200
+++ i386-dis.c	13 Oct 2009 02:17:19 -0000
@@ -6316,7 +6316,9 @@ static const struct dis386 three_byte_ta
+#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
+#include "i386-dis_tables.c"
 static const struct dis386 vex_table[][256] = {
   /* VEX_0F */
@@ -7192,6 +7194,7 @@ static const struct dis386 vex_table[][2
     { "(bad)",		{ XX } },
 static const struct dis386 vex_len_table[][2] = {
   /* VEX_LEN_10_P_1 */
Comment 1 H.J. Lu 2009-10-13 16:26:10 UTC
The proposed solution isn't acceptable since vex_table is very dynamic.
Comment 2 Jerker Bäck 2009-10-13 16:51:41 UTC
Oh, it was not meant as a fix. Just as an information.
Comment 3 H.J. Lu 2009-10-14 14:56:53 UTC
(In reply to comment #2)
> Oh, it was not meant as a fix. Just as an information.

You can try enum.
Comment 4 Ineiev 2009-10-15 16:03:18 UTC
Subject: Re:  opcodes/i386-dis.c exceeds 256 levels of nested 

On 10/14/09, hjl dot tools at gmail dot com
<sourceware-bugzilla@sourceware.org> wrote:
> You can try enum.

Like via the attached sed script (I'm sorry, I should have sent it a
year ago); the script applies to current CVS default head revision.

Best regards,
Comment 5 Ineiev 2009-10-15 16:03:19 UTC
Created attachment 4285 [details]
Comment 6 H.J. Lu 2009-10-15 21:32:54 UTC
(In reply to comment #5)
> Created an attachment (id=4285)

Nice. Jerker, please give it a try.
Comment 7 cvs-commit@gcc.gnu.org 2009-10-15 22:50:54 UTC
Subject: Bug 10767

CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2009-10-15 22:50:09

Modified files:
	opcodes        : ChangeLog i386-dis.c 

Log message:
	2009-10-15  H.J. Lu  <hongjiu.lu@intel.com>
	Ineiev <ineiev@gmail.com>
	PR binutils/10767
	* i386-dis.c: Use enum instead of nested macros.


Comment 8 Jerker Bäck 2009-10-15 23:32:58 UTC
Problem solved, the code now compiles
Comment 9 H.J. Lu 2009-10-16 17:57:40 UTC