Questions tagged [x86-64]

1

votes
1

answer
34

Views

How do the hex numbers after a jump instruction translate into a memory address?

I have this in my code disassembly: I see the jump instruction code E9, but how the numbers after E9 translate into the memory address shown?
Arush Agarampur
1

votes
2

answer
1.3k

Views

Wait for keypress Assembly NASM, Linux

I'm working on a Hello World in Assembly for x86-64. I have managed to create one that finishes when Enter key is pressed, but I have to finish it when ANY key is pressed. This is the code for waiting the ENTER Key: mov rax, 0 mov rdi, 0 mov rdx, 1 syscall I can't use any int xh or something like t...
Guolf3377
1

votes
2

answer
64

Views

How can I compare the first character of a string with another character in x86-64 assembly?

I have an initialized string 'Hello, World!' from which I would like to extract the first character (i.e. 'H') and comapre it a character that is passed into a register at run time. I have tried comparing the first character of 'Hello, World!' with 'H' through the following code: global start sectio...
mooncow
1

votes
1

answer
47

Views

Previously faulting unaligned calls now working?

I'm not sure if I'm delusional, but I'm near certain calls used to fail on System V Linux x86_64 if they weren't aligned upon entry (i.e. you'd purposely disalign the stack before a call so it's aligned upon entry). For example (this now works): .data str: .asciz 'string literal' .text .globl main m...
oldjohn1994
1

votes
1

answer
2.2k

Views

Write a jump command to a x86-64 binary file

I'm debugging a Mac OS X 64bit app with GDB. I see that jumping over a chunk of code solves all my problems. But: How can I patch the executable file to implement the jump? I want the app to automatically jump to a defined point in the code without the debugger. This is what I want to do: At address...
John White
1

votes
0

answer
45

Views

Loop exiting early when making Linux system calls [duplicate]

This question already has an answer here: Why do x86-64 Linux system calls modify RCX, and what does the value mean? 1 answer What are the calling conventions for UNIX & Linux system calls on i386 and x86-64 4 answers I am trying to write a program that prints an integer, the integer is stored in...
うちわ 密か
1

votes
1

answer
75

Views

Ubuntu 16.04 server amd64 install failed

I created a bootable usb using etcher on Mac os. The PC I installed on is a Dell Inspiron with Windows 7 64bit. Installation fails at the select and install step. None of the packages are able to install, causing the install to abort. I was only able to install Ubuntu 16.04 i386. Which is not capabl...
Omar Vivar
1

votes
0

answer
151

Views

How to avoid generation of extra assembly instruction by gcc compiler for an inline assembly function

I have two questions about generation of assembly code by gcc as a result of using inline assembly function in C file. Let me first explains my situation/code and then I will ask questions. Situation: I have defined following macro NBL2SPM which calls the mySimMagic2() function. #define NBL2SPM(comp...
NUM
1

votes
0

answer
343

Views

Cross-compile from x86-64 Ubuntu to Windows with clang++

The program is as follows: #include int main() { } Everything goes OK if I use clang++ helloworld.cpp But when I try to cross-compile it for Windows I get an error: clang++ helloworld.cpp -target x86_64-win32 helloworld.cpp:1:10: fatal error: 'iostream' file not found #include ^ 1 error generated....
user9162106
1

votes
1

answer
157

Views

which mode in intel x86-64 is faster to execute instructions

Intel has - real mode - protected mode - virtual real mode - 64-bit mode Out of these modes, which one execute the same sets of instructions faster? using prefixes one can change the addresses & sizes that can similar to other modes.
Lakshman Siddardha
1

votes
0

answer
204

Views

Running Kestrel in 64-bit mode with ASP.NET Core MVC web apps

With a ASP.NET Core MVC web app, is there a way to run the Kestrel web server in 64-bit (or AnyCPU) mode? If I change my app's target platform from the default x86 to either x64 or AnyCPU, it no longer runs, producing a System.BadImageFormatException when trying to start Kestrel (Microsoft.AspNetCor...
Paul Lambert
1

votes
0

answer
95

Views

leal and indirect addressing

Why is that replacing movl $84, 3(%rsi) with movl $3, %ecx leal (%esi, %ecx, 1), %r11d movl $84, (%r11d) results in Segmentation fault (core dumped) and how can I solve it? (I will be using %ecx as a counter later on to loop through the array) As I understand it, movl $84, 3(%rsi) moves...
xiuolpcpb
1

votes
0

answer
113

Views

Pushing imm32 ends up in pushing imm64? [duplicate]

This question already has an answer here: How many bytes does the push instruction push onto the stack when I don't specify the operand size? 2 answers push on 64bit intel osx 4 answers From the intel instruction reference: 68 id PUSH imm32 It means pushing dword-sized immediates is valid in 64-bi...
St.Antario
1

votes
1

answer
32

Views

How bad is modifying the timer interrupt?

