void return_input (void) { char array[30]; gets (array); printf(“%sn”, array); } After compiling it in gcc, this function is converted to the following Assembly code: push %ebp mov %esp,%ebp sub $0x28,%esp mov %gs:0x14,%eax mov %eax,-0x4(%ebp) xor %eax,%eax lea -0x22(%ebp),%eax mov %eax,(%esp) call 0x8048374 lea -0x22(%ebp),%eax mov %eax,(%esp) call 0x80483a4 mov -0x4(%ebp),%eax xor %gs:0x14,%eax je 0x80484ac call 0x8048394 leave ret I
Tag: assembly
g++ 4.6.1 compiler error: Error: unknown pseudo-op: `.cfi_personality’
I have a file which compiles without errors or warnings on my macbook pro running osx (snow leopard) using g++ (4.6.1). I just uploaded it to our linux cluster (not run by me) and tried to compile there (also using gcc 4.6.1). This time I many strange error messages with the assembler. How do I interpret the following error? Answer
Getting cpu cycles using RDTSC – why does the value of RDTSC always increase?
I want to get the CPU cycles at a specific point. I use this function at that point: (editor’s note: “=A” is wrong for x86-64; it picks either RDX or RAX. Only in 32-bit mode will it pick the EDX:EAX output you want. See How to get the CPU cycle count in x86_64 from C++?.) The problem is that it
Permanently Change Disassembly Flavor in GDB
How can I permanently change the disassembly flavor in GDB. I tried:set disassembly-flavor intel in GDB, but when I fire up GDB later it still has the att flavor. Answer gdb executes a ~/.gdbinit file when it starts, if present; you should be able to add the line to it.
x86_64 Assembly Linux System Call Confusion
I am currently learning Assembly language on Linux. I have been using the book ‘Programming From the Ground Up’ and all the examples are 32-bit. My OS is 64-bit and I have been trying to do all the examples in 64-bit. I am having trouble however: This merely just calls the Linux exit System call or it should. Instead it
Linking C function lib to x86 assembly program in modern 64bit Linux
I’m going through a book focusing on x86 programming (Professional Assembly Language, WROX 2005). I had some problems last night and I was hoping to sort this out before returning home today so I can get a running-start and continue the text. My machine runs x64 Ubuntu (11.04 if I’m not mistaken) so the text focusing on 32bit x86 is
Why data and stack segments are executable?
I have just noticed that my simple program has its data and stack segments executable. I saw it in /proc/[pid]/maps, and simple code confirmed it. For example: then causes prog to execute int3 instruction. Programs written in C and built with gcc have their data, stack and heap non-executable, so why those written in assembly behave in a different manner?
How to print out registers in Linux kernel?
I want to print out values of a couple of registers from the linux kernel code running on ARM. Particularly I have the following assembly in linux – How do I print out the values of r2, r3 and r5 in kmsg? I do not want to use the variable names and want to get the values from registers. Answer
C++/Assembly IDE on Linux [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 4 years ago. Improve this question What I’m looking for is an IDE that will run on
Simple polymorphic engine
I have to program a simple polymorphic engine. I use linux (32-bit) and i can code in assembly and c. I don’t know how to start. Can you give me a schema for constructing such an engine? My idea is to make a program that: read the code section of a file encrypts it in a buffer, make space at