[build] Warn on zero-length symbols when building symbol table

Make build_symbol_table.py output statistics on the symbol table it
builds, and emit warnings for zero-length symbols. Also added lengths to
several functions defined in asm that this uncovered.
This commit is contained in:
Justin C. Miller
2023-02-06 00:37:26 -08:00
parent ab31825ab3
commit 8966380ef9
6 changed files with 51 additions and 21 deletions

View File

@@ -42,15 +42,17 @@ bsp_idle:
jmp bsp_idle
.end:
global interrupts_enable: function hidden
global interrupts_enable: function hidden (interrupts_enable.end - interrupts_enable)
interrupts_enable:
sti
ret
.end:
global interrupts_disable: function hidden
global interrupts_disable: function hidden (interrupts_disable.end - interrupts_disable)
interrupts_disable:
cli
ret
.end:
section .bss
align 0x100

View File

@@ -1,33 +1,39 @@
global get_rsp: function hidden
global get_rsp: function hidden (get_rsp.end - get_rsp)
get_rsp:
mov rax, rsp
ret
.end:
global get_rip: function hidden
global get_rip: function hidden (get_rip.end - get_rip)
get_rip:
pop rax ; do the same thing as 'ret', except with 'jmp'
jmp rax ; with the return address still in rax
.end:
global get_caller: function hidden
global get_caller: function hidden (get_caller.end - get_caller)
get_caller:
; No prelude - don't touch rsp or rbp
mov rax, [rbp+8]
ret
.end:
global get_grandcaller: function hidden
global get_grandcaller: function hidden (get_grandcaller.end - get_grandcaller)
get_grandcaller:
; No prelude - don't touch rsp or rbp
mov rax, [rbp]
mov rax, [rax+8]
ret
.end:
global get_gsbase: function hidden
global get_gsbase: function hidden (get_gsbase.end - get_gsbase)
get_gsbase:
rdgsbase rax
ret
.end:
global _halt: function hidden
global _halt: function hidden (_halt.end - _halt)
_halt:
hlt
jmp _halt
.end:

View File

@@ -1,15 +1,17 @@
global idt_write: function hidden
global idt_write: function hidden (idt_write.end - idt_write)
idt_write:
lidt [rdi] ; first arg is the IDT pointer location
ret
.end:
global idt_load: function hidden
global idt_load: function hidden (idt_load.end - idt_load)
idt_load:
sidt [rdi] ; first arg is where to write the idtr value
ret
.end:
global gdt_write: function hidden
global gdt_write: function hidden (gdt_write.end - gdt_write)
gdt_write:
lgdt [rdi] ; first arg is the GDT pointer location
@@ -27,9 +29,11 @@ gdt_write:
.next:
ltr cx ; fourth arg is the TSS
ret
.end:
global gdt_load: function hidden
global gdt_load: function hidden (gdt_load.end - gdt_load)
gdt_load:
sgdt [rdi] ; first arg is where to write the gdtr value
ret
.end:

View File

@@ -26,7 +26,7 @@ bits 16
default rel
align 8
global ap_startup: function hidden
global ap_startup: function hidden (ap_startup.end - ap_startup)
ap_startup:
jmp .start_real
@@ -102,15 +102,16 @@ align 8
mov rax, [BASE + (.ret - ap_startup)]
jmp rax
.end:
global ap_startup_code_size: function hidden
global ap_startup_code_size: data hidden
ap_startup_code_size:
dq ($ - ap_startup)
section .text
global init_ap_trampoline: function hidden
global init_ap_trampoline: function hidden (init_ap_trampoline.end - init_ap_trampoline)
init_ap_trampoline:
push rbp
mov rbp, rsp
@@ -129,6 +130,7 @@ init_ap_trampoline:
pop rbp
ret
.end:
extern long_ap_startup
global ap_idle:function hidden (ap_idle.end - ap_idle)

View File

@@ -1,6 +1,6 @@
%include "tasking.inc"
global task_switch: function hidden
global task_switch: function hidden (task_switch.end - task_switch)
task_switch:
push rbp
mov rbp, rsp
@@ -60,8 +60,10 @@ task_switch:
pop rbp
ret
.end:
global _current_gsbase: function hidden
global _current_gsbase: function hidden (_current_gsbase.end - _current_gsbase)
_current_gsbase:
mov rax, [gs:CPU_DATA.self]
ret
.end: