mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
The goal was to improve readability, but along the way a few things were gained. - Sorted sym and map files - Infrastructure for supporting multiple .o versions - Valgrind-proof, as far as my testing goes anyways - Improved verbosity messages - Added error checking - Performance improvements, see end of commit message The readability improvement was spurred while trying to make sense of the old code while trying to implement features such as sorted sym and map files. I also did my best to remove hardcoded logic, such that modifications should be doable; for example, "RAM loading" sections, which are linked against a different location than the one they're stored at. Some work remains to be done, see the "TODO:" and "FIXME:" comments. Further, while regression tests pass, this new linker should be tested on different codebases (ideally while instrumented with `make develop` and under valgrind). The few errors spotted in the man pages (alignment) need to be corrected. Finally, documentation comments need to be written, I have written a lot of them but not all. This also provides a significant performance boost (benchmarked with a 51994-symbol project): Current master RGBLINK: 2.02user 0.03system 0:02.06elapsed 99%CPU (0avgtext+0avgdata 84336maxresident)k 0inputs+11584outputs (0major+20729minor)pagefaults 0swaps Rewritten RGBLINK: 0.19user 0.06system 0:00.63elapsed 40%CPU (0avgtext+0avgdata 32460maxresident)k 23784inputs+11576outputs (0major+7672minor)pagefaults 0swaps
89 lines
1.4 KiB
C
89 lines
1.4 KiB
C
/*
|
|
* This file is part of RGBDS.
|
|
*
|
|
* Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#ifndef RGBDS_LINKDEFS_H
|
|
#define RGBDS_LINKDEFS_H
|
|
|
|
enum RPNCommand {
|
|
RPN_ADD = 0x00,
|
|
RPN_SUB = 0x01,
|
|
RPN_MUL = 0x02,
|
|
RPN_DIV = 0x03,
|
|
RPN_MOD = 0x04,
|
|
RPN_UNSUB = 0x05,
|
|
|
|
RPN_OR = 0x10,
|
|
RPN_AND = 0x11,
|
|
RPN_XOR = 0x12,
|
|
RPN_UNNOT = 0x13,
|
|
|
|
RPN_LOGAND = 0x21,
|
|
RPN_LOGOR = 0x22,
|
|
RPN_LOGUNNOT = 0x23,
|
|
|
|
RPN_LOGEQ = 0x30,
|
|
RPN_LOGNE = 0x31,
|
|
RPN_LOGGT = 0x32,
|
|
RPN_LOGLT = 0x33,
|
|
RPN_LOGGE = 0x34,
|
|
RPN_LOGLE = 0x35,
|
|
|
|
RPN_SHL = 0x40,
|
|
RPN_SHR = 0x41,
|
|
|
|
RPN_BANK_SYM = 0x50,
|
|
RPN_BANK_SECT = 0x51,
|
|
RPN_BANK_SELF = 0x52,
|
|
|
|
RPN_HRAM = 0x60,
|
|
|
|
RPN_CONST = 0x80,
|
|
RPN_SYM = 0x81
|
|
};
|
|
|
|
enum SectionType {
|
|
SECTTYPE_WRAM0,
|
|
SECTTYPE_VRAM,
|
|
SECTTYPE_ROMX,
|
|
SECTTYPE_ROM0,
|
|
SECTTYPE_HRAM,
|
|
SECTTYPE_WRAMX,
|
|
SECTTYPE_SRAM,
|
|
SECTTYPE_OAM,
|
|
|
|
SECTTYPE_INVALID
|
|
};
|
|
|
|
enum SymbolType {
|
|
SYMTYPE_LOCAL,
|
|
SYMTYPE_IMPORT,
|
|
SYMTYPE_EXPORT
|
|
};
|
|
|
|
enum PatchType {
|
|
PATCHTYPE_BYTE,
|
|
PATCHTYPE_WORD,
|
|
PATCHTYPE_LONG,
|
|
PATCHTYPE_JR,
|
|
|
|
PATCHTYPE_INVALID
|
|
};
|
|
|
|
/**
|
|
* Tells whether a section has data in its object file definition,
|
|
* depending on type.
|
|
* @param type The section's type
|
|
* @return `true` if the section's definition includes data
|
|
*/
|
|
static inline bool sect_HasData(enum SectionType type)
|
|
{
|
|
return type == SECTTYPE_ROM0 || type == SECTTYPE_ROMX;
|
|
}
|
|
|
|
#endif /* RGBDS_LINKDEFS_H */
|