x86-64

lldb affecting rcx value upon EXC_SYSCALL

浪尽此生 提交于 2020-03-24 00:58:08
问题 I noticed that upon an invalid 64bit MacOS syscall xor eax,eax syscall ;lldb stops here after the syscall When lldb stops the process while single stepping on: thread #1, stop reason = EXC_SYSCALL (code=5797, subcode=0x1) The rcx is equal to rsp . However when lldb is not attached or is not single stepping rcx is equal to expected return address after the syscall (i.e. is exactly of the same value as rip in user space). Is this some kind of a bug / side effect? I'm observing this on MacOS 10

C11 Atomic Acquire/Release and x86_64 lack of load/store coherence?

时光怂恿深爱的人放手 提交于 2020-03-17 10:58:59
问题 I am struggling with Section 5.1.2.4 of the C11 Standard, in particular the semantics of Release/Acquire. I note that https://preshing.com/20120913/acquire-and-release-semantics/ (amongst others) states that: ... Release semantics prevent memory reordering of the write-release with any read or write operation that precedes it in program order. So, for the following: typedef struct test_struct { _Atomic(bool) ready ; int v1 ; int v2 ; } test_struct_t ; extern void test_init(test_struct_t* ts,

C11 Atomic Acquire/Release and x86_64 lack of load/store coherence?

£可爱£侵袭症+ 提交于 2020-03-17 10:58:47
问题 I am struggling with Section 5.1.2.4 of the C11 Standard, in particular the semantics of Release/Acquire. I note that https://preshing.com/20120913/acquire-and-release-semantics/ (amongst others) states that: ... Release semantics prevent memory reordering of the write-release with any read or write operation that precedes it in program order. So, for the following: typedef struct test_struct { _Atomic(bool) ready ; int v1 ; int v2 ; } test_struct_t ; extern void test_init(test_struct_t* ts,

Can't link a shared library from an x86-64 object from assembly because of PIC

女生的网名这么多〃 提交于 2020-03-14 14:50:35
问题 I'm porting a shared library from 32-bit to 64-bit. It's composed of some assembly (written for NASM) that exports several procedures and a little bit of higher-level C glue code. I'm building on a 64-bit Debian machine with NASM 2.10.01 and GNU ld 2.22. Having fixed all the push/pop issues (pushing 32-bit parts of registers obviously won't work in 64-bit mode), I've got the object to assemble, but now I'm halted by the linking stage. Here are my command lines - assembly: nasm -Ox -dPTC_ARCH

Can't link a shared library from an x86-64 object from assembly because of PIC

依然范特西╮ 提交于 2020-03-14 14:47:27
问题 I'm porting a shared library from 32-bit to 64-bit. It's composed of some assembly (written for NASM) that exports several procedures and a little bit of higher-level C glue code. I'm building on a 64-bit Debian machine with NASM 2.10.01 and GNU ld 2.22. Having fixed all the push/pop issues (pushing 32-bit parts of registers obviously won't work in 64-bit mode), I've got the object to assemble, but now I'm halted by the linking stage. Here are my command lines - assembly: nasm -Ox -dPTC_ARCH

Can't link a shared library from an x86-64 object from assembly because of PIC

六眼飞鱼酱① 提交于 2020-03-14 14:45:05
问题 I'm porting a shared library from 32-bit to 64-bit. It's composed of some assembly (written for NASM) that exports several procedures and a little bit of higher-level C glue code. I'm building on a 64-bit Debian machine with NASM 2.10.01 and GNU ld 2.22. Having fixed all the push/pop issues (pushing 32-bit parts of registers obviously won't work in 64-bit mode), I've got the object to assemble, but now I'm halted by the linking stage. Here are my command lines - assembly: nasm -Ox -dPTC_ARCH

segmentation fault(core dumped) error while using inline assembly

馋奶兔 提交于 2020-03-14 05:36:31
问题 I'm using inline assembly in GCC. I want to rotate a variable content 2 bits to the left (I moved the variable to the rax register and then rotate it 2 times). I wrote the code below but I faced segmentation fault(core dumped) error. I would be grateful if you could help me. uint64_t X = 13835058055282163712U; asm volatile( "movq %0 , %%rax\n" "rol %%rax\n" "rol %%rax\n" :"=r"(X) :"r"(X) ); printf("%" PRIu64 "\n" , X); 回答1: The key to understanding inline asm is to understand that each asm

【转帖】超能课堂(186) CPU中的那些指令集都有什么用?

