Implemented dynamic section alignment

This commit is contained in:
2025-03-09 00:23:23 +01:00
parent b67f3b0977
commit 947a8db937
9 changed files with 35 additions and 23 deletions

View File

@ -19,15 +19,14 @@ func (c *compiler) move(x asm.Instruction) {
start := Address(len(c.code))
c.code = x86.LoadAddress(c.code, operands.Register, 0x00_00_00_00)
end := Address(len(c.code))
size := uint32(4)
position := end - size
position := end - 4
opSize := position - start
if strings.HasPrefix(operands.Label, "data ") {
c.dataPointers = append(c.dataPointers, &pointer{
Position: position,
OpSize: uint8(opSize),
Size: uint8(size),
Size: uint8(4),
Resolve: func() Address {
destination, exists := c.dataLabels[operands.Label]
@ -44,7 +43,7 @@ func (c *compiler) move(x asm.Instruction) {
c.codePointers = append(c.codePointers, &pointer{
Position: position,
OpSize: uint8(opSize),
Size: uint8(size),
Size: uint8(4),
Resolve: func() Address {
destination, exists := c.codeLabels[operands.Label]