disassembly

How to disassemble 16-bit x86 boot sector code in GDB with “x/i $pc”? It gets treated as 32-bit

萝らか妹 提交于 2019-11-26 12:17:28
问题 For example, with a boot sector that BIOS prints a to the screen main.asm : org 0x7c00 bits 16 cli mov ax, 0x0E61 int 0x10 hlt times 510 - ($-$$) db 0 dw 0xaa55 Then: nasm -o main.img main.asm qemu-system-i386 -hda main.img -S -s & gdb -ex \'target remote localhost:1234\' \\ -ex \'break *0x7c00\' \\ -ex \'continue\' \\ -ex \'x/3i $pc\' I get: 0x7c00: cli 0x7c01: mov $0x10cd0e61,%eax 0x7c06: hlt So it looks like the mov ax, 0x0E61 was interpreted as a 32-bit mov %eax and ate up the next

Translation of machinecode into LLVM IR (disassembly / reassembly of X86_64. X86. ARM into LLVM bitcode)

元气小坏坏 提交于 2019-11-26 11:57:03
问题 I would like to translate X86_64, x86, ARM executables into LLVM IR (disassembly). What solution do you suggest ? 回答1: mcsema is a production-quality binary lifter. It takes x86 and x86-64 and statically "lifts" it to LLVM IR. It's actively maintained, BSD licensed, and has extensive tests and documentation. https://github.com/trailofbits/mcsema 回答2: Consider using RevGen tool developed within the S2E project. It allows converting x86 binaries to LLVM IR. The source code could be checked out

How can I see parse tree, intermediate code, optimization code and assembly code during COMPILATION?

我的梦境 提交于 2019-11-26 11:05:07
问题 I am studying Compilers course, compilation of program follows below steps Lexical analysis Syntax analysis Semantic analysis Intermediate code generation Code optimization Target code generation. How can I see output of each step e.g I want to see parse tree after syntax analysis. I am compiling program on Linux machine with GCC compiler. We can see assembly code of the program by using -Wa compiler option in gcc, similarly is there options to see Tokens, Parse tree and Inetmediate code. 回答1

How to disassemble, modify and then reassemble a Linux executable?

喜夏-厌秋 提交于 2019-11-26 09:17:58
问题 Is there anyway this can be done? I\'ve used objdump but that doesn\'t produce assembly output that will be accepted by any assembler that I know of. I\'d like to be able to change instructions within an executable and then test it afterwards. 回答1: I don't think there is any reliable way to do this. Machine code formats are very complicated, more complicated than assembly files. It isn't really possible to take a compiled binary (say, in ELF format) and produce a source assembly program which

How can I see the assembly code for a C++ program?

余生长醉 提交于 2019-11-26 08:39:35
问题 How can I see the assembly code for a C++ program? What are the popular tools to do this? 回答1: Ask the compiler If you are building the program yourself, you can ask your compiler to emit assembly source. For most UNIX compilers use the -S switch. If you are using the GNU assembler, compiling with -g -Wa,-alh will give intermixed source and assembly on stdout ( -Wa asks compiler driver to pass options to assembler, -al turns on assembly listing, and -ah adds "high-level source" listing): g++

How Math.Pow (and so on) actually works

佐手、 提交于 2019-11-26 08:34:24
问题 So I was googling for a long time and i found almost nothing. I found some info about possible implementation of Math.Pow from this url, but they are inaccurate, for example this code public static double PowerA(double a, double b) { int tmp = (int)(BitConverter.DoubleToInt64Bits(a) >> 32); int tmp2 = (int)(b * (tmp - 1072632447) + 1072632447); return BitConverter.Int64BitsToDouble(((long)tmp2) << 32); } static void Main(string[] args) { double x = 12.53, y = 16.45; Console.WriteLine(Math.Pow

What does @plt mean here?

夙愿已清 提交于 2019-11-26 07:55:23
问题 0x00000000004004b6 <main+30>: callq 0x400398 <printf@plt> Anyone knows? UPDATE Why two disas printf give me different result? (gdb) disas printf Dump of assembler code for function printf@plt: 0x0000000000400398 <printf@plt+0>: jmpq *0x2004c2(%rip) # 0x600860 <_GLOBAL_OFFSET_TABLE_+24> 0x000000000040039e <printf@plt+6>: pushq $0x0 0x00000000004003a3 <printf@plt+11>: jmpq 0x400388 (gdb) disas printf Dump of assembler code for function printf: 0x00000037aa44d360 <printf+0>: sub $0xd8,%rsp