I am interested in executing a function which is written in C language:- I want to call this fun() through assembly language which i have written:- (NASM 64bit) I have created object file by using these commands nasm -f elf64 MyAsm.asm and gcc -c CLang.c. When I merge these two file with gcc gcc MyASM.o CLang…
Tag: x86-64
X86-64 passing float and int as arguments
When passing a float to a function as the first argument the %xmm0 register gets set. What if we want to pass an integer as the second argument in the function. Which one of %rdi or %rsi gets the argument? e.g. avg ( float f, int i ) Is the order preserved, so that %rsi will get the int? Edit:
What is C-state Cx in cpupower monitor
I am profiling an application for execution time on an x86-64 processor running linux. Before starting to benchmark the application, I want to make sure that the Dynamic Frequency scaling and idle states are disabled. Check on Frequency scaling This tells me that the Frequency scaling(Intel’s Turbo Boos…
Linux perf_events annotation frame pointer confusion
I ran sudo perf record -F 99 find / followed by sudo perf report and selected “Annotate fdopendir” and here are the first seven instructions: push %rbp push %rbx mov %edi,%esi mov %edi,%ebx mov $0x1,%edi sub $0xa8,%rsp mov %rsp,%rbp The first instruction appears to be saving the caller’s bas…
Reason for collapse of memory bandwidth when 2KB of data is cached in L1-cache
In a self-educational project I measure the bandwidth of the memory with help of the following code (here paraphrased, the whole code follows at the end of the question): BLOCK_SIZE is choosen in such a way, that a whole 64byte cache line is fetched per single integer-addition. My machine (an Intel-Broadwell)…
Finding mapped memory from inside a process
Setup: Ubuntu 18×64 x86_64 application Arbitrary code execution from inside the application I’m trying to write code which should be able to find structures in memory even with ASLR enabled. Sadly, I couldn’t find any static references to those regions, so I’m guessing I have to use the…
Transition of multi-core processor from real mode to protected mode in Linux
I’m trying to learn more about operating systems and I am currently taking a look how the Linux kernel is loaded and initialized. Thanks to several related questions and this book, I was mostly able to understand how the transition from real mode to protected mode works. However, the one thing I donR…
Why doesn’t this attempt at using sys_write do anything?
Here it is: Not only does this code not segfault, it also outputs nothing. According to what I’ve read, a program should call sys_exit, or it would segfault, but this does not happen. Answer This instruction will interpret the data at “msg” as 64-bit value and load that value into the regist…
Pass values from C program to Assembly language
I would like to pass values from C program to Assembly using the linked assembly method instead of inline assembly method in C. Below is the Assembly program(GCD) which is am working on. And this is the C program from with I am trying to pass the values to assembly program When I compile using the below metho…
Is it possible to use both 64 bit and 32 bit instructions in the same executable in 64 bit Linux?
A 64 bit CPU (amd64) supports 32 bit Intel instructions in the compatibility mode. Also, a 64 bit Linux installation allows running ELFs containing 32 bit instructions if the ELF header says it is a 32 bit executable. I was wondering if it is possible to put some assembly instructions inside the ELF which swi…