x86-64

Parsing Call and Ret with ptrace.

自作多情 提交于 2019-12-03 07:09:07
I try to parse all the Calls and Rets from an executable with ptrace. Conforming the the x64opcode , I found opcodes for Calls: 0xe8 and for Rets: 0xc3, 0xc2, 0xca, 0xcb . Since I parsed them I found more Rets than Calls. There is the program I trace: void func() { write(1, "i", 1); } int main(int ac) { func(); return(0); } There is my tracer: int tracer(t_info *info) { int status; long ptr; int ret = 0; int call = 0; waitpid(info->pid, &status, 0); while (WIFSTOPPED(status)) { ptrace(PTRACE_GETREGS, info->pid, NULL, info->regs); ptr = ptrace(PTRACE_PEEKDATA, info->pid, info->regs->rip); if ((

difference between MMX and XMM register?

大兔子大兔子 提交于 2019-12-03 06:50:38
I'm currently learning assembly programming on Intel x86 processor. Could someone please explain to me, what is the difference between MMX and XMM register? I'm very confused in terms of what functions they serve and the difference and similarities between them? MM registers are the registers used by the MMX instruction set, one of the first attempts to add (integer-only) SIMD to x86. They are 64 bit wide and they are actually aliases for the mantissa parts of the x87 registers (but they are not affected by the FPU top of the stack position); this was done to keep compatibility with existing

movq assembly function

泄露秘密 提交于 2019-12-03 06:50:08
问题 I was reading some code and was not sure what this line does: movq (%rsp), %rsp 回答1: movq (assuming you're talking about x86) is a move of a quadword (64-bit value). This particular instruction: movq (%rsp), %rsp looks very much like code that will walk up through stack frames. This particular instruction grabs the quadword pointed to by the current stack pointer, and loads it into the stack pointer, overwriting it. By way of example, this code sequence (based on real code, and in Intel

When to do or not do INVLPG, MOV to CR3 to minimize TLB flushing

谁都会走 提交于 2019-12-03 06:48:15
问题 Prologue I am an operating system hobbyist, and my kernel runs on 80486+, and already supports virtual memory. Starting from 80386, the x86 processor family by Intel and various clones thereof has supported virtual memory with paging. It is well known that when the PG bit in CR0 is set, the processor uses virtual address translation. Then, the CR3 register points to the top-level page directory, that is the root for 2-4 levels of page table structures that map the virtual addresses to

“Unexplainable” core dump

旧城冷巷雨未停 提交于 2019-12-03 06:41:13
问题 I've seen many core dumps in my life, but this one has me stumped. Context: multi-threaded Linux/x86_64 program running on a cluster of AMD Barcelona CPUs the code that crashes is executed a lot running 1000 instances of the program (the exact same optimized binary) under load produces 1-2 crashes per hour the crashes happen on different machines (but the machines themselves are pretty identical) the crashes all look the same (same exact address, same call stack) Here are the details of the

Disassemble into x86_64 on OSX10.6 (But with _Intel_ Syntax)

旧街凉风 提交于 2019-12-03 06:34:39
I know of otool -tv , but I would much rather use the Intel syntax rather than AT&Ts, mainly to easily follow along in a book and not have to look over thousands of % 's and $ 's. I'd also appreciate any tips to where I might find gdb 's config file. EDIT: I forgot: I'm running a 64bit processor, but was wondering if it would be possible to also disassemble into 32 bit assembly? Not only that, but does OSX's gdb 's list command work differently than the standard GNU version? Thanks so much! (Also, if you have any idea where I might find a little disassembler from C -> MIPS, that'd be very fun

I want to create a simple assembler in C. Where should I begin? [duplicate]

两盒软妹~` 提交于 2019-12-03 06:01:07
问题 This question already has answers here : Building an assembler (4 answers) How Do You Make An Assembler? [closed] (4 answers) Closed 6 years ago . I've recently been trying to immerse myself in the world of assembly programming with the eventual goal of creating my own programming language. I want my first real project to be a simple assembler written in C that will be able to assemble a very small portion of the x86 machine language and create a Windows executable. No macros, no linkers.

Intel x86 0x2E/0x3E Prefix Branch Prediction actually used?

守給你的承諾、 提交于 2019-12-03 05:40:39
问题 In the latest Intel software dev manual it describes two opcode prefixes: Group 2 > Branch Hints 0x2E: Branch Not Taken 0x3E: Branch Taken These allow for explicit branch prediction of Jump instructions (opcodes like Jxx ) I remember reading a couple of years ago that on x86 explicit branch prediction was essentially a no-op in the context of gccs branch prediciton intrinsics. I am now unclear if these x86 branch hints are a new feature or whether they are essentially no-ops in practice. Can

x86_64 calling conventions and stack frames

无人久伴 提交于 2019-12-03 05:35:06
I am trying to make sense out of the executable code that GCC (4.4.3) is generating for an x86_64 machine running under Ubuntu Linux. In particular, I don't understand how the code keeps track of stack frames. In the old days, in 32-bit code, I was accustomed to seeing this "prologue" in just about every function: push %ebp movl %esp, %ebp Then, at the end of the function, there would come an "epilogue," either sub $xx, %esp # Where xx is a number based on GCC's accounting. pop %ebp ret or simply leave ret which accomplishes the same thing: Set the Stack Pointer to the top of the current frame

How to intercept a hot key in Cocoa when the application window is not active

我是研究僧i 提交于 2019-12-03 04:38:56
问题 I am trying to create a utility that doesn't open a window when executed, and that would be activated from a hot key; I read that currently Cocoa doesn't have a function for that, and that I should use a deprecated Carbon function. Isn't there really a way to use global hot keys in Cocoa? What should I do: wait for Cocoa to introduce a function for that, or use the carbon function until a similar function is not introduced in Cocoa? 回答1: Use the Carbon Event Manager's RegisterEventHotKey