Learn Minix with Bochs (3)-Debug Startup process _ assembly

Source: Internet
Author: User
/boot file is a real-mode executable, the running address is 0x10000, using the Disassembly tool to open the boot file, you can see that Boothead.s's first instruction was compiled at 0x1000:0030. As noted earlier, this is where you jump from BOOTBLOCK.S to. This instruction is a jump:

JMP 1002:0015

It actually jumps to the following line:

MOV ax, 1000//directive address: 0x10035

...

Next you can see the code that runs into Boothead.s to invoke the boot function in the assembly code:

...

JMP No_ext

Adj_ext:

Add (DI), BX! ADD ext mem above 16M to mem below 16M

No_ext:

! Time to switch to a higher level language (not much higher)

Call _boot//calling the boot function

Combining the disassembly code of the/boot file, you can determine that the boot function address is 0x1267a.

Start Bochs, and then run after you set a breakpoint in the Debug window:

<BOCHS:1>PB 0x10124//Set Physical address breakpoint

<bochs:2>c

After running for some time, Bochs stopped at the 0x10124 place. Next step into the boot function:

<bochs:3>s

<BOCHS:4>U/10//List Disassembly code

0001267A:(): Push BP

0001267b:(): mov bp, sp

0001267d:(): Call. +0XE6CB

00012680:(): Call. +0XECCC

...

From the disassembly code listed, you can see that the EXECUTE function invocation should be in the 0x1002:266a line, so set the breakpoint:

<BOCHS:5>PB 0x1268a

Unfortunately, the system does not stop at the expected place, but has been running, it seems to be because of some reason the breakpoint has been invalidated. The test found that the Assembly statement did not return at the first Call statement (Initialize function), which is why. In fact, if you look at the code of the Initialize function, this function copies the launcher to the far end of the low memory (640k), which is close to 640k. So the base address of the entire startup code changes after a sentence in this function, and it seems to be a lot of effort to track the boot code completely.

<BOCHS:6>PB 0x1267d//breakpoint set at Initialize function

<bochs:7>s//Enter function

<bochs:8>u/20

The startup program that copies to the new address runs the second procedure relocate called in the Initialize function, which is located in Boothead.s. So you can find the second call instruction (that is, the relocate function) to go in, and the final return address of the assembly function is the address of the new location.

<BOCHS:8>PB 0x10e13//Set breakpoints at relocate entrance (the address of the next instruction is 0x10e16)

<bochs:9>c

<bochs:10>s//Enter relocate

<bochs:11>u/20

<BOCHS:12>PB 0x10251//Set breakpoint at relocate return point

<bochs:13>c

<bochs:14>s

Can be seen, the return of the new address is 0x93606,boot code on the machine was relocated to the 0X93606-0X10E16=0X827F0 place.

Now we can reset the breakpoint on the Execute function. It should be located in 0x94e7a, so enter the following:

<BOCHS:14>PB 0x94e7a

The operation can be found, Bochs really stopped in the expected position, it seems that the previous analysis process is no problem. The next step is to further track the Minix boot process.

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.