x86-64

Do we also refer to the registers RAX, RBX etc as R1, R2 and so on?

僤鯓⒐⒋嵵緔 提交于 2019-12-05 18:50:26
I am studying 8086/8080 microprocessors. The registers used in them have names, RAX RBX RCX RDX and go on until R8 when the registers are named as R8, R9... to R15. I wanted to know Do we also refer to the registers RAX, RBX etc as R1, R2 and so on? Standard practice is for the first 8 registers to keep their historical name. This convention is used in the documentation from Intel and AMD and in most assemblers. The reason for this is that these names are mnemonic for the function of the register. For example rsp sticks out as the stack pointer; r4 not so much. The new registers, by contrast,

Create and test x86-64 ELF executable shellcode on a Linux machine

守給你的承諾、 提交于 2019-12-05 18:48:22
I am creating a training on buffer overflows and stack/heap attacks. I am working on an Ubuntu 12.04 x86_64 machine and want to show some sample buggy programs and the ways you could exploit those vulnerabilities. I am trying to start with the most basic shellcode I have found so far, the simple exit call, which should exit the program being overflowed. Hereby the exitcall.asm : ;exitcall.asm [SECTION .text] global _start _start: xor ebx,ebx ; zero out ebx, same function as mov ebx,0 mov al, 1 ; exit command to kernel int 0x80 I've got this asm file from other tutorials, written for i386

Unsigned 64-bit to double conversion: why this algorithm from g++

放肆的年华 提交于 2019-12-05 16:41:57
问题 Using g++ 4.9.2 if I compile bool int_dbl_com(const unsigned long long x, const double y) { return x <= y; } then the assembler output (for the Windows x64 calling convention) is: testq %rcx, %rcx # x in RCX js .L2 pxor %xmm0, %xmm0 cvtsi2sdq %rcx, %xmm0 ucomisd %xmm0, %xmm1 # y in XMM1 setae %al ret The command cvtsi2sdq is signed conversion, and the first test and jump combination is to check if %rcx < 0 . If so, we go to L2, and this I don't understand: .L2: movq %rcx, %rax andl $1, %ecx

How do you check syscall for x86_64?

佐手、 提交于 2019-12-05 16:03:11
I can't find a dedicated official website to search for such information . For example,if I want to do exit ,how should I do it with syscall introduced in x86_64? Any manual for this kind of details? I'm on Centos. Glibc sysdeps/unix/sysv/linux/x86_64/syscall.S , see if this helps. Let the C library do it for you: movl $0, %rdi # or whatever exit code you want (0-127) call _exit You really do not want to make system calls yourself. The C library insulates you from a bunch of low-level ABI issues (many system calls exist in more than one version, depending on exactly which kernel you have; some

How do i write Simple inline asm instruction from C on Linux 64 bit?

蓝咒 提交于 2019-12-05 15:58:01
i am writing a simple c program and my requirement is to print RIP(Instruction Pointer) from some function of the program. i dont want to use ptrace. the one thing i tried with inline asm is: asm("movl %%rip, %0;" : "=r"(val) ) this should copy my rip register value to variable val, but i am getting compilation error. if i use ebp/esp which are base pointer and stack pointers for 32 bit machine, i dont get any compilation error and my val has some hexadecimal number assigned. i have few questions here: 1) as my machine is 63 bit, how was above instruction able to read 32 bit registers? 2) why

what would be the benefit of moving a register to itself in x86-64

你离开我真会死。 提交于 2019-12-05 15:57:27
I'm doing a project in x86-64 NASM and came across the instruction: mov rdi, rdi in the output of a compiler my professor wrote. I have searched all over but can't find mention of why this would be needed. Does it affect the flags or is it something clever that I don't understand? To give some context it's present in a loop right before the same register is decremented with sub . zx485 The instruction mov rdi, rdi is just an inefficient 3 byte NOP, equivalent to an actual NOP instruction. Assembling it, it generates the byte combination 48 89 ff mov rdi, rdi That can be considered as a NOP

Speed up x64 assembler ADD loop

时光毁灭记忆、已成空白 提交于 2019-12-05 15:44:21
问题 I'm working on arithmetic for multiplication of very long integers (some 100,000 decimal digits). As part of my library I to add two long numbers. Profiling shows that my code runs up to 25% of it's time in the add() and sub() routines, so it's important they are as fast as possible. But I don't see much potential, yet. Maybe you can give me some help, advice, insight or ideas. I'll test them and get back to you. So far my add routine does some setup and then uses a 8-times unrolled loop: mov

passing rvalue to non-ref parameter, why can't the compiler elide the copy?

爷,独闯天下 提交于 2019-12-05 14:38:31
struct Big { int a[8]; }; void foo(Big a); Big getStuff(); void test1() { foo(getStuff()); } compiles (using clang 6.0.0 for x86_64 on Linux so System V ABI, flags: -O3 -march=broadwell ) to test1(): # @test1() sub rsp, 72 lea rdi, [rsp + 40] call getStuff() vmovups ymm0, ymmword ptr [rsp + 40] vmovups ymmword ptr [rsp], ymm0 vzeroupper call foo(Big) add rsp, 72 ret If I am reading this correctly, this is what is happening: getStuff is passed a pointer to foo 's stack ( rsp + 40 ) to use for its return value, so after getStuff returns rsp + 40 through to rsp + 71 contains the result of

Using RIP-relative addressing in OSX x64 assembly

混江龙づ霸主 提交于 2019-12-05 14:29:55
I was trying to make a basic printf example in x86-64 assembly code for OSX, here's my first version: section .data msg db 'hello', 0Ah section .text extern _printf global _main _main: sub rsp, 8 mov rdi, msg mov rax, 0 call _printf add rsp, 8 ret So this code is moving the absolute address of msg into rdi for the first argument to _printf , and gcc then complains about the lack of position-independent code. The binary still works though: → nasm -f macho64 new.asm && gcc -m64 -o new new.o && ./new ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code

XCode 6.1 Missing required architecture X86_64 in file for extern library

旧巷老猫 提交于 2019-12-05 13:01:25
I have an issue when trying to use an external lib : I can't compile the project as it throws an exception as below. ld: warning: ignoring file /Users/renaudcousin/Documents/XCode/WORK/StimShopPOC/StimShopPOC/libStimshop_SDK.a, missing required architecture x86_64 in file /Users/renaudcousin/Documents/XCode/WORK/StimShopPOC/StimShopPOC/libStimshop_SDK.a (3 slices) Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_StimshopSDK", referenced from: objc-class-ref in ViewController.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v