Skip to content

Commit

Permalink
Add more RGBLINK tests (gbdev#1639)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 authored Jan 29, 2025
1 parent f61019d commit e20347e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/link/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static void readPatch(
tryReadLong(
nodeID,
file,
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s node ID: %s",
"%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s node ID: %s",
fileName,
sectName.c_str(),
i
Expand All @@ -248,31 +248,31 @@ static void readPatch(
tryReadLong(
patch.lineNo,
file,
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s line number: %s",
"%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s line number: %s",
fileName,
sectName.c_str(),
i
);
tryReadLong(
patch.offset,
file,
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s offset: %s",
"%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s offset: %s",
fileName,
sectName.c_str(),
i
);
tryReadLong(
patch.pcSectionID,
file,
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s PC offset: %s",
"%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s PC offset: %s",
fileName,
sectName.c_str(),
i
);
tryReadLong(
patch.pcOffset,
file,
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s PC offset: %s",
"%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s PC offset: %s",
fileName,
sectName.c_str(),
i
Expand All @@ -281,7 +281,7 @@ static void readPatch(
PatchType,
type,
file,
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s type: %s",
"%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s type: %s",
fileName,
sectName.c_str(),
i
Expand All @@ -290,7 +290,7 @@ static void readPatch(
tryReadLong(
rpnSize,
file,
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s RPN size: %s",
"%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s RPN size: %s",
fileName,
sectName.c_str(),
i
Expand Down
13 changes: 9 additions & 4 deletions src/link/section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static void doSanityChecks(Section &section) {
error(
nullptr,
0,
"%s: ROMX sections must be in bank 1 (if any) with option -t",
"Section \"%s\" has type ROMX, which must be in bank 1 (if any) with option `-t`",
section.name.c_str()
);
} else {
Expand All @@ -270,15 +270,20 @@ static void doSanityChecks(Section &section) {
error(
nullptr,
0,
"%s: WRAMX sections must be in bank 1 with options -w or -d",
"Section \"%s\" has type WRAMX, which must be in bank 1 with options `-w` or `-d`",
section.name.c_str()
);
} else {
section.type = SECTTYPE_WRAM0;
}
}
if (isDmgMode && section.type == SECTTYPE_VRAM && section.bank == 1) {
error(nullptr, 0, "%s: VRAM bank 1 can't be used with option -d", section.name.c_str());
error(
nullptr,
0,
"Section \"%s\" has type VRAM, which must be in bank 0 with option `-d`",
section.name.c_str()
);
}

// Check if alignment is reasonable, this is important to avoid UB
Expand All @@ -292,7 +297,7 @@ static void doSanityChecks(Section &section) {
error(
nullptr,
0,
"%s: %s sections cannot be aligned to $%04x bytes",
"Section \"%s\" has type %s, which cannot be aligned to $%04x bytes",
section.name.c_str(),
sectionTypeInfo[section.type].name.c_str(),
section.alignMask + 1
Expand Down
2 changes: 1 addition & 1 deletion test/link/invalid-bank-t.out
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
error: test: ROMX sections must be in bank 1 (if any) with option -t
error: Section "test" has type ROMX, which must be in bank 1 (if any) with option `-t`
Linking failed with 1 error
3 changes: 3 additions & 0 deletions test/link/invalid-ram-types-d.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
error: Section "test1" has type WRAMX, which must be in bank 1 with options `-w` or `-d`
error: Section "test2" has type VRAM, which must be in bank 0 with option `-d`
Linking failed with 2 errors
5 changes: 5 additions & 0 deletions test/link/invalid-ram-types.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SECTION "test1", WRAMX, BANK[2]
db

SECTION "test2", VRAM, BANK[1]
db
2 changes: 1 addition & 1 deletion test/link/vram-fixed-dmg-mode-d.out
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
error: v1: VRAM bank 1 can't be used with option -d
error: Section "v1" has type VRAM, which must be in bank 0 with option `-d`
Linking failed with 1 error

0 comments on commit e20347e

Please sign in to comment.