c++ - C++ 中 undefined reference

标签 c++ c makefile gdb mips

我正在尝试将一个被黑的程序移植到 GDB-7.6.1。前面的在GDB-3.2.2下没问题。 然而,尽管我没有触及与这些宏定义变量相关的任何内容,但我遇到了一些编译错误。最重要的是,Makefile中的相关语句是相同的。但 objdump 显示它们在宏变量上是不同的。

配置后,编译器会报错

libsim.a(engine.o): In function `delayslot32':
/home/ruizhewu/work/gdb/gdb761-5-M3/gdb-7.6.1/lx-bcm-sc/sim/mips/../../../sim/mips/mips.igen:77: undefined reference to `SC_PRE_PROC_DELAY_SLOT'
/home/ruizhewu/work/gdb/gdb761-5-M3/gdb-7.6.1/lx-bcm-sc/sim/mips/../../../sim/mips/mips.igen:85: undefined reference to `SC_POST_PROC_DELAY_SLOT'


bash-3.2$ objdump -t libsim.a |less

........

support.o:     file format elf64-x86-64

SYMBOL TABLE:

000000000000021d g     F .text  00000000000000bd delayslot32
0000000000000000         *UND*  0000000000000000 SC_PRE_PROC_DELAY_SLOT


engine.o:     file format elf64-x86-64

SYMBOL TABLE:
000000000000d72f l     F .text  00000000000000bd delayslot32

...

...

...


0000000000000000         *UND*  0000000000000000 SC_PRE_PROC_DELAY_SLOT

之前的程序,engine.o只有delayslot32,但没有SC_PRE_PROC_DELAY_SLOT

mips.igen 代码是:

:function:::address_word:delayslot32:address_word target
{
  instruction_word delay_insn;
  SC_PRE_PROC_DELAY_SLOT(SD, CIA);
  sim_events_slip (SD, 1);
  DSPC = CIA;
  CIA = CIA + 4; /* NOTE not mips16 */
  STATE |= simDELAYSLOT;
  delay_insn = IMEM32 (CIA); /* NOTE not mips16 */
  idecode_issue (CPU_, delay_insn, (CIA));
  STATE &= ~simDELAYSLOT;
  SC_POST_PROC_DELAY_SLOT(SD);
  return target;
}

makefile实际上和gdb3.2.2下的程序是一样的:

sim/mips/Makefile:

semantics.o: sim-main.h scSupport.h adslExtension.h semantics.c $(SIM_EXTRA_DEPS)
engine.o: sim-main.h scSupport.h adslExtension.h engine.c $(SIM_EXTRA_DEPS)
support.o: sim-main.h support.c $(SIM_EXTRA_DEPS)
idecode.o: sim-main.h scSupport.h adslExtension.h idecode.c $(SIM_EXTRA_DEPS)
itable.o: sim-main.h itable.c $(SIM_EXTRA_DEPS)
scSupport.o: scSupport.h adslExtension.h scSupport.c $(SIM_EXTRA_DEPS)

编译器提示的 undefined variable 实际上是在其中定义的 scSupport.h

#define SC_PRE_PROC_DELAY_SLOT(sd, cia)         scEventEndOfInstExe(sd, cia)
#define SC_POST_PROC_DELAY_SLOT(sd)

最佳答案

对我来说,很明显,头文件 scSupport.h 没有包含在使用宏的文件之一中。或者宏是有条件定义的,但实际上并未设置。

找出发生这种情况的原因。

关于c++ - C++ 中 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21690346/

相关文章:

c++ - 如何在C++中将不同模板类型的对象相乘

c++ - 模板隐式实例化发生在使用之前

c++ - 涉及逻辑与 (&&) 的复杂表达式

c++ - 从 `boost::static-visitor` 派生以删除代码重复

c++ - 为什么 {} 一阶转换为 std::nullptr_t?

c - 如何修复C语言中的 "Conditional jump or move depends on uninitialised value(s)"错误

c - 缓存的 SSL session 是否包含以前的 X.509 证书信息?

perl - 如何使用 makefile/autoconf 制作可安装的 Perl 程序?

docker - 如何使用dockerfile RUN --mount挂载本地文件夹?

makefile - GNU makefile 中是否可以有多个 .PHONY 目标?