Information Security system design basics Fifth Week study summary-20135227 Huang

Source: Internet
Author: User

X86 addressing mode through three generations:

1 The flat mode of the DOS era, not distinguishing between user space and kernel space, very insecure

2-8086 segmented mode

3 IA32 Flat mode with protected mode

Fs.

Instruction set architecture, instruction and format for machine-level programs. It defines the processing state, the format of the instruction, and the effect of each instruction on the state.

There are two ways to get assembly code:

Gcc-s xxx.c-o xxx.s Get assembly code, also can be used objdump-d XXX disassembly

(Disassembly does not require access to the source code of the program or assembly code)

C language data type in IA32 size in:

P111 page table.

8 registers ( each) :

The Eax,ecx,edxe;bx,esi,edi is a six general-purpose register.

ESI EDI can be used to manipulate arrays

EBP (frame pointer), ESP (stack pointer) holds pointers to important positions in the program stack.

Immediate number, memory, register addressing mode:

P113 table formula. 3.1 of the examples help to test the mastery of No.

In particular: Effective address calculation method IMM (eb,ei,s) = Imm + R[eb] + r[ei]*s

Data transfer instructions:

Mov:movb,movw,movl transfer bytes, words, double words, respectively

Movz (0 expansion, high position with 0 fill): Ditto, press stack out of the stack see p114 table. (Note that the address value of the top of the stack is the smallest in the stack)

MOVS (symbol extension, high position with the original highest value): Ibid.

In C, the pointer is the address, and the indirect reference pointer is to place the pointer in a register, and then use the register in memory.

Arithmetic and logical operations:

Four integer operations: Load valid address, unary operation, two-dollar operation, shift.

See p119 form for details.

Control:

The core is the jump statement.

Unconditional jump: jmp jump target can be a direct jump, that is, the jump target is a part of the instruction code, or an indirect jump, the target is read from the register or memory.

Conditional jump: Determine the Condition: Flag p124 page. Jump instruction, p128.

CMP is not to change the subtraction of the source operand, but to change the flag bit after doing the comparison.

SUB is to change the subtraction of the source operand.

Cycle

If-else structure of the assembly:

The three-version code of the p130 page helps to understand the assembly code.

Do-while structure of the assembly:

p133 Page Three of code.

while structure of the assembly:

p135 Page Three of code.

for structure of the assembly:

p138 Three versions of the code for a page.

Conditional Delivery directives:

P140 of three code.

The performance of the instruction based on conditional data transfer is better than that of conditional control transfer instruction. However, conditional data transfer is very limited, but they can be used more often.

Switch:

p145,146 two pages of three code when understanding the core.

Note that none of the cases are classified as default. The assembly jumps directly to the end of all cases.

Process:

Stack: Stack top pointer,%esp. In assembly language, before executing a subroutine, the address of the next instruction of the jump instruction is pressed into the stack to protect it, and after the subroutine executes, the stack is guaranteed to continue executing the main program.

The call instruction transfers control to the beginning of a function, and the RET instruction returns to the next instruction after the call instruction.

stack frame of gdb command:

BACKTRACE/BT N

n is a positive integer that represents only the stack information for the top n-tier of the stack.

The-n table is a negative integer that prints only the stack information for the n-tier below the stack.

Frame n

N is an integer starting from 0, which is the layer number in the stack. For example: Frame 0, representing the top of the stack, frame 1, represents the second layer of the stack.

This instruction means moving to n the specified stack frame and printing the selected stack's information. If n is not present, the information for the current frame is printed.

Up n

Moves the n layer to the top of the stack without hitting N, which means moving up one layer.

Down n

Moves the n layer below the stack, without hitting N, to move down one layer.

Lab Exercises:

I use Vim to save the MAINANGELA.C

View Assembly Code

Reference blog: 20135202 Shang (Reference content: GDB's stack frame command)

Information Security system design basics Fifth Week study summary-20135227 Huang

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.