Linux Assembly Learning

Source: Internet
Author: User
Linux Assembly Learning-general Linux technology-Linux programming and kernel information. The following is a detailed description. Source: alime house
These days seem to have found the strength of learning in the past, hoping to continue and enrich your senior.

The following are the compilation Study Notes for the past two days:

When you use as to debug the assembler, you need to use the-gstabs parameter to compile the debugging information into the executable file. Note that if you use gcc, it is implemented by using the-g parameter.

In the debugging process, if you want to set a breakpoint, you cannot set the breakpoint by using the C language debugging method, you must use the following format: B "or break" * _ start "or other custom start tags" + number of lines from _ start; and the first statement after the start tag must be nop, which means null operation. Otherwise, the breakpoint you set is invalid, which is also a defect of the GUN assembler.

If the C library function is called in the assembler we write, the library file must be linked to the target code During connection. in linux, there are two methods: first, static connections are used to directly connect the target code to executable files, which will inevitably create a large executable file. Second, dynamic connections, during runtime, the dynamic Connection Library is called by the operating system, which saves space and multiple programs can share the dynamic Connection Library. However, if gcc is used for compilation, this part can be omitted, because the gcc compiler automatically connects to the required C library file.

The assembler in linux is composed of three common segments: Data Segment, bss segment, and code segment. All assembler programs must have code segments :. section. text, which is the place where the instruction code is placed. The data segment is optional :. section. data or. rodata ", use. the data segment declared by the data command. Any data element of this segment is stored in the memory and can be read and written by the assembly language instructions. the data segment declared by the rodata command. Any data element in this segment can only be accessed in read-only mode. The data declared by the bss segment "Format :. section. bss is initialized with 0 or null. One advantage of bss is that this part of data is not in the executable program, so it does not occupy much space as much data is declared in the data segment.

In linux, the dollar sign $ must be added before the number to be an immediate number.

Address Change query mode in the assembler in linux:

Base_address (offset_address, index, size) à base_address + offset_address + index * size;

When a tag is used to reference the data value contained in the memory location, you must use the $ symbol to obtain the data value address.
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.