Skip to content

Commit ad2be68

Browse files
committed
Make globals always have 2+ chars as suffix
As discussed on chat, there currently is the bug where certain suffixes are interpreted by the (m68k) assembler. Example: `move.l #global.w,-44(%fp)` `.w` is interpreted by the assembler as a size hint for `#global`.
1 parent 2e0595b commit ad2be68

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/context.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,10 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
606606
let mut name = String::with_capacity(prefix.len() + 6);
607607
name.push_str(prefix);
608608
name.push('.');
609-
name.push_str(&(idx as u64).to_base(ALPHANUMERIC_ONLY));
609+
// Offset the index by the base so that always at least two characters
610+
// are generated. This avoids cases where the suffix is interpreted as
611+
// size by the assembler (for m68k: .b, .w, .l).
612+
name.push_str(&(idx as u64 + ALPHANUMERIC_ONLY as u64).to_base(ALPHANUMERIC_ONLY));
610613
name
611614
}
612615
}

0 commit comments

Comments
 (0)