RGBLINK(1)
β¨ NAME β¨
rgblink β Game Boy linker. This is the RGBLINK(1) page from the General Commands Manual, and it's literally the moment your object files get linked into one ROM, bestie. π
π οΈ SYNOPSIS π οΈ
Okay so here's the exact group-chat invite for the command:
rgblink [-dhMtVwx] [-v [-v ...]] [-B param] [--color when]
[-l linker_script] [-m map_file] [-n sym_file] [-O overlay_file]
[-o out_file] [-p pad_value] [-S spec] [-W warning] file ...
π DESCRIPTION π
The rgblink program links RGB object files β typically the ones made by rgbasm(1) β into a single Game Boy ROM file. The object file format is documented over in rgbds(5), iykyk. π¦
ROM0 sections get placed in the first 16 KiB of the output ROM, and ROMX sections get placed in any 16 KiB βbankβ except the first. If your ROM is only gonna be 32 KiB, you can use the -t option to change this. Slay.
Similarly, WRAM0 sections get placed in the first 4 KiB of WRAM (βbank 0β), and WRAMX sections get placed in any bank of the last 4 KiB. If your ROM doesn't use banked WRAM, you can use the -w option to change this. π
Also, if your ROM is designed for a monochrome Game Boy, you can make sure you don't use any incompatible section by using the -d option. That one implies -w, but it also prohibits the use of banked VRAM. No cap. π
π¬ ARGUMENTS
Okay bestie, so rgblink takes the usual short and long options β think -V and --version, the classic duo. Options later in the command line override ones set earlier, except when duplicate options are considered an error. And yes, you can abbreviate options as long as the abbreviation is unambiguous: --verb is --verbose, but --ver is invalid because it could also be --version. The way that little trap is set up? Iconic. π
Unless otherwise noted, passing - (a single dash) as a file name makes rgblink use standard input for input files, or standard output for output files. To suppress this behavior and open a file in the current directory actually called -, pass ./- instead. Using standard input or output for more than one file in a single command may produce unexpected results. So maybe don't do that unless you enjoy chaos. π
rgblink accepts decimal, hexadecimal, octal, and binary for numeric option arguments. Decimal numbers are written as usual; hexadecimal numbers must be prefixed with either $ or 0x; octal numbers must be prefixed with either & or 0o; and binary numbers must be prefixed with either % or 0b. (The prefixes $ and & will likely need escaping or quoting to avoid being interpreted by the shell.) Leading zeros (after the base prefix, if any) are accepted, and letters are not case-sensitive. For example, all of these are equivalent: 42, 042, 0x2A, 0X2A, 0x2a, &52, 0o52, 0O052, 0b00101010, 0B101010. Numeric literacy slay. π₯
β¨ The following options are accepted β¨
-B param,--backtrace paramβ configures how location backtraces are printed if warnings or errors occur. This flag may be specified multiple times with different parameters that combine meaningfully. Ifparamis a positive number, it specifies the maximum backtrace depth, abbreviating deeper ones. Other valid parameter values are:0β do not limit the maximum backtrace depth; this is the default.allβ force all locations to be printed, even "quiet" ones (see βExcluding locations from backtracesβ inrgbasm(5)for details).no-allβ do not print "quieted" locations in backtraces; this is the default.collapseβ print all locations on one line.no-collapseβ print one location per line; this is the default.
--color whenβ specify when to highlight warning and error messages with color:always,never, orauto.autodetermines whether to use colors based on theNO_COLOR: https://no-color.org/orFORCE_COLOR: https://force-color.org/environment variables, or whether the output is to a TTY. Rainbow diagnostics era π-d,--dmgβ enable DMG mode. Prohibit the use of sections that don't exist on a DMG, such as VRAM bank 1. This option automatically enables-w. Very βwe're keeping it original hardwareβ of it. π-h,--helpβ print help text for the program and exit. (Help text wraps to the value of theCOLUMNSenvironment variable if that is defined as nonzero; or else to the console window width if output is to a TTY.) Sir, this is a help menu π-l linker_script,--linkerscript linker_scriptβ specify a linker script file that tells the linker how sections must be placed in the ROM. The attributes assigned in the linker script must be consistent with any assigned in the code. Seergblink(5)for more information about the linker script format. Consistency is lowkey the whole vibe here.-M,--no-sym-in-mapβ if specified, the map file will not list symbols, only sections. Just sections, no symbol lore. π«Ά-m map_file,--map map_fileβ write a map file to the given filename, listing how sections and symbols were assigned. Your little map of who went where.-n sym_file,--sym sym_fileβ write a symbol file to the given filename, listing all visible labels and exported numeric constants. Labels output their bank and address, numeric constants output their value, following this specification:https://rgbds.gbdev.io/sym/. Several external programs can use this information, for example to help debugging ROMs. Debugging besties, rise. π¦-O overlay_file,--overlay overlay_fileβ if specified, sections will be overlaid "on top" of the ROM imageoverlay_file: empty space between sections will be filled by the corresponding bytes fromoverlay_file. This is useful to patch an existing ROM. Note that all sections must be fixed (forced bank and address)! No cap, this one has a requirement. π₯-o out_file,--output out_fileβ write the ROM image to the given file. The main character output file, honestly. π-p pad_value,--pad pad_valueβ when inserting padding between sections, pad with this value. The default is0. Padding but make it intentional.-S spec,--scramble specβ enables a different βscramblingβ algorithm for placing sections. See βScrambling algorithmβ below for an explanation and a description ofspec. We love a feature with lore. π-t,--tinyβ expand the ROM0 section size from 16 KiB to the full 32 KiB assigned to ROM. ROMX sections that are fixed to a bank other than 1 become errors, other ROMX sections are treated as ROM0. Useful for ROMs that fit in 32 KiB. Tiny ROM, big energy. β¨-V,--versionβ print the version of the program and exit. Hi, what's your version? π-v,--verboseβ be verbose. The verbosity level is increased by one each time the flag is specified, with each level including the previous:- Print the
rgblinkconfiguration before taking actions. - Print a notice before significant actions.
- Print some of the actions' intermediate results.
- Print some internal debug information.
- Print detailed internal information.
- Print the
The verbosity level does not go past 6.
Note that verbose output is only intended to be consumed by humans, and may change without notice between RGBDS releases; relying on those for scripts is not advised. So don't script against the yapping, bestie. π
-W warning,--warning warningβ set warning flagwarning. A warning message will be printed ifwarningis an unknown warning flag. See the βDIAGNOSTICSβ section for a list of warnings. Warning girlies stay informed. π-w,--wramxβ expand the WRAM0 section size from 4 KiB to the full 8 KiB assigned to WRAM. WRAMX sections that are fixed to a bank other than 1 become errors, other WRAMX sections are treated as WRAM0. More WRAM, same drama. π-x,--nopadβ disables padding the end of the final file. This option automatically enables-t. You can use this to make binary files that are not a ROM. When making a ROM, note that not using this is not a replacement forrgbfix(1)'s-poption! Important caveat, don't skip it. π@at_fileβ read more options and arguments from a file, as if its contents were given on the command line. Arguments are separated by whitespace or newlines. Lines starting with a hash sign (#) are considered comments and ignored.
No shell processing is performed, such as wildcard or variable expansion. There is no support for escaping or quoting whitespace to be included in arguments. The standard -- to stop option processing also disables at-file processing. Note that while -- can be used inside an at-file, it only disables option processing within that at-file, and processing continues in the parent scope. At-file inception, but make it precise. π§
π² Scrambling algorithm
The default section placement algorithm tries to place sections into as few banks as possible. (It turns out that section placement is an NP-complete problem known as "bin packing", so rgblink does not attempt to find the optimal solution, but instead uses a "first-fit" heuristic to find a good one in a reasonable amount of time.) There are no guarantees about where this algorithm will place sections, apart from the bank, address, and alignment constraints manually specified for the sections. So like, don't get attached to a layout. π
βScramblingβ instead places sections into a given pool of banks, trying to minimize the number of sections sharing a given bank. This is useful to catch broken bank assumptions, such as expecting two different sections to land in the same bank (that is not guaranteed unless both are manually assigned the same bank number). There are still no guarantees about where this algorithm will place sections, apart from the bank pool size and any manually specified section constraints. Chaos, but controlled chaos. π
A scrambling spec is a comma-separated list of region specs. A trailing comma is allowed, as well as whitespace between all specs and their components. Each region spec has the following form:
region[=size]
region specifies the section type, and size specifies the number of banks in the pool for that section type. region must be one of the following (case-insensitive), while size must be a positive decimal integer between 1 and the corresponding maximum. Certain regions allow omitting the size, in which case it defaults to its maximum value.
romxβ max size65535; size optional? No.sramβ max size256; size optional? No.wramxβ max size7; size optional? Yes.
A size of 0 disables scrambling for that region. Zero means βnot todayβ for that region. π
For example, romx=64,wramx,sram=4 will scramble ROMX sections among ROM banks 1 to 64, WRAMX sections among RAM banks 1 to 7, and SRAM sections among SRAM banks 0 to 3.
Later region specs override earlier ones; for example, romx=42, Romx=0 disables scrambling for romx. Case-insensitive but order-sensitive, iykyk. π
The arguments to multiple -S options are processed as if concatenated; for example, -S romx=16 -S wramx=8 -S sram=4 will work the same as -S romx=16,wramx=8,sram=4.
wramx scrambling is silently ignored if -w is passed (including if implied by -d), as WRAMX sections will be treated as WRAM0. Silently ignored. Not even a text back. π
π DIAGNOSTICS π
Okay so quick vibe check on warnings bestie: warnings are diagnostic messages that flag possibly erroneous behavior that doesn't necessarily ruin the linking process. Think of them as your compiler gently going "girlβ¦" π«Ά The following options change how those warnings get processed.
-Werrorβ turns all the warnings into errors, no cap. You can negate it as-Wno-errorif you want to stop everything from being turned into an error. π-Werror=β makes the specific warning or meta warning you name into an error, fr. You append the warning's name to it (example:-Werror=obsolete), and that warning gets implicitly enabled and turned into an error. Its negation is-Wno-error=, which prevents a specified warning from being turned into an error β even if-Werroris in effect. π
The following warnings are the "meta" warnings, meaning they enable a whole collection of other warnings. If some specific warning gets toggled by a meta flag and by a specific one, the more specific one takes priority. And when it's a tie, position on the command line is the tie breaker β the last one takes effect. π
-Wallβ enables warnings that are likely to indicate an error or undesired behavior, and that can easily be fixed. The responsible icon. β¨-Weverythingβ enables literally every warning. Not me turning the chaos dial to max. π
The following warnings are the actual warning flags; each description includes its corresponding warning flag. Note that each of these flags also has a negation (for example, -Wobsolete enables the warning that -Wno-obsolete disables; and -Wall enables every warning that -Wno-all disables). Only the non-default flag is listed here. And ignoring the no- prefix, the entries are listed alphabetically, because we're organized like that. π
-Wno-assertβ warn whenWARN-type assertions fail. (See "Aborting the assembly process" inrgbasm(5)forASSERT.) π«Ά-Wdivβ warn when dividing the smallest negative integer (-2**31) by-1, which yields itself due to integer overflow. Math said no. π This warning is enabled by-Wall.-Wno-large-constantβ warn when a constant too large to fit in a signed 32-bit integer is encountered. That number ate too much. π-Wno-obsoleteβ warn when obsolete features are encountered, which have been deprecated and may later be removed. The "this is so not the vibe anymore" warning. π-Wshiftβ warn when shifting right a negative value. Use a division by2**Ninstead. This warning is enabled by-Wall. πΈ-Wshift-amountβ warn when a shift's operand is negative or greater than 32. This warning is enabled by-Wall. π₯-Wtruncation=β warn when an implicit truncation (for example,dbto an 8-bit value) loses some bits. So like:-Wtruncation=0or-Wno-truncationdisables this warning entirely.-Wtruncation=1or just plain-Wtruncationwarns when an N-bit value is2**Nor greater, or less than-2**N. And-Wtruncation=2also warns when an N-bit value is less than-2**(N-1), which will not fit in two's complement encoding. She's thorough, okay? π
π EXAMPLES π
All you need for a basic ROM is an object file, and you can make it into a ROM image like so:
$ rgblink -o bar.gb foo.o
The resulting bar.gb will not have correct checksums (unless you put them in the assembly source, you sneaky thing π). You should use rgbfix(1) to fix these so that the program will actually run in a Game Boy:
$ rgbfix -v bar.gb
Here's a more complete example, because we love a glow-up:
$ rgblink -o bin/game.gb -n bin/game.sym -p 0xFF obj/title.o
obj/engine.o
π BUGS π
Please report bugs or mistakes in this documentation on GitHub: https://github.com/gbdev/rgbds/issues. Don't be shy, they're literally so nice about it. π«Ά
π SEE ALSO π
rgbasm(1), rgblink(5), rgbfix(1), rgbgfx(1), gbz80(7), rgbds(5), rgbds(7)
The whole friend group, together at last. π
β HISTORY β
rgblink was originally written by Carsten SΓΈrensen as part of the ASMotor package, and was later repackaged in RGBDS by Justin Lloyd. It is now maintained by a number of contributors at https://github.com/gbdev/rgbds. Main character energy from day one, honestly. π
That's a wrap bestie!! π This icon of a manual page is brought to you by Debian, dated September 22, 2026, and it answers to the name RGBLINK(1) β slay, periodt. π
β¨
π¦ where this page comes from
- arch rolling: rgbds 1.0.4-1 Β· MIT
- nixpkgs unstable: rgbds 1.0.4
- π the page's license: MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms