无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站广告联系 微信:wuyouceo QQ:184822951
12
返回列表 发新帖
楼主: 求道者
打印 上一主题 下一主题

[求助] 问些wee菜单很怪的问题。

    [复制链接]
31#
 楼主| 发表于 2019-10-29 23:06:31 | 显示全部楼层
wintoflash 发表于 2019-10-29 22:57
这个和我编译grub4dos的时候遇到的错误一样.我不懂汇编,所以没办法了


这个能搞定的话,应该能连同grub4dos一起迁移到gcc9吧……

yaya救命啊
回复

使用道具 举报

32#
 楼主| 发表于 2019-10-30 21:02:22 | 显示全部楼层
不点 发表于 2019-10-30 10:17
贴出 248 行以及 375 行附近的代码看看,汇编代码的错误,应该有办法解决。

忽然想起来了,可能没法 ...

248行和附近
  1. /* begin characteristics distinguish this sector from others */
  2.     .byte    0x8E, 0xDB        //movw    %bx, %ds
  3.     .byte    0x68, 0xE0, 0x07    //pushw    $0x07E0
  4.     .byte    0x07            //popw    %es    /* ES=0x07E0 */

  5.     //cmpl    $0xCE1A02B0, (wee63_signature - _start1 + 4 + STAGE2_SIZE - 4)
  6.     .byte    0x66, 0x81, 0x3E    //cmpl
  7.     .word    (wee63_signature - _start1 + STAGE2_SIZE)
  8.                 //this word is a pointer to the bootlace
  9.                 //signature near the end of pre_stage2
  10.                 //this word varies according to STAGE2_SIZE.
  11.     .byte    0xB0, 0x02, 0x1A, 0xCE    //this is the bootlace signature.
  12.                     //it should also appear at near the end
  13.                     //of pre_stage2
  14. /* end characteristics distinguish this sector from others */
复制代码


375行和附近
  1.         movb        $0x80, %dl        /* try hard drive first */
  2. 1:
  3.         xorl        %eax, %eax
  4.         pushaw
  5.         pushl        %eax
  6.         pushl        %eax
  7.         pushw        %es
  8.         pushw        %ax
  9.         pushw        $127        //$63
  10.         pushw        $0x10
  11.         movw        %sp, %si        /* DS:SI=SS:SP=disk address packet */
  12.         movw        $0x4200, %ax
  13.         call        int13
  14.         popaw
  15.         popaw

  16.         /* compare the sector to the MBR, ignoring BPB */

  17.         movw        $0x5A, %si
  18.         movw        %si, %di
  19.         movw        $((0x200 - 0x5A) / 2), %cx
  20.         cs repz cmpsw
  21.         je        1f
  22.         testb        %dl, %dl        /* floppy tried? */
  23.         je        Error_or_prev_MBR        /* yes. fail */
  24.         movb        $0, %dl                /* then try floppy */
  25.         jmp        1b
  26. 1:

  27.         movw        %es, %bx
  28.         addw        $((wee63_signature - _start1 + 4 + STAGE2_SIZE - 4) >> 4), %bx
  29.         movw        %bx, %ds

  30.         cmpl        $0xCE1A02B0, ((STAGE2_SIZE - 4) & 0x0F)
  31.         jne        Error_or_prev_MBR        /* Missing helper */
  32. 2:
  33.         ljmp        $0, $0x8200
复制代码

点评

这个已经说过了,是新版 gcc 编译的二进制结果体积太大导致的,无解。就是 STAGE2_SIZE 超级大,很多 M 字节。你的编译过程中,应该出现这个超级大的中间结果文件,那就是新版 gcc 编译出的中间结果文件。  详情 回复 发表于 2019-10-31 02:19
回复

使用道具 举报

33#
 楼主| 发表于 2019-10-30 21:12:44 | 显示全部楼层
不点 发表于 2019-10-30 10:17
贴出 248 行以及 375 行附近的代码看看,汇编代码的错误,应该有办法解决。

忽然想起来了,可能没法 ...

clang编译 报这个错
  1. clang -m32 -mno-sse -g  -c asm.S -o ./asm.o
  2. asm.S:7618:5: error: invalid operand for instruction
  3. cs lodsb
  4.     ^~~~~
  5. asm.S:7627:5: error: invalid operand for instruction
  6. cs lodsb
  7.     ^~~~~
  8. asm.S:8566:15: error: unexpected token in argument list
  9. addr32 loopz 1b
  10.               ^
  11. make: *** [Makefile:66:asm.o] 错误 1
复制代码

点评

clang 的汇编器可能不支持前缀 cs 和 addr32 等。解决办法: 把 cs lodsb 写成两行: .byte 0x2E // 手动编码前缀 cs lodsb 同理,把 addr32 loopz 1b 也写成两行: .byte 0x67 // 手动编码  详情 回复 发表于 2019-10-31 02:40
回复

使用道具 举报

34#
 楼主| 发表于 2019-10-31 13:00:01 | 显示全部楼层
本帖最后由 求道者 于 2019-10-31 13:01 编辑
不点 发表于 2019-10-31 02:40
clang 的汇编器可能不支持前缀 cs 和 addr32 等。解决办法:

把 cs lodsb 写成两行:

  1. make
  2. make WEE127=1 BUILDIDUNSUPPORTTED=0 wee127/wee63.mbr
  3. make[1]: 进入目录“/home/daiaji/grubutils/grubutils/wee”
  4. clang -m32 -mno-sse -g -DMBRSECTORS127 -c asm.S -o wee127/asm.o
  5. asm.S:4218:12: error: unknown token in expression
  6. lcall %cs:*(ROM_int15 - int13_handler)
  7.            ^
  8. asm.S:5708:12: error: unknown token in expression
  9. lcall %cs:*(ROM_int15 - int13_handler)
  10.            ^
  11. asm.S:5789:11: error: unknown token in expression
  12. ljmp %cs:*(ROM_int15 - int13_handler)
  13.           ^
  14. asm.S:5835:11: error: unknown token in expression
  15. ljmp %cs:*(ROM_int15 - int13_handler)
  16.           ^
  17. asm.S:5872:12: error: unknown token in expression
  18. lcall %cs:*(ROM_int15 - int13_handler)
  19.            ^
  20. asm.S:6042:12: error: unknown token in expression
  21. lcall %cs:*(ROM_int15 - int13_handler)
  22.            ^
  23. asm.S:6169:11: error: unknown token in expression
  24. ljmp %cs:*(ROM_int15 - int13_handler)
  25.           ^
  26. make[1]: *** [Makefile:66:wee127/asm.o] 错误 1
  27. make[1]: 离开目录“/home/daiaji/grubutils/grubutils/wee”
  28. make: *** [Makefile:55:wee127/wee63.mbr] 错误 2
复制代码
而且clang不支持-mpreferred-stack-boundary=2

点评

这次的错误其实只有一个:都是不认识 %cs:*(ROM_int15 - int13_handler) 这很容易搞。试试两个办法,其一,试试去掉星号,看看能否通过。其二,那就得手动替它汇编了。手动汇编还得查阅 intel 相关指令手册。你就  详情 回复 发表于 2019-10-31 15:08
回复

使用道具 举报

35#
 楼主| 发表于 2019-10-31 18:42:41 | 显示全部楼层
本帖最后由 求道者 于 2019-10-31 18:56 编辑
不点 发表于 2019-10-31 15:08
这次的错误其实只有一个:都是不认识 %cs:*(ROM_int15 - int13_handler)

这很容易搞。试试两个办法, ...
  1. asm.S:4218:2: error: unknown use of instruction mnemonic without a size suffix
  2. lcall %cs:(ROM_int15 - int13_handler)
  3. ^
  4. asm.S:5708:2: error: unknown use of instruction mnemonic without a size suffix
  5. lcall %cs:(ROM_int15 - int13_handler)
  6. ^
复制代码
似乎是编译失败……
但我不不知道产物去哪了……

并没有wee127/asm.o
回复

使用道具 举报

36#
 楼主| 发表于 2019-10-31 19:23:56 | 显示全部楼层
本帖最后由 求道者 于 2019-10-31 19:29 编辑
不点 发表于 2019-10-31 19:01
说明去掉星号起作用了。它还要求精确的字宽后缀。给指令添加w后缀试试。w代表 word,即 16 位宽度。

就 ...
  1. make
  2. make WEE127=1 BUILDIDUNSUPPORTTED=0 wee127/wee63.mbr
  3. make[1]: 进入目录“/home/daiaji/grubutils/grubutils/wee”
  4. clang -m32 -mno-sse -g -DMBRSECTORS127 -c asm.S -o wee127/asm.o
  5. asm.S:4218:9: error: invalid operand for instruction
  6. lcallw %cs:(ROM_int15 - int13_handler)
  7.         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. asm.S:5708:9: error: invalid operand for instruction
  9. lcallw %cs:(ROM_int15 - int13_handler)
  10.         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11. asm.S:5789:8: error: invalid operand for instruction
  12. ljmpw %cs:(ROM_int15 - int13_handler)
  13.        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  14. asm.S:5835:8: error: invalid operand for instruction
  15. ljmpw %cs:(ROM_int15 - int13_handler)
  16.        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  17. asm.S:5872:9: error: invalid operand for instruction
  18. lcallw %cs:(ROM_int15 - int13_handler)
  19.         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  20. asm.S:6042:9: error: invalid operand for instruction
  21. lcallw %cs:(ROM_int15 - int13_handler)
  22.         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. asm.S:6169:8: error: invalid operand for instruction
  24. ljmpw %cs:(ROM_int15 - int13_handler)
  25.        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  26. make[1]: *** [Makefile:66:wee127/asm.o] 错误 1
  27. make[1]: 离开目录“/home/daiaji/grubutils/grubutils/wee”
  28. make: *** [Makefile:55:wee127/wee63.mbr] 错误 2
复制代码

回复

使用道具 举报

37#
 楼主| 发表于 2019-10-31 20:03:01 | 显示全部楼层
不点 发表于 2019-10-31 19:57
这次报操作数错误。试试去掉%cs:,在指令前面插入一行 .byte 0x2E