Suppose we're talking about a cloud linux server. For a project I have. How bad would it be to modify the timer interrupt such that on each tick the processor will also check 1-4 cached dwords ? Will that run the system totally unstable? Much slower? Second, is the timer interrupt is anywhere near...
David Salame
1

votes
0

answer
35

Views

Changing order of data section affects result in x64 using RIP relative addressing

I'm writing some x86-64 assembly, and changing the order of the data section seems to change the result. Here is the data section: .data pstr: .asciz '%d\n' a: .long 10 b: .long 3 c: .long 300 dnm2: .long 0 And here is the code, which is doing a = b / a and then printing a. (In a...
user6397000
1

votes
0

answer
162

Views

x86-64 assembly shell sort algorithm conversion

I have been working on this assembly program to sort a list of numbers, it seems like I am following the logic of the shell sort but when I run it continuously runs, therefore there is an issue in my sort any ideas where I am making a mistake? Im pretty sure the integer to base 36 macro works but I...
Denis Dimitrov
1

votes
0

answer
42

Views

Declaring variables in Yasm

Here's is a simple program: %include 'utils/system.inc' section .data first: db 'First is bigger', 0xA,0 second: db 'Second is bigger', 0xA,0 a: db 18 b: db 20 section .text global start start: mov rax, [a wrt rip] mov rbx, [b wrt rip] cmp rax, rbx jle else mov rsi...
nullbyte
1

votes
0

answer
101

Views

why is my code and data segments in one elf64-x86-64 elf readelf

readelf -e output is below. Notice that my code and data segments are rolled into one? How is this being done? Can I disable it? I'm using openSuse 42.2 which is a 64-bit OS. I'm running out of ideas, I've searched everywhere. The only reference I can find is via this website https://timothylottes.g...
Winston Ang
1

votes
0

answer
127

Views

Reading the output of objdump on linux x86_64

