x86-64

How to push a 64bit int in NASM?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 06:14:53
问题 I'm trying to push a 64bit integer but when assembling NASM seems to want to see it as a DWORD not a QWORD. I'm using ASM to create the shellcode I need to inject a 64bit DLL into a 64bit process. The first QWORD is the old instruction pointer, the second is the address containing the address of the DLL, the third is the address of LoadLibrary. The placeholders are filled in at runtime. section .text global _start _start: BITS 64 PUSH QWORD 0xACEACEACACEACEAC PUSHFQ push rax PUSH QWORD

How can I accurately benchmark unaligned access speed on x86_64

寵の児 提交于 2019-12-17 04:02:13
问题 In an answer, I've stated that unaligned access has almost the same speed as aligned access a long time (on x86/x86_64). I didn't have any numbers to back up this statement, so I've created a benchmark for it. Do you see any flaws in this benchmark? Can you improve on it (I mean, to increase GB/sec, so it reflects the truth better)? #include <sys/time.h> #include <stdio.h> template <int N> __attribute__((noinline)) void loop32(const char *v) { for (int i=0; i<N; i+=160) { __asm__ ("mov (%0),

Targeting both 32bit and 64bit with Visual Studio in same solution/project

五迷三道 提交于 2019-12-17 02:53:12
问题 I have a little dilemma on how to set up my visual studio builds for multi-targeting. Background: c# .NET v2.0 with p/invoking into 3rd party 32 bit DLL's, SQL compact v3.5 SP1, with a Setup project. Right now, the platform target is set to x86 so it can be run on Windows x64. The 3rd party company has just released 64 bit versions of their DLL's and I want to build a dedicated 64bit program. This raises some questions which I haven't got the answers to yet. I want to have the exact same code

Printing an integer as a string with AT&T syntax, with Linux system calls instead of printf

邮差的信 提交于 2019-12-17 02:51:26
问题 I have written a Assembly program to display the factorial of a number following AT & t syntax.But it's not working.here is my code .text .globl _start _start: movq $5,%rcx movq $5,%rax Repeat: #function to calculate factorial decq %rcx cmp $0,%rcx je print imul %rcx,%rax cmp $1,%rcx jne Repeat # Now result of factorial stored in rax print: xorq %rsi, %rsi # function to print integer result digit by digit by pushing in #stack loop: movq $0, %rdx movq $10, %rbx divq %rbx addq $48, %rdx pushq

__builtin_prefetch, How much does it read?

廉价感情. 提交于 2019-12-17 02:38:18
问题 I'm trying to optimize some C++ (RK4) by using __builtin_prefetch I can't figure out how to prefetch a whole structure. I don't understand how much of the const void *addr is read. I want to have the next values of from and to loaded. for (int i = from; i < to; i++) { double kv = myLinks[i].kv; particle* from = con[i].Pfrom; particle* to = con[i].Pto; //Prefetch values at con[i++].Pfrom & con[i].Pto; double pos = to->px- from->px; double delta = from->r + to->r - pos; double k1 = axcel(kv,

Oracle12c Linux x86-64安装体验

你说的曾经没有我的故事 提交于 2019-12-16 06:29:18
1.添加一块新硬盘并格式化 [root@localhost ~]# cd /dev [root@localhost dev]# ls [root@localhost dev]# fdisk /dev/sdb [root@localhost dev]# mkfs -t xfs /dev/sdb1 2.创建orc目录 [root@localhost dev]# mkdir /orc 3.修改主机名 [root@localhost ~]# vim /etc/hostname #末行添加以下内容 HOSTNAME=oracle 4.修改域名解析 [root@localhost ~]# vim /etc/hosts #末行添加以下内容 192.168.142.151 oracle 5.挂载新硬盘到orc目录 [root@oracle ~]# mount /dev/sdb1 /orc 6.下载环境软件包 [root@oracle ~]# yum -y install binutils compat-libcapl compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC

linux系统——ld-linux.so.X查找和加载共享动态库的顺序

橙三吉。 提交于 2019-12-15 03:27:00
linux系统——ld-linux.so.X查找和加载共享动态库的顺序 ld-linux.so查找共享库的顺序: Glibc安装的库中有一个为ld-linux.so.X,其中X为一个数字,在不同的平台上名字也会不同。可以用ldd查看: #ldd /bin/cat linux-gate.so.1 => (0x00bfe000) libc.so.6 => /lib/libc.so.6 (0x00a4a000) /lib/ld-linux.so.2 (0x00a28000) 最后一个没有“=>”的就是。其中第一个不是实际的库文件,你是找不到的,它是一个虚拟库文件用于和kernel交互。 /lib/ld-linux.so.2以及它的64位版本/lib64/ld-linux-x86-64.so.2虽然看起来是共享库文件,但实际上他们可以独立运行。他们的功能是负责动态加载。它们通过读取可执行文件的头部信息来确定哪些库文件是必须的,以及哪些需要加载。加载完成后,它会通过修正执行文件里的相关的地址指针来和加载的库文件完成动态链接,此时程序就可以运行了。 ld-linux.so是专门负责寻找库文件的库。以cat为例,cat首先告诉ld-linux.so它需要libc.so.6这个库文件,ld-linux.so将按一定顺序找到libc.so.6库再给cat调用。 那ld-linux

Why does calling the C abort() function from an x86_64 assembly function lead to segmentation fault (SIGSEGV) instead of an abort signal?

早过忘川 提交于 2019-12-14 04:25:27
问题 Consider the program: main.c #include <stdlib.h> void my_asm_func(void); __asm__( ".global my_asm_func;" "my_asm_func:;" "call abort;" "ret;" ); int main(int argc, char **argv) { if (argv[1][0] == '0') { abort(); } else if (argv[1][0] == '1') { __asm__("call abort"); } else { my_asm_func(); } } Which I compile as: gcc -ggdb3 -O0 -o main.out main.c Then I have: $ ./main.out 0; echo $? Aborted (core dumped) 134 $ ./main.out 1; echo $? Aborted (core dumped) 134 $ ./main.out 2; echo $?

Understanding TLB from CPUID results on Intel

江枫思渺然 提交于 2019-12-14 03:46:00
问题 I'm exploring leaf 0x02 of the cpuid instruction and came up with a few questions. There is a table in the documentation which describes what cpuid results mean for the TLB configuration. Here they are: case 1 56H TLB Data TLB0: 4 MByte pages, 4-way set associative, 16 entries [...] B4H TLB Data TLB1: 4 KByte pages, 4-way associative, 256 entries Does it mean that there are only 2 levels of TLB? How to query the number of levels of TLB cache in case some x86 vendor decides to provide 3 levels

Does (p+x)-x always result in p for pointer p and integer x in gcc linux x86-64 C++

大城市里の小女人 提交于 2019-12-14 03:31:08
问题 Suppose we have: char* p; int x; As recently discussed in another question, arithmetic including comparison operations on invalid pointers can generate unexpected behavior in gcc linux x86-64 C++. This new question is specifically about the expression (p+x)-x : can it generate unexpected behavior (i.e., result not being p ) in any existing GCC version running on x86-64 linux? Note that this question is just about pointer arithmetic; there is absolutely no intention to access the location