Skip to content

Commit 31dab8a

Browse files
authored
[metal] Fix bug: do not initialize IDT & TSS if unneeded (#654)
libc/intrin/interrupts.S should not be linked in unless an IDT (or TSS) is explicitly requested somewhere (i.e. it should probably not be a mandatory module).
1 parent 7a06760 commit 31dab8a

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

ape/ape.lds

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,6 @@ HIDDEN(v_ape_realsectors =
569569
HIDDEN(v_ape_realpages = v_ape_realsectors / (4096 / 512));
570570
HIDDEN(v_ape_highsectors =
571571
(ROUNDUP(RVA(_edata), 512) / 512) - v_ape_realsectors);
572-
PROVIDE_HIDDEN(_tss = 0);
573-
PROVIDE_HIDDEN(_tss_end = 0);
574572
TSSDESCSTUB2(_tss, _tss, _tss_end ? _tss_end - _tss - 1 : 0);
575573
#endif
576574

ape/macros.internal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@
182182

183183
// Task State Segment Descriptor Entries.
184184
.macro .tssdescstub name:req
185+
.ifndef \name
186+
.weak \name
187+
.set \name,0
188+
.endif
189+
.ifndef \name\()_end
190+
.weak \name\()_end
191+
.set \name\()_end,0
192+
.endif
185193
.stub \name\()_desc_ent0,quad
186194
.stub \name\()_desc_ent1,quad
187195
.endm

libc/intrin/interrupts.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ __excep0_isr:
9393
ezlea .excep_msg,di # stack should be 16-byte aligned now
9494
xor %eax,%eax # kprintf is variadic, remember to
9595
# pass no. of vector regs. used (= 0)
96-
.weak kprintf # weakly link kprintf() because this
97-
ezlea kprintf,bx # module is a mandatory dependency
98-
test %ebx,%ebx # and we want to keep life.com tiny
96+
.weak kprintf # weakly link kprintf() because we
97+
ezlea kprintf,bx # want to keep life.com tiny
98+
test %ebx,%ebx
9999
jz 8f
100100
call *%rbx # print error message
101101
8: cli

0 commit comments

Comments
 (0)