Csapp: Exception Control Flow

Source: Internet
Author: User

In general cases, the sequence of instructions processed by the processor is contiguous (sequential execution).

The exception control flow provides a jump to instructions, part of which is implemented by the hardware, and partly by the operating system.

Exception handling

at system startup, the operating system allocates and initializes a jump table called the exception table:

The code that will find and execute the corresponding exception handler from the Jump table when the exception is triggered (so-called kernel-state code?):

System calls

Each system call is an exception, and an exception is triggered when a system call function in the C library is called.

In a IA32 system, a system call is provided through a trap instruction called an int 0x80 (exception number).

All Linux system calls are passed through registers.

Here is an example of a system call

int Main () {    write (1"Hello, world\n");    Exit (0);      }

The corresponding assembly code

Main:    movl $4,%eax       system call number    MOVL $,%ebx       file descriptor    movl $string,%ecx "Hello, world\n"     movl $len,%edx     length    int $0x80      ...

Csapp: Exception Control Flow

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.