如何协调GDB中的指令指针和当前行?

发布于 2025-01-12 05:34:57 字数 1507 浏览 1 评论 0原文

我有两个代码段:.multiboot.text 和 .text
它们在内存中的位置如下:
linker.ld

SECTIONS
{
    . = 0x00100000;
    /* The kernel will live at 3GB + 1MB in the virtual address space, */
    /* which will be mapped to 1MB in the physical address space. */

    _kernel_start = .;
    .multiboot.text : {
        *(.multiboot.text)
    }

    . += 0xC0000000;
    /* Add a symbol that indicates the start address of the kernel. */
    .text ALIGN (4K) : AT (ADDR (.text) - 0xC0000000)
    {
        *(.text)
    }
}

start.asm

section .multiboot.text
. . .
    ; Jump to higher half with an absolute jump.
    ; <breakpoint is successfully triggered here>
    ; <single>
    lea ecx, .higher_half
    jmp ecx

section .text
.higher_half:
    ; Unmap the identity mapping as it is now unnecessary.
    ; <breakpoint doesn't work here>
    mov [boot_page_directory + 0], DWORD 0

    ; Reload crc3 to force a TLB flush so the changes to take effect.
    mov ecx, cr3
    mov cr3, ecx
. . .

在我的 start.asm 文件中,我从 .multiboot.text 传递控制权段到 .text 并且 IP 从 0x001 更改???在 0xC01 上???并且调试器无法使此更改与当前行协调
因此,逐步调试对我不起作用
调试工作,但不显示该行

我该如何帮助他呢?

我使用 nasm 和 -g 标志编译 start.asm,这意味着存在调试信息
注意,代码本身物理上位于内存的下半部分,但是IP的这种差异是由于虚拟内存造成的

I have two code segments: .multiboot.text and .text
They are located in memory as follows:
linker.ld

SECTIONS
{
    . = 0x00100000;
    /* The kernel will live at 3GB + 1MB in the virtual address space, */
    /* which will be mapped to 1MB in the physical address space. */

    _kernel_start = .;
    .multiboot.text : {
        *(.multiboot.text)
    }

    . += 0xC0000000;
    /* Add a symbol that indicates the start address of the kernel. */
    .text ALIGN (4K) : AT (ADDR (.text) - 0xC0000000)
    {
        *(.text)
    }
}

start.asm

section .multiboot.text
. . .
    ; Jump to higher half with an absolute jump.
    ; <breakpoint is successfully triggered here>
    ; <single>
    lea ecx, .higher_half
    jmp ecx

section .text
.higher_half:
    ; Unmap the identity mapping as it is now unnecessary.
    ; <breakpoint doesn't work here>
    mov [boot_page_directory + 0], DWORD 0

    ; Reload crc3 to force a TLB flush so the changes to take effect.
    mov ecx, cr3
    mov cr3, ecx
. . .

In my start.asm file, I pass control from the .multiboot.text segment to the .text and IP changes from 0x001????? on 0xC01????? and the debugger cannot reconcile this change with the current line
As a result of this, step-by-step debugging does not work for me
debugging works, but does not display the line

How can I help him with this?

I compile start.asm using nasm and the -g flag, which means debugging information is present
Pay attention to the fact that the code itself is physically located in the lower half of memory, however, such a difference in IP is due to virtual memory

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文