Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent reference behavior #496

Closed
ISSOtm opened this issue Mar 21, 2020 · 1 comment
Closed

Inconsistent reference behavior #496

ISSOtm opened this issue Mar 21, 2020 · 1 comment
Labels
bug Unexpected behavior / crashes; to be fixed ASAP! rgbasm This affects RGBASM rgblink This affects RGBLINK
Milestone

Comments

@ISSOtm
Copy link
Member

ISSOtm commented Mar 21, 2020

issotm@sheik-kitty ~% cat /tmp/a  
SECTION "test", ROM0[0]
	dw CONSTANT

X equ 42
EXPORT X
issotm@sheik-kitty ~% cat /tmp/b
Y equ 69
EXPORT Y
issotm@sheik-kitty ~% rgbds/rgbasm -o /tmp/oa /tmp/a -DCONSTANT=X
ERROR: /tmp/a(4):
    'X' referenced as label at /tmp/a(2)
error: Assembly aborted (1 errors)!
1 issotm@sheik-kitty ~% rgbds/rgbasm -o /tmp/oa /tmp/a -DCONSTANT=Y
issotm@sheik-kitty ~% rgbds/rgbasm -o /tmp/ob /tmp/b             
issotm@sheik-kitty ~% rgbds/rgblink -o /tmp/g /tmp/oa /tmp/ob
issotm@sheik-kitty ~% xxd /tmp/g | head -n 1
00000000: 4500 0000 0000 0000 0000 0000 0000 0000  E...............
issotm@sheik-kitty ~% echo $((0x45))
69

The check that "references can only be overridden by labels" was added because RGBASM essentially considers references to be labels without a value.

This is indeed inconsistent with RGBLINK's behavior, so which should be considered right? I'd say RGBLINK, but then this means there might be more or less obscure behavior with refs that this would change. On the other hand, RGBLINK cannot adopt's RGBASM's behavior anyways because it has no symbol type information, and I don't think it would make sense to add any, right?

@ISSOtm ISSOtm added bug Unexpected behavior / crashes; to be fixed ASAP! rgbasm This affects RGBASM rgblink This affects RGBLINK labels Mar 21, 2020
@ISSOtm
Copy link
Member Author

ISSOtm commented Mar 30, 2020

I think the path to take is pretty clear. Treat refs as labels, allow them to be overridden by any type of symbols, and harden RGBLINK. RGBLINK needs to be hardened anyways...

issotm@sheik-kitty ~% echo 'CONST equ 1\nEXPORT CONST' | rgbasm -o /tmp/o1 -
issotm@sheik-kitty ~% echo 'SECTION"a",ROM0\ndb CONST' | rgbasm -o /tmp/o2 -
issotm@sheik-kitty ~% rgblink /tmp/o1 /tmp/o2
issotm@sheik-kitty ~% rgblink /tmp/o1 /tmp/o2 -o /tmp/g
issotm@sheik-kitty ~% xxd /tmp/g | head -n 1
00000000: 0100 0000 0000 0000 0000 0000 0000 0000  ................
issotm@sheik-kitty ~% echo 'SECTION"a",ROM0\ndb BANK(CONST)' | rgbasm -o /tmp/o2 -
issotm@sheik-kitty ~% rgblink /tmp/o1 /tmp/o2 -o /tmp/g                           
src/link/patch.c:260:33: runtime error: member access within null pointer of type 'struct Section'
zsh: segmentation fault (core dumped)  rgblink /tmp/o1 /tmp/o2 -o /tmp/g

@ISSOtm ISSOtm added this to the v0.4.1 milestone Apr 4, 2020
@ISSOtm ISSOtm closed this as completed in e098bf4 Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behavior / crashes; to be fixed ASAP! rgbasm This affects RGBASM rgblink This affects RGBLINK
Projects
None yet
Development

No branches or pull requests

1 participant