-
Notifications
You must be signed in to change notification settings - Fork 2
Questions
Asami edited this page Dec 25, 2018
·
10 revisions
Questions
- Why does BIOS read IPL to 0x7c00? Does current architecture use this mechanism?
- What is OS header defined in
os.ls
? What is the role of it?
os.ls
OUTPUT_FORMAT("binary");
SECTIONS {
.head 0x0 : {
LONG(64 * 1024) /* 0 : size(stack+.data+heap) */
LONG(0x69726148) /* 4 : "Hari" */
LONG(0) /* 8 : mmarea*/
LONG(0x310000) /* 12 : stack初期値 & .data転送先 */
LONG(SIZEOF(.data)) /* 16 : size of .data */
LONG(LOADADDR(.data)) /* 20 : size of .data */
LONG(0xE9000000) /* 24 : E9000000 */
LONG(hari_main - 0x20) /* 28 : entry - 0x20 */
LONG(0x01) /* 32 : heap領域開始アドレス */
}
.text : {*(.text)}
.data 0x310000 : AT ( ADDR(.text) + SIZEOF(.text) ) {
*(.data)
*(.rodata*)
*(.bss)
}
/DISCARD/ : { *(.eh_frame) }
}
api.ls
OUTPUT_FORMAT("binary");
SECTIONS
{
.head 0x0 : {
LONG(128 * 1024) /* 0x0000(DWORD): The size of data segment for API. */
LONG(0x69726148) /* 0x0004(DWORD): Signature "Hari". */
LONG(0) /* 0x0008(DWORD): The size of spare area in data segment. */
LONG(0x0400) /* 0x000c(DWORD): Init value of ESP & the destination of .data. */
LONG(SIZEOF(.data)) /* 0x0010(DWORD): The size of .data. */
LONG(LOADADDR(.data)) /* 0x0014(DWORD): The file place of init value of .data. */
LONG(0xE9000000) /* 0x0018(DWORD): 0xE9000000. JMP to the app's entry address. */
LONG(hari_main - 0x20) /* 0x001c(DWORD): Entry address - 0x20. */
LONG(24 * 1024) /* 0x0020(DWORD): Start address of heap area(malloc area). */
}
/* The area for program code. */
/* 複数のファイルがある場合は? 複数の .text 領域を全てここに配置する? */
.text : { *(.text) }
/* The area for variables having initial values. */
.data 0x0400 : AT ( ADDR(.text) + SIZEOF(.text) ) {
*(.data)
*(.rodata) /* The area for const variables. */
*(.bss*) /* The area for variables not having initial values. */
}
/DISCARD/ : { *(.eh_frame) }
}
- What is an app segment by adding 0x60?
- What is the purpose of a linker script?
- How does an assembly function return values to a caller written by C?
- Why does a C compiler execute
__alloca()
when it allocates a variable more than 4k bytes? In the case allocating a variable less than 4k bytes, it is ok just to subtract ESP. Probably, the number of 4k bytes is affected by paging system? - What the difference between
malloc()
andalloca()
? In my understanding, malloc allocates memory in heap space, but alloca allocates memory in stack space.