aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2020-03-17 22:28:03 +0100
committerjohannst <johannes.stoelp@gmail.com>2020-03-17 22:28:03 +0100
commit955a20fd6c75404a7c6a752a453c4a29c7b73980 (patch)
tree7d6e00e66992b3d0a1e7c7c4879ddc9000b38cf9
parent3ac5fd0dd79d58bc565cdb0c3187e8dd087c2964 (diff)
downloadnotes-955a20fd6c75404a7c6a752a453c4a29c7b73980.tar.gz
notes-955a20fd6c75404a7c6a752a453c4a29c7b73980.zip
updated od
-rw-r--r--src/od.md12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/od.md b/src/od.md
index 65cc050..47f567a 100644
--- a/src/od.md
+++ b/src/od.md
@@ -11,7 +11,7 @@
-N <n> dump <n> bytes (hex of start with 0x)
```
-## ascii chars to hex string
+## ASCII to hex string
```markdown
echo -n AAAABBBB | od -An -w4 -tx4
>> 41414141
@@ -23,13 +23,20 @@
>> 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.
```markdown
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
+```
+
+With the offset of `-j 0x0009c0` we can dump `-N 0x30` bytes from the beginning of
+the `.rodata` section as follows:
+```markdown
od -j 0x0009c0 -N 0x30 -tx4 -w4 foo
>> 0004700 00020001
>> 0004704 00000000
@@ -39,3 +46,4 @@
>> 0004750 00000003
>> 0004754 00000004
```
+**Note**: Numbers starting with `0x` will be interpreted as hex by `od`.