bug with -native true and MLton_bug

Matthew Fluet fluet@CS.Cornell.EDU
Tue, 12 Dec 2000 10:15:22 -0500 (EST)


> Matthew, I think there is a problem with the way the native backend handles
> MLton_bug.  I had a buggy version of MLton that actually generated code that
> called MLton_bug, and the result produced was not correct.  Of course, there's
> no SML example I can send you, but if you could look into it, that would be
> great.


Really simple fix, I think.  In x86codegen.h, change the line

	char* MLton_bug_msg = "cps machine";				\

to

	char MLton_bug_msg[] = "cps machine";				\

In the first version, MLton_bug_msg is compiled as follows:

.globl MLton_bug_msg
.section	.rodata
.LC0:
	.string	"cps machine"
.data
	.align 4
	.type	 MLton_bug_msg,@object
	.size	 MLton_bug_msg,4
MLton_bug_msg:
	.long .LC0

Note that there is one level of indirection from MLton_bug_msg to the
actual string.

In the revised version, it's compiled like:

.globl MLton_bug_msg
.data
	.type	 MLton_bug_msg,@object
	.size	 MLton_bug_msg,12
MLton_bug_msg:
	.string	"cps machine"

without the level of indirection.

The translation of MLton_bug was relying on MLton_bug_msg being the label
of the string.


Note, if there is some reason why char* is better than char[], it's a
really easy fix to change the the translation to use the level of
indirection.