Skip to content

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 ques…

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…

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…

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 fr…

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,…