0

So I'm learning Intel x86 and in my class we went over xxd and objdump, which are hex dump commands.

However I was never explained what a hexdump really was, so after a little research all I could find is that is was, quite simply, a dump of a file's data.

So that actually raises more questions: since I'm learning asm, if hexdump is data, where doe the code to manipulate that data is? From my understanding, a file contained code that would be executed. But if there's only data in a file, where is that code in the file, or if disassembled where is the asm?

Delupara
  • 359
  • 1
  • 4
  • 10

1 Answers1

2

A hexdump is just a way to encode binary data using only the characters 0-9 and a-f. This makes it easier for humans to read and type, without memorizing the numerical value of 256 glyphs.


The asm tag wiki has some info on what assembly is all about. Machine code is a binary format for representing machine instructions, designed to be parsed by hardware (the CPU). An assembler is a program that assembles bytes into a binary file, following the instructions in an asm source file. Typically assemblers default to outputting a structured file format like ELF or Windows PE, but you can use a flat binary output format if you want to define everything yourself. You can use pseudo-instructions like db (NASM syntax) or .byte GNU syntax to assemble whatever bytes you want in whatever order you want into an output file.

Some other completely different binary formats include PDF and ZIP. They're designed to be parsed by software.


This question is like asking what the relationship is between a text file and asm. (Or C, or anything.) Although not quite. Or maybe: the relationship between an editor window and a C program.

My point is that a hexdump doesn't have any specific meaning, and can be done on any stream of bytes, whatever those bytes mean.

Community
  • 1
  • 1
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • Okay so, there is a asm source file, so whenever CPU is reading ELF from a file, it will process the rest with the asm source file? – Delupara Mar 11 '16 at 14:49
  • 1
    No, the assembler and linker process the asm source file and creates ELF file, then the operating system loader knows to hook ELF into CPU process. once you have ELF, in machine's perspective it does not require asm file. You the programmer require it to modify and re-assemble (re-compile in high level language terms) – Bijoy Mar 11 '16 at 14:58
  • Okay, after reading more I got a clarification: a hexdump is a hex représentation of machine code? Also thanks for the clarification @Bijoy – Delupara Mar 11 '16 at 15:04
  • @Programgenesis: No, a hex dump is just a hex representation of *anything*. Doesn't have to be machine code. That's why I added the last section. – Peter Cordes Mar 11 '16 at 15:05
  • @Bijoy: thanks for your edit suggestion, but I liked my wording better. Assemblers aren't limited to just assembling mnemonics into machine code and making executables. That's what they're good at, but it's useful to think of it as just a way to get certain bytes output in a certain order. This may help understand directives like `$` (reference to the current output position). – Peter Cordes Mar 11 '16 at 15:10