- Changes most `/* comments */` to `// comments`
- Changes `/**` block comments consistently to `/*`
- Adds consistent license comments to all files
Also renames `T_POP_SET` to `T_Z80_SET`
* Add scramble flags to RGBLINK
-S and -W will scramble ROMX and WRAMX respectively.
* Modify scramble CLI
CLI now takes a list of comma-separated values.
Added arg_error to clean up messages.
Co-authored-by: Eldred Habert <eldredhabert0@gmail.com>
* Document scrambling functionality
Co-authored-by: Eldred Habert <eldredhabert0@gmail.com>
Fixes the test case from #800
The `out.gb` output was corrected, since the two "test"
fragments have a different order in ROM than in SRAM.
It is effectively:
; ROM0[$0000], fragments ordered by size
jr Label
dw Label
db 0
; SRAM[$a000], fragments ordered by .o order
ds 1 ; db 0
ds 2 ; jr Label
Label: ; $a003
ds 2 ; dw Label
Use C11 standard _Noreturn instead of attributes (except, of course, MSVC)
Remove unused helpers
Avoid trapping in release builds, in favor of just unreachability
Improve shim when __builtin_* are not available
This should help make RGBDS portable to systems with 16-bit integers,
like DOS.
For kicks, use the macros for 16-bit and 8-bit integers.
Fix other miscellaneous things, like #include ordering and other
printf-format related things.
Reduce repitition in math.c while I'm there.
"fixed" and "aligned" location checking advanced the target location to places
regardless of the associated free space, potentially breaking the assumption
that the location was always further in memory than the free space's base.
Rather than adding more code to try keeping that assumption true, harden
`isLocationSuitable` and handle that case as well.
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
They do not take any room, so they can only be used to define symbols at
a given location. I ran into trouble with such a SECTION failing to be
placed where specified, which doesn't make sense.
This way, it also makes sense to have such a SECTION in the middle of
another one, but that should be fine, since there's no actual overlap.
The linker script now allows you to assign a section with the same
attributes as in the source.
To do this, I've removed a check from AssignSectionAddressAndBankByName
that would never be triggered, due to that condition being checked
before. Shouldn't this and IsSectionSameTypeBankAndAttrs be condensed
into a single function?
With permission from the main authors [1], most of the code has been
relicensed under the MIT license.
SPDX license identifiers are used so that the license headers in source
code files aren't too large.
Add CONTRIBUTORS.rst file.
[1] https://github.com/rednex/rgbds/issues/128
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
NULL error messages have been given a description.
Messages that weren't descriptive enough now also print the name of the
function that has failed.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
ROMX and WRAMX bank numers are stored in an object file as their number
minus one. This means that this offset has to be applied somewhere.
The old code applied the fix for ROMX and WRAMX in two different places.
It looks like the patch that added support for WRAMX didn't set the
offset correctly in 'src/link/assign.c'. When this was fixed, it was
done in the wrong place, in 'src/asm/asm.y'. This patch moves the fix to
'src/link/assign.c'.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
The bank of a section can be requested with `BANK("Section Name")`, and
the bank of the current section with `BANK(@)`. In both cases, the bank
number is resolved by the linker.
New commands have been added to the list of RPN commands of object
files, and the rest has been moved so that new additions don't force a
new change in the number of the enumerations.
Increase object file version, as it is now incompatible with the old
format.
Update manpages to reflect the new ways of using `BANK()` and the new
format of the object files.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Not all occurrences have been replaced, in some cases they have been
left as they were before (like in rgbgfx and when they are in the
interface of a C standard library function).
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This is useful to generate error messages when there is a symbol that
appears in more than one object file.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
rgblink option -w has been restored to its previous behaviour: make WRAM
a continous section instead of spliting it into WRAM0 and WRAMX.
To enable DMG mode, option -d has to be used instead. This option
automatically enables -w.
Update tests.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Files can now be included with the following syntax:
INCLUDE "path.link"
The maximum include depth is 5.
Fixed linkerscript parser and lexer error messages so that they are more
informative (show file and line of the error).
Man page updated.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
Replace spaces by tabs for consistency. The rest of the codebase uses
tabs, so the linkerscript parser has to change.
Removed trailing tabs in all codebase.
Signed-off-by: AntonioND <antonio_nd@outlook.com>
Instead of converting from ROMX to ROM0 with -t and preventing the use
of WRAMX at all with -w, make each option prohibit the type of section
they affect.
This is a good idea because it can prevent a developer from making
mistakes when switching from using the options to not using them.
Generally, a change from using one single bank to multiple banks is
something that will take a lot of effort, and forgetting sections in
ROM0 or WRAM0 will only make the free space of those areas to be
reduced (and maybe prevent compilation), but it won't cause any problems
because of a forgotten bank swap in the code.
Signed-off-by: AntonioND <antonio_nd@outlook.com>