x86-64

How do you make a 8 byte call in x64 assembly? [duplicate]

a 夏天 提交于 2021-02-08 10:52:10
问题 This question already has answers here : Handling calls to (potentially) far away ahead-of-time compiled functions from JITed code (1 answer) How to execute a call instruction with a 64-bit absolute address? (1 answer) Call an absolute pointer in x86 machine code (2 answers) Closed 8 months ago . I am trying to hook a function in a process that is 64 bit, the relative jump is over 4 bytes so I can't do it via normal methods. Is there any way to jump 8 bytes relative or absolute? Cheers if any

Linux getting terminal arguments from _start not working with inline assembly in C

爷,独闯天下 提交于 2021-02-08 08:57:14
问题 I am trying to write my own _start function using inline assembly. But when I try to read argc and argv from stack (%rsp and %rsp + 8) I get wrong values. I don't know what I am doing wrong. #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <syscall.h> int main(int argc, char *argv[]) { printf("%d\n", argc); printf("%s\n", argv[0]); printf("got here\n"); return 0; } void _start() { __asm__( "xor %rbp, %rbp;" "movl (%rsp), %edi;" "lea 8(%rsp), %rsi;" "xor %rax, %rax;" "call

Linux getting terminal arguments from _start not working with inline assembly in C

非 Y 不嫁゛ 提交于 2021-02-08 08:57:03
问题 I am trying to write my own _start function using inline assembly. But when I try to read argc and argv from stack (%rsp and %rsp + 8) I get wrong values. I don't know what I am doing wrong. #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <syscall.h> int main(int argc, char *argv[]) { printf("%d\n", argc); printf("%s\n", argv[0]); printf("got here\n"); return 0; } void _start() { __asm__( "xor %rbp, %rbp;" "movl (%rsp), %edi;" "lea 8(%rsp), %rsi;" "xor %rax, %rax;" "call

Booting gem5 X86 Ubuntu Full System Simulation

ぃ、小莉子 提交于 2021-02-08 03:14:00
问题 I need to run a relatively newer version of x86 disk image on gem5. Starting from this guide I used Ubuntu 12.04 disk image with Kernel v3.2.1 as that combination was worked for someone else. After some point, simulator just hangs, please share any ideas about the reason and possible solutions. Thank you! You may find the output on the m5term/telnet below. After that, is the process to prepare the disk image and the kernel for reference. The last part of the terminal of gem5 (m5term/telnet):

Booting gem5 X86 Ubuntu Full System Simulation

天涯浪子 提交于 2021-02-08 03:07:09
问题 I need to run a relatively newer version of x86 disk image on gem5. Starting from this guide I used Ubuntu 12.04 disk image with Kernel v3.2.1 as that combination was worked for someone else. After some point, simulator just hangs, please share any ideas about the reason and possible solutions. Thank you! You may find the output on the m5term/telnet below. After that, is the process to prepare the disk image and the kernel for reference. The last part of the terminal of gem5 (m5term/telnet):

VEX prefixes encoding and SSE/AVX MOVUP(D/S) instructions

Deadly 提交于 2021-02-07 13:50:22
问题 I'm trying to understand the VEX prefix encoding for the SSE/AVX instructions. So please bear with me if I ask something simple. I have the following related questions. Let's take the MOVUP(D/S) instruction ( 0F 10 ). If I follow the 2-byte VEX prefix encoding correctly: The following two instruction encodings produce the same result: db 0fh, 10h, 00000000b ; movups xmm0,xmmword ptr [rax] db 0c5h, 11111000b, 10h, 00000000b ; vmovups xmm0,xmmword ptr [rax] As these two: db 066h, 0fh, 10h,

Linker error on relocating a program above 2GB in x86_64 linux?

亡梦爱人 提交于 2021-02-07 13:23:38
问题 I have a user program which normally compiles to have an entry point at 0x400460 which I have to relocate to have an entry point starting at within 2GB of the shared libraries loaded in Linux. e.g linux-vdso.so.1 => (0x00007fff109cd000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcd195e6000) /lib64/ld-linux-x86-64.so.2 (0x00007fcd199af000) I am using gcc command line argument -Wl,-Ttext=0x80000000 to specify the start address for the .text segemnt. The issue is that when I am giving

Why does GCC on x86-64 insert a NOP inside of a function?

我的未来我决定 提交于 2021-02-07 12:29:19
问题 Given the following C function: void go(char *data) { char name[64]; strcpy(name, data); } GCC 5 and 6 on x86-64 compile (plain gcc -c -g -o followed by objdump ) this to: 0000000000000000 <go>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 48 83 ec 50 sub $0x50,%rsp 8: 48 89 7d b8 mov %rdi,-0x48(%rbp) c: 48 8b 55 b8 mov -0x48(%rbp),%rdx 10: 48 8d 45 c0 lea -0x40(%rbp),%rax 14: 48 89 d6 mov %rdx,%rsi 17: 48 89 c7 mov %rax,%rdi 1a: e8 00 00 00 00 callq 1f <go+0x1f> 1f: 90 nop 20: c9 leaveq 21:

How does the linker find the main function?

空扰寡人 提交于 2021-02-07 06:25:06
问题 How does the linker find the main function in an x86-64 ELF-format executable? 回答1: A very generic overview, the linker assigns the address to the block of code identified by the symbol main . As it does for all the symbols in your object files. Actually, it doesn't assign a real address but assigns an address relative to some base which will get translated to a real address by the loader when the program is executed. The actual entry point is not likely main but some symbol in the crt that

Why is tailcall optimization not performed for types of class MEMORY?

 ̄綄美尐妖づ 提交于 2021-02-07 05:20:43
问题 I'm trying to understand the implication of System V AMD64 - ABI for returning by value from a function. For the following data type struct Vec3{ double x, y, z; }; the type Vec3 is of class MEMORY and thus the following is specified by the ABI concerning "Returning of Values": If the type has class MEMORY, then the caller provides space for the return value and passes the address of this storage in %rdi as if it were the first argument to the function. In effect, this address becomes a