nasm

How can I link dynamically to glibc in Ubuntu

十年热恋 提交于 2021-02-10 05:02:36
问题 I am trying to assemble and link this tiny x86 assembly code in Linux (Ubuntu 18.04 LTS): ;hello.asm global _start extern scanf, printf, exit section .data read_name db '%255s', 0 msg db 'Hello, %s', 0 section .text _start: sub esp, 256 push esp push read_name call scanf add esp, 8 push esp push msg call printf add esp, 264 push dword 0 call exit I am using nasm to assemble and ld to link. As you can probably tell, the code uses C functions, so it has to be linked to glibc . Since my code is

How can I link dynamically to glibc in Ubuntu

百般思念 提交于 2021-02-10 05:00:33
问题 I am trying to assemble and link this tiny x86 assembly code in Linux (Ubuntu 18.04 LTS): ;hello.asm global _start extern scanf, printf, exit section .data read_name db '%255s', 0 msg db 'Hello, %s', 0 section .text _start: sub esp, 256 push esp push read_name call scanf add esp, 8 push esp push msg call printf add esp, 264 push dword 0 call exit I am using nasm to assemble and ld to link. As you can probably tell, the code uses C functions, so it has to be linked to glibc . Since my code is

How can I link dynamically to glibc in Ubuntu

不羁岁月 提交于 2021-02-10 05:00:10
问题 I am trying to assemble and link this tiny x86 assembly code in Linux (Ubuntu 18.04 LTS): ;hello.asm global _start extern scanf, printf, exit section .data read_name db '%255s', 0 msg db 'Hello, %s', 0 section .text _start: sub esp, 256 push esp push read_name call scanf add esp, 8 push esp push msg call printf add esp, 264 push dword 0 call exit I am using nasm to assemble and ld to link. As you can probably tell, the code uses C functions, so it has to be linked to glibc . Since my code is

How can I link dynamically to glibc in Ubuntu

百般思念 提交于 2021-02-10 04:59:07
问题 I am trying to assemble and link this tiny x86 assembly code in Linux (Ubuntu 18.04 LTS): ;hello.asm global _start extern scanf, printf, exit section .data read_name db '%255s', 0 msg db 'Hello, %s', 0 section .text _start: sub esp, 256 push esp push read_name call scanf add esp, 8 push esp push msg call printf add esp, 264 push dword 0 call exit I am using nasm to assemble and ld to link. As you can probably tell, the code uses C functions, so it has to be linked to glibc . Since my code is

Can't understand assembly mov instruction between register and a variable

点点圈 提交于 2021-02-10 00:36:30
问题 I am using NASM assembler on linux 64 bit. There is something with variables and registers I can't understand. I create a variable named "msg": msg db "hello, world" Now when I want to write to the stdout I move the msg to rsi register, however I don't understand the mov instruction bitwise ... the rsi register consists of 64 bit , while the msg variable has 12 symbols which is 8 bits each , which means the msg variable has a size of 12 * 8 bits , which is greater than 64 bits obviously. So

Can't understand assembly mov instruction between register and a variable

南笙酒味 提交于 2021-02-10 00:31:28
问题 I am using NASM assembler on linux 64 bit. There is something with variables and registers I can't understand. I create a variable named "msg": msg db "hello, world" Now when I want to write to the stdout I move the msg to rsi register, however I don't understand the mov instruction bitwise ... the rsi register consists of 64 bit , while the msg variable has 12 symbols which is 8 bits each , which means the msg variable has a size of 12 * 8 bits , which is greater than 64 bits obviously. So

Instructions appended to end of assembly

孤者浪人 提交于 2021-02-09 09:21:46
问题 I am trying to follow this tutorial for creating a binary file, but the linker appears to be appending additional instructions at the end of the assembly. I assume this is the OS's tear-down process. The tutorial attempts to compile a bare bones 32-bit C program on Linux: int main() { } using these commands: gcc -c test.c ld -o test -Ttext 0x0 -e main test.o objcopy -R .note -R .comment -S -O binary test test.bin ndisasm -b 32 test.bin I am running 64-bit Linux, and hence modified the

Instructions appended to end of assembly

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-09 09:21:25
问题 I am trying to follow this tutorial for creating a binary file, but the linker appears to be appending additional instructions at the end of the assembly. I assume this is the OS's tear-down process. The tutorial attempts to compile a bare bones 32-bit C program on Linux: int main() { } using these commands: gcc -c test.c ld -o test -Ttext 0x0 -e main test.o objcopy -R .note -R .comment -S -O binary test test.bin ndisasm -b 32 test.bin I am running 64-bit Linux, and hence modified the

Instructions appended to end of assembly

吃可爱长大的小学妹 提交于 2021-02-09 09:20:15
问题 I am trying to follow this tutorial for creating a binary file, but the linker appears to be appending additional instructions at the end of the assembly. I assume this is the OS's tear-down process. The tutorial attempts to compile a bare bones 32-bit C program on Linux: int main() { } using these commands: gcc -c test.c ld -o test -Ttext 0x0 -e main test.o objcopy -R .note -R .comment -S -O binary test test.bin ndisasm -b 32 test.bin I am running 64-bit Linux, and hence modified the

OFFSET Operator in Assembly language for x86 Processors

ⅰ亾dé卋堺 提交于 2021-02-08 09:18:24
问题 I am rather confused by the concept OFFSET Operator. According to Kip R. Irvine's book Assembly Language for x86 Processors, he defines the Offset Operator as the operator that returns the distance of a variable from the beginning of its enclosing segment. He also says the Offset Operator returns the offset of a data label and that represents the distance (in bytes) of the label from the beginning of the data segment. What is the offset? What does he mean by the distance of the label from the