diff --git a/src/asm/section.c b/src/asm/section.c index 2ba7490e..d5a92b89 100644 --- a/src/asm/section.c +++ b/src/asm/section.c @@ -160,9 +160,9 @@ static unsigned int mergeSectUnion(struct Section *sect, enum SectionType type, /* Check if alignment offsets are compatible */ } else if ((alignOffset & 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", - sect->align, sect->alignOfs); + 1u << sect->align, sect->alignOfs); } else if (alignment > sect->align) { // If the section is not fixed, its alignment is the largest of both sect->align = alignment; @@ -213,9 +213,9 @@ static unsigned int mergeFragments(struct Section *sect, enum SectionType type, PRIx32 "\n", sect->org); /* Check if alignment offsets are compatible */ } 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", - sect->align, sect->alignOfs); + 1u << sect->align, sect->alignOfs); } else if (alignment > sect->align) { // If the section is not fixed, its alignment is the largest of both sect->align = alignment; diff --git a/test/asm/incompatible-alignment.asm b/test/asm/incompatible-alignment.asm new file mode 100644 index 00000000..c3b71bef --- /dev/null +++ b/test/asm/incompatible-alignment.asm @@ -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] diff --git a/test/asm/incompatible-alignment.err b/test/asm/incompatible-alignment.err new file mode 100644 index 00000000..c9e5f064 --- /dev/null +++ b/test/asm/incompatible-alignment.err @@ -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) diff --git a/test/asm/incompatible-alignment.out b/test/asm/incompatible-alignment.out new file mode 100644 index 00000000..e69de29b diff --git a/test/link/section-union/align-ofs-conflict.out b/test/link/section-union/align-ofs-conflict.out index 73eaf453..5aa6bd47 100644 --- a/test/link/section-union/align-ofs-conflict.out +++ b/test/link/section-union/align-ofs-conflict.out @@ -1,6 +1,6 @@ error: Section "conflicting alignment" is defined with conflicting 8-byte alignment (offset 7) and 16-byte alignment (offset 14) --- ERROR: (18): - Section already declared with incompatible 3-byte alignment (offset 7) + Section already declared with incompatible 8-byte alignment (offset 7) FATAL: (18): Cannot create section "conflicting alignment" (1 error) diff --git a/test/link/section-union/different-ofs.out b/test/link/section-union/different-ofs.out index ab9f0f79..494d315a 100644 --- a/test/link/section-union/different-ofs.out +++ b/test/link/section-union/different-ofs.out @@ -1,6 +1,6 @@ error: Section "conflicting alignment" is defined with conflicting 8-byte alignment (offset 7) and 8-byte alignment (offset 6) --- ERROR: (18): - Section already declared with incompatible 3-byte alignment (offset 7) + Section already declared with incompatible 8-byte alignment (offset 7) FATAL: (18): Cannot create section "conflicting alignment" (1 error)