x86-64

Detecting an illegal instruction opcode on Intel PIN

房东的猫 提交于 2019-12-01 10:13:22
问题 I am writing a Pin tool where I want to detect an instruction with a particular opcode. I have an executable from a sample C program where I am printing hello world. The architecture used is x86_64 and I have the trace of assembly instructions in the program. I am giving this program's assembly instruction trace to the Intel PIN tool, on which I am running the instruction trace and performing operations. My goal here is to detect a particular opcode from my original program. For example I

Y86-64指令集体系结构1

╄→尐↘猪︶ㄣ 提交于 2019-12-01 10:06:32
一. 乱糟糟的概念 指令集体系结构(ISA ):一个处理器支持的指令和指令的字节级编码(每条指令被编码成由一个字节序列或多个字节序列组成的二进制格式) 不同的处理器家族有不同的ISA(例如Intel IA32和x86-64、IBM/Freescale Power和ARM处理器家族)有不同的ISA 同一处理器家族的不同处理器有相同的ISA ISA为编译器编写者和处理器设计人员之间提供了一个概念抽象层:编译器编写者只需知道允许哪些指令,指令的字节级编码是什么;而处理器设计者只需建造出执行这些指令对应的二进制编码的处理器。 计算机科学的重要思想:用巧妙的方法在提高性能的同时又保持一个更简单、更抽象模型的功能。 数字硬件设计:基本构件块,如何连接以及操作,硬件控制语言(硬件系统控制部分的简单语言,用它来描述处理器设计) 二. 创建Y86-64指令集 较x86-64处理器支持的指令集而言,Y86-64指令集的 数据类型 、 指令 、 寻址方式 较少。 好处在于: 字节级编码简单,CPU译码逻辑简单 。 可以实现一些处理整数的程序。 在这一章中,我们会学习到如何用这个新定义出来的Y86-64指令集来设计处理器,并自己设计出来一个处理器, CMU设计了一些研究和测试处理器设计的工具,包括:Y86-64的汇编器,以及运行Y86-64程序的模拟器

Start x86_64 code on x86 (32bit) Linux, running on x86_64 CPU

穿精又带淫゛_ 提交于 2019-12-01 09:41:54
问题 ?Is it possible to start an x86_64 code on i686 Linux (x86, 32-bit)? My CPU is modern Core 2 and it can run x86_64 64-bit code itself, but the OS is 32bit. The code to start is pure mathematic, and it need almost no interaction with OS. I want to measure, how fast will be my program in 64bit mode comparing with 32-bit mode. The program is to solve huge combinatoric problem and full size run is dozens of hours. I can start 64bit code with qemu, but it will be not native execution and speed in

Is it possible to interrupt a process and checkpoint it to resume it later on?

