[M3devel] cm3: what are *.mc files
Rodney M. Bates
rodney_bates at lcwb.coop
Fri Jun 12 20:00:00 CEST 2015
On 06/12/2015 09:51 AM, Elmar Stellnberger wrote:
>
> Thanks a lot Rodney and Jay;
> that will certainly help my implementation.
>
> So far all *.mc files found on my machine have the
> following signature:
> 16_FD,00,01,{00}
>
> except a few text - .mc from PM3 which start
> alltogether with "begin_unit".
>
> Rodney, do you believe that I can rely on the 4th byte
> to be zero as generated by the Modula-3 middle end. -
> or would anyone be ready to uphold such a guarantee
> for the future?
>
The 4th byte is not really dependable for the future. It never has had
a real magic number. The FD,00,01 is a version number on the binary
format, so even it is likely to change.
The 4th byte zero is a binary opcode for begin_unit, equivalent
to the "begin_unit" in the PM3 text version.
I think the most reliable long-term way is just to look for file names *.mc and
*.ic. Be sure to look for both. *.mc is for a MODULE and *.ic is for an
INTERFACE. These can be regenerated from source and will not be needed once a
compile is complete, unless you are into vetting/debugging the compiler.
So deleting them is quite safe.
I suppose we could add a magic number. We already have a front/back end
compatibility change between the release and head compilers. I can do this,
if there is consensus we should. How would we choose the number?
> Anyone here who has applied "od" on an .mc generated
> by a very recent compiler? - do they start with
> 16_FD,10,01,?00?
>
> Most binary file types would guarantee a header of at
> least 4 Byte and it should be more straight forward and
> secure to check 32bit instead of 24bit if possible.
>
> Any suggestions?
>
>
> Am 10.06.15 um 02:21 schrieb Rodney M. Bates:
>>
>>
>> On 06/09/2015 03:02 PM, Elmar Stellnberger wrote:
>>> What are *.mc - files?
>>> They appear in TARGET - directories;
>>> most of them are just called _m3main.mc but some of them have other names.
>>>
>>> I ask because I am writing a program which should recognize and clear object files.
>>> It does not seem to be sufficient to check for uppercase directories which are located together with an src directory.
>>>
>>> Usually files of a specific type start with a 32bit magic;
>>> however the mc files all have different starting sequences.
>>>
>>> Is there still a straight forward way to recognize an .mc file just by its binary content?
>>>
>>
>> They will start with either 16_FD 16_00 16_01, produced by older versions of cm3,
>> or 16_FD 16_10 16_01, produced by a very recent head compiler.
>> Ignore the 4th byte.
>
>
> Am 09.06.15 um 22:14 schrieb Jay K:
>> ps:
>>
>> foo.m3 => foo.mc => cm3cg => foo.ms => as => foo.mo
>> foo.i3 => foo.ic => cm3cg => foo.is => as => foo.io
>>
>> again, see cm3 -keep, err better yet, cm3 -keep -verbose
>> You can see it running cm3cg and as and rm.
>>
>>
>> - Jay
>>
>
--
Rodney Bates
rodney.m.bates at acm.org
More information about the M3devel
mailing list