1
在編譯XV6之前,我讀了this page來構建我自己的編譯器工具鏈。結果是類似的。在MAC上編譯XV6
➜ xv6-public git:(master) ✗ i386-jos-elf-objdump -i
BFD header file version (GNU Binutils) 2.27
elf32-i386
(header little endian, data little endian)
i386
➜ xv6-public git:(master) ✗ i386-jos-elf-gcc -v
Using built-in specs.
COLLECT_GCC=i386-jos-elf-gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i386-jos-elf/6.1.0/lto-wrapper
Target: i386-jos-elf
Configured with: ../configure --prefix=/usr/local --target=i386-jos-elf --disable-werror --disable-libssp --disable-libmudflap --with-newlib
--without-headers --enable-languages=c CC=/usr/bin/gcc
Thread model: single
gcc version 6.1.0 (GCC)
但是當我開始編譯XV6,出現錯誤:
➜ xv6-public git:(master) ✗ make
i386-jos-elf-gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -fvar-tracking -fvar-tracking-assignments -O0 -g -Wall -MD -gdwarf-2 -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pic -O -nostdinc -I. -c bootmain.c
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:5:2: error: unknown directive
.type waitdisk, @function
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:11:2: error: instruction requires: Not 64-bit mode
pushl %ebp
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:26:1: error: unexpected token at start of statement
/APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:27:1: error: unexpected token at start of statement
/8 "x86.h" 1
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:29:1: error: unexpected token at start of statement
/0 "" 2
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:31:1: error: unexpected token at start of statement
/NO_APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:39:2: error: instruction requires: Not 64-bit mode
popl %ebp
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:46:2: error: unknown directive
.size waitdisk, .-waitdisk
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:48:2: error: unknown directive
.type readsect, @function
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:54:2: error: instruction requires: Not 64-bit mode
pushl %ebp
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:61:2: error: instruction requires: Not 64-bit mode
pushl %edi
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:62:2: error: instruction requires: Not 64-bit mode
pushl %ebx
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:74:1: error: unexpected token at start of statement
/APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:75:1: error: unexpected token at start of statement
/24 "x86.h" 1
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:77:1: error: unexpected token at start of statement
/0 "" 2
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:79:1: error: unexpected token at start of statement
/NO_APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:86:1: error: unexpected token at start of statement
/APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:87:1: error: unexpected token at start of statement
/24 "x86.h" 1
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:89:1: error: unexpected token at start of statement
/0 "" 2
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:91:1: error: unexpected token at start of statement
/NO_APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:101:1: error: unexpected token at start of statement
/APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:102:1: error: unexpected token at start of statement
/24 "x86.h" 1
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:104:1: error: unexpected token at start of statement
/0 "" 2
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:106:1: error: unexpected token at start of statement
/NO_APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:116:1: error: unexpected token at start of statement
/APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:117:1: error: unexpected token at start of statement
/24 "x86.h" 1
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:119:1: error: unexpected token at start of statement
/0 "" 2
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:121:1: error: unexpected token at start of statement
/NO_APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:132:1: error: unexpected token at start of statement
/APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:133:1: error: unexpected token at start of statement
/24 "x86.h" 1
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:135:1: error: unexpected token at start of statement
/0 "" 2
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:137:1: error: unexpected token at start of statement
/NO_APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:144:1: error: unexpected token at start of statement
/APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:145:1: error: unexpected token at start of statement
/24 "x86.h" 1
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:147:1: error: unexpected token at start of statement
/0 "" 2
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:149:1: error: unexpected token at start of statement
/NO_APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:161:1: error: unexpected token at start of statement
/APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:162:1: error: unexpected token at start of statement
/15 "x86.h" 1
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:164:1: error: unexpected token at start of statement
/0 "" 2
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:166:1: error: unexpected token at start of statement
/NO_APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:170:2: error: instruction requires: Not 64-bit mode
popl %ebx
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:172:2: error: instruction requires: Not 64-bit mode
popl %edi
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:174:2: error: instruction requires: Not 64-bit mode
popl %ebp
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:181:2: error: unknown directive
.size readsect, .-readsect
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:183:2: error: unknown directive
.type readseg, @function
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:189:2: error: instruction requires: Not 64-bit mode
pushl %ebp
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:196:2: error: instruction requires: Not 64-bit mode
pushl %edi
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:197:2: error: instruction requires: Not 64-bit mode
pushl %esi
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:198:2: error: instruction requires: Not 64-bit mode
pushl %ebx
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:222:2: error: instruction requires: Not 64-bit mode
pushl %esi
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:223:2: error: instruction requires: Not 64-bit mode
pushl %ebx
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:237:2: error: instruction requires: Not 64-bit mode
popl %ebx
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:240:2: error: instruction requires: Not 64-bit mode
popl %esi
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:243:2: error: instruction requires: Not 64-bit mode
popl %edi
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:246:2: error: instruction requires: Not 64-bit mode
popl %ebp
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:253:2: error: unknown directive
.size readseg, .-readseg
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:255:2: error: unknown directive
.type bootmain, @function
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:260:2: error: instruction requires: Not 64-bit mode
pushl %ebp
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:267:2: error: instruction requires: Not 64-bit mode
pushl %edi
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:268:2: error: instruction requires: Not 64-bit mode
pushl %esi
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:269:2: error: instruction requires: Not 64-bit mode
pushl %ebx
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:276:2: error: instruction requires: Not 64-bit mode
pushl $0
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:277:2: error: instruction requires: Not 64-bit mode
pushl $4096
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:278:2: error: instruction requires: Not 64-bit mode
pushl $65536
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:288:2: error: instruction requires: Not 64-bit mode
popl %ebx
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:291:2: error: instruction requires: Not 64-bit mode
popl %esi
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:293:2: error: instruction requires: Not 64-bit mode
popl %edi
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:295:2: error: instruction requires: Not 64-bit mode
popl %ebp
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:333:2: error: instruction requires: Not 64-bit mode
pushl 4(%ebx)
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:334:2: error: instruction requires: Not 64-bit mode
pushl 16(%ebx)
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:335:2: error: instruction requires: Not 64-bit mode
pushl %edi
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:354:1: error: unexpected token at start of statement
/APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:355:1: error: unexpected token at start of statement
/45 "x86.h" 1
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:357:1: error: unexpected token at start of statement
/0 "" 2
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:359:1: error: unexpected token at start of statement
/NO_APP
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:365:2: error: unknown directive
.size bootmain, .-bootmain
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:369:11: error: mach-o section specifier uses an unknown section type
.section .debug_info,"",@progbits
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:993:11: error: mach-o section specifier uses an unknown section type
.section .debug_abbrev,"",@progbits
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:1454:11: error: mach-o section specifier uses an unknown section type
.section .debug_loc,"",@progbits
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:1785:11: error: mach-o section specifier uses an unknown section type
.section .debug_aranges,"",@progbits
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:1797:11: error: mach-o section specifier uses an unknown section type
.section .debug_line,"",@progbits
^
/var/folders/nc/w_y2cp4j4jx2vz4w_1rjy_kh0000gn/T//cc8pMjCq.s:1799:11: error: mach-o section specifier uses an unknown section type
.section .debug_str,"MS",@progbits,1
^
make: *** [bootblock] Error 1
我有很多搜索博客,沒有人有這個問題。 我使用MAC OS X EI Capitan(10.11.3)
我也有這個問題,但發現簡單地啓動一個Ubuntu VM要容易得多。 – Turtle