English 中文(简体)
为什么在编篡精子的变符号时,日落C++的编纂者改名?
原标题:Why does sun C++ compiler change symbol names when compiling with debug infos?

我有这一资料来源:

// ConstPointer.cpp
const short * const const_short_p_const = 0;
const short * const_short_p = 0;

(SUN C++ Compiler 5.10):

# CC ConstPointer.cpp -c -o ConstPointer.o
# CC -g ConstPointer.cpp -c -o ConstPointer-debug.o

此处为物体文档的编号, debug information:

# nm -C ConstPointer.o


ConstPointer.o:

[Index]   Value      Size    Type  Bind  Other Shndx   Name

[2]     |         0|       0|SECT |LOCL |0    |10     |
[3]     |         0|       0|SECT |LOCL |0    |9      |
[4]     |         0|       0|OBJT |LOCL |0    |6      |Bbss.bss
[1]     |         0|       0|FILE |LOCL |0    |ABS    |ConstPointer.cpp
[5]     |         0|       0|OBJT |LOCL |0    |3      |Ddata.data
[6]     |         0|       0|OBJT |LOCL |0    |5      |Dpicdata.picdata
[7]     |         0|       0|OBJT |LOCL |0    |4      |Drodata.rodata
[9]     |         4|       4|OBJT |GLOB |0    |3      |const_short_p
[8]     |         0|       4|OBJT |LOCL |0    |3      |const_short_p_const

Here are the symbol names of the object file with debug information:

# nm -C ConstPointer-debug.o


ConstPointer-debug.o:

[Index]   Value      Size    Type  Bind  Other Shndx   Name

[4]     |         0|       0|SECT |LOCL |0    |9      |
[2]     |         0|       0|SECT |LOCL |0    |8      |
[3]     |         0|       0|SECT |LOCL |0    |10     |
[10]    |         0|       4|OBJT |GLOB |0    |3      |$XAHMCqApZlqO37H.const_short_p_const
[5]     |         0|       0|NOTY |LOCL |0    |6      |Bbss.bss
[1]     |         0|       0|FILE |LOCL |0    |ABS    |ConstPointer.cpp
[6]     |         0|       0|NOTY |LOCL |0    |3      |Ddata.data
[7]     |         0|       0|NOTY |LOCL |0    |5      |Dpicdata.picdata
[8]     |         0|       0|NOTY |LOCL |0    |4      |Drodata.rodata
[9]     |         4|       4|OBJT |GLOB |0    |3      |const_short_p

为什么有变式的<代码>const_short_p_const? <代码>g++>在汇编假信息时未作改动。 它像我的汇编者一样。 你认为什么? 第二张<条码>const(固定点)。

EDIT for Drew Hall s comment: For example you have two files:

// ConstPointer.cpp
const short * const const_short_p_const = 0;

void foo();

int main(int argc, const char *argv[]) {
  foo();
  return 0;
}

以及

// ConstPointer2.cpp
extern const short * const const_short_p_const;

void foo() {
  short x = *const_short_p_const;
}

罚款:

# CC ConstPointer2.cpp -g -c -o ConstPointer2.o
# CC ConstPointer.cpp -g -c -o ConstPointer.o      

但是,由于符号不同,连接并不可行。 Const Pointer2.o的文号为const_short_p_const,但Const Pointer.o的文号为$XAHMCqApZlqO37H.const_short_p_const

# CC ConstPointer.o ConstPointer2.o -o ConstPointer
Undefined                       first referenced
 symbol                             in file
const_short_p_const                 ConstPointer2.o
最佳回答

Maybe this is linked to the fact that a global const variable is implicitely static in C++?

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签