Rangi42
edc9e07a2d
Move all common error checks together inside mergeSections
2025-01-17 02:18:40 -05:00
Rangi
382ad17969
Don't output sections in reverse order ( #1613 )
2025-01-17 01:28:17 -05:00
Rangi42
fac5e35d24
Prefer empty braces to semicolons for empty loop bodies
2025-01-17 00:20:33 -05:00
Rangi42
f23a14afc7
Remove unnecessary semicolons after closing braces
2025-01-17 00:01:06 -05:00
Rangi42
d9773424e4
RGBDS_OBJECT_VERSION_STRING is a literal
2025-01-04 03:53:59 -05:00
Rangi42
4e2464a69d
Replace some #define with constexpr
2025-01-04 03:53:59 -05:00
Rangi42
151f83db6d
Using C++20 [[unlikely]] here would be excessive micro-optimization
2024-12-23 14:14:10 -05:00
Sylvie
c1c5b10082
Deprecate LDH with $00-$FF ( #1575 )
2024-12-10 21:27:37 -05:00
Sylvie
b877c81c32
Use C++-style casts ( #1576 )
2024-12-09 21:56:54 -05:00
Rangi42
0d3980d039
Refactor how map file sections are printed
...
This makes size-0 sections print as "($0000 bytes)" instead of
"(0 bytes)", which is more consistent.
2024-10-23 17:10:39 +02:00
Rangi42
ab6244d81c
Escape characters in section names in map files
2024-10-23 17:10:39 +02:00
Sylvie
bc5a71ff88
Update some RGBLINK error messages ( #1544 )
2024-10-16 01:42:49 +02:00
Sylvie
4cd0dd5314
Use setmode instead of fdopen ( #1520 )
2024-09-29 14:06:59 -04:00
Sylvie
22767e36e2
Refer to "end of line", not "newline" ( #1517 )
2024-09-23 02:15:02 +02:00
Rangi42
6bc2446966
Rephrase error messages for consistency
2024-09-10 21:38:50 +02:00
Sylvie
1dcc000572
Report locations for RGBLINK errors with conflicting objects ( #1494 )
...
This requires updating the object file format to record the
fstack context for sections themselves, not just for patches.
2024-09-10 19:23:48 +02:00
Rangi42
11f0e88b30
Factor out common sanity checks for section union and fragment
2024-09-06 21:55:28 -04:00
Rangi42
d917df406d
Use camelCase instead of lowercase for static functions
2024-09-06 21:48:57 -04:00
Sylvie
323028d9f2
RGBLINK lists local symbols when encountering an unknown symbol reference ( #1496 )
2024-09-06 21:31:13 -04:00
Rangi42
26fcff831d
Run clang-format
2024-08-27 01:49:05 -04:00
Rangi42
b77ba1d87d
Forward declare struct Section to avoid a nested header include
2024-08-26 22:58:38 -04:00
ISSOtm
8286d9c462
Check that there is enough room to write a patch when linking
...
Prevents segfaulting if a patch's offset is too large
2024-08-26 22:58:38 -04:00
ISSOtm
77129b9e80
Fix a false positive reported by scan-build
...
Arguably this also makes the logic a little clearer, so might as well
2024-08-23 01:34:36 +02:00
Sylvie
57c3d74b9e
Use a custom generic tagged union Either instead of std::variant for efficiency ( #1476 )
...
* Implement custom generic tagged union `Either`
This should be more efficient than `std::variant`, while still
keeping runtime safety as it `assert`s when `get`ting values.
* Use `Either` for RPN expressions
* Use `Either` for file stack node data
* Use `Either` for `File` buffer
* Use `Either` for `STRFMT` args
* Use `Either` for RGBLINK symbol values
* Support an equivalent of `std::monostate` for `Either`
* Use `Either` for lexer tokens
* Use `Either` for symbol values
* Use `Either` for lexer mmap/buffer state
2024-08-20 21:19:11 +02:00
ISSOtm
86140b5b2f
Correctly apply section fragment offsets to contained symbols
2024-08-18 19:44:04 +02:00
ISSOtm
369296693c
Avoid softlock if linker script contains a comment but no newline
2024-08-18 19:44:04 +02:00
ISSOtm
47b2e0e912
Trap bad __at() values too
...
Those set the section type earlier than the linker script,
so a check needs to be performed there too
2024-08-18 19:44:04 +02:00
ISSOtm
28733fe312
Implement floating bank in linker script
...
Turns out that we can solve being unable to choose a bank to change
the PC of, by simply refusing to choose!
2024-08-18 19:44:04 +02:00
ISSOtm
e45a422da3
Clarify error message when a section lacks a type
...
The previous commit has made this precision possible
2024-08-18 19:44:04 +02:00
ISSOtm
9fd4ba90cc
Trap invalid section types in RGBDS objs
2024-08-18 19:44:04 +02:00
ISSOtm
e548ecc6fa
Report attempts to assign a SDCC area in a way inconsistent with its data
...
This actually avoids breaking the (segfaulting) invariant that
a section whose type "has data" has as many bytes of `->data` as
its `->size`.
2024-08-18 19:44:04 +02:00
ISSOtm
00b0914436
Reserve space to avoid file sym array realloc
...
This line was missing; in its absence, as soon as the array reallocs,
all registered symbol pointers are invalidated, leading to a crash
(e.g. when generating a sym file).
Made the reallocation check into a hard error, too.
Since fileSymbols gets registered with each section, we would have to
change that, and then it cascades throughout all of RGBLINK.
This will be handled correctly in the Rust port.
2024-08-18 19:44:04 +02:00
Ruben Zwietering
60c03ec1e3
Clear the old line buffer when filling the next one in nextLine
2024-08-18 19:44:04 +02:00
Ruben Zwietering
379aa8c267
Use line.reserve in sdobj_ReadFile instead of constructor
...
Passing a count parameter to the vector constructor does not reserve
count elements but instead fills the vector with count elements.
This caused the endianness check to fail first because the first 256
characters were null bytes.
2024-08-18 19:44:04 +02:00
Sylvie
b987e5669f
Comment the parsers better ( #1463 )
2024-08-09 21:36:52 -04:00
Sylvie
e93190d491
Implement BITWIDTH and TZCOUNT functions ( #1450 )
2024-08-07 10:39:30 -04:00
Sylvie
fc8707886c
Output exported numeric constants to sym file ( #1439 )
2024-08-06 10:58:35 -04:00
Sylvie
2706f94788
Multiple fixes and enhancements to RPN behavior: ( #1448 )
...
- FIX: `Label & const` was not actually doing the `& const` masking
(fixes #1446 )
- ADD: `LOW(Label)` can be constant if `Label` is aligned to 8 or more bits
(resolves #1444 )
- ADD: `!expr` can be constant 0 if `expr` has any non-zero bits
(resolves #1447 )
- `LOW()` and `HIGH()` have their own RPN operator values
(resolves #1445 )
The change to RPN values means that the object file version was incremented.
This also refactors unary operators and functions, combining their
evaluation similarly to binary ones.
2024-08-06 13:54:55 +02:00
Sylvie
f304e1dd7f
Implement state file output for RGBASM ( #1435 )
2024-08-05 12:41:40 -04:00
Sylvie
d4231f9efa
Remove redundant "unknown option" error messages ( #1441 )
...
`getopt` already prints "unrecognized option"
2024-08-05 16:04:53 +02:00
Sylvie
6a65cbc9ed
Some refactoring and reformatting ( #1431 )
2024-07-26 11:51:27 -04:00
Sylvie
352551d4f8
Allow padding to coexist with overlay file ( #1395 )
2024-05-17 11:14:44 +02:00
Sylvie
3e9d2cab12
Make some error messages more consistent ( #1393 )
...
* Update some error messages
* Make non-A destination operand syntactically invalid
2024-04-20 23:13:01 +02:00
Sylvie
a234da42a6
Replace assert with assume for release build optimization ( #1390 )
2024-04-02 11:09:31 -04:00
Rangi42
cf7bdb19b6
Run clang-format 14 on everything
...
Later versions may need some proprties added or changed to not
format closing braces weirdly.
2024-03-28 09:17:27 -04:00
ISSOtm
20b7b591d4
Run clang-format
...
Fix some small style inconsistencies
2024-03-28 01:41:25 +01:00
ISSOtm
e5078aba3b
Clean up #includes
...
Remove unused headers, and avoid relying on transitive inclusions
`include-what-you-use` has been very useful for this!
2024-03-28 01:25:38 +01:00
ISSOtm
cae7b5dcf6
Use standard attribute syntax instead of IBM __attribute__
...
Move format attrs to proper standard location
For some reason, GCC 13 is more lax than earlier versions...
2024-03-27 20:01:12 -04:00
Rangi42
506911d7d0
Refactor to avoid redundant obj_CheckAssertions function
2024-03-27 16:19:01 -04:00
Sylvie
a68bebf4a2
Use a Defer struct to close files and restore lexer state with RAII ( #1379 )
2024-03-27 10:42:53 -04:00