I am trying to learn to exploit a sprintf vulnerability. I've gotten to: env -i ./addhost a a '$(python -c 'import sys; sys.stdout.write('sh;#AAAABBBB%037956x%10$hp%63387x%10$hp')')' But reading the objdump code on x86_64 I get addresses like: jmpq *0x20093a(%rip) Which would imply that to get to...
oxagast
1

votes
0

answer
64

Views

linking functions in shared object - ld

I'm trying to write a library (shared object) in assembly. I'm compiling with nasm and linking with ld. I've got 2 ASM files containing differents symbols. I'm trying to call a symbol contained in the first file from the second one, but ld keep throwing an error : relocation R_X86_64_PC32 against sy...
Nathan Schwarz
1

votes
0

answer
58

Views

Assembly language Average of arr

I am starting learn assebly(86-64,AT&T syntax)and I have problems with finding avearge of array(aver should be in float), could you give some example how can I find it .Here part of my code movq counter,%rcx #counter stored how many elements in arr I have...
Malika Sadullaeva
1

votes
0

answer
91

Views

Segmentation fault(core dumped) when trying to scanf

I wrote the code by using Assembly AT&T and it always displays Segmentation fault (core dumped) My program should display Enter the value for n: Then it should take the value and then display this value but After taking the value is displays the error I have mentioned above my code is: .global _st...
1

votes
0

answer
216

Views

Array input using scanf in nasm

I'm trying to read floating point input for array using loop and then printing the array. After reading n values, it gives segmentation fault. I can't figure out what is wrong. How can i correct the error? %macro exit 0 mov rax,60 mov rdi,0 syscall %endmacro extern printf extern scanf ;------------...
welkin
1

votes
0

answer
70

Views

An assembly code in book CSAPP [duplicate]

This question already has an answer here: Why does System V / AMD64 ABI mandate a 16 byte stack alignment? 1 answer What does it mean to align the stack? 6 answers In the book CSAPP, 3.7.5 Local Storage in Registers, there is a calling function: long P(long x, long y) { long u = Q(y); long v = Q(x...
Manhooo
1

votes
0

answer
57

Views

Interpretation of IEEE-754 doubles between machines

I have two machines, one is a MIPSPro machine running IRIX and the other one is an x86_64 machine running RHEL 6.7. In both of these machines I am reading a binary stream of data and converting each 8 bytes to a doubles. I.e both doubles contain the same bytes. I should mention that the values ar...
Iliketoproveit
1

votes
0

answer
362

Views

Windows x86_64: “node.exe is not a valid win32 application”

There is a problem with amd64 jdk on amd64 windows and maven-frontend-plugin: When mvn compile is ran, it grabs amd64 version of node.exe, which is expected; then it tries to run npm.cmd install, to install deps. Problem is that after that, everything fails: [ERROR] Failed to execute goal com.github...
Mikhail Krutov
1

votes
0

answer
265

Views

Find address in x64 executable from memory address

This post (Find an instruction in an executable file, given its address in a running process?) contains detailed instructions how to calculate an address within an executable file from a memory address of a running process. How do I determine the base address to use if I want to apply the formula t...
Stefan
1

votes
0

answer
208

Views

What do the differences in the assembly mean for these printf calls

So given the following c program: #include int main() { int a = 3; printf('hello world %d\n', a); } Running it with clang x86-64 v6.0 produces the following assembly with no optimisations: main: # @main pushq %rbp movq %rsp, %rbp subq $16, %rsp movabsq $.L.str, %rdi movl $3, -4(%rbp) movl -4(%rbp),...
flooblebit
1

votes
0

answer
49

Views

how to obtain return address of current user stack frame from linux kernel x86_64 [VMI]

I want to obtain the return address of the current user stack frame from some Linux kernel structure on a Linux x86_64 VM using a VMI-based approach. I can access the content of more or less all registers, but solely at the moment of a context switch (CR3 event), so registers like RBP or RSP are po...
auermich
23

votes
1

answer
434

Views

Why might a C++ compiler duplicate a function exit basic block?

Consider the following snippet of code: int* find_ptr(int* mem, int sz, int val) { for (int i = 0; i < sz; i++) { if (mem[i] == val) { return &mem[i]; } } return nullptr; } GCC on -O3 compiles this to: find_ptr(int*, int, int): mov rax, rdi test esi, esi jle .L4 # why no...
Alex Reinking
1

votes
1

answer
280

Views

How to increment value of global variable in assembly in linux

I am going through the assembly implementation of AES algorithm to understand, how sbox and lookup table are implemented/accessed. Theoretically I know, AES uses 10 rounds when key length=128bits. There is one part where one loop of 200 lines of code (representation of AES rounds) is executed. _x8...
bholanath
1

votes
1

answer
66

Views

Trouble Reading Bin File Output of NASM through a Hex Converter

On Ubuntu 17.10.1 x86_64 I was interested in the way that different assemblers assemble assembly code (namely NASM), to see if I could build a mini-assembler as a mini project. So I wrote some very simple assembly commands: test.asm mov ax, 48 mov bx, 48 add ax, bx I assembled the file with no optim...
1

votes
0

answer
75

Views

Breaking a stack/call frame information chain on ELF/Linux?

I'm trying to do a rather niche thing which is essentially breaking the CFI (Call Frame Information in DWARF EH info) and rbp & rsp links between frames. Main reason for that is that is that past a certain point in thread control flow I want to do a call continuation which is basically a one-way ta...
1

votes
0

answer
88

Views

Buffer Overflow to Modify the Return Address

I'm needing to modify the return address so I can call print_good function. I need an offset value, and a hex value to store to do so. The offset that I calculated from using obj is 0xcd, which was gotten 0x40074e(the puts function which I believe prints out try again) minus 400686(The address of th...
1

votes
0

answer
55

Views

What's wrong with my NASM program?

I recently started programming in assembly language and could get something wrong. This code is supposed to write out '21947392': section .data nl db 10 section .bss number resb 19 .end resb 1 section .text GLOBAL start start: mov rdi, 21947392 call _printNumber mov rax, 0x2000001 xor rdi, rdi sysca...
Going To Dark
1

votes
1

answer
48

Views

Boot loader makes different results after lgdt in different virtual machines

I'm writing a simple boot loader. The boot loader is compiled from two assembly files: boot.asm, protected_start.asm. boot.asm loads protected_start to 0x10000, sets GDTR, enters protected mode and jump to 0x10000. So the encoding is set to 16-bit in boot.asm, 32-bit in protected_start.asm. I use QE...
paxbun
1

votes
0

answer
50

Views

Assembly, Reserving Space with resq in YASM

Using YASM I have tried to reserve space for 2000 quadwords, but when I do this I get a SIGSEGV when I try to write into the reserved block of quadwords. If I reserve space for only 300 quadwords, the program runs without error. What causes this? ; Using Windows 7 (Intel Celeron 64-bits) ; yasm -f w...
Patrick Clot
1

votes
0

answer
115

Views

Are x86-64 CPU registers shared among multiple cores? [duplicate]

This question already has an answer here: Does each core has its own private set of registers? 2 answers What does multicore assembly language look like? 10 answers Why each logical CPU has it's own CR3 register in case of multithreading? 1 answer Can I temporarily enable FTZ and DAZ floating-poi...
MikeF
0

votes
0

answer
5

Views

Long jump with a selector decided at run time in x86

I'm trying to perform a long jump in assembly so that I can load a descriptor from the GDT into the segment register CS. I realize I can do this by hard coding the address like this (jmp 0xAB:some_label) but I don't want to hard code the address like that. I see that the jump instruction has the fol...
GamefanA
1

votes
0

answer
80

Views

ContinueDebugEvent results in crash in my debugger but not in x64dbg

I made a small debugging application specifically to modify a protected executable, when using the application I can hand off the debugging by suspending the process then calling DebugActiveProcessStop and attaching x64dbg to the process and resuming. The target I'm debugging performs a checksum on...

View additional questions