cmsc430/www

long label names bug

Opened this issue · 0 comments

According to the NASM docs: Maximum length of an identifier is 4095 characters.

What they mean is "only the first 4095 characters are used in an identifier," so you don't get an assembly-time error if you have a label name that exceeds this bound, it just truncates the label to the first 4095 characters.

This is problematic for our compiler starting with Iniquity since labels are derived from user-provided function names. If you define two very long function names that are only distinguished from each other after the character limit, then you'll get a "inconsistently redefined" error from NASM.

This may seem unlikely for function names and could potentially be considered a static error or something, but it's more problematic for string literals, which also derive label names.

The solution seems to be to change symbol->label and symbol->data-label to truncate the string before appending the unique eq hash code on the end.