make
make WEE127=1 BUILDIDUNSUPPORTTED=0 wee127/wee63.mbr
make[1]: 进入目录“/home/daiaji/grubutils/grubutils/wee”
clang -m32 -mno-sse -g -DMBRSECTORS127 -c asm.S -o wee127/asm.o
asm.S:4220:9: error: invalid operand for instruction
lcallw (ROM_int15 - int13_handler)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
回复

使用道具 举报

38#
 楼主| 发表于 2019-10-31 20:45:16 | 显示全部楼层
不点 发表于 2019-10-31 20:29
添加星号试试
lcallw *(ROM_int15 - int13_handler)

-rw-r--r-- 1 daiaji daiaji 126M 10月 31 20:44 wee127.mbr
-rw-r--r-- 1 daiaji daiaji 126M 10月 31 20:44 wee63.mbr
能编译但是产物非常大
代码我改成这样了

  1.          .byte 0x2E
  2.         lcallw        *(EXT_C(ROM_int15) - int13_handler)

  3.         .byte 0x2E
  4.         ljmpw        *(EXT_C(ROM_int15) - int13_handler)
复制代码

回复

使用道具 举报

39#
 楼主| 发表于 2019-10-31 21:34:22 | 显示全部楼层
本帖最后由 求道者 于 2019-10-31 21:35 编辑
不点 发表于 2019-10-31 21:08
这么大的文件,是错的。我猜可能是操作系统底层更改造成的。算了,不折腾了。安心用旧版 gcc 编译吧。


前面汇编代码部分似乎被充了很多零,然后菜单前面有100M多的零.
可能是填充出了问题,gcc是对的。

点评

跟踪 Makefile 的执行过程,可以了解究竟是哪个步骤增大了体积。  详情 回复 发表于 2019-10-31 21:40
回复

使用道具 举报

40#
 楼主| 发表于 2019-10-31 21:44:14 | 显示全部楼层
不点 发表于 2019-10-31 21:40
跟踪 Makefile 的执行过程,可以了解究竟是哪个步骤增大了体积。

pre_stage2 非常大
这不正常吧?
回复

使用道具 举报

41#
 楼主| 发表于 2019-10-31 22:43:11 | 显示全部楼层
本帖最后由 求道者 于 2019-10-31 22:47 编辑
不点 发表于 2019-10-31 22:26
这个 pre_stage2 是 gcc 生成的,是编译过程生成的。情况与 grub4dos 一样,无解了。老老实实用旧版 gcc 吧 ...


好消息恐怕是,两者的迁移经验应该是差不多的,未来也许能完成迁移……
谁知道这东西是怎么生成的?

点评

我个人感觉,折腾 gcc 的意义不大。我也不想研究,究竟是 bin-utils 的原因呢,还是 gcc 的原因,拟或是别的什么原因(比如 Linux 内核的原因)。整个 Linux 内核连同 GNU 工具链,都不可靠,而且是越来越不可靠。  详情 回复 发表于 2019-11-1 17:05
回复

使用道具 举报

42#
 楼主| 发表于 2019-11-1 18:19:39 | 显示全部楼层
不点 发表于 2019-11-1 17:05
我个人感觉,折腾 gcc 的意义不大。我也不想研究,究竟是 bin-utils 的原因呢,还是 gcc 的原因,拟或是 ...

你这完完全全就是不符合客观事实的臆测了!
事实就是gcc起码直接告诉你就是pre_stage2生成的有问题!
clang还有一堆汇编方法不支持,要手动汇编!最后pre_stage2还是很大!
没错,clang是没怎么报警告,但这只是说明clang习惯宽松的语法检测!或者干脆不报!
这不能说明clang更好,更先进!

clang还浪费了一堆时间!

感觉顶多就是语法变了!
搞不好还是c的问题!
回复

使用道具 举报

43#
 楼主| 发表于 2019-11-1 18:43:36 | 显示全部楼层
  1. gcc -m32 -mno-sse -g -o 1.bin -nostdlib -Wl,-N -Wl,-Ttext -Wl,308200 -Wl,-N -Wl,--build-id=none ./asm.o ./builtins.o ./disk_io.o ./fsys_ext2fs.o ./fsys_fat.o ./fsys_ntfs.o

  2. ls -alh 1.bin
  3. -rwxr-xr-x 1 daiaji daiaji 122K 11月  1 18:41 1.bin

  4. objcopy -O binary 1.bin

  5. ls -alh 1.bin         
  6. -rwxr-xr-x 1 daiaji daiaji 126M 11月  1 18:41 1.bin
复制代码


我个人的一点点进展
不知道为什么objcopy -O binary之后体积变大
我不知道objcopy -O binary是怎么工作的……

点评

我不懂,所以,臆测一下,也很自然。谁懂,谁就多劳啊! 你这不已经很有成效了吗?发现 objcopy 使得体积变大。抱歉,对这些,我又是完全不懂。 让懂的人来帮你,或者,你自己查资料搞定。  详情 回复 发表于 2019-11-1 20:14
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-5-5 12:18

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表