当我在“类 os”中调用自定义成员函数时,JVM 9 中的“未定义引用”错误

晴空塔

我正在破解JVM9 源代码,尤其是class os部分.

我想做的是:

(1) 添加一个static intnamed数组gc_tid[64]来存储一些线程id信息。

(2)加一个static int nr_gc_tid;来统计上面的线程数

所以,我只在class os 这里添加了另外两个成员,类似于之前的变量成员static size_t _page_sizes[page_sizes_max];

(我在这里所做的一切都是为了模仿_page_sizes中的声明方式os.hpp

class os: AllStatic {
    public:
    ...
    static int  gc_tid[64];
    static int nr_gc_tid;
    ...
};

我也有做两件事的初始化nr_gc_tidgc_tid[64]

所以,我这里写了一个static void init_gc_tid(void)in作为成员函数。hotspot/src/share/vm/runtime/os.hpp public

static void init_gc_tid(void);

然后,我init_gc_tid(void)hotspot/src/os/linux/vm/os_linux.cpp之前定义了这个函数void os::init(void)(我在这里所做的一切都是为了模仿如何os::init(void)在 中声明os.hpp,并在 中定义os_linux.cpp

void os::init_gc_tid(void){
  //step 1: init nr_gctid as 0
  nr_gc_tid = 0;
  //step 2: init all gc tid as -100
  int i = 0;
  for(i = 0; i < 64; ++i){
    gc_tid[i] = -100;
  }
}

最后,我here之后调用我的init_gc_tid函数os::init(void)init_page_sizes((size_t) Linux::page_size());

但它不起作用。当我make的JVM9项目。我收到类似的错误

Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Compiling 11 properties into resource bundles for java.logging
Compiling 3 files for COMPILE_CREATE_SYMBOLS
Compiling 11 properties into resource bundles for jdk.management.agent
Compiling 3 properties into resource bundles for jdk.jdi
Compiling 2 files for BUILD_BREAKITERATOR_BASE
Compiling 11 properties into resource bundles for jdk.jartool
Compiling 2 files for BUILD_BREAKITERATOR_LD
Compiling 4 properties into resource bundles for jdk.jlink
Compiling 3 properties into resource bundles for jdk.jlink
Compiling 1 properties into resource bundles for jdk.jlink
Compiling 224 properties into resource bundles for jdk.localedata
Creating buildtools/jdk.vm.compiler.replacements.verifier.jar
Compiling 6 properties into resource bundles for java.base
Compiling 11 properties into resource bundles for java.base
Creating ct.sym classes
Creating buildtools/jdk.vm.compiler.match.processor.jar
Creating support/symbols/ct.sym
Compiling 100 properties into resource bundles for java.desktop
Compiling 2897 files for java.base
/home/wxf/sandboxJDK/9jdk/build/linux-x86_64-normal-server-slowdebug/hotspot/variant-server/libjvm/objs/os_linux.o: In function `os::init_gc_tid()':
/home/wxf/sandboxJDK/9jdk/hotspot/src/os/linux/vm/os_linux.cpp:4726: undefined reference to `os::nr_gc_tid'
/home/wxf/sandboxJDK/9jdk/hotspot/src/os/linux/vm/os_linux.cpp:4730: undefined reference to `os::gc_tid'
collect2: error: ld returned 1 exit status
make[3]: *** [/home/wxf/sandboxJDK/9jdk/build/linux-x86_64-normal-server-slowdebug/support/modules_libs/java.base/server/libjvm.so] Error 1
lib/CompileJvm.gmk:207: recipe for target '/home/wxf/sandboxJDK/9jdk/build/linux-x86_64-normal-server-slowdebug/support/modules_libs/java.base/server/libjvm.so' failed
make[3]: *** Waiting for unfinished jobs....
/home/wxf/sandboxJDK/9jdk/build/linux-x86_64-normal-server-slowdebug/hotspot/variant-server/libjvm/objs/os_linux.o: In function `os::init_gc_tid()':
/home/wxf/sandboxJDK/9jdk/hotspot/src/os/linux/vm/os_linux.cpp:4726: undefined reference to `os::nr_gc_tid'
/home/wxf/sandboxJDK/9jdk/hotspot/src/os/linux/vm/os_linux.cpp:4730: undefined reference to `os::gc_tid'
collect2: error: ld returned 1 exit status
lib/CompileGtest.gmk:64: recipe for target '/home/wxf/sandboxJDK/9jdk/build/linux-x86_64-normal-server-slowdebug/hotspot/variant-server/libjvm/gtest/libjvm.so' failed
make[3]: *** [/home/wxf/sandboxJDK/9jdk/build/linux-x86_64-normal-server-slowdebug/hotspot/variant-server/libjvm/gtest/libjvm.so] Error 1
make/Main.gmk:263: recipe for target 'hotspot-server-libs' failed
make[2]: *** [hotspot-server-libs] Error 2
make[2]: *** Waiting for unfinished jobs....

ERROR: Build failed for target 'default (exploded-image)' in configuration 'linux-x86_64-normal-server-slowdebug' (exit code 2) 
Stopping sjavac server

=== Output from failing command(s) repeated here ===
* For target hotspot_variant-server_libjvm_gtest_objs_BUILD_GTEST_LIBJVM_link:
/home/wxf/sandboxJDK/9jdk/build/linux-x86_64-normal-server-slowdebug/hotspot/variant-server/libjvm/objs/os_linux.o: In function `os::init_gc_tid()':
/home/wxf/sandboxJDK/9jdk/hotspot/src/os/linux/vm/os_linux.cpp:4726: undefined reference to `os::nr_gc_tid'
/home/wxf/sandboxJDK/9jdk/hotspot/src/os/linux/vm/os_linux.cpp:4730: undefined reference to `os::gc_tid'
collect2: error: ld returned 1 exit status
* For target hotspot_variant-server_libjvm_objs_BUILD_LIBJVM_link:
/home/wxf/sandboxJDK/9jdk/build/linux-x86_64-normal-server-slowdebug/hotspot/variant-server/libjvm/objs/os_linux.o: In function `os::init_gc_tid()':
/home/wxf/sandboxJDK/9jdk/hotspot/src/os/linux/vm/os_linux.cpp:4726: undefined reference to `os::nr_gc_tid'
/home/wxf/sandboxJDK/9jdk/hotspot/src/os/linux/vm/os_linux.cpp:4730: undefined reference to `os::gc_tid'
collect2: error: ld returned 1 exit status

* All command lines available in /home/wxf/sandboxJDK/9jdk/build/linux-x86_64-normal-server-slowdebug/make-support/failure-logs.
=== End of repeated output ===

=== Make failed targets repeated here ===
lib/CompileJvm.gmk:207: recipe for target '/home/wxf/sandboxJDK/9jdk/build/linux-x86_64-normal-server-slowdebug/support/modules_libs/java.base/server/libjvm.so' failed
lib/CompileGtest.gmk:64: recipe for target '/home/wxf/sandboxJDK/9jdk/build/linux-x86_64-normal-server-slowdebug/hotspot/variant-server/libjvm/gtest/libjvm.so' failed
make/Main.gmk:263: recipe for target 'hotspot-server-libs' failed
=== End of repeated output ===

Hint: Try searching the build log for the name of the first failed target.
Hint: If caused by a warning, try configure --disable-warnings-as-errors.

/home/wxf/sandboxJDK/9jdk/make/Init.gmk:291: recipe for target 'main' failed
make[1]: *** [main] Error 2
/home/wxf/sandboxJDK/9jdk/make/Init.gmk:185: recipe for target 'default' failed
make: *** [default] Error 2

我突出显示错误部分:

对 `os::nr_gc_tid' 的未定义引用

对 `os::gc_tid' 的未定义引用

晴空塔

这篇文章有帮助,静态变量链接错误

添加

int os:: gc_tid[64];
int os:: nr_gc_tid;

os_linux.cpp文件的开头

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

我的代码中的C ++未定义引用错误?

当我从服务中调用函数时,“ this”是未定义的

C ++中对类成员的“未定义”引用

类c ++中的静态成员未定义引用

访问另一个插件中的类时出错(错误:未定义的引用)

我已经收到一个错误:“在main函数中:对Fraction :: Fraction()的未定义引用”

在我的C代码中收到2个错误,指出“未定义的引用”

当我使用一个类来定义绑定函数时,条目未定义错误显示

当我们引用非静态数据成员时,细分错误实际上是未定义的行为吗

错误:对类名::member_variable 的未定义引用

未定义对类的引用

调用类中未定义的函数

为什么我不断收到“未定义的引用”错误?

C ++对共享库中类的构造函数和析构函数的未定义引用错误

对纯抽象类中的方法的未定义引用

在继承的类中对运算符<<的未定义引用

当我创建自定义异常类时,如何使用提供的参数调用基本构造函数?

JavaScript类:构造函数中定义的成员未定义?

对类的静态成员的未定义引用

对静态类成员的未定义引用

TypeError:当我从导入的类[TypeScript]调用方法时,无法读取未定义的属性

致命错误:调用第9行中未定义的方法PDO :: select()

在函数中使用简单类时出现未定义的引用错误

对我的函数的未定义引用

对模板基类的成员函数的未定义引用

如何修复 Python 中的“未定义类名”错误?

NameError:类__init __()方法中的名称未定义错误

Python 错误:类中的全局变量未定义

Laravel中未定义的方法std类错误