下载
中文
注册

构建QEMU时出现报错“undefined reference to 'stime'”

问题描述

构建QEMU时出现如下报错“undefined reference to 'stime'”。

/usr/bin/ld: linux-user/syscall.o: in function `do_syscall1':
/root/test/qemu-4.1.0/linux-user/syscall.c:7660: undefined reference to 'stime'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:209: qemu-ppc64abi32] Error 1
make: *** [Makefile:472: ppc64abi32-linux-user/all] Error 2
/root/test/qemu-4.1.0/target/arm/pauth_helper.c: In function 'pauth_original_ptr':
/root/test/qemu-4.1.0/target/arm/pauth_helper.c:321:17: note: parameter passing for argument of type 'ARMVAParameters' {aka 'struct ARMVAParameters'} changed in GCC 9.1
  321 | static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param)
      |                 ^~~~~~~~~~~~~~~~~~
/usr/bin/ld: linux-user/syscall.o: in function 'do_syscall1':
/root/test/qemu-4.1.0/linux-user/syscall.c:7660: undefined reference to 'stime'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:209: qemu-ppc64] Error 1
make: *** [Makefile:472: ppc64-linux-user/all] Error 2

解决方案

修改配置文件“./linux-user/syscall.c”。

  1. 执行如下命令,打开配置文件“./linux-user/syscall.c”。

    vim ./linux-user/syscall.c

  2. 修改TARGET_NR_stime函数。

    修改前的代码如下。

    #ifdef TARGET_NR_stime /* not on alpha */
           case TARGET_NR_stime:
                 {
                      time_t host_time;
                      if (get_user_sal(host_time, argl))
                           return -TARGET_EFAULT;
                      return get_errno(stime(&host_time));
                 }
    #endif
    修改后的代码段如下加粗字体标注。
    #ifdef TARGET_NR_stime /* not on alpha */
           case TARGET_NR_stime:
                 {
                      time_t host_time;
                      if (get_user_sal(host_time, argl))
                           return -TARGET_EFAULT;
                    struct timespec res;
                    res.tv_sec = host_time;
                    return get_errno(clock_settime(CLOCK_REALTIME, &res));
                 }
    #endif