x86-64

If we marked memory as WC(Write Combined), then do we have any consistency automatically?

混江龙づ霸主 提交于 2019-12-07 20:11:13
问题 As we know on x86 architecture the acquire-release consistency provided automatically - i.e. all operations automatically ordered without any fences, exclude first store and next load operations. (As said Herb Sutter on page 34: https://onedrive.live.com/view.aspx?resid=4E86B0CF20EF15AD!24884&app=WordPdf&authkey=!AMtj_EflYn2507c ) If we put MFENCE(LFENCE+SFENCE) between them, then store can't be reordered, and load can't be reordered - i.e. we provided sequential consistency . But if we

Why do ES and DS zero out eventually on 64 bit kernel when set to TLS selectors?

不羁岁月 提交于 2019-12-07 17:33:49
问题 The 32-bit program below calls set_thread_area(2) to create an entry in GDT, which is meant to be used for TLS. Typically the resulting selector is put into FS or GS and successfully used. But if it is put into DS or ES , running on a 64-bit kernel, eventually (after context switch I guess) this selector zeroes out. But if I instead use modify_ldt(2) and put selector of the resulting LDT entry into these segment registers, they appear to hold their values! Also, if I put e.g. selector of 64

Xcode 8.1 Undefined symbols for architecture x86_64 Error

霸气de小男生 提交于 2019-12-07 16:44:49
问题 Undefined symbols for architecture x86_64: "_BROADCAST_MODE_IBEACON", referenced from: -[MainViewController tableView:cellForRowAtIndexPath:] in MainViewController.o "_OBJC_CLASS_$_TZBeaconSDK", referenced from: objc-class-ref in MainViewController.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) I take that error when I want to use simulator. There is no problem when I build it on iPhone. There is only problem

Alignment of vectors in LLVM's amd64 output

ⅰ亾dé卋堺 提交于 2019-12-07 16:29:34
问题 I'm trying to use vectors inside structs with LLVM. I have the following C definition of my struct: struct Foo { uint32_t len; uint32_t data[32] __attribute__ ((aligned (16))); }; and here's some LLVM code to add 42 to element number 3 of the data field: %Foo = type { i32, <32 x i32> } define void @process(%Foo*) { _L1: %data = getelementptr %Foo* %0, i32 0, i32 1 %vec = load <32 x i32>* %data %x = extractelement <32 x i32> %vec, i32 3 %xNew = add i32 42, %x %vecNew = insertelement <32 x i32>

Why did they use numbers for register names in x86-64?

只谈情不闲聊 提交于 2019-12-07 13:46:33
问题 AFAIK x86-64 adds a number of general purpose registers to those derived from Intel x86 ( rax , rcx , etc), called r8 - r15 . Why did they name the new registers like this? Why not just follow existing naming convention and call them like rfx , rgx ... ? 回答1: Numbering CPU registers is the norm, almost any processor does that. The 8086 processor however is ancient, they had an extremely limited transistor budget back in 1976. Implementing a 16-bit processor with only 20,000 active transistors

Create and test x86-64 ELF executable shellcode on a Linux machine

自作多情 提交于 2019-12-07 13:00:11
问题 I am creating a training on buffer overflows and stack/heap attacks. I am working on an Ubuntu 12.04 x86_64 machine and want to show some sample buggy programs and the ways you could exploit those vulnerabilities. I am trying to start with the most basic shellcode I have found so far, the simple exit call, which should exit the program being overflowed. Hereby the exitcall.asm : ;exitcall.asm [SECTION .text] global _start _start: xor ebx,ebx ; zero out ebx, same function as mov ebx,0 mov al,

64bit nasm division idiv

眉间皱痕 提交于 2019-12-07 12:43:30
问题 ;print out division message mov rcx, 0 ;zero out register mov rax, [input] mov rcx, [input2] idiv rcx ;divide rax by rcx mov rdi, rax ;for printing purposes call print_int I can't seem to figure out why this isn't dividing, I'm getting a enrror "Floating Point Exception" I'm using a 64bit machine and the values are integers not floating point.... ideas? I know after the division takes place the quotient should be in rax, and the remainder should be in rdx i believe, but as of right now i'm

Why are global variables in x86-64 accessed relative to the instruction pointer?

余生长醉 提交于 2019-12-07 11:21:10
问题 I have tried to compile c code to assembly code using gcc -S -fasm foo.c . The c code declare global variable and variable in the main function as shown below: int y=6; int main() { int x=4; x=x+y; return 0; } now I looked in the assembly code that has been generated from this C code and I saw, that the global variable y is stored using the value of the rip instruction pointer. I thought that only const global variable stored in the text segment but, looking at this example it seems that also

How do you check syscall for x86_64?

旧时模样 提交于 2019-12-07 10:39:39
问题 I can't find a dedicated official website to search for such information . For example,if I want to do exit ,how should I do it with syscall introduced in x86_64? Any manual for this kind of details? I'm on Centos. 回答1: Glibc sysdeps/unix/sysv/linux/x86_64/syscall.S, see if this helps. 回答2: Let the C library do it for you: movl $0, %rdi # or whatever exit code you want (0-127) call _exit You really do not want to make system calls yourself. The C library insulates you from a bunch of low

Do we also refer to the registers RAX, RBX etc as R1, R2 and so on?

狂风中的少年 提交于 2019-12-07 10:08:21
问题 I am studying 8086/8080 microprocessors. The registers used in them have names, RAX RBX RCX RDX and go on until R8 when the registers are named as R8, R9... to R15. I wanted to know Do we also refer to the registers RAX, RBX etc as R1, R2 and so on? 回答1: Standard practice is for the first 8 registers to keep their historical name. This convention is used in the documentation from Intel and AMD and in most assemblers. The reason for this is that these names are mnemonic for the function of the