我试图在我的x86-64 Linux中编译Rasta Ring0 Debugger版本0.3,它是一个Linux内核模块。我已经使用Vim正则表达式替换了我的问题How to convert Linux 32-bit gcc inline assembly to 64-bit code?中解释的使用64位汇编的32位内联汇编,并且gcc没有给出语法错误。但是我还有其他一些错误。
我的电脑是配备Intel Core i7-2760QM的联想W520笔记本电脑,我使用的是Debian GNU / Linux Wheezy。
这些是$ make >make_output.txt 2>&1
make -C /lib/modules/`uname -r`/build/ SUBDIRS=`pwd` modules
make[1]: Entering directory `/usr/src/linux-3.5.4'
/usr/src/linux-3.5.4/arch/x86/Makefile:96: CONFIG_X86_X32 enabled but no binutils support
CC [M] /home/user/code/rr0d/0.3/module_nux.o
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/breakpoint.o
/home/user/code/rr0d/0.3/breakpoint.c: In function ‘insert_bp’:
/home/user/code/rr0d/0.3/breakpoint.c:66:24: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
首先,CONFIG_X86_X32 enabled but no binutils support
。但在我的自定义内核.config
中,很明显它是一个64位系统:
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86_64 3.5.4 Kernel Configuration
#
CONFIG_64BIT=y
# CONFIG_X86_32 is not set
CONFIG_X86_64=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_OUTPUT_FORMAT="elf64-x86-64"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
其次,$ make >make_output.txt 2>&1
输出中有一行:
/bin/sh: 1: nobjdump: not found
显然,没有nobjdump
这样的程序,它应该是objdump
。这n
可能来自哪里?以后ld
也会以nld
的形式出现同样的错误。这个错误可能产生的任何想法都可以解决吗?
Makefile
如下:
# EXTRA_CFLAGS += -O2 -Wall -DLINUX_26
EXTRA_CFLAGS += -O2 -Wall -DLINUX_26 -m64
OBJ := module_nux.o breakpoint.o buffering.o command.o disasmbak.o idt.o
OBJ += keyboard.o page.o video.o utils.o import_symb.o core_rr0d.o pci.o
MODULE := rr0d.o
obj-m := $(MODULE)
rr0d-objs := $(OBJ)
default:
make -C /lib/modules/`uname -r`/build/ SUBDIRS=`pwd` modules
clean:
rm -f *.o .*.o.cmd .*.ko.cmd *.mod.c *~
rm -rf .tmp_versions
mrproper:
make clean
rm -f *.ko
在Makefile
我向-m64
添加了EXTRA_FLAGS
,但未更改make
输出。
在输出结束时(下面的整个输出),还有三个与上面相同类型的错误:
/bin/sh: 1: nobjdump: not found
/bin/sh: 1: nobjdump: not found
/bin/sh: 1: nld: not found
显然,不应该有3个n
个字母。可能这与Rasta Ring0调试器无关,因为在尝试编译'parrot' sample device driver for Linux 2.6 and 3.0时我也遇到了相同的错误。
那么,任何想法如何解决这些编译错误?谷歌搜索了几天没有帮助,我完全没有想法。
这是整个$ make >make_output.txt 2>&1
输出(包括上面已经显示的8行):
make -C /lib/modules/`uname -r`/build/ SUBDIRS=`pwd` modules
make[1]: Entering directory `/usr/src/linux-3.5.4'
/usr/src/linux-3.5.4/arch/x86/Makefile:96: CONFIG_X86_X32 enabled but no binutils support
CC [M] /home/user/code/rr0d/0.3/module_nux.o
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/breakpoint.o
/home/user/code/rr0d/0.3/breakpoint.c: In function ‘insert_bp’:
/home/user/code/rr0d/0.3/breakpoint.c:66:24: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/breakpoint.c:74:19: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/breakpoint.c:80:33: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/breakpoint.c:81:46: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/breakpoint.c: In function ‘is_breakpoint’:
/home/user/code/rr0d/0.3/breakpoint.c:127:30: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/breakpoint.c: In function ‘parse_inst’:
/home/user/code/rr0d/0.3/breakpoint.c:310:28: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/breakpoint.c:312:19: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/breakpoint.c: In function ‘is_hw_breakpoint’:
/home/user/code/rr0d/0.3/breakpoint.c:600:40: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/buffering.o
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/command.o
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/disasmbak.o
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/idt.o
/home/user/code/rr0d/0.3/idt.c: In function ‘translate_logic_to_linear’:
/home/user/code/rr0d/0.3/idt.c:92:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/idt.c: In function ‘visualise_idt’:
/home/user/code/rr0d/0.3/idt.c:157:1: warning: the frame size of 2064 bytes is larger than 2048 bytes [-Wframe-larger-than=]
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/keyboard.o
/home/user/code/rr0d/0.3/keyboard.c: In function ‘back_disasm’:
/home/user/code/rr0d/0.3/keyboard.c:500:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/keyboard.c:511:27: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/keyboard.c: In function ‘handle_scancode’:
/home/user/code/rr0d/0.3/keyboard.c:784:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/keyboard.c:839:55: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/keyboard.c:1230:24: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/keyboard.c:1245:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/keyboard.c:1250:43: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/page.o
/home/user/code/rr0d/0.3/page.c: In function ‘basetp’:
/home/user/code/rr0d/0.3/page.c:68:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/page.c: In function ‘get_page_info’:
/home/user/code/rr0d/0.3/page.c:190:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/page.c:193:23: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/page.c: In function ‘write_save_dirty’:
/home/user/code/rr0d/0.3/page.c:355:33: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/page.c:359:17: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/page.c: In function ‘poked1’:
/home/user/code/rr0d/0.3/page.c:405:49: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/page.c:434:33: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/page.c:447:17: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/page.c:472:17: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/video.o
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/utils.o
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/import_symb.o
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/core_rr0d.o
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘printf_disasm’:
/home/user/code/rr0d/0.3/core_rr0d.c:314:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:318:53: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:319:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:344:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:358:44: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:393:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:417:11: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘dump_data’:
/home/user/code/rr0d/0.3/core_rr0d.c:457:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:459:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:464:53: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:465:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘_kbdhandle’:
/home/user/code/rr0d/0.3/core_rr0d.c:817:41: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:824:45: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: At top level:
/home/user/code/rr0d/0.3/core_rr0d.c:841:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘kbdhandle’:
/home/user/code/rr0d/0.3/core_rr0d.c:845:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘step_by_step’:
/home/user/code/rr0d/0.3/core_rr0d.c:1041:44: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1063:49: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: At top level:
/home/user/code/rr0d/0.3/core_rr0d.c:1181:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘int0_handle’:
/home/user/code/rr0d/0.3/core_rr0d.c:1185:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: At top level:
/home/user/code/rr0d/0.3/core_rr0d.c:1366:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘int1_handle’:
/home/user/code/rr0d/0.3/core_rr0d.c:1370:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘_int3_handle’:
/home/user/code/rr0d/0.3/core_rr0d.c:1430:30: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: At top level:
/home/user/code/rr0d/0.3/core_rr0d.c:1495:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘int3_handle’:
/home/user/code/rr0d/0.3/core_rr0d.c:1499:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: At top level:
/home/user/code/rr0d/0.3/core_rr0d.c:1540:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘int6_handle’:
/home/user/code/rr0d/0.3/core_rr0d.c:1544:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: At top level:
/home/user/code/rr0d/0.3/core_rr0d.c:1586:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘int13_handle’:
/home/user/code/rr0d/0.3/core_rr0d.c:1589:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘_int14_handle’:
/home/user/code/rr0d/0.3/core_rr0d.c:1605:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1606:36: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: At top level:
/home/user/code/rr0d/0.3/core_rr0d.c:1648:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘int14_handle’:
/home/user/code/rr0d/0.3/core_rr0d.c:1651:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘_int128_handle’:
/home/user/code/rr0d/0.3/core_rr0d.c:1664:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1665:36: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: At top level:
/home/user/code/rr0d/0.3/core_rr0d.c:1687:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘int128_handle’:
/home/user/code/rr0d/0.3/core_rr0d.c:1691:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘init_rr0d’:
/home/user/code/rr0d/0.3/core_rr0d.c:1791:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1794:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1846:18: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1848:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1849:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1850:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1851:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1852:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1853:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1854:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/home/user/code/rr0d/0.3/core_rr0d.c:1869:49: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/user/code/rr0d/0.3/core_rr0d.c: In function ‘cleanup_rr0d’:
/home/user/code/rr0d/0.3/core_rr0d.c:1938:36: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/bin/sh: 1: nobjdump: not found
CC [M] /home/user/code/rr0d/0.3/pci.o
/bin/sh: 1: nobjdump: not found
LD [M] /home/user/code/rr0d/0.3/rr0d.o
/bin/sh: 1: nld: not found
make[2]: *** [/home/user/code/rr0d/0.3/rr0d.o] Error 127
make[1]: *** [_module_/home/user/code/rr0d/0.3] Error 2
make[1]: Leaving directory `/usr/src/linux-3.5.4'
make: *** [default] Error 2
答案 0 :(得分:3)
安装binutils并尝试删除驱动程序路径中的空格。查看完整的详细信息:
答案 1 :(得分:2)
如果binutils
签入,则会显示此警告
/usr/src/linux-headers-*-common/arch/x86/Makefile
失败:
ifdef CONFIG_X86_X32
x32_ld_ok := $(call try-run,\
/bin/echo -e '1: .quad 1b' | \
$(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \
$(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMPO" && \
$(LD) -m elf32_x86_64 "$$TMPO" -o "$$TMP",y,n)
ifeq ($(x32_ld_ok),y)
CONFIG_X86_X32_ABI := y
KBUILD_AFLAGS += -DCONFIG_X86_X32_ABI
KBUILD_CFLAGS += -DCONFIG_X86_X32_ABI
else
$(warning CONFIG_X86_X32 enabled but no binutils support)
endif
endif
如果binutils
程序集编译没有成功,则失败。
可以手动检查上面的命令(可执行文件和标志可能不同):
CC=gcc-6
KBUILD_AFLAGS="-D__ASSEMBLY__ -m64"
OBJCOPY=objcopy
LD=ld
TMP=/tmp/dummytmp.tmp
TMPO=/tmp/dummyo.o
/bin/echo -e '1: .quad 1b' | \
$CC $KBUILD_AFLAGS -c -x assembler -o "$$TMP" - && \
$OBJCOPY -O elf32-x86-64 "$$TMP" "$$TMPO" && \
$LD -m elf32_x86_64 "$$TMPO" -o "$$TMP"
Debian(可能还有Ubuntu)用户可以检查系统完整性:
debsums -s
重新安装损坏的包裹:
apt-get install --reinstall <space separated packages>
答案 2 :(得分:1)
在解决了这两个问题后回答自己,第一个是Banthar,第二个是我自己。
第一个问题是CONFIG_X86_32
和CONFIG_X86_X32
是两个不同的变量。 CONFIG_X86_X32
(64位模式的x32 ABI)必须设置为N
才能解决与binutils
支持相关的问题。
另一个问题是nobjdump
和nld
:
/bin/sh: 1: nobjdump: not found
/bin/sh: 1: nld: not found
这可以通过符号链接轻松修复:
$ su
# cd /usr/bin
# ln -s objdump nobjdump
# ln -s ld nld
答案 3 :(得分:0)
我不确定nobjdump: not found
,但是如果内核源目录属于CONFIG_X86_X32 enabled but no binutils support
并且您以非特权用户身份运行,则在某些情况下有可能获得root
。尝试sudo make
。
CONFIG_X86_X32 enabled but no binutils support
的另一个常见原因是编译目录中的空格,但这显然不是您要解决的问题。