Skip to content
Advertisement

Tag: x86

What is %gs in Assembly

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

Is malloc deterministic?

Is malloc deterministic? Say If I have a forked process, that is, a replica of another process, and at some point both of them call the malloc function. Would the address allocated be the same in both processes? Assuming that other parts of execution are also deterministic. Note: Here, I’m only talking about virtual memory, not physical one. Answer There

Why makecontext does not work with pthreads

From makecontext() manual… Due to limitations in the current pthread implementation, makecontext should not be used in programs which link against the pthread(3) library (whether threads are used or not). Now my question is, why it doesn’t work and what are the alternative methods. Actually I’m interested in switching stacks in a user-level thread at some points, but I’m seeing

undefined reference to sync_fetch_and_add_4

Whenever I try to use __sync_fetch_and_add with -m32 on a 64 bit machine, I get the following error, while it compiles fine with normal 64 bit. I am using gcc compiler 4.1.2. What can be the problem here and what is the solution? Answer Using -march=i486 flag did the trick for me.

Self modifying code always segmentation faults on Linux

i found an article about self modifying code and tried to do some examples, but i get always segmentation faults. As fas as i can understand, there is a violation in memory permissions. The code segment is (r)ead/e(x)ecute and so the attempt of writting results to this fault. Is there a way to test the program either by changing the

Setting GDB hardware watchpoint/how to set software watchpoint

An earlier question explained that on x86 the size of objects being watched is limited by debug registers. As expected, I can “watch” a double variable. But I can’t watch a double datamember, for example, produces But when you try to continue execution, it says Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. even though

Compile/run assembler in Linux?

I’m fairly new to Linux (Ubuntu 10.04) and a total novice to assembler. I was following some tutorials and I couldn’t find anything specific to Linux. So, my question is, what is a good package to compile/run assembler and what are the command line commands to compile/run for that package? Answer The GNU assembler (gas) and NASM are both good

Advertisement