Skip to content

Commit 2fc6c35

Browse files
author
Austin Clements
committed
Make the ELF entry point a physical address
This way, the bootloader doesn't have to translate the entry point. This also makes xv6 multiboot-compliant and follows the convention used by Linux.
1 parent 68b5872 commit 2fc6c35

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

bootmain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bootmain(void)
4343

4444
// Call the entry point from the ELF header.
4545
// Does not return!
46-
entry = (void(*)(void))(elf->entry - KERNBASE);
46+
entry = (void(*)(void))(elf->entry);
4747
entry();
4848
}
4949

entry.S

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@
2525
.globl multiboot_header
2626
multiboot_header:
2727
#define magic 0x1badb002
28-
#define flags (1<<16 | 1<<0)
28+
#define flags 0
2929
.long magic
3030
.long flags
3131
.long (-magic-flags)
32-
.long multiboot_header # beginning of image
33-
.long multiboot_header
34-
.long edata
35-
.long end
36-
.long entry
32+
33+
# By convention, the _start symbol specifies the ELF entry point.
34+
# Since we haven't set up virtual memory yet, our entry point is
35+
# the physical address of 'entry'.
36+
.globl _start
37+
_start = V2P_WO(entry)
3738

3839
# Entering xv6 on boot processor. Machine is mostly set up.
3940
.globl entry

0 commit comments

Comments
 (0)