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

q3asm: garbage in JTRGSEG #278

Open
ec- opened this issue Mar 27, 2017 · 1 comment
Open

q3asm: garbage in JTRGSEG #278

ec- opened this issue Mar 27, 2017 · 1 comment

Comments

@ec-
Copy link

ec- commented Mar 27, 2017

I've put many strict checks in my engine so it detects some weird things in ioq3' q3asm output QVMs:

  • jump targets set on instructions that you're never jumping in
    q3e
  • duplicate entries in JTRGSEG
    hex
    As long as you're set more jump targets than needed - it is ok, just optimization pass will be skipped.
    But when you set less jump targets than needed - it may turn into unsafe opzimization.
    So as long as I can see unneeded/duplicated jump targets here - I can't say that you doesn't miss jumps in other places.
    "crude test for labels"
    https://github.com/ioquake/ioq3/blob/master/code/tools/asm/q3asm.c#L982
    does something wrong
@jjbarr
Copy link

jjbarr commented Jan 14, 2019

I just dumped more time than is strictly reasonable into actually examining this codebase to find out why this is.

Now, disclaimer: I am not a contributor, and I have spent a mere few hours looking at this thing. But I think I'm right enough to make a fool of myself over it on GitHub, so...

Anyways, the uneeded and duped targets exist because the only check for putting something in JTRGSEG is right there on the line you specified. That is, literally any use of address followed by a sym in the objfile is gonna place the sym's value into JTRGSEG.

This could be fixed. OTOH, I'm not sure it's worth it. It's not gonna miss a jump unless it's to a static address, which, by my admittedly limited understanding of LCC's architecture, Shouldn't Happen. The dupes could be fixed by scanning back on JTRGSEG, but the erroneous targets could only be eliminated by looking at the previously assembled instruction. Which may just be more trouble than it's worth. For that matter, scanning back on JTRGSEG might be more trouble than it's worth...

EDIT: A question that should have occurred to me did not occur to me: does this happen in your Q3asm, @ec- ? Because your q3asm seems to have an essentially identical implementation of this section of code, so if the bug doesn't appear there might be something else at work here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants