英文:
Linux kernel's symbol has two addresses?
问题
发现内核符号在调试核心转储进程的一些问题时具有2个地址。
(gdb) info line binfmt_elf.c:2385
"fs/binfmt_elf.c"的第2385行从地址0xffff00000830dd84 <elf_core_dump+3460>开始,结束于0xffff00000830dd88 <elf_core_dump+3464>。
"fs/binfmt_elf.c"的第2385行从地址0xffff00000831083c <elf_core_dump+3460>开始,结束于0xffff000008310840 <elf_core_dump+3464>。
(gdb) info line binfmt_elf.c:2345
"fs/binfmt_elf.c"的第2345行从地址0xffff0000083106b8 <elf_core_dump+3072>开始,结束于0xffff0000083106c0 <elf_core_dump+3080>。
"fs/binfmt_elf.c"的第2345行从地址0xffff00000830dbfc <elf_core_dump+3068>开始,结束于0xffff00000830dc04 <elf_core_dump+3076>。
nm 告诉相同的结果:
nm vmlinux | grep elf_core_dump
ffff00000830d000 t elf_core_dump
ffff00000830fab8 t elf_core_dump
平台信息:aarch64,内核(4.20)由我自己构建,配置从 alpine virt aarch64 复制而来。
为什么?
英文:
Found out kernel symbol has 2 address when debuging some problem of coredump process.
(gdb) info line binfmt_elf.c:2385
Line 2385 of "fs/binfmt_elf.c" starts at address 0xffff00000830dd84 <elf_core_dump+3460> and ends at 0xffff00000830dd88 <elf_core_dump+3464>.
Line 2385 of "fs/binfmt_elf.c" starts at address 0xffff00000831083c <elf_core_dump+3460> and ends at 0xffff000008310840 <elf_core_dump+3464>.
(gdb) info line binfmt_elf.c:2345
Line 2345 of "fs/binfmt_elf.c" starts at address 0xffff0000083106b8 <elf_core_dump+3072> and ends at 0xffff0000083106c0 <elf_core_dump+3080>.
Line 2345 of "fs/binfmt_elf.c" starts at address 0xffff00000830dbfc <elf_core_dump+3068> and ends at 0xffff00000830dc04 <elf_core_dump+3076>.
nm tell the same result:
nm vmlinux | grep elf_core_dump
ffff00000830d000 t elf_core_dump
ffff00000830fab8 t elf_core_dump
plat infomation:aarch64,kernel(4.20) was build by my self,config was copied from alpine virt aarch64
why?
答案1
得分: 2
The function elf_core_dump
is a static one, so it can be defined in the several source files.
As for funny output of gdb, in which the line
Line 2385 of "fs/binfmt_elf.c"
appears twice, then it is because the source file fs/binfmt_elf.c
is included into other source file, fs/compat_binfmt_elf.c
by using
/*
* We share all the actual code with the native (64-bit) version.
*/
#include "binfmt_elf.c"
(https://elixir.bootlin.com/linux/v4.20.17/source/fs/compat_binfmt_elf.c#L131).
So every function in the binfmt_elf.c
is actually defined twice in the resulted kernel image:
- the first definition is created when compile the file
binfmt_elf.c
- the second definition is created when compile the file
compat_binfmt_elf.c
.
英文:
The function elf_core_dump
is a static one, so it can be defined in the several source files.
As for funny output of gdb, in which the line
Line 2385 of "fs/binfmt_elf.c"
appears twice, then it is because the source file fs/binfmt_elf.c
is included into other source file, fs/compat_binfmt_elf.c
by using
/*
* We share all the actual code with the native (64-bit) version.
*/
#include "binfmt_elf.c"
(https://elixir.bootlin.com/linux/v4.20.17/source/fs/compat_binfmt_elf.c#L131).
So every function in the binfmt_elf.c
is actually defined twice in the resulted kernel image:
- the first definition is created when compile the file
binfmt_elf.c
- the second definition is created when compile the file
compat_binfmt_elf.c
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论