代码之家  ›  专栏  ›  技术社区  ›  Sibi

写入x86程序集中的.bss节

  •  1
  • Sibi  · 技术社区  · 6 年前

    .bss 2 在缓冲区内,而不发出系统调用。有可能吗?

    我的尝试失败了:

            .section .text
    
            .section .bss
    
            .lcomm SAMPLE_BUFFER, 8
    
            .globl _start
    
    _start:
    
            movl $2,SAMPLE_BUFFER
    
            movl $1, %eax
            int $0x80
    

    执行时:

      $ as --32 buffer.s -o buffer.o
      $ ld -m elf_i386 buffer.o -o buffer
      $ ./buffer
      fish: “./buffer” terminated by signal SIGSEGV (Address boundary error)
    
    1 回复  |  直到 6 年前
        1
  •  4
  •   fuz    6 年前

    你需要确保切换回 .text 发出机器代码前的部分 _start . 按原样,你的地方 _开始 .bss 它不是可执行的,会使你的程序崩溃。

    推荐文章