What is "asmlinkage "? -Syscall prototype description

Source: Internet
Author: User
Tags define function

Http://www.jollen.org/blog/2006/10/_asmlinkage.html
What is "asmlinkage "?

Jollen posted at October 26,200

A friend sent me a message saying that the system call data in the kernel is (c ), why is there a "asmlinkage" string before each prototype declaration? For example:

AsmlinkageLong sys_nice (INT increment)

"Asmlinkage" is an important GCC tag in i386 system call ).

When System Call handler calls the corresponding system call routine, it pushes the value of the general-purpose memory recorder to the stack, therefore, the system call routine is used by the stack to retrieve the number of records of the System Call handler. This is the intention of asmlinkage standards.

System Call handler is the assembly code, and system call routine (for example, sys_nice) is the C code. When assembly code calls the C function and uses the stack-based parameter data, add "asmlinkage" before the prototype of C function ".

After "asmlinkage" is added, the C function retrieves the dynamic number from the stack instead of the Register (probably after Optimized Program ).

More advanced description...

The 80x86 assembly has two ways to calculate the number of rows:

1. Register Method
2. Stack Method

Most of the Register Methods use the general-purpose Memory to collect statistics. This method is simple and fast. Another kind of practice is to use stack. The mode of assembly code is as follows:

Push number1
Push number2
Push Number3
Call sum

The simplest way to set values in 'sum' procedure is:

Pop ax
Pop ax
Pop BX
Pop CX

Stack top is an IP address. The number of records that we assign to sum procedure is obtained from the last entry of the stack.

Other related asmlinkage

1. asmlinkage is a definition
2. "asmlinkage" is specified in/Usr/include/Linux/linkage. h
3. If you have readLinkage. h, The "_ attribute _" method will be found. This method is used by GCC to define function attribute.

-- Jollen

Related Article

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.