霸气de小男生 提交于 2019-12-01 09:21:17
Lets say, you have an application, which is consuming up all the computational power. Now you want to do some other necessary work. Is there any way on Linux, to interrupt that application and checkpoint its state, so that later on it could be resumed from the state it was interrupted? Especially I am interested in a way, where the application could be stopped and restarted on another machine. Is that possible too? In general terms, checkpointing a process is not entirely possible (because a process is not only an address space, but also has other resources likes file descriptors, and TCP/IP

Using gdb to check register's values

旧巷老猫 提交于 2019-12-01 09:11:16
How can I see what values the registers hold? I have the following line of assembly: mov 0x8(%rax), %rax cpm %ebx, (%rax) Using the command: (gdb) p/x $ebx (gdb) p/x $rbx $3 = 0xb I get the value that is stored in this register. However, when I try to see what it is stored int the memory location (%rax) I have the following problem: (gdb) display *(int *)$rax Disabling display 10 to avoid infinite recursion. 10: *(int *)$rax = Cannot access memory at address 0x17 I cannot not understand why this happens and moreover how to find out what (%rax) has in. To see the values of the registers just

Checking up Intel assembly opcodes easily in Linux

↘锁芯ラ 提交于 2019-12-01 08:53:59
I have been looking for an practical tool that would print the opcodes of any Intel 64-bit or 32-bit instruction in Linux, eg. something like Hiew's assembler in DOS. A web-based service would be one option too. As I wasn't able to find any, I made my own bash script, that creates an assembly source file from command line parameters (instruction[s] and <32/64>), compiles, links and disassembles it and shows the correct rows of disassembly. But is there already some program that would show all the possible encodings for any given instruction, eg. for mov eax,ebx ? My approach using nasm , ld

Error moving a constant byte value into %ebx

谁说我不能喝 提交于 2019-12-01 08:46:58
问题 I'm working through Computer Systems, A Programmer's Perspective (3rd edition), and Practice Problem 3.3 contains the following line: movb $0xF, (%ebx) I'm supposed to find out what's wrong with this line of x86-64 assembly, and the answer key states: "Cannot use %ebx as address register", which doesn't make sense to me. My understanding is that this line intends to copy 0xF to a location in main memory, however %ebx is a 32-bit register, memory addresses are 64 bits wide on 64-bit machines,

计算机系统导论——读书笔记——第四章 处理器体系结构(持续更新)

别等时光非礼了梦想. 提交于 2019-12-01 08:03:09
2019年10月14日 1.指令集体系结构(Instruction-Set Architecture, ISA):一个处理器支持的指令和指令的字节级编码. 2.硬件控制语言(Hardware Control Language, HCL):一种描述硬件系统控制部分的简单语言. 4.1 Y86-64指令集体系结构 状态单元、指令集和他们的编码、一组编程规范、异常事件处理 4.1.1 程序员可见的状态 4.1.2 Y86-64指令 1. Y86-64 vs x86-64 : Y86-64指令集是x86-64的子集,只包含8字节(q)操作 前者简单,后者紧凑(常数值编码灵活、字段不固定) 2. Y86-64指令 (1)movq指令:irmovq,rrmovq,mrmovq,rmmovq(格式为: 源+目的+movq,源和目的包括i(instant number),r(register),m(memory);注意,不允许immovq或mmmovq) (2)4个整数操作:addq,subq,andq,xorq(注意,只对寄存器操作,同时设置条件码ZF、SF、OF) (3)7个跳转指令:jmp,jle,jl,je,jne,jge,jg (4)6个条件传送指令:cmovle,cmovl,cmove,cmovne,cmovge,cmovg(注意:只能寄存器->寄存器) (5)call,ret (6

OS X - x64: stack not 16 byte aligned error

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 07:33:29
I know that OS X is 16 byte stack align, but I don't really understand why it is causing an error here. All I am doing here is to pass an object size (which is 24) to %rdi, and call malloc. Does this error mean I have to ask for 32 bytes ? And the error message is: libdyld.dylib`stack_not_16_byte_aligned_error: -> 0x7fffc12da2fa <+0>: movdqa %xmm0, (%rsp) 0x7fffc12da2ff <+5>: int3 libdyld.dylib`_dyld_func_lookup: 0x7fffc12da300 <+0>: pushq %rbp 0x7fffc12da301 <+1>: movq %rsp, %rbp Here is the code: Object_copy: pushq %rbp movq %rbp, %rsp subq $8, %rsp movq %rdi, 8(%rsp) # save self address

Compute (a*b)%m FAST for 64-bit unsigned arguments in C(++) on x86-64 platforms?

大憨熊 提交于 2019-12-01 07:33:19
问题 I'm looking for a fast method to efficiently compute ( a ⋅ b ) modulo n (in the mathematical sense of that) for a , b , n of type uint64_t . I could live with preconditions such as n!=0 , or even a<n && b<n . Notice that the C expression (a*b)%n won't cut it, because the product is truncated to 64 bits. I'm looking for (uint64_t)(((uint128_t)a*b)%n) except that I do not have a uint128_t (that I know, in Visual C++). I'm in for a Visual C++ (preferably) or GCC/clang intrinsic making best use