[objdump]-D -S 结果如何看?
objdump -D -S kernel/fork.o > fork_dump.txt但是dup_mm() 函数中找不到0x224这个位置? 请明白的人指教!
其中出错的位置为:
[ 10.072152] [<c00ec87c>] (vma_prio_tree_add+0x0/0xd4) from [<c00314a4>] (dup_mm+0x224/0x3e4)
[ 10.080952] r5:dde25340 r4:ddf0e1c0
[ 10.084821] [<c0031280>] (dup_mm+0x0/0x3e4) from [<c0031e70>] (copy_process+0x7b4/0xe14)
[ 10.093283] [<c00316bc>] (copy_process+0x0/0xe14) from [<c00325fc>] (do_fork+0xf0/0x36c)
[ 10.101705] [<c003250c>] (do_fork+0x0/0x36c) from [<c0012f04>] (sys_fork+0x38/0x40)
[ 10.109646] [<c0012ecc>] (sys_fork+0x0/0x40) from [<c000f040>] (ret_fast_syscall+0x0/0x30)
dup_mm() @linux3.4.39-kernel/fork.o反汇编后的结果为:
00001080 <dup_mm>:
/*
* Allocate a new mm structure and copy contents from the
* mm structure of the passed in task structure.
*/
struct mm_struct *dup_mm(struct task_struct *tsk)
{
1080: e1a0c00d mov ip, sp
1084: e92ddff0 push {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc}
1088: e24cb004 sub fp, ip, #4
108c: e24dd024 sub sp, sp, #36 ; 0x24
1090: e92d4000 push {lr}
1094: ebfffffe bl0 <__gnu_mcount_nc>
1098: e1a0200d mov r2, sp
109c: e3c23d7f bic r3, r2, #8128 ; 0x1fc0
10a0: e1a05000 mov r5, r0
10a4: e3c3303f bic r3, r3, #63 ; 0x3f
struct mm_struct *mm, *oldmm = current->mm;
10a8: e593300c ldr r3,
10ac: e593822c ldr r8, ; 0x22c
int err;
if (!oldmm)
10b0: e3580000 cmp r8, #0
return NULL;
10b4: 01a04008 moveq r4, r8
struct mm_struct *dup_mm(struct task_struct *tsk)
{
struct mm_struct *mm, *oldmm = current->mm;
int err;
if (!oldmm)
10b8: 0a0000c8 beq 13e0 <dup_mm+0x360>
return NULL;
mm = allocate_mm();
10bc: e3003000 movw r3, #0
10c0: e3403000 movt r3, #0
10c4: e3a010d0 mov r1, #208 ; 0xd0
10c8: e5930014 ldr r0,
10cc: ebfffffe bl0 <kmem_cache_alloc>
if (!mm)
10d0: e2504000 subs r4, r0, #0
10d4: 0a0000c1 beq 13e0 <dup_mm+0x360>
goto fail_nomem;
memcpy(mm, oldmm, sizeof(*mm));
10d8: e1a01008 mov r1, r8
10dc: e3a02e19 mov r2, #400 ; 0x190
10e0: ebfffffe bl0 <memcpy>
mm_init_cpumask(mm);
/* Initializing for Swap token stuff */
mm->token_priority = 0;
10e4: e3a07000 mov r7, #0
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
mm->pmd_huge_pte = NULL;
#endif
if (!mm_init(mm, tsk))
10e8: e1a00004 mov r0, r4
memcpy(mm, oldmm, sizeof(*mm));
mm_init_cpumask(mm);
/* Initializing for Swap token stuff */
mm->token_priority = 0;
10ec: e5847178 str r7, ; 0x178
mm->last_interval = 0;
10f0: e584717c str r7, ; 0x17c
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
mm->pmd_huge_pte = NULL;
#endif
if (!mm_init(mm, tsk))
10f4: ebfffe5b bla68 <mm_init.isra.41>
10f8: e3500000 cmp r0, #0
/* don't put binfmt in mmput, we haven't got module yet */
mm->binfmt = NULL;
mmput(mm);
fail_nomem:
return NULL;
10fc: 01a04000 moveq r4, r0
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
mm->pmd_huge_pte = NULL;
#endif
if (!mm_init(mm, tsk))
1100: 0a0000b6 beq 13e0 <dup_mm+0x360>
goto fail_nomem;
if (init_new_context(tsk, mm))
1104: e1a01004 mov r1, r4
1108: e1a00005 mov r0, r5
110c: ebfffffe bl0 <__init_new_context>
static void dup_mm_exe_file(struct mm_struct *oldmm, struct mm_struct *newmm)
{
/* It's safe to write the exe_file pointer without exe_file_lock because
* this is called during fork when the task is not yet in /proc */
newmm->exe_file = get_mm_exe_file(oldmm);
1110: e1a00008 mov r0, r8
1114: ebfffffe ble78 <get_mm_exe_file>
struct rb_node **rb_link, *rb_parent;
int retval;
unsigned long charge;
struct mempolicy *pol;
down_write(&oldmm->mmap_sem);
1118: e288c03c add ip, r8, #60 ; 0x3c
111c: e50bc03c str ip, ; 0x3c
flush_cache_dup_mm(oldmm);
/*
回复 1# 王非文
dup_mm+0x224 指的时dup_mm的开始地址+0x224。以你这个输出来看,是0x00001080 + 0x224 = 0x000012A4
回复 2# Tinnal
是想知道 -D -S反汇编之后,汇编代码和C代码如何对应着看?对于这个例子,
struct mm_struct *dup_mm(struct task_struct *tsk)
{
...
static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
{
vma_prio_tree_add(tmp, mpnt);
}
...
}
dup_mm() 函数中反汇编之后,如何与OOPS 对应起来,
[ 10.072152] [<c00ec87c>] (vma_prio_tree_add+0x0/0xd4) from [<c00314a4>] (dup_mm+0x224/0x3e4)
[ 10.080952] r5:dde25340 r4:ddf0e1c0
[ 10.084821] [<c0031280>] (dup_mm+0x0/0x3e4) from [<c0031e70>] (copy_process+0x7b4/0xe14)
[ 10.093283] [<c00316bc>] (copy_process+0x0/0xe14) from [<c00325fc>] (do_fork+0xf0/0x36c)
[ 10.101705] [<c003250c>] (do_fork+0x0/0x36c) from [<c0012f04>] (sys_fork+0x38/0x40)
[ 10.109646] [<c0012ecc>] (sys_fork+0x0/0x40) from [<c000f040>] (ret_fast_syscall+0x0/0x30)
具体问题是,0x3e4 是指 dup_mm() 汇编之后的总长度吗? 按道理说应该是dup_mmap() call 的 vma_prio_tree_add() 为什么OOPS 上显示是 dup_mm() call 的呢?
用addr2line
页:
[1]