Commit Graph

567 Commits

Author SHA1 Message Date
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
jidoc01 c8630eee95 Document the feature of input from stdin
Since #329, rgbasm can get input from stdin. I updated the manpage
file related to it, which explain the description and usages in
rgbasm.
2019-07-08 23:28:46 +09:00
Antonio Niño Díaz 4040555532 Merge pull request #365 from dbrotz/terminate-bracketed-symbol
Terminate standalone bracketed symbol strings
2019-07-07 11:46:43 +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
Antonio Niño Díaz dfdb107105 Merge pull request #370 from jidoc01/fix_bug
Fix comment bug
2019-07-06 11:10:17 +01:00
jidoc01 38110a833d Fix comment bug
There is a bug in processing the comments in source files. It's
related to #326. And this bug comes out when you comment something
with the character ';', and include the quotation mark without its
pair in it.

The lastest version of rgbds compiler has a step to parse the given
source to convert its line endings to a unified one, and it
processes quotation marks even before it processes the comments.

I edited a little bit of the source, and it works fine now.
2019-07-05 13:48:24 +09:00
dbrotz 484d15dbb2 Handle unprintable characters more gracefully
* Skip UTF-8 byte order mark at beginning of file
* Error on other unexpected unprintable characters
2019-07-04 17:14:55 -07:00
dbrotz 1decf5d0d4 Fix out of bounds array access in lexer
If the type char is signed, then in the function
yylex_GetFloatMaskAndFloatLen(), *s can have a negative value and be converted
to a negative int32_t which is then used as an array index. It should be
converted to uint8_t instead to ensure that the value is in the bounds of the
tFloatingFirstChar, tFloatingSecondChar, and tFloatingChars arrays.
2019-07-04 17:01:29 -07:00
dbrotz 74e9de1b71 Check for RPN stack overflow in linker 2019-07-04 16:49:23 -07: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
dbrotz b3120aea25 Terminate standalone bracketed symbol strings
Standalone bracketed symbols like the following weren't being zero-terminated.

X EQUS {Y}

This doesn't apply to bracketed symbols that aren't standalone, but are
instead found in a string. For example, the following works even without this
fix.

X EQUS "{Y}"
2019-07-04 16:01:57 -07:00
Jakub Kądziołka df15c97b6e Handle zero-byte files gracefully 2019-07-03 16:38:35 +02:00
Jakub Kądziołka 0d97b58265 Avoid potentially implementation-defined behavior when using a pipe as input 2019-07-03 16:38:00 +02:00
Jakub Kądziołka 8d5a53f529 Handle non-seekable input correctly 2019-07-03 15:38:14 +02:00
Jakub Kądziołka 20f9492899 Allow using - to indicate input from stdin 2019-07-03 15:38:14 +02:00
Antonio Niño Díaz d00ec024a2 Merge pull request #351 from dbrotz/fix-strsub-strlen
Use code points instead of bytes for STRSUB/STRLEN
2019-06-07 10:31:11 +01: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 975f85260d Use code points instead of bytes for STRSUB/STRLEN 2019-06-02 16:10:34 -07:00
dbrotz f29d768989 Set all of expr struct's fields in mergetwoexpressions() 2019-05-31 08:59:50 -07:00
Antonio Niño Díaz cc458a9693 Fix a few checkpatch issues 2019-05-31 12:34:14 +01:00
Antonio Niño Díaz d2bd9a2368 Merge pull request #337 from dbrotz/one-pass
Use only one pass
2019-05-31 12:10:46 +01:00
dbrotz b909a5063a Include symbol name in 'symbol too long' error message 2019-05-29 10:56:59 -07:00
Marcus Huderle b2c1f6122e Properly set all 16 characters in ROM header title 2019-05-18 19:43:54 -05:00
dbrotz e12e7b2acc Don't assign PC to macro symbols
Macros have nothing to do with the current PC, so this doesn't make any sense.
The value isn't ever used either.
2019-05-09 15:01:06 -07:00
dbrotz 249acace08 Prevent non-reloc symbol from shadowing reloc symbol 2019-05-09 12:48:10 -07:00
dbrotz 021990b8e0 Properly check if a symbol's full name is too long 2019-05-05 20:21:55 -07:00
dbrotz 540564694c Add missing space to error message 2019-05-05 18:13:10 -07:00
dbrotz 8da4feb83c Use sym_FindSymbol() where possible 2019-05-05 18:10:05 -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
Antonio Niño Díaz a37a09c09c Merge pull request #328 from NieDzejkob/better-linker-errors
Print location information in linker errors where viable #328
2019-03-10 23:41:14 +01:00
Antonio Niño Díaz 8ece231d8b Merge pull request #327 from NieDzejkob/symbol-length-check
Fix symbol length checking
2019-03-10 23:40:03 +01:00
Jakub Kądziołka e7de0745ad Improve documentation of the object format 2019-03-04 09:45:14 +01:00
Jakub Kądziołka 7af2d5dfe1 Print location information in linker errors where viable 2019-03-03 22:55:17 +01:00
Jakub Kądziołka 2f2f14bf80 Fix symbol length checking
When the while loop in `ParseSymbol` stops because of the symbol length,
`copied` will have the value of `MAXSYMLEN`, which is obviously not
greater than `MAXSYMLEN`. Changing the condition to `>=` fixes the
issue.

As a bonus, the correct union field will now be used. It shouldn't
matter, but it's technically UB to use a wrong one.
2019-03-02 19:11:53 +01:00
Antonio Niño Díaz 65d7909466 Merge pull request #319 from mid-kid/patch-317
Allow linker script to consider section attributes
2019-01-19 16:15:42 +00: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
mid-kid d07ba6971b Update a symbol's filename and line when defined
Currently, all symbols are assigned a filename and line when they're
first encountered and added to the internal hash table. This is often
not expected and leads to erroneous error messages.
2019-01-12 12:57:58 +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
Antonio Niño Díaz a99b7f6902 Merge pull request #314 from dbrotz/fix-314
Fix #314
2018-12-10 23:09:39 +00:00
Antonio Niño Díaz b3391f699f Merge pull request #310 from dbrotz/fix-302
Fix #302
2018-12-10 23:05:22 +00:00
dbrotz a05fd9b818 Print full file path in error messages 2018-12-06 22:59:24 -08:00
dbrotz 6c1ec59a5b Use separate function to append newlines 2018-12-05 01:32:06 -08:00
dbrotz a060f135b8 Only add newlines to file if necessary 2018-12-02 20:43:20 -08:00
dbrotz f5d3087e9b Check if integer constants only contain radix prefix 2018-12-02 16:16:41 -08:00
dbrotz 3806eb3139 Fix ambiguity in const parsing 2018-12-02 13:49:12 -08:00