Commit Graph

347 Commits

Author SHA1 Message Date
ISSOtm
f710f21ad8 Reorder warnings alphabetically 2019-12-06 12:06:21 +01:00
ISSOtm
b1d4be66e4 Remove deprecated "section charmap" feature 2019-12-04 01:56:06 +01:00
ISSOtm
2d7d9eef9f Fix some make checkcodebase errors
- Reorder checkpatch ignore flags alphabetically
- Fix checkpatch WARNINGs and CHECKs when they make sense
- Add more checkpatch ignores
2019-12-04 00:16:28 +01:00
ISSOtm
d93ad2e650 Rename all functions imported from musl
This is to avoid conflicting with libraries, which occurred in the mingw builds
2019-11-23 23:08:44 +01:00
ISSOtm
191ee4ba1f Add support for toggleable warnings 2019-11-18 20:45:21 +01:00
ISSOtm
faa7893761 Fix develop error in getopt_long_only
The error was due to casting `const` away for permuting argv
elements, which is necessary for a libc for compatibility with older
systems, but not for us.

Checkpatch will complain about the style not being followed, but this is not
our code, so it can be ignored.
2019-11-09 00:48:00 +01:00
ISSOtm
7233f568a7 Report overlapping sections whenever possible 2019-11-06 08:40:13 +01:00
Eldred Habert
197f1e9b7b Merge pull request #444 from ISSOtm/fix_develop
Fix errors in `make develop`
2019-11-06 08:34:37 +01:00
ISSOtm
0649e6d65f Add long options 2019-11-06 00:48:41 +01:00
ISSOtm
072c965ba5 Add musl's implementation of getopt_long_only
Both `getopt_long` and `getopt_long_only` are GNU-specific, so we'll be
copying musl's implementation for portability.
This was retrieved as of commit 90251cf73dfdd44e7a3f085d236e89a7dff1b00b.

musl is licensed as MIT, which is compatible (being identical...) to RGBDS'.
The file is being copied as-is, without a copyright notice or attribution,
but this is only to have a verbatim copy in the history. Those will be added
in the next commit.
2019-11-06 00:40:55 +01:00
Eldred Habert
ff8e38fcc6 Merge pull request #441 from ISSOtm/linker_error_stack
Make linker output error stacks instead of their top level
2019-11-03 16:41:09 +01:00
ISSOtm
bf75971a3a Only open files when necessary 2019-11-02 22:37:10 +01:00
ISSOtm
5bd0076233 Write some doc comments 2019-11-02 22:37:10 +01:00
ISSOtm
0e24adcafd Rewrite RGBLINK entirely
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
2019-11-02 22:37:10 +01:00
ISSOtm
323738e7b8 Increase version number to 0.3.9 2019-11-01 17:38:43 +01:00
ISSOtm
f7c2665e14 Fix errors in make develop 2019-10-30 13:34:21 +01:00
ISSOtm
ae0b95ec6d Make linker output error stacks instead of their top level 2019-10-11 17:12:18 +02:00
ISSOtm
55fbecee49 Add info about string expansions in error reports
This is especially useful when an EQUS expands to another one, to help
track them.
This is done separately from the file stack as the EQUS stack is separate
(which is itself because EQUS are managed *way* differently).
2019-09-12 10:02:24 +02:00
ISSOtm
b44f5825a5 Make RGBDS behave identically whether writing a .o
Some errors are only tripped in `out_WriteObject`, which was
basically a stub when `-o` wasn't specified. Now, instead,
errors are checked in a separate function before out_WriteFile
2019-09-02 15:04:46 +02:00
ISSOtm
37089ef940 Improve error stack
The old error stack was fairly obtuse and hard to use for debugging.
This improves it notably by ensuring all line numbers are relative
to the file, and not, say, the macro definition.
This is a breaking change if you were parsing the old stack, but
the change should be painless, and the new stack only brings more info.
The syntax is unchanged for files, macros see their name prefixed
with the file they're defined in and a pair of colors, REPT blocks
simply append a '::REPT~n' to the context they're in, where 'n' is
the number of iterations the REPT has done.
This is especially helpful in macro-heavy code such as rgbds-structs.
2019-09-02 14:18:29 +02:00
Eldred Habert
4ef27a0d23 Merge pull request #411 from ISSOtm/recursion_limit
Add a recursion limit
2019-09-02 02:21:16 +02:00
Eldred Habert
89dc14fcaf Merge pull request #408 from ISSOtm/plumbing
Fix memory leaks with macro args
2019-09-01 22:16:27 +02:00
ISSOtm
e0e8170fe6 Add recursion limit for string expansions
Unlike macros, REPTs and INCLUDEs, this recursion depth is independent.
This is intentional, because string expansions work very differently.

While it's easy to know when a string expansion begins, checking where it
ends is much more complicated, since the expansion's contents are simply
injected back into the lex buffer. Therefore, the depth has to be checked
after lexing took place.
Because of this, the placement of the expansion end check is somewhat
haphazard, but I think it's good. While I have no certainty, all tests
ended with all expansions properly ended, and I couldn't find any pitfalls.

