Earlier quoted context omitted.
This is an interesting idea, but gets tricky if someone writes self-modifying code! There are Uxn instructions which write to RAM; normally , this is used for storing data, but nothing prevents programs from editing their own code as they're running.
> but nothing prevents programs from editing their own code as they're running On some platforms writing to memory mapped in with PROT_EXEC will trigger a page fault and the process will be killed. In other words, self modifying executables are effectively forbidden by design (the workaround is to unmap the memory, map it as PROT_WRITE, modify, unmap, map it in as PROT_EXEC, and resume execution - which is what JITs…
Beating the Compiler
11–20 of 78 posts
Re: Beating the Compiler
#12Good article, brings the data to back it up. Unfortunately, it was hard to read with the monokai.css theme because comments were nearly invisible, and a lot of your information was in comments. Changing the color from #75715e to #95917e did the trick. I guess Monokai is for programmers who never read comments.
Re: Beating the Compiler
#13I see you already tried what I thought of, which is getting rid of the jump table and making each instruction handler the same size. Do you think that could still work if you limited each instruction handler to 64 or 32 bytes instead of 256, and then for longer handlers jumped to a larger body of code somewhere else?
Re: Beating the Compiler
#14> // SAFETY: do you trust me? No. Have you seen the safer-ffi crate? Then you won't have to commit the deadly sin of writing unsafe Rust
Re: Beating the Compiler
#15Re: Beating the Compiler
#16> // SAFETY: do you trust me? No. Have you seen the safer-ffi crate? Then you won't have to commit the deadly sin of writing unsafe Rust
It looks to me like that crate is supposed to help with exposing rust functions to C safely, not calling foreign functions in foreign code safely. Am I missing something?
Re: Beating the Compiler
#17 &mut h as *mut _ as *mut _
What is going on here?Re: Beating the Compiler
#18IMHO the best way to think of it (well, it's how I have long thought of it) is two lemmas: 1 - The compiler has more "fingers" than a human does. Back when I wrote programs in assembly I would use printout to keep track of what I was doing and for debugging, and so would often put a finger on the paper to mark where a jump was and then go to the destination to see if it matched up, etc. This process isn't at all scal…
Re: Beating the Compiler
#19I find this strange: &mut h as *mut _ as *mut _ What is going on here?
Re: Beating the Compiler
#20Earlier quoted context omitted.
This is an interesting idea, but gets tricky if someone writes self-modifying code! There are Uxn instructions which write to RAM; normally , this is used for storing data, but nothing prevents programs from editing their own code as they're running.
> but nothing prevents programs from editing their own code as they're running On some platforms writing to memory mapped in with PROT_EXEC will trigger a page fault and the process will be killed. In other words, self modifying executables are effectively forbidden by design (the workaround is to unmap the memory, map it as PROT_WRITE, modify, unmap, map it in as PROT_EXEC, and resume execution - which is what JITs…