Fix section merge alignment error message (#919)

Co-authored-by: Eldred Habert <eldredhabert0@gmail.com>
This commit is contained in:
martendo
2021-08-17 18:03:46 -04:00
committed by GitHub
parent 94d07c78d8
commit 0f321bc797
6 changed files with 18 additions and 6 deletions

View File

@@ -160,9 +160,9 @@ static unsigned int mergeSectUnion(struct Section *sect, enum SectionType type,
/* Check if alignment offsets are compatible */ /* Check if alignment offsets are compatible */
} else if ((alignOffset & mask(sect->align)) } else if ((alignOffset & mask(sect->align))
!= (sect->alignOfs & mask(alignment))) { != (sect->alignOfs & mask(alignment))) {
fail("Section already declared with incompatible %" PRIu8 fail("Section already declared with incompatible %u"
"-byte alignment (offset %" PRIu16 ")\n", "-byte alignment (offset %" PRIu16 ")\n",
sect->align, sect->alignOfs); 1u << sect->align, sect->alignOfs);
} else if (alignment > sect->align) { } else if (alignment > sect->align) {
// If the section is not fixed, its alignment is the largest of both // If the section is not fixed, its alignment is the largest of both
sect->align = alignment; sect->align = alignment;
@@ -213,9 +213,9 @@ static unsigned int mergeFragments(struct Section *sect, enum SectionType type,
PRIx32 "\n", sect->org); PRIx32 "\n", sect->org);
/* Check if alignment offsets are compatible */ /* Check if alignment offsets are compatible */
} else if ((curOfs & mask(sect->align)) != (sect->alignOfs & mask(alignment))) { } else if ((curOfs & mask(sect->align)) != (sect->alignOfs & mask(alignment))) {
fail("Section already declared with incompatible %" PRIu8 fail("Section already declared with incompatible %u"
"-byte alignment (offset %" PRIu16 ")\n", "-byte alignment (offset %" PRIu16 ")\n",
sect->align, sect->alignOfs); 1u << sect->align, sect->alignOfs);
} else if (alignment > sect->align) { } else if (alignment > sect->align) {
// If the section is not fixed, its alignment is the largest of both // If the section is not fixed, its alignment is the largest of both
sect->align = alignment; sect->align = alignment;

View File

@@ -0,0 +1,8 @@
; These section fragments have alignments that make them non-contiguous,
; and thus are incompatible
SECTION FRAGMENT "Test", ROM0,ALIGN[8]
ds 1
SECTION FRAGMENT "Test", ROM0,ALIGN[8]

View File

@@ -0,0 +1,4 @@
ERROR: incompatible-alignment.asm(8):
Section already declared with incompatible 256-byte alignment (offset 0)
FATAL: incompatible-alignment.asm(8):
Cannot create section "Test" (1 error)

View File

View File

@@ -1,6 +1,6 @@
error: Section "conflicting alignment" is defined with conflicting 8-byte alignment (offset 7) and 16-byte alignment (offset 14) error: Section "conflicting alignment" is defined with conflicting 8-byte alignment (offset 7) and 16-byte alignment (offset 14)
--- ---
ERROR: <stdin>(18): ERROR: <stdin>(18):
Section already declared with incompatible 3-byte alignment (offset 7) Section already declared with incompatible 8-byte alignment (offset 7)
FATAL: <stdin>(18): FATAL: <stdin>(18):
Cannot create section "conflicting alignment" (1 error) Cannot create section "conflicting alignment" (1 error)

View File

@@ -1,6 +1,6 @@
error: Section "conflicting alignment" is defined with conflicting 8-byte alignment (offset 7) and 8-byte alignment (offset 6) error: Section "conflicting alignment" is defined with conflicting 8-byte alignment (offset 7) and 8-byte alignment (offset 6)
--- ---
ERROR: <stdin>(18): ERROR: <stdin>(18):
Section already declared with incompatible 3-byte alignment (offset 7) Section already declared with incompatible 8-byte alignment (offset 7)
FATAL: <stdin>(18): FATAL: <stdin>(18):
Cannot create section "conflicting alignment" (1 error) Cannot create section "conflicting alignment" (1 error)