EEC-Developers / eec

Enhanced E Compiler - AmigaE programming
Other
12 stars 3 forks source link

Unsupported member object access using inline PPC load instruction crashes compiler #11

Open Hypexed opened 3 years ago

Hypexed commented 3 years ago

The ECX guide is vague and lacks more examples but some PPC ASM constructs are unsupported. The compiler will attempt to throw an error but will send a corrupt pointer to output and crash. Depending on the severity it can recover after the crash and will write corrupt code to binary.

Consider the following construct: LZW Rx, .member(object:Rx)

This will crash:

DEF object:PTR TO object, base:REG PTR TO object

LZW R13, .member(object)
LZW R13, .member(object:object)
LZW R13, .member(base:object)
LZW R13, member(base)

As you can see, technically it should accept base as base is a register, but it doesn't work and crashes. On top of this it's also rather complicated. In most cases, internally it will need to load the base in and the load a member off the base. But if the base is already a register all it needs to do is to load member offset from base. I also tested using OFFSETOF to calculate a member offset from base but it gives another error about that even after setting it in a CONST value.

The problem code is in ppcgen.e in the doAsm() proc at the section examining "." member case.