帅比萌擦擦* 提交于 2020-03-06 07:59:31
超能课堂(186) CPU中的那些指令集都有什么用? https://www.expreview.com/68615.html 我们都知道之所以计算机能够进行计算,主要靠的是大规模集成电路中由晶体管组成的逻辑电路。这些逻辑电路使得计算机能够进行运算及判断。但对于一个简单逻辑电路来讲,它只能进行一个完整运算中的部分操作,所以人们通过组合这些简单逻辑电路,这样就可以让计算机进行复杂的运算了。当CPU设计人员将这些组合逻辑电路制作成通用运算单元后,我们将一定格式的指令及数据输入,即可得到运算结果。而当需要的运算种类越来越多、运算越来越复杂后,CPU设计人员就将这些指令进行划分重构,组成一整套进行运算的集合,这就是 指令集 。 图片来自 Unsplash 不过以上面向CPU指令集设计师及CPU微架构设计师的,CPU指令设计者将不同一些计算机操作设计成指令,然后微架构设计师通过这些指令的格式等进行微架构设计。而对于软件开发者,更多接触到的是软件层面的汇编语言,通过汇编语言指令就可以让程序员控制计算机了。计算机软硬件架构是有层次的,随着高级语言的开发,GUI的出现,更多的人可以方便的使用计算机。虽然编程语言越来越“高级”,软件越来越华丽,但是其依然需要通过CPU中的海量晶体管进行运算,调用指令集。 从英特尔开发出8086处理器开始,x86指令集就开始形成了,此后英特尔推出了80286

IA64与x86-64的区别

亡梦爱人 提交于 2020-03-04 10:41:07
win7 sp1下载地址 :https://download.microsoft.com/download/0/A/F/0AFB5316-3062-494A-AB78-7FB0D4461357/windows6.1-KB976932-X64.exe 说到IA-64与x86-64可能很多人会比较陌生。不知道你在下载系统的时候有没有注意过,有的地方标注了x86/64/ia-64全版本等字样。那x86/x64/ia-64都是什么东西的版本呢?答案就是CPU。 系统有x64,x86与ia-64三种版本之分,分别用于不同的CPU。较老的CPU只能安装x86版的系统,也就是我们常见的32位系统。因为微软的缘故,32位系统在过去的很长一段时间内,占据着桌面计算机的主流地位。64位系统能够在较新的x86-64架构的CPU上运行。而ia-64则只能运行于INTEL的安腾系列处理器。 x86:从1978年来的8086处理器开始,就已经出现了x86架构CPU,即32位处理器。 x86-64:又简称为x64,最初开发为1999年AMD,为了扩充IA64。当时的x86-64架构诞生颇有时代意义,处理器的发展遇到了瓶颈,内存寻址空间由于受到32位CPU的限制而只能最大到约4G。于是就有了x86-64。后被INTEL所采用。 ia-64:其实ia64的历史早于x86-64x,最初由INTEL和惠普联合推出

IA64与x64的区别

元气小坏坏 提交于 2020-03-04 10:40:54
说到IA-64与x86-64可能很多人会比较陌生。不知道你在下载系统的时候有没有注意过,有的地方标注了x86/64/ia-64全版本等字样。那x86/x64/ia-64都是什么东西的版本呢?答案就是CPU。 系 统有x64,x86与ia-64三种版本之分,分别用于不同的CPU。较老的CPU只能安装x86版的系统,也就是我们常见的32位系统。因为微软的缘 故,32位系统在过去的很长一段时间内,占据着桌面计算机的主流地位。64位系统能够在较新的x86-64架构的CPU上运行。而ia-64则只能运行于 INTEL的安腾系列处理器。 x86:从1978年来的8086处理器开始,就已经出现了x86架构CPU,即32位处理器。 x86-64:又简称为x64,最初开发为1999年AMD,为了扩充IA64。当时的x86-64架构诞生颇有时代意义,处理器的发展遇到了瓶颈,内存寻址空间由于受到32位CPU的限制而只能最大到约4G。于是就有了x86-64。后被INTEL所采用。 ia- 64:其实ia64的历史早于x86-64x,最初由INTEL和惠普联合推出。由于ia-64不与32位兼容,所以没有受到重视。直到INTEL采用了 AMD的x86-64架构,才正式的批量生产。而后为了日益扩张的计算需求,INTEL重新将IA-64拿出来,发布了安腾系列服务器CPU。 虽然x86-64和IA