Use nasm to compile a 16-bit elf File

Source: Internet
Author: User

It is mentioned in the document that nasm has 16-bit segment scalability when outputting elf target files (elf only has 32-bit and 64-bit formats as we all know ). I do not know whether the official statement is true or false. I have tried either of the following situations:

In 1-16-bit real-time mode, the kernel on the floppy disk is converted into a kernel by using int 13 H. load the elf file to the H address, find the elf entry address, and then jump in. The code execution is incorrect, input "u/10 entry" (the entry is calculated slowly during debugging). The command at the entrance is strange, similar to the command at the kernel. asm is different. I suspect that commands in the elf file cannot be executed in 16-bit real-world mode. Paste kernel. asm below:

Kernel. asmglobal _ start [section. data] db 0 [section. text] _ start: mov ah, 00001010 bmov al, 'y' mov bx, 2 * 8mov gs, bxmov [gs: 0], axjmp $

Scenario 2 -- modify the preceding kernel. asm: use [bits 16] to modify the. text Segment. Then, we first enter the 32-bit protection mode, and then LOAD the elf File LOAD segments at h to their respective locations (by program h
Specifies the vaddr In the eader). When jmp reaches the elf entry, the command execution will still fail. However, remove [bits 16] and re-compile it.

I will not explain the above two errors. I will look back later.

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.