assembly - SegFaults in my Assembler? But that's impossible! :O -


Ok, so I understand that we have all our C / C ++ programmers at one time, our unusual slavery, demonic signs, SIGSEGV, Segmentation fault now, I (emphasis on the last stress) This magical GCC (or G ++) The compiler, or what you have, is understood to have some form of unsuccessful safe / checking system within certain parts of the machine code.

But! Today I was walking with some old X86 codear with a good old NASM on virtualized arch Linux system, and for a lot of my surprise and contemplation, once again failed by my coding efforts by Naphitius Segfault.

The code that generates a dangerous signal:

  mov eax, 0x7 mov [0xB8000], eax  

Now, I Understand that the Linux kernel loads your assembled program in a shell and executes it from there, but I thought it talks with the MOV instructions processor in 1 to 1, how the Earth can detect the kernel I'm trying to use a little memory, it does not want me, and the instructions Central?

I do not pretend to understand that when your program loads into a shell, you have permission to shell or even have a shell or how it works, But I used to say that ASM gave you complete control over the processor. How does this interfere with my direct commands for magical kernel processors, and essentially, when I write the pure machine code, why do I have to go through this series of operating system commands? : O

Linux executes your program (ON) In addition, it is using to limit storage locations, which can access your program. Specifically, your program attempts to write the 0xB8000 (VGA framebuffer), in which it is not allowed to modify. The processor detects it, and it throws a Linux kernel handles this exception, and translates it into one. Suppose you did not set up a custom handler for your signal, then the kernel kills your process. To avoid this and get full access to your hardware, you must either write a Linux device driver that will run in full kernel mode (0 ring on x86), or Linux will bypass completely.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -