From 2a064a9d1bbb8de6ce489b685cce026eee167cd2 Mon Sep 17 00:00:00 2001 From: johannst Date: Tue, 17 Mar 2020 22:48:49 +0000 Subject: deploy: fb719f52b73920fb18c7f3080ebb1fc73300be49 --- od.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'od.html') diff --git a/od.html b/od.html index de6c878..f91b1c6 100644 --- a/od.html +++ b/od.html @@ -81,7 +81,7 @@ @@ -158,7 +158,7 @@ -j <n> skip <n> bytes from <file> (hex if start with 0x) -N <n> dump <n> bytes (hex of start with 0x) -

ascii chars to hex string

+

ASCII to hex string

  echo -n AAAABBBB | od -An -w4 -tx4
     >> 41414141
     >> 42424242
@@ -168,13 +168,18 @@
     >>         del   E   L   F  nl      # ta
     >>         177   E   L   F  \n      # tc
 
-

extract part of file (eg .rodata section form ELF)

+

Extract parts of file

+

For example .rodata section from an elf file. We can use readelf to get the +offset into the file where the .rodata section starts.

  readelf -W -S foo
     >> Section Headers:
     >> [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
     >> ...
     >> [15] .rodata           PROGBITS        00000000004009c0 0009c0 000030 00   A  0   0 16
-  od -j 0x0009c0 -N 0x30 -tx4 -w4 foo
+
+

With the offset of -j 0x0009c0 we can dump -N 0x30 bytes from the beginning of +the .rodata section as follows:

+
  od -j 0x0009c0 -N 0x30 -tx4 -w4 foo
     >> 0004700 00020001
     >> 0004704 00000000
     >> *
@@ -183,6 +188,7 @@
     >> 0004750 00000003
     >> 0004754 00000004
 
+

Note: Numbers starting with 0x will be interpreted as hex by od.

-- cgit v1.2.3