1RGBLINK(5)                  BSD File Formats Manual                 RGBLINK(5)
2

NAME

4     rgblink — linker script file format
5

DESCRIPTION

7     The linker script is an external file that allows the user to specify the
8     order of sections at link time and in a centralized manner.
9
10     A linker script consists on a series of banks followed by a list of sec‐
11     tions and, optionally, commands.  They can be lowercase or uppercase, it
12     is ignored.  Any line can contain a comment starting with ‘;’ that ends
13     at the end of the line:
14
15           ROMX $F ; This is a comment
16             "Functions to read array"
17             ALIGN 8
18             "Array aligned to 256 bytes"
19
20           WRAMX 2
21             "Some variables"
22
23     Numbers can be in decimal or hexadecimal format (the prefix is ‘$’).  It
24     is an error if any section name or command is found before setting a
25     bank.
26
27     Files can be included by using the INCLUDE keyword, followed by a string
28     with the path of the file that has to be included.
29
30     The possible bank types are: ROM0, ROMX, VRAM, SRAM, WRAM0, WRAMX, OAM
31     and HRAM.  Unless there is a single bank, which can occur with types
32     ROMX, VRAM, SRAM and WRAMX, it is needed to specify a bank number after
33     the type.
34
35     When a new bank statement is found, sections found after it will be
36     placed right from the beginning of that bank.  If the linker script
37     switches to a different bank and then comes back to a previous one, it
38     will continue from the last address that was used.
39
40     The only two commands are ORG and ALIGN:
41
42     •   ORG sets the address in which new sections will be placed.  It can
43         not be lower than the current address.
44
45     •   ALIGN will increase the address until it is aligned to the specified
46         boundary (it tries to set to 0 the number of bits specified after the
47         command: ‘ALIGN 8’ will align to $100).
48
49     Note: The bank, alignment, address and type of sections can be specified
50     both in the source code and in the linker script.  For a section to be
51     able to be placed with the linker script, the bank, address and alignment
52     must be left unassigned in the source code or be compatible with what is
53     specified in the linker script.  For example, ‘ALIGN[8]’ in the source
54     code is compatible with ‘ORG $F00’ in the linker script.
55

SEE ALSO

57     rgbasm(1), rgblink(1), rgbfix(1), rgbds(5), rgbds(7)
58

HISTORY

60     rgblink was originally written by Carsten Sørensen as part of the ASMotor
61     package, and was later packaged in RGBDS by Justin Lloyd.  It is now
62     maintained by a number of contributors at https://github.com/gbdev/rgbds
63
64BSD                             March 28, 2021                             BSD
Impressum