Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago. Improve this question I’m trying to write a simple operating system from scratch as a way to improve understanding on how OS and
Tag: assembly
ELF label address
I have the following code in .s file: Its object file has the following: After linking, it becomes: How does the argument 0x0 to pushq at byte 20 of the object file gets converted to 0x400578 in the final executable? Which section of the object file contains this information? Answer You answered your own question: After linking…. Here is a
Buffer Overflow: NOP sled not working [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 5 years ago. Improve this question Hey I’m trying to do a buffer overflow on a basic C program,
Reading user input as an integer
I wrote an Assembly program (x86_64 Linux NASM) that prints an integer to console, based in the algorithm suggested my the comments in this post, which is basically this: All works just fine under the following script: After compiling it, the number 567 gets printed on the screen (console). But if I try to do the same but allowing the
Scanf a char pointer in Assembly
So I have a task to do, which requires from me to scanf a char* in assembly. I tried this code: It writes down first printf correctly, then it waits for input (so scanf works), but then when I enter anything -> Segmentation fault. I know, that the char* should be somehow initialized, but how can I do it from
GDB – Assembly program returns /bin/sh: 0: Can’t open �
I am presently learning 64-bit assembly language from the related Pentester Academy course. The code I’m working on creates the following error when ran in GDB: /bin/sh: 0: Can’t open � [Inferior 1 (process 4049) exited with code 0177] I have googled the error and exit code and haven’t found anything helpful. I tried analyzing the code in GDB over
What is the difference between retq and ret?
Let’s consider the following program, which computes an unsigned square of the argument: This is properly compiled by as, but disassembles to Is there any difference between ret and retq? Answer In long (64-bit) mode, you return (ret) by popping a quadword address from the stack to %rip. In 32-bit mode, you return (ret) by popping a dword address from
push/pop segmentation fault in simple multiplication function
my teacher is doing a crash course in assembly with us, and I have no experience in it whatsoever. I am supposed to write a simple function that takes four variables and calculates (x+y)-(z+a) and then prints out the answer. I know it’s a simple problem, but after hours of research I am getting no where, any push in the
Running 32-bit code in 64-bit process on Linux – memory access
I’m experimenting with running 32-bit code inside a 64-bit Linux process. The 32-bit code is completely self-contained, it makes direct IA32 system calls on its own. If I were to load this code in a 32-bit process, it would run just fine. Initially, I thought I could just allocate a stack for the 32-bit code, switch to it and everything
Responsibility of stack alignment in 32-bit x86 assembly
I am trying to get a clear picture of who (caller or callee) is reponsible of stack alignment. The case for 64-bit assembly is rather clear, that it is by caller. Referring to System V AMD64 ABI, section 3.2.2 The Stack Frame: The end of the input argument area shall be aligned on a 16 (32, if __m256 is passed