Finally, `pCurrentStringExpansion` has been made global so error printing
can use it to tell the user if an error occurred inside of an expansion.
2019-08-31 15:50:08 +02:00
dbrotz
d3db5f0d76 Add pushc and popc directives 2019-08-30 19:36:23 -07:00
ISSOtm
dfb3072381 Fix memory leaks with macro args
REPT blocks nested in macros (and possibly other cases) leaked
memory on every call. Unlike most other memory leaks, which would
be freed at the end of program execution if they were done properly,
those piled up the more compilation went on.
I believe memory usage could have started being fairly high on
large projects following the "one master file INCLUDEs all the rest"
so this may have actually been worth it.
2019-08-31 03:52:42 +02:00
ISSOtm
dc2c97fe0c Comment and improve ParseSymbol and AppendMacroArg 2019-08-31 02:31:46 +02:00
ISSOtm
6068b565f5 Add recursion limit for INCLUDE and macros
(And REPT.)
Not exactly a *recursion* limit, more like a *stack depth* limit,
but calling it "recursion" conveys its purpose better.
The default of 64 is super overkill: even in a a project with
what I believe to be above-average levels of nesting, the
level only peaked at 6.
Keeping in mind the purpose of this is to catch infinite
recursion, which is still caught quickly (in usual cases, anyways),
this default seems sensible.
And it passes tests. What more do you need?
2019-08-31 02:31:42 +02:00
dbrotz
e05199ca1e Add support for multiple charmaps
This adds two new directives: newcharmap and setcharmap.
newcharmap creates a new charmap and switches to it.
setcharmap switches to an existing charmap.
2019-08-29 21:54:06 -07:00
Eldred Habert
05becf3f4b Merge pull request #381 from NieDzejkob/rgbgfx-curve
rgbgfx: Add an option to take the CGB's color profile into account
2019-08-29 22:19:36 +02:00
ISSOtm
64752da42d Add "print types" to bracketed symbols
Should partially cover #178 and close #270.
This allows printing numbers in different bases and without the dollar prefix
This is especially useful in macros because the dollar isnt a valid character
for symbol names, requiring heavy `STRSUB` usage.
2019-08-29 14:04:58 +02:00
Jakub Kądziołka
91984cb7e7 rgbgfx: Add an option to take the CGB's color profile into account 2019-08-20 14:38:17 +02:00
Antonio Niño Díaz
b019b03946 Merge pull request #358 from dbrotz/fix-357
Fix buffer overflow when creating patches with long RPN expressions
2019-07-12 00:49:08 +01:00
Antonio Niño Díaz
defb221c98 Merge pull request #360 from jidoc01/master
Improve charmap structure with trie.
2019-07-07 11:46:08 +01:00
jidoc01
e7dc094e56 Improve charmap structure with trie
Charmap's previous structure was using brute-force comparison for
converting the strings in source files. It always compared given
strings to all of the strings in charmap, which was very costly
in huge projects.
For its improvement, I changed its structure into trie, which is
being used in many string-processing areas. It's now much faster
than before.
2019-07-06 19:25:44 +09:00
dbrotz
015d2b0830 Fix buffer overflow when creating patches with long RPN expressions
The createpatch() function was using a fixed-size buffer. I've changed it
to be dynamically allocated. I saw that the RPN format used in patches is
slightly different from the one used internally in the assembler, so I
added a new member to the Expression struct to track the patch size.

I've also limited the RPN expression length to 1MB. I realized that the
patch RPN expression could potentially be longer than the internal RPN
expression, so the internal expression would need a limit smaller than
UINT32_MAX. I thought 1MB would be a reasonable limit.
2019-07-04 16:49:09 -07:00
Jakub Kądziołka
8d5a53f529 Handle non-seekable input correctly 2019-07-03 15:38:14 +02:00
Antonio Niño Díaz
0bcd53778a Merge pull request #346 from qguv/tilemap-mirrored-duplicates
gfx: Add mirrored tile check when generating tilemap
2019-06-07 10:29:15 +01:00
Quint Guvernator
21aea281bd gfx: Add mirrored tile check when generating tilemap 2019-06-04 13:22:59 +02:00
dbrotz
249acace08 Prevent non-reloc symbol from shadowing reloc symbol 2019-05-09 12:48:10 -07:00
dbrotz
23f5e9dacc Use only one pass 2019-05-05 15:50:56 -07:00
Antonio Niño Díaz
6ff9435e0a Merge pull request #335 from dbrotz/fix-334
Dynamically allocate RPN expression buffer
2019-05-05 23:33:36 +01:00
dbrotz
40006c6152 Make yylex() return int 2019-05-02 19:53:45 -07:00
dbrotz
b256e4c2e3 Dynamically allocate RPN expression buffer 2019-05-02 19:31:26 -07:00
Jakub Kądziołka
7af2d5dfe1 Print location information in linker errors where viable 2019-03-03 22:55:17 +01:00
jmle
c59cb6a828 Increase version number to 0.3.8 2019-02-20 00:10:02 +01:00
mid-kid
c63af05427 Allow linker script to consider section attributes
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?
2019-01-18 12:37:23 +01:00
Antonio Niño Díaz
4b40d63dfd Merge pull request #311 from dbrotz/fix-222
Fix #222 and #255
2018-12-10 23:17:39 +00:00
dbrotz
a05fd9b818 Print full file path in error messages 2018-12-06 22:59:24 -08:00
dbrotz
3806eb3139 Fix ambiguity in const parsing 2018-12-02 13:49:12 -08:00
Antonio Niño Díaz
748943f6fc Increase version number to 0.3.7
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
2018-05-02 20:04:00 +01:00