0

I want to do this:

BITS 64

segment .text
global _start

_start:
    push 11
    init_bss_with_11_bytes_from_the_stack

    mov rax, 60
    mov rdi, 0
    syscall

segment .bss
hello: ????

Is there a way to do this? I can't find anything on this, should I just overallocate memory and then use it? and what if it overflows?

I'm sorry how this question is not that verbose, but this question's title talks for itself, nothing else to add

Ari157
  • 95
  • 4
  • 16
  • 1
    I don't think this makes sense. The BSS section is allocated by the loader before anything is executed. The executable file contains the size of the BSS. – Barmar Jun 24 '22 at 21:12
  • @Barmar Okay, will see what (if anything) I can do about it, I need to programatically generate a buffer the size of an item on the stack for SYS_read, but I'm not sure what I can do, will see – Ari157 Jun 24 '22 at 21:15
  • Use `malloc()` for dynamic memory allocation. – Barmar Jun 24 '22 at 21:16
  • 1
    And if you cannot use the libc, use the `sbrk` or `mmap` system calls to allocate memory. Read the man pages carefully; `sbrk` works different than the libc wrapper. – fuz Jun 24 '22 at 21:16
  • @Barmar I can't use libc, has to be purely asm with no dependencies – Ari157 Jun 24 '22 at 21:17

0 Answers0