Script.c: fix bogus varsz detection if alignment is off
commitf516ed2e1debc2c6fe4d90a2a338e34a414a154f
authorrofl0r <rofl0r@users.noreply.github.com>
Sun, 14 Jul 2019 14:04:24 +0000 (14 15:04 +0100)
committerrofl0r <rofl0r@users.noreply.github.com>
Sun, 14 Jul 2019 14:04:24 +0000 (14 15:04 +0100)
tree02c713924e1edfd386080b38f74bcf825337fc90
parent9cc5a29811173f26ceaf34ac5555c01f24590604
Script.c: fix bogus varsz detection if alignment is off

when putting an unref'd char variable into a script such as here:

int x;
string y;
char b;
string z;
char c[64];

the char b was assumed to be an int, so all further var lookups
became misaligned. the datadata fixup for string z was read partially
and interpreted as an int (with a value of fixup addend << 8).
that means not even the .data + X fixup was emitted, which would then
break reassembling.

this commit does the following things:
1) if current pos is a datadata fixup, we can safely say it's a
   "pointer", so size must be 4
2) all undetected variable size *must* default to 1 rather than 4.
   this is much more spammy, but the only safe way. otherwise
   we might read over real variables' boundaries.
3) the string detection has been moved out of the size detection
   function, which better separates responsibilities of the 2
   funcs.
Script.c