【发布时间】:2016-06-21 20:04:31
【问题描述】:
我有以下示例代码。我想查看目标文件中的重定位表条目。为此,我使用了
objdump -r test.o
示例代码:
#include <stdio.h>
char * myfunction ();
int x=20;
int main()
{
printf (" \n Inside main ");
char * p = myfunction ();
printf (" \n My string is %s ", p);
}
char * myfunction ()
{
char * key ="jaka";
return key;
}
Objdump -r test.o 的输出
test.o: file format elf64-x86-64
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
0000000000000009 R_X86_64_32 .rodata
0000000000000013 R_X86_64_PC32 printf-0x0000000000000004
000000000000001d R_X86_64_PC32 myfunction-0x0000000000000004
000000000000002d R_X86_64_32 .rodata+0x0000000000000010
0000000000000037 R_X86_64_PC32 printf-0x0000000000000004
0000000000000045 R_X86_64_32S .rodata+0x0000000000000024
RELOCATION RECORDS FOR [.eh_frame]:
OFFSET TYPE VALUE
0000000000000020 R_X86_64_PC32 .text
0000000000000040 R_X86_64_PC32 .text+0x000000000000003d
问题:
根据我的理解,全局变量“x”应该在重定位表中的某个地方,我无法找到。
如果我在这里忽略了什么,请帮助我?
【问题讨论】: