x86-64

How to force nasm to address variables position-independent?

无人久伴 提交于 2020-01-04 05:35:13
问题 How to tell NASM (or LD) to process labels in a way that will make the segment position-independent? The segment is going to be moved from one file to another and I want it to work properly on any position in any file. Here is the code that illustrates my problem: section .text ... message: db 'hello world!',0x00 ... mov rax,SYSCALL_WRITE mov rdi,STDOUT mov rsi,message mov rdx,13 syscall In the orginal executable it prints "Hello world!", but when the segment is moved to another elf, it

Filling x86_64 Pointers Top Sixteen Bits With Tag Data?

ぐ巨炮叔叔 提交于 2020-01-04 04:54:10
问题 Since current x86_64 implementations are only capable of a forty eight bit "virtual" address space to reduce MMU complexity, could the top sixteen bits be used to implement security tag data. Do the current implementations restrict this (even know the IP and other segment registers are a full sixty four bits) usage and restrict the top sixteen bits of pointers to only contain virtual addresses and not other data? 回答1: No, you cannot. The top 16 bits are currently required to all be the same

Is it possible to replace every instance of a particular function with a dummy in a compiled binary?

久未见 提交于 2020-01-03 17:30:56
问题 Is it possible to alter the way that an existing x86-64 binary references and/or calls one particular function. Specifically, is it possible to alter the binary such nothing happens (similar to a nop ) at the times when that function would normally have executed? I realize that there are powerful speciality tools out there (ie decompilers/disassemblers) for just this sort of task, but what I'm really wondering is if the executable formats are human-readable "enough" to be able to do this sort

CS:APP example uses idivq with two operands?

限于喜欢 提交于 2020-01-03 08:33:08
问题 I am reading about x86-64 (and assembly in general) through the book "computer systems a programmer's perspective"(3rd edition). The author, in compliance with other sources from the web, states that idivq takes one operand only - just as this one claims. But then, the author, some chapters later, gives an example with the instruction idivq $9, %rcx . Two operands? I first thought this was a mistake but it happens a lot in the book from there. Also, the dividend should be given from the

Performance difference of signed and unsigned integers of non-native length

一笑奈何 提交于 2020-01-03 06:04:40
问题 There is this talk, CppCon 2016: Chandler Carruth “Garbage In, Garbage Out: Arguing about Undefined Behavior...", where Mr. Carruth shows an example from the bzip code. They have used uint32_t i1 as an index. On a 64-bit system the array access block[i1] will then do *(block + i1) . The issue is that block is a 64-bit pointer whereas i1 is a 32-bit number. The addition might overflow and since unsigned integers have defined overflow behavior the compiler needs to add extra instructions to

Performance difference of signed and unsigned integers of non-native length

好久不见. 提交于 2020-01-03 06:04:10
问题 There is this talk, CppCon 2016: Chandler Carruth “Garbage In, Garbage Out: Arguing about Undefined Behavior...", where Mr. Carruth shows an example from the bzip code. They have used uint32_t i1 as an index. On a 64-bit system the array access block[i1] will then do *(block + i1) . The issue is that block is a 64-bit pointer whereas i1 is a 32-bit number. The addition might overflow and since unsigned integers have defined overflow behavior the compiler needs to add extra instructions to

Printing Stack Frames

孤人 提交于 2020-01-03 03:43:09
问题 So I am currently learning about stack frames, and I wanted to experiment printing the stack frame (manually) of a function. I have the following picture in mind of a stack frame (I may be wrong): | | 0xffff0fdc +--------------------------------+ | ... | 0xffff0fd8 +--------------------------------+ | parameter 2 | 0xffff0fd4 +--------------------------------+ | parameter 1 | 0xffff0fd0 +--------------------------------+ | return address | 0xffff0fcc +--------------------------------+ | local

What efficient way to load x64 ymm register with 4 seperated doubles?

瘦欲@ 提交于 2020-01-03 02:54:59
问题 What is the most efficient way to load a x64 ymm register with 4 doubles evenly spaced i.e. a contiguous set of doubles 0 1 2 3 4 5 6 7 8 9 10 .. 100 And i want to load for example 0, 10, 20, 30 4 doubles at any position i.e. i want to load for example 1, 6, 22, 43 回答1: The simplest approach is VGATHERQPD which is an AVX2 instruction available on Haswell and up. VGATHERQPD ymm1, [rsi+xmm7*8], ymm2 Using dword indices specified in vm32x, gather double-pre-cision FP values from memory

64bit compilation with visual studio express 2013

£可爱£侵袭症+ 提交于 2020-01-03 02:22:44
问题 I have to compile a C++ project and make it run as 64bit application to avoid the 32bit memory limitation. My IDE is Visual Studio 2013 Express for Windows Desktop I couldn't find a clear answer on how to do this, anybody has a solution ? 回答1: From command line, load the cross-compiler : call %VSDIR%\VC\vcvarsall.bat x86_amd64 Open solution %VSDIR%\Common7\IDE\WDExpress.exe solution.sln and that's it. The x86_amd64 switch to a compiler (which happens to be a 32bit program) that produces 64bit

is it certain in which register arguments and variables are stored?

笑着哭i 提交于 2020-01-02 16:16:18
问题 I'm still uncertain how registers are being used by the assembler say I have a program: int main(int rdi, int rsi, int rdx) { rdx = rdi; return 0; } Would this in assembly be translated into: movq %rdx, %rdi ret rax; I'm new to AT&T and have hard time predicting when a certain register will be used. Looking at this chart from Computer Systems - A programmer's perspective , third edition, R.E. Bryant and D. R. O'Hallaron: charter 回答1: Is it certain in which register arguments and variables are