Clean up linker script symbols
This commit is contained in:
parent
b9675019e7
commit
ba9cf30e67
@ -13,7 +13,9 @@ import hulk.memory;
|
|||||||
import ldc.llvmasm;
|
import ldc.llvmasm;
|
||||||
|
|
||||||
__gshared EFI_SYSTEM_TABLE * st;
|
__gshared EFI_SYSTEM_TABLE * st;
|
||||||
|
/** HULK binary start address, 4KB-aligned. */
|
||||||
extern extern(C) __gshared ubyte _hulk_bin_start;
|
extern extern(C) __gshared ubyte _hulk_bin_start;
|
||||||
|
/** HULK binary end address, 4KB-aligned. */
|
||||||
extern extern(C) __gshared ubyte _hulk_bin_end;
|
extern extern(C) __gshared ubyte _hulk_bin_end;
|
||||||
private align(4096) __gshared ubyte[1024 * 1024] scratch_buffer;
|
private align(4096) __gshared ubyte[1024 * 1024] scratch_buffer;
|
||||||
/** Index to the memory map region being used to allocate page tables. */
|
/** Index to the memory map region being used to allocate page tables. */
|
||||||
@ -39,14 +41,9 @@ private ulong hulk_bin_size()
|
|||||||
return cast(ulong)&_hulk_bin_end - cast(ulong)&_hulk_bin_start;
|
return cast(ulong)&_hulk_bin_end - cast(ulong)&_hulk_bin_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ulong hulk_total_size()
|
|
||||||
{
|
|
||||||
return cast(ulong)hulk_header().total_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ulong hulk_bss_size()
|
private ulong hulk_bss_size()
|
||||||
{
|
{
|
||||||
return hulk_total_size() - hulk_bin_size();
|
return cast(ulong)hulk_header().hulk_bss_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ulong hulk_stack_size()
|
private ulong hulk_stack_size()
|
||||||
|
@ -11,14 +11,14 @@ import hulk.bootinfo;
|
|||||||
struct HulkHeader
|
struct HulkHeader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Total size of memory to be mapped.
|
* HULK BSS size.
|
||||||
|
*
|
||||||
|
* The OS loader must map memory to a zeroed range of this size.
|
||||||
*
|
*
|
||||||
* The OS loader must ensure that virtual memory is mapped for this entire
|
|
||||||
* size.
|
|
||||||
* This value is really an integer, but is stored as a pointer because it
|
* This value is really an integer, but is stored as a pointer because it
|
||||||
* is provided by the linker and LDC does not like us to cast it.
|
* is provided by the linker and LDC does not like us to cast it.
|
||||||
*/
|
*/
|
||||||
void * total_size;
|
void * hulk_bss_size;
|
||||||
|
|
||||||
/** Entry point. */
|
/** Entry point. */
|
||||||
void * entry;
|
void * entry;
|
||||||
|
@ -54,7 +54,7 @@ struct hippo
|
|||||||
{
|
{
|
||||||
size_t usable_memory;
|
size_t usable_memory;
|
||||||
ulong[2][4] reserved = [
|
ulong[2][4] reserved = [
|
||||||
[header.bootinfo.hulk_phys, cast(ulong)header.total_size - LinkerAddresses.hulk_bss_size],
|
[header.bootinfo.hulk_phys, LinkerAddresses.hulk_binary_size],
|
||||||
[header.bootinfo.bss_phys, LinkerAddresses.hulk_bss_size],
|
[header.bootinfo.bss_phys, LinkerAddresses.hulk_bss_size],
|
||||||
[header.bootinfo.stack_phys, header.stack_size],
|
[header.bootinfo.stack_phys, header.stack_size],
|
||||||
[cast(ulong)header.bootinfo.fb.buffer, header.bootinfo.fb.height * header.bootinfo.fb.stride * 4u],
|
[cast(ulong)header.bootinfo.fb.buffer, header.bootinfo.fb.height * header.bootinfo.fb.stride * 4u],
|
||||||
|
@ -21,11 +21,11 @@ import hulk.pic;
|
|||||||
import hulk.acpi;
|
import hulk.acpi;
|
||||||
import hulk.apic;
|
import hulk.apic;
|
||||||
|
|
||||||
extern extern(C) __gshared ubyte _hulk_total_size;
|
extern extern(C) __gshared ubyte _hulk_bss_size;
|
||||||
|
|
||||||
@(ldc.attributes.section(".hulk_header"))
|
@(ldc.attributes.section(".hulk_header"))
|
||||||
private __gshared HulkHeader hulk_header = {
|
private __gshared HulkHeader hulk_header = {
|
||||||
&_hulk_total_size, /* total_size */
|
&_hulk_bss_size, /* hulk_bss_size */
|
||||||
&hulk_start, /* entry */
|
&hulk_start, /* entry */
|
||||||
16u * 1024u, /* stack_size */
|
16u * 1024u, /* stack_size */
|
||||||
HULK_VIRTUAL_BASE_ADDRESS, /* virt_base */
|
HULK_VIRTUAL_BASE_ADDRESS, /* virt_base */
|
||||||
|
@ -2,6 +2,7 @@ SECTIONS
|
|||||||
{
|
{
|
||||||
. = 0xFFFF800000000000;
|
. = 0xFFFF800000000000;
|
||||||
_hulk_mem_start = .;
|
_hulk_mem_start = .;
|
||||||
|
_hulk_header_start = .;
|
||||||
|
|
||||||
.hulk_header :
|
.hulk_header :
|
||||||
{
|
{
|
||||||
@ -9,6 +10,7 @@ SECTIONS
|
|||||||
}
|
}
|
||||||
|
|
||||||
. = ALIGN(4K);
|
. = ALIGN(4K);
|
||||||
|
_hulk_header_end = .;
|
||||||
_hulk_text_start = .;
|
_hulk_text_start = .;
|
||||||
|
|
||||||
.text :
|
.text :
|
||||||
@ -18,6 +20,7 @@ SECTIONS
|
|||||||
|
|
||||||
. = ALIGN(4K);
|
. = ALIGN(4K);
|
||||||
_hulk_text_end = .;
|
_hulk_text_end = .;
|
||||||
|
_hulk_rodata_start = .;
|
||||||
|
|
||||||
.rodata :
|
.rodata :
|
||||||
{
|
{
|
||||||
@ -26,12 +29,17 @@ SECTIONS
|
|||||||
|
|
||||||
. = ALIGN(4K);
|
. = ALIGN(4K);
|
||||||
|
|
||||||
|
_hulk_rodata_end = .;
|
||||||
|
_hulk_data_start = .;
|
||||||
|
|
||||||
.data :
|
.data :
|
||||||
{
|
{
|
||||||
*(.data)
|
*(.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
. = ALIGN(4K);
|
. = ALIGN(4K);
|
||||||
|
_hulk_data_end = .;
|
||||||
|
_hulk_binary_size = . - _hulk_mem_start;
|
||||||
_hulk_bss_start = .;
|
_hulk_bss_start = .;
|
||||||
|
|
||||||
.bss :
|
.bss :
|
||||||
@ -41,7 +49,13 @@ SECTIONS
|
|||||||
}
|
}
|
||||||
|
|
||||||
. = ALIGN(4K);
|
. = ALIGN(4K);
|
||||||
_hulk_bss_size = . - _hulk_bss_start;
|
_hulk_bss_end = .;
|
||||||
_hulk_mem_end = .;
|
_hulk_mem_end = .;
|
||||||
_hulk_total_size = _hulk_mem_end - _hulk_mem_start;
|
|
||||||
|
_hulk_header_size = _hulk_header_end - _hulk_header_start;
|
||||||
|
_hulk_text_size = _hulk_text_end - _hulk_text_start;
|
||||||
|
_hulk_rodata_size = _hulk_rodata_end - _hulk_rodata_start;
|
||||||
|
_hulk_data_size = _hulk_data_end - _hulk_data_start;
|
||||||
|
_hulk_bss_size = _hulk_bss_end - _hulk_bss_start;
|
||||||
|
_hulk_mem_size = _hulk_mem_end - _hulk_mem_start;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ struct hurl
|
|||||||
/* Turn on NXE (no execute enable) flag in the EFER MSR. */
|
/* Turn on NXE (no execute enable) flag in the EFER MSR. */
|
||||||
wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_NXE);
|
wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_NXE);
|
||||||
m_pt_base = allocate_pt();
|
m_pt_base = allocate_pt();
|
||||||
size_t hulk_bin_phys_size = cast(ulong)header.total_size - LinkerAddresses.hulk_bss_size;
|
size_t hulk_binary_size = LinkerAddresses.hulk_binary_size;
|
||||||
/* Identity map all physical RAM. */
|
/* Identity map all physical RAM. */
|
||||||
map_range(0u,
|
map_range(0u,
|
||||||
0u,
|
0u,
|
||||||
@ -45,10 +45,10 @@ struct hurl
|
|||||||
/* Map HULK binary region. */
|
/* Map HULK binary region. */
|
||||||
map_range(HULK_VIRTUAL_BASE_ADDRESS,
|
map_range(HULK_VIRTUAL_BASE_ADDRESS,
|
||||||
header.bootinfo.hulk_phys,
|
header.bootinfo.hulk_phys,
|
||||||
hulk_bin_phys_size,
|
hulk_binary_size,
|
||||||
PT_WRITABLE);
|
PT_WRITABLE);
|
||||||
/* Map HULK BSS region. */
|
/* Map HULK BSS region. */
|
||||||
map_range(HULK_VIRTUAL_BASE_ADDRESS + hulk_bin_phys_size,
|
map_range(HULK_VIRTUAL_BASE_ADDRESS + hulk_binary_size,
|
||||||
header.bootinfo.bss_phys,
|
header.bootinfo.bss_phys,
|
||||||
LinkerAddresses.hulk_bss_size,
|
LinkerAddresses.hulk_bss_size,
|
||||||
PT_WRITABLE | PT_NO_EXECUTE);
|
PT_WRITABLE | PT_NO_EXECUTE);
|
||||||
|
@ -3,39 +3,137 @@
|
|||||||
*/
|
*/
|
||||||
module hulk.linker_addresses;
|
module hulk.linker_addresses;
|
||||||
|
|
||||||
private extern extern(C) __gshared ubyte _hulk_mem_start;
|
private extern extern(C) __gshared ubyte _hulk_header_start;
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_header_end;
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_header_size;
|
||||||
|
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_text_start;
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_text_end;
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_text_size;
|
||||||
|
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_rodata_start;
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_rodata_end;
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_rodata_size;
|
||||||
|
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_data_start;
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_data_end;
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_data_size;
|
||||||
|
|
||||||
private extern extern(C) __gshared ubyte _hulk_bss_start;
|
private extern extern(C) __gshared ubyte _hulk_bss_start;
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_bss_end;
|
||||||
private extern extern(C) __gshared ubyte _hulk_bss_size;
|
private extern extern(C) __gshared ubyte _hulk_bss_size;
|
||||||
|
|
||||||
|
/* hulk_binary includes header, text, rodata, and data */
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_binary_size;
|
||||||
|
|
||||||
|
/* hulk_mem includes header, text, rodata, data, and bss */
|
||||||
|
private extern extern(C) __gshared ubyte _hulk_mem_start;
|
||||||
private extern extern(C) __gshared ubyte _hulk_mem_end;
|
private extern extern(C) __gshared ubyte _hulk_mem_end;
|
||||||
private extern extern(C) __gshared ubyte _hulk_total_size;
|
private extern extern(C) __gshared ubyte _hulk_mem_size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This struct provides access to linker-defined symbols.
|
* This struct provides access to linker-defined symbols.
|
||||||
*/
|
*/
|
||||||
public struct LinkerAddresses
|
public struct LinkerAddresses
|
||||||
{
|
{
|
||||||
public static @property ulong hulk_mem_start()
|
public static @property ulong hulk_header_start()
|
||||||
{
|
{
|
||||||
return cast(ulong)&_hulk_mem_start;
|
return cast(ulong)&_hulk_header_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static @property ulong hulk_header_end()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_header_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @property ulong hulk_header_size()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_header_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static @property ulong hulk_text_start()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_text_start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @property ulong hulk_text_end()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_text_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @property ulong hulk_text_size()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_text_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static @property ulong hulk_rodata_start()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_rodata_start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @property ulong hulk_rodata_end()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_rodata_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @property ulong hulk_rodata_size()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_rodata_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static @property ulong hulk_data_start()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_data_start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @property ulong hulk_data_end()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_data_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @property ulong hulk_data_size()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_data_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static @property ulong hulk_bss_start()
|
public static @property ulong hulk_bss_start()
|
||||||
{
|
{
|
||||||
return cast(ulong)&_hulk_bss_start;
|
return cast(ulong)&_hulk_bss_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static @property ulong hulk_bss_end()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_bss_end;
|
||||||
|
}
|
||||||
|
|
||||||
public static @property ulong hulk_bss_size()
|
public static @property ulong hulk_bss_size()
|
||||||
{
|
{
|
||||||
return cast(ulong)&_hulk_bss_size;
|
return cast(ulong)&_hulk_bss_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static @property ulong hulk_binary_size()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_binary_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static @property ulong hulk_mem_start()
|
||||||
|
{
|
||||||
|
return cast(ulong)&_hulk_mem_start;
|
||||||
|
}
|
||||||
|
|
||||||
public static @property ulong hulk_mem_end()
|
public static @property ulong hulk_mem_end()
|
||||||
{
|
{
|
||||||
return cast(ulong)&_hulk_mem_end;
|
return cast(ulong)&_hulk_mem_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @property ulong hulk_total_size()
|
public static @property ulong hulk_mem_size()
|
||||||
{
|
{
|
||||||
return cast(ulong)&_hulk_total_size;
|
return cast(ulong)&_hulk_mem_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user