Search code examples
assemblygoogle-nativeclient

How to interpret ncval's output?


I am trying to port some software to native-client. It uses some inline asm at multiple locations in the code for speed reasons. (Most of them are really simple one-line ones, which are so simple that they should be considered safe.)

I got the project to compile and link, but at the moment it failes Chrome's code analysis. Ncval outputs the following:

segment[0] p_type 6 p_offset 0 vaddr 0 paddr 0 align 4
    filesz b4 memsz b4 flags 4
segment[1] p_type 1 p_offset 10000 vaddr 20000 paddr 20000 align 65536
    filesz 2e91a0 memsz 2e91a0 flags 5
parsing segment 1
VALIDATOR: 31be8: Illegal instruction
segment[2] p_type 1 p_offset 300000 vaddr 10020000 paddr 10020000 align 65536
    filesz 72aac memsz 72aac flags 4
segment[3] p_type 1 p_offset 380000 vaddr 100a0000 paddr 100a0000 align 65536
    filesz 1cb8 memsz 29658 flags 6
*** client_x86_32.nexe IS UNSAFE ***
Validated client_x86_32.nexe
***  client_x86_32.nexe is UNSAFE ***

But I don't really know what this output means. I can see that it found at least one illegal instruction. I did an objdump of client_x86_32.nexe, and I tried to figure out what the address of the illegal instruction(s?) is based on ncval's output, but I couldn't, because I don't know how to calculate it based on the ncval output.

Any help is welcome.

(In the meantime I will start removing asm blocks from the code, and hope I find the offending block, so that I can correct it to be safe.)


Solution

  • the validator's output gave the code address, 0x31be8. try using gdb or objdump on client_x86_32.nexe to see what instruction is at the address 0x31be8, and compare that with your asm blocks.