x86-64

Lightweight method to use Amd64 instructions under 32-bit Windows?

人走茶凉 提交于 2019-12-12 10:43:12
问题 For some CPU-bound code using 64-bit variables, it is beneficial to use the Amd64 instruction set rather than x86. How can it be done under 32-bit Windows (e.g. Windows XP SP3)? Of course I assume a modern, Amd64-enabled CPU. I'm excluding the working but heavyweight method: running a full-blown 64-bit OS as a virtual machine, e.g. Ubuntu for Amd64 under Virtualbox. I understand some assembly is needed, and there will restrictions, in particular addressing more memory than 32-bit Windows

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

落爺英雄遲暮 提交于 2019-12-12 09:42: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

Difference in ABI between x86_64 Linux functions and syscalls

痞子三分冷 提交于 2019-12-12 09:35:25
问题 The x86_64 SysV ABI's function calling convention defines integer argument #4 to be passed in the rcx register. The Linux kernel syscall ABI, on the other hand, uses r10 for that same purpose. All other arguments are passed in the same registers for both functions and syscalls. This leads to some strange things. Check out, for example, the implementation of mmap in glibc for the x32 platform (for which the same discrepancy exists): 00432ce0 <__mmap>: 432ce0: 49 89 ca mov %rcx,%r10 432ce3: b8

Operations on hexadecimal strings in context of uint128_t integers

老子叫甜甜 提交于 2019-12-12 09:25:02
问题 The upper limit for standard Linux library function strtoull is 64 bits. Does there exist an implementation for strtoX -family function for Linux x86_64 environment that operates on uint128_t integers? Possible prototype: uint128_t strtoulll(const char *nptr, char **endptr, int base); Also, how can you print uint128_t integers using printf / sprintf ? 回答1: There is no type uint128_t as of the standard. A type __int128 is mentioned as "common extension" only in J.5.6, but still not part of the

Handling calls to (potentially) far away ahead-of-time compiled functions from JITed code

荒凉一梦 提交于 2019-12-12 07:46:54
问题 This question was put on hold as too broad, presumably because of the research I included in an effort to "show my work" instead of asking a low effort question. To remedy this, allow me to summarize the entire question in a single sentence (credit to @PeterCordes for this phrase): How do I efficiently call (x86-64) ahead-of-time compiled functions (that I control, may be further than 2GB away) from JITed code (that I am generating)? This alone, I suspect, would be put on hold as "too broad."

NUnit “missing” GPSVC.DLL on Windows 7/64

陌路散爱 提交于 2019-12-12 07:10:04
问题 I recently upgraded from Vista/32 to Win7/64. On my old machine, everything was working fine. Unfortunately, on my new machine NUnit won't load my unit tests, with the error message "System.IO.FileNotFoundException: Could not load file or assembly 'UnitTest' or one of its dependencies. The system cannot find the file specified" . (Actually, I had to go through all of my solution's projects and set them to 32-bit to get this far.) So I loaded up Dependency Walker, and it told me that I was

missing required architecture x86_64 in …libMumbleKit.a (3 slices)

别等时光非礼了梦想. 提交于 2019-12-12 06:52:10
问题 I am trying to include MumbleKit as a library instead of having to compile it each time by following the suggestion of a member of this forum. Yet when I try to compile on the simulator I get: missing required architecture x86_64 in …libMumbleKit.a (3 slices) I think I added all the necessary versions to MumbleKit before generating the library: arm64 armv7 armv7s armv7k arm7s x86_64 i386 notwithstanding, when I execute: lipo -info libMumbleKit.a I get: Architectures in the fat file:

x64: How to do a relative jmp *%rax?

旧时模样 提交于 2019-12-12 06:48:46
问题 I want to encode a 64 bit relative jump to the address stored in %rax in x64 assembly. AFAIK, there is no opcode for this, so I calculate the corresponding absolute address for the relative address manually and then I do an absolute jump to the absolute address: # destination address, relative to end of jmp instruction, is stored in %rax 00007ffff7ff6020: 0x0000488d1505000000 lea 0x5(%rip),%rdx # load %rip+5 (rip + size of add and jmpq) into %rdx 00007ffff7ff6027: 0x0000000000004801d0 add

Error trying to build a fat universal binary with gcc on Ubuntu

此生再无相见时 提交于 2019-12-12 06:37:31
问题 I try to run a very simple code, but it reports error, can anyone give some suggestions? I am using Ubuntu14 and gcc4.9. xin@ubuntu:~/pipes$ gcc -arch i386 -arch x86_64 channel.cpp gcc: error: i386: No such file or directory gcc: error: x86_64: No such file or directory gcc: error: unrecognized command line option ‘-arch’ gcc: error: unrecognized command line option ‘-arch’ 回答1: Looks like you are trying to use the Apple OS/X (Darwin) GCC/CLang method of compiling code to a universal binary

Reversed Mach-O 64-bit x86 Assembly analysis

冷暖自知 提交于 2019-12-12 06:25:01
问题 This question is for Intel x86 assembly experts to answer. Thanks for your effort in advance! Problem Specification I am analysing a binary file, which match Mach-O 64-bit x86 assembly . I am currently using MacOS 64 OS. The assembly comes from objdump . The problem is that when I am learning assembly, I can see variable name "$xxx", I can see string value in ascii and I can also see the callee name like "call _printf" But in this assembly, I can get nothing above: no main function: