diff --git a/src/asm/section.cpp b/src/asm/section.cpp index ba518ccfb..0af2c4356 100644 --- a/src/asm/section.cpp +++ b/src/asm/section.cpp @@ -83,7 +83,7 @@ void sect_CheckSizes() { if (uint32_t maxSize = sectionTypeInfo[sect.type].size; sect.size > maxSize) { error( "Section '%s' grew too big (max size = 0x%" PRIX32 " bytes, reached 0x%" PRIX32 - ").\n", + ")\n", sect.name.c_str(), maxSize, sect.size @@ -239,7 +239,7 @@ static void mergeSections( } if (sect.modifier != mod) { - sectError("Section already declared as %s section\n", sectionModNames[sect.modifier]); + sectError("Section already declared as SECTION %s\n", sectionModNames[sect.modifier]); } else { switch (mod) { case SECTION_UNION: @@ -850,8 +850,8 @@ void sect_PCRelByte(Expression &expr, uint32_t pcShift) { if (offset < -128 || offset > 127) { error( - "jr target must be between -128 and 127 bytes away, not %" PRId16 - "; use jp instead\n", + "JR target must be between -128 and 127 bytes away, not %" PRId16 + "; use JP instead\n", offset ); writeByte(0); diff --git a/src/link/patch.cpp b/src/link/patch.cpp index c474e4518..d47bbd105 100644 --- a/src/link/patch.cpp +++ b/src/link/patch.cpp @@ -516,8 +516,8 @@ static void applyFilePatches(Section §ion, Section &dataSection) { error( patch.src, patch.lineNo, - "jr target must be between -128 and 127 bytes away, not %" PRId16 - "; use jp instead\n", + "JR target must be between -128 and 127 bytes away, not %" PRId16 + "; use JP instead", jumpOffset ); } diff --git a/src/link/section.cpp b/src/link/section.cpp index 189726a6f..3e7d3eea9 100644 --- a/src/link/section.cpp +++ b/src/link/section.cpp @@ -133,12 +133,12 @@ static void mergeSections(Section &target, std::unique_ptr
&&other) { if (target.modifier != other->modifier) { fprintf( stderr, - "error: Section \"%s\" is defined as %s at ", + "error: Section \"%s\" is defined as SECTION %s at ", target.name.c_str(), sectionModNames[target.modifier] ); target.src->dump(target.lineNo); - fprintf(stderr, ", but as %s at ", sectionModNames[other->modifier]); + fprintf(stderr, ", but as SECTION %s at ", sectionModNames[other->modifier]); other->src->dump(other->lineNo); putc('\n', stderr); exit(1); diff --git a/src/linkdefs.cpp b/src/linkdefs.cpp index 6e00b01b1..7d8378966 100644 --- a/src/linkdefs.cpp +++ b/src/linkdefs.cpp @@ -68,7 +68,7 @@ SectionTypeInfo sectionTypeInfo[SECTTYPE_INVALID] = { // clang-format on char const * const sectionModNames[] = { - "regular", // SECTION_NORMAL - "union", // SECTION_UNION - "fragment", // SECTION_FRAGMENT + "(no modifier)", // SECTION_NORMAL + "UNION", // SECTION_UNION + "FRAGMENT", // SECTION_FRAGMENT }; diff --git a/test/asm/invalid-jr.err b/test/asm/invalid-jr.err index 7a98f9bc5..0b2cd9ede 100644 --- a/test/asm/invalid-jr.err +++ b/test/asm/invalid-jr.err @@ -1,3 +1,3 @@ error: invalid-jr.asm(3): - jr target must be between -128 and 127 bytes away, not -258; use jp instead + JR target must be between -128 and 127 bytes away, not -258; use JP instead error: Assembly aborted (1 error)! diff --git a/test/asm/load-overflow.err b/test/asm/load-overflow.err index 53ab05827..b7fcecd5c 100644 --- a/test/asm/load-overflow.err +++ b/test/asm/load-overflow.err @@ -3,13 +3,13 @@ warning: load-overflow.asm(5): [-Wempty-data-directive] warning: load-overflow.asm(6): [-Wempty-data-directive] DB directive without data in ROM error: load-overflow.asm(26): - Section 'Overflow' grew too big (max size = 0x8000 bytes, reached 0x8002). + Section 'Overflow' grew too big (max size = 0x8000 bytes, reached 0x8002) error: load-overflow.asm(26): - Section 'oops' grew too big (max size = 0x2000 bytes, reached 0x2002). + Section 'oops' grew too big (max size = 0x2000 bytes, reached 0x2002) error: load-overflow.asm(26): - Section 'Moar overflow' grew too big (max size = 0x8000 bytes, reached 0xD000). + Section 'Moar overflow' grew too big (max size = 0x8000 bytes, reached 0xD000) error: load-overflow.asm(26): - Section 'hmm' grew too big (max size = 0x2000 bytes, reached 0x4000). + Section 'hmm' grew too big (max size = 0x2000 bytes, reached 0x4000) error: load-overflow.asm(26): - Section 'lol' grew too big (max size = 0x2000 bytes, reached 0x3000). + Section 'lol' grew too big (max size = 0x2000 bytes, reached 0x3000) error: Assembly aborted (5 errors)! diff --git a/test/asm/section-union.err b/test/asm/section-union.err index 86e0c0abe..9cc344c28 100644 --- a/test/asm/section-union.err +++ b/test/asm/section-union.err @@ -1,4 +1,4 @@ error: section-union.asm(37): - Section already declared as union section + Section already declared as SECTION UNION FATAL: section-union.asm(37): Cannot create section "test" (1 error) diff --git a/test/link/invalid-patches.asm b/test/link/invalid-patches.asm new file mode 100644 index 000000000..471a0c384 --- /dev/null +++ b/test/link/invalid-patches.asm @@ -0,0 +1,10 @@ +section "zero", rom0 +Zero:: +db 1 % Zero +db 2 ** (Zero - 1) +db BANK(NonexistentSymbol) +db BANK("NonexistentSection") +db STARTOF("NonexistentSection") +db SIZEOF("NonexistentSection") +ldh [Zero], a +jr Zero + 200 diff --git a/test/link/invalid-patches.out b/test/link/invalid-patches.out new file mode 100644 index 000000000..619e2452d --- /dev/null +++ b/test/link/invalid-patches.out @@ -0,0 +1,9 @@ +error: invalid-patches.asm(10): JR target must be between -128 and 127 bytes away, not 190; use JP instead +warning: invalid-patches.asm(9): LDH is deprecated with values from $00 to $FF; use $FF00 to $FFFF +error: invalid-patches.asm(8): Requested SIZEOF() of section "NonexistentSection", which was not found +error: invalid-patches.asm(7): Requested STARTOF() of section "NonexistentSection", which was not found +error: invalid-patches.asm(6): Requested BANK() of section "NonexistentSection", which was not found +error: invalid-patches.asm(5): Requested BANK() of symbol "NonexistentSymbol", which was not found +error: invalid-patches.asm(4): Exponent by negative value -1 +error: invalid-patches.asm(3): Modulo by 0 +Linking failed with 7 errors diff --git a/test/link/section-conflict/different-mod/a.asm b/test/link/section-conflict/different-mod/a.asm new file mode 100644 index 000000000..f5153ec44 --- /dev/null +++ b/test/link/section-conflict/different-mod/a.asm @@ -0,0 +1,2 @@ +section fragment "test", rom0 +db 1 diff --git a/test/link/section-conflict/different-mod/b.asm b/test/link/section-conflict/different-mod/b.asm new file mode 100644 index 000000000..ba1bf3cb3 --- /dev/null +++ b/test/link/section-conflict/different-mod/b.asm @@ -0,0 +1,2 @@ +section union "test", rom0 +db 2 diff --git a/test/link/section-conflict/different-mod/out.err b/test/link/section-conflict/different-mod/out.err new file mode 100644 index 000000000..7f18667ff --- /dev/null +++ b/test/link/section-conflict/different-mod/out.err @@ -0,0 +1 @@ +error: Section "test" is defined as SECTION FRAGMENT at section-conflict/different-mod/a.asm(1), but as SECTION UNION at section-conflict/different-mod/b.asm(1) diff --git a/test/link/test.sh b/test/link/test.sh index db9bae047..44d443585 100755 --- a/test/link/test.sh +++ b/test/link/test.sh @@ -269,6 +269,15 @@ rgblinkQuiet "$otemp" "$test"/b.rel 2>"$outtemp" tryDiff "$test"/out.err "$outtemp" evaluateTest +test="section-conflict/different-mod" +startTest +"$RGBASM" -o "$otemp" "$test"/a.asm +"$RGBASM" -o "$gbtemp" "$test"/b.asm +continueTest +rgblinkQuiet "$otemp" "$gbtemp" 2>"$outtemp" +tryDiff "$test"/out.err "$outtemp" +evaluateTest + test="section-fragment/good" startTest "$RGBASM" -o "$otemp" "$test"/a.asm