x86-64

x86_64 align stack and recover without saving registers

旧街凉风 提交于 2019-12-09 06:32:02
问题 I'm writing interrupt handling routines for x86_64. The ABI specifies that before calling a C function I must align the stack to 16 bytes. The x86_64 ISA specifies that on entry to an ISR, my stack is 8 byte aligned. I need to align my stack pointer to 16 bytes therefore. The issue is that on return from my C function, I must recover the (potentially) unaligned stack pointer so that I can return from my interrupt correctly. I wonder if there is a way to do this without using a general purpose

Cross compile windows 64 bit .exe from linux

拥有回忆 提交于 2019-12-09 04:44:47
问题 I know that if I want to compile a 32 bit .exe for windows on Linux I can just install and use the mingw32 package (e.g. apt-get install mingw32) on linux. What if I want to compile a windows .exe that is 64 bit? Is there tools or a method to do this? 回答1: It looks like my answer lies with the Mingw-w64 project which is available for host OSes Linux, Darwin & Windows 来源: https://stackoverflow.com/questions/2689813/cross-compile-windows-64-bit-exe-from-linux

With Hyper Threading, threads of one physical core are exchanging via what level of cache L1/L2/L3?

守給你的承諾、 提交于 2019-12-09 03:38:06
问题 Does the Hyper Threading allow to use of L1-cache to exchange the data between the two threads, which are executed simultaneously on a single physical core, but in two virtual cores? With the proviso that both belong to the same process, i.e. in the same address space. Page 85 (2-55) - Intel® 64 and IA-32 Architectures Optimization Reference Manual : http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf 2.5.9 Hyper-Threading

Efficient way to set first N or last N bits of __m256i to 1, the rest to 0

两盒软妹~` 提交于 2019-12-09 03:09:38
问题 How to set to 1 efficiently with AVX2 first N bits last N bits of __m256i , setting the rest to 0 ? These are 2 separate operations for tail and head of a bit range, when the range may start and end in the middle of __m256i value. The part of the range occupying full __m256i values is processed with all- 0 or all- 1 masks. 回答1: The AVX2 shift instructions vpsllvd and vpsrlvd have the nice property that shift counts greater than or equal to 32 lead to zero integers within the ymm register. In

x86 Assembly: INC and DEC instruction and overflow flag

北慕城南 提交于 2019-12-08 22:51:41
问题 In x86 assembly, the overflow flag is set when an add or sub operation on a signed integer overflows, and the carry flag is set when an operation on an unsigned integer overflows. However, when it comes to the inc and dec instructions, the situation seems to be somewhat different. According to this website, the inc instruction does not affect the carry flag at all. But I can't find any information about how inc and dec affect the overflow flag, if at all. Do inc or dec set the overflow flag

Error handling for system calls in x86 assembly, under Linux

扶醉桌前 提交于 2019-12-08 13:35:22
问题 I cannot find a definitive answer for how to correctly implement error handling for system calls in x86 assembly, under Linux. Shows that, returning from a syscall, register rax contains the result of the system-call. A value in the range between -4095 and -1 indicates an error. Logically then, if we ‘look’ at the return value in rax , and the value lies within this range, we can conclude that an error has occurred, and we can act on this information appropriately. However, how do we know

How does the 64 bit linux kernel kick off a 32 bit process from an ELF

*爱你&永不变心* 提交于 2019-12-08 13:31:05
问题 By looking at binfmt_elf.c in the kernel source, I have not been able to figure out what the kernel (64 bit) does differently when spawning a 32 bit process vs a 64 bit process. Can anybody explain to me what I am missing? (This question is related to my other question about having 32 bit instructions in the same process as 64 bit instructions (link), but this qualifies as a separate question.) 回答1: If the execveat system call is used to start a new process, we first enter fs/exec.c in the

Call C functions from 64-bit assembly

北慕城南 提交于 2019-12-08 10:38:03
问题 On ubuntu 16.04 $ cat hola.asm extern puts global main section .text main: mov rdi,message call puts ret message: db "Hola",0 $ nasm -f elf64 hola.asm $ gcc hola.o /usr/bin/ld: hola.o: relocation R_X86_64_PC32 against symbol `puts@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status Use: $gcc -fPIC hola.o -o hola && ./hola Hola The docs: -fPIC If supported for the target machine,

Pushing imm32 ends up in pushing imm64? [duplicate]

扶醉桌前 提交于 2019-12-08 08:48:05
问题 This question already has answers here : How many bytes does the push instruction push onto the stack when I don't specify the operand size? (2 answers) push on 64bit intel osx (4 answers) Closed last year . From the intel instruction reference: 68 id PUSH imm32 It means pushing dword-sized immediates is valid in 64-bit program. So I wrote the following program: section .text global _start _start: call _foo mov rax, 60 syscall _foo: push word 0xFFFF ;ok pop ax ;ok push dword 0xFFFFFFFF ;

g++ ld can't find RInside symbols for x86_64 architecture

江枫思渺然 提交于 2019-12-08 08:19:29
问题 I get a linker error saying that symbol(s) cannot be found when I try to compile an RInside sample file with g++. Any assistance would be appreciated. R version 2.13.1 is installed on Mac OS X 10.5. Rcpp and RInside include files have been copied to the usr/include directory. R headers and libraries have been included using the -I and -L modifiers of g++ as shown: $g++ -I/Library/Frameworks/R.framework/Headers -L/Library/Frameworks/R.framework/Libraries rinside_sample0.cpp The rinside_sample0