klange wrote:
Look at the offsets for your sections - that’s how far into the file they are. They’re still ending up at 0x10000 which is no bueno. The next thing to try would be specifying a smaller alignment in your linker script…
Well, after compiling everything using this script:
Code:
/* Specify where the entry point is (start): */
ENTRY(start)
/* Define t(he sections of our binary: */
SECTIONS
{
. = 1M; /* All OS data will start 1M in. */
/* Set the boot section: */
.boot : ALIGN(0x250)
{
KEEP(*(.multiboot_header)) /* Include the multiboot header. */
}
/* Set the text section: */
.text : ALIGN(0x250)
{
*(.text) /* Include the text section (CPU instructions). */
}
}
I get the same error.
Those are the results of the
Code:
readelf -a kernel.bin
command:
Quote:
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x100000
Start of program headers: 64 (bytes into file)
Start of section headers: 5168 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 1
Size of section headers: 64 (bytes)
Number of section headers: 9
Section header string table index: 8
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .text PROGBITS 0000000000100000 00000400
00000000000004e2 0000000000000000 AX 0 0 1024
[ 2] .rodata PROGBITS 00000000001004e8 000008e8
0000000000000088 0000000000000000 A 0 0 8
[ 3] .eh_frame PROGBITS 0000000000100570 00000970
0000000000000158 0000000000000000 A 0 0 8
[ 4] .bss NOBITS 00000000001006e0 00000ac8
0000000000007020 0000000000000000 WA 0 0 32
[ 5] .comment PROGBITS 0000000000000000 00000ac8
0000000000000011 0000000000000001 MS 0 0 1
[ 6] .symtab SYMTAB 0000000000000000 00000ae0
00000000000005e8 0000000000000018 7 50 8
[ 7] .strtab STRTAB 0000000000000000 000010c8
0000000000000323 0000000000000000 0 0 1
[ 8] .shstrtab STRTAB 0000000000000000 000013eb
0000000000000041 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
l (large), p (processor specific)
There are no section groups in this file.
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000000400 0x0000000000100000 0x0000000000100000
0x00000000000006c8 0x0000000000007700 RWE 0x400
Section to Segment mapping:
Segment Sections...
00 .text .rodata .eh_frame .bss
There is no dynamic section in this file.
There are no relocations in this file.
The decoding of unwind sections for machine type Advanced Micro Devices X86-64 is not currently supported.
Symbol table '.symtab' contains 63 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000100000 0 SECTION LOCAL DEFAULT 1
2: 00000000001004e8 0 SECTION LOCAL DEFAULT 2
3: 0000000000100570 0 SECTION LOCAL DEFAULT 3
4: 00000000001006e0 0 SECTION LOCAL DEFAULT 4
5: 0000000000000000 0 SECTION LOCAL DEFAULT 5
6: 0000000000000000 0 FILE LOCAL DEFAULT ABS /root/env/src/impl/x86_64
7: 00000000000b8000 0 NOTYPE LOCAL DEFAULT ABS VIDEO_ADDR
8: 000000002f4b2f4f 0 NOTYPE LOCAL DEFAULT ABS OK_TEXT
9: 0000000000001000 0 NOTYPE LOCAL DEFAULT ABS ALIGNMENT_MEMORY
10: 0000000000004000 0 NOTYPE LOCAL DEFAULT ABS STACK_MEMORY
11: 0000000036d76289 0 NOTYPE LOCAL DEFAULT ABS BOOTLOADER_MAGIC_NUMBER
12: 000000004f524f45 0 NOTYPE LOCAL DEFAULT ABS ERROR_PRINT_VALUE_1
13: 000000004f3a4f52 0 NOTYPE LOCAL DEFAULT ABS ERROR_PRINT_VALUE_2
14: 000000004f204f20 0 NOTYPE LOCAL DEFAULT ABS ERROR_PRINT_VALUE_3
15: 0000000080000000 0 NOTYPE LOCAL DEFAULT ABS MAGIC_CHECK_VALUE_1
16: 0000000080000001 0 NOTYPE LOCAL DEFAULT ABS MAGIC_CHECK_VALUE_2
17: 0000000000000b11 0 NOTYPE LOCAL DEFAULT ABS PW_CODE
18: 0000000000000083 0 NOTYPE LOCAL DEFAULT ABS PWH_CODE
19: 0000000000000200 0 NOTYPE LOCAL DEFAULT ABS MAPPED_VALUE
20: 0000000000200000 0 NOTYPE LOCAL DEFAULT ABS TWO_MB
21: 00000000c0000080 0 NOTYPE LOCAL DEFAULT ABS ENABLE_LONG_MODE
22: 000000000010002d 0 NOTYPE LOCAL DEFAULT 1 check_multiboot
23: 0000000000100035 0 NOTYPE LOCAL DEFAULT 1 check_multiboot.no_multib
24: 000000000010003c 0 NOTYPE LOCAL DEFAULT 1 check_cpuid
25: 0000000000100050 0 NOTYPE LOCAL DEFAULT 1 check_cpuid.no_cpuid
26: 0000000000100057 0 NOTYPE LOCAL DEFAULT 1 check_long_mode
27: 0000000000100075 0 NOTYPE LOCAL DEFAULT 1 check_long_mode.no_long_m
28: 0000000000100079 0 NOTYPE LOCAL DEFAULT 1 setup_page_tables
29: 000000000010009c 0 NOTYPE LOCAL DEFAULT 1 setup_page_tables.loop_me
30: 00000000001000b9 0 NOTYPE LOCAL DEFAULT 1 enable_paging
31: 00000000001000e4 0 NOTYPE LOCAL DEFAULT 1 error
32: 00000000001006e0 0 NOTYPE LOCAL DEFAULT 4 page_table_l4
33: 00000000001016e0 0 NOTYPE LOCAL DEFAULT 4 page_table_l3
34: 00000000001026e0 0 NOTYPE LOCAL DEFAULT 4 page_table_l2
35: 00000000001036e0 0 NOTYPE LOCAL DEFAULT 4 stack_bottom
36: 00000000001076e0 0 NOTYPE LOCAL DEFAULT 4 stack_top
37: 00000000001004e8 0 NOTYPE LOCAL DEFAULT 2 gdt64
38: 0000000000000008 0 NOTYPE LOCAL DEFAULT ABS gdt64.code_segment
39: 00000000001004f8 0 NOTYPE LOCAL DEFAULT 2 gdt64.pointer
40: 0000000000000000 0 FILE LOCAL DEFAULT ABS /root/env/src/impl/x86_64
41: 0000000000000000 0 FILE LOCAL DEFAULT ABS main.c
42: 0000000000100508 8 OBJECT LOCAL DEFAULT 2 NUM_COLS
43: 0000000000100510 8 OBJECT LOCAL DEFAULT 2 NUM_ROWS
44: 0000000000000000 0 FILE LOCAL DEFAULT ABS print.c
45: 0000000000100550 8 OBJECT LOCAL DEFAULT 2 NUM_COLS
46: 0000000000100558 8 OBJECT LOCAL DEFAULT 2 NUM_ROWS
47: 0000000000000000 0 FILE LOCAL DEFAULT ABS terminal.c
48: 0000000000100560 8 OBJECT LOCAL DEFAULT 2 NUM_COLS
49: 0000000000100568 8 OBJECT LOCAL DEFAULT 2 NUM_ROWS
50: 0000000000100312 133 FUNC GLOBAL DEFAULT 1 print_char
51: 0000000000100228 234 FUNC GLOBAL DEFAULT 1 print_newline
52: 00000000001001ef 57 FUNC GLOBAL DEFAULT 1 print_clear
53: 0000000000100415 51 FUNC GLOBAL DEFAULT 1 set_system_terminal
54: 0000000000100124 104 FUNC GLOBAL DEFAULT 1 kernel_main
55: 0000000000100448 93 FUNC GLOBAL DEFAULT 1 create_terminal
56: 000000000010018c 99 FUNC GLOBAL DEFAULT 1 clear_row
57: 00000000001003ed 40 FUNC GLOBAL DEFAULT 1 print_set_color
58: 0000000000100397 86 FUNC GLOBAL DEFAULT 1 print_string
59: 0000000000100110 0 NOTYPE GLOBAL DEFAULT 1 long_mode_start
60: 0000000000100000 0 NOTYPE GLOBAL DEFAULT 1 start
61: 00000000001004a5 61 FUNC GLOBAL DEFAULT 1 init_terminal
62: 00000000001076e0 32 OBJECT GLOBAL DEFAULT 4 system_terminal
No version information found in this file.
And why don't I see the '.boot' section in the command results?