Am I missing something?
linked.id
Code: Select all
SECTIONS
{
.SystemFunctions 0x7100 :
{
*(.SystemFunctions)
}
.StartKernel 0x[~~.StartKernel~~] :
{
*(.StartKernel)
}
.text :
{
. = ALIGN(64);
*(.text)
}
.rodata :
{
. = ALIGN(64);
*(.rodata)
}
.bss :
{
. = ALIGN(64);
*(COMMON)
*(.bss)
}
.staticmemory (NOLOAD):
{
. = ALIGN(64);
*(.staticmemory)
}
}
Code: Select all
struct tSystemFunction
{
void (*DoSomething)(QWORD);
QWORD (*SystemFunctionSanityCheck)(QWORD);
};
const __attribute__((section(".SystemFunctions"))) struct tSystemFunction* SystemFunction = null;
void StartKernel(void) __attribute__((section(".StartKernel")));
void StartKernel(void)
{
QWORD XOR = 0x1234432178900987;
SystemFunction->SystemFunctionSanityCheck(XOR);
return;
}
Code: Select all
DatabaseServer.lkr: file format elf64-x86-64
Disassembly of section .StartKernel:
0000000000302000 <_Z11StartKernelv>:
302000: 48 a1 00 71 00 00 00 movabs rax,ds:0x7100
302007: 00 00 00
30200a: 48 bf 87 09 90 78 21 movabs rdi,0x1234432178900987
302011: 43 34 12
302014: 48 8b 40 08 mov rax,QWORD PTR [rax+0x8]
302018: ff e0 jmp rax
Disassembly of section .text:
000000000030201c <.text>:
30201c: 66 2e 0f 1f 84 00 00 nop WORD PTR cs:[rax+rax*1+0x0]
302023: 00 00 00
302026: 66 2e 0f 1f 84 00 00 nop WORD PTR cs:[rax+rax*1+0x0]
30202d: 00 00 00
302030: 66 2e 0f 1f 84 00 00 nop WORD PTR cs:[rax+rax*1+0x0]
302037: 00 00 00
30203a: 66 0f 1f 44 00 00 nop WORD PTR [rax+rax*1+0x0]
???? C Code:
Code: Select all
struct tSystemFunction
{
void (*DoSomething)(QWORD);
QWORD (*SystemFunctionSanityCheck)(QWORD);
};
const __attribute__((section(".SystemFunctions"))) struct tSystemFunction* SystemFunction = null;
void StartKernel(void) __attribute__((section(".StartKernel")));
void StartKernel(void)
{
QWORD XOR = 0x1234432178900987;
SystemFunction->SystemFunctionSanityCheck(XOR);
SystemFunction->SystemFunctionSanityCheck(XOR);
return;
}
???? Assembly:
Code: Select all
DatabaseServer.lkr: file format elf64-x86-64
Disassembly of section .StartKernel:
0000000000302000 <_Z11StartKernelv>:
302000: 53 push rbx
302001: 48 bb 00 71 00 00 00 movabs rbx,0x7100
302008: 00 00 00
30200b: 48 bf 87 09 90 78 21 movabs rdi,0x1234432178900987
302012: 43 34 12
302015: 48 8b 03 mov rax,QWORD PTR [rbx]
302018: ff 50 08 call QWORD PTR [rax+0x8]
30201b: 48 8b 13 mov rdx,QWORD PTR [rbx]
30201e: 48 bf 87 09 90 78 21 movabs rdi,0x1234432178900987
302025: 43 34 12
302028: 5b pop rbx
302029: 48 8b 42 08 mov rax,QWORD PTR [rdx+0x8]
30202d: ff e0 jmp rax
Disassembly of section .text:
0000000000302030 <.text>:
302030: 66 2e 0f 1f 84 00 00 nop WORD PTR cs:[rax+rax*1+0x0]
302037: 00 00 00
30203a: 66 0f 1f 44 00 00 nop WORD PTR [rax+rax*1+0x0]