Update readelf.nu
This commit is contained in:
@ -1,36 +1,13 @@
|
|||||||
#!/bin/env nu
|
#!/bin/env nu
|
||||||
|
|
||||||
def elf-sections [
|
# Inpect ELF-files
|
||||||
|
def elf [
|
||||||
elf: string # ELF-file to inspect
|
elf: string # ELF-file to inspect
|
||||||
|
get?: cell-path
|
||||||
] {
|
] {
|
||||||
LANG=C readelf --wide --sections $elf |
|
if $get == null {
|
||||||
parse -r " +\\[ *\\S+\\] +(?<name>\\.\\S+) +(?<type>\\S+) +0*(?<addr>\\S+) +0*(?<off>\\S+) +0*(?<size>\\S+).*" |
|
^elf $elf | from json
|
||||||
into int -r 16 "addr" "off" "size"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
def elf-symbols [
|
|
||||||
elf: string # ELF-file to inspect
|
|
||||||
--section (-s): string
|
|
||||||
] {
|
|
||||||
|
|
||||||
let symbols = (
|
|
||||||
LANG=C readelf --wide --syms --demangle=rust $elf |
|
|
||||||
tail -n +5 |
|
|
||||||
parse -r " *(?<num>\\d+): (?<addr>\\S+) +(?<size>\\S+) +(?<type>\\S+) +(?<bind>\\S+) +(?<vis>\\S+) +(?<ndx>\\S+) (?<name>.*)" |
|
|
||||||
into int "size" |
|
|
||||||
into int "num" |
|
|
||||||
into int -r 16 "addr"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if $section == null {
|
|
||||||
$symbols
|
|
||||||
} else {
|
} else {
|
||||||
let section = (elf-sections $elf | where name == $section | first)
|
^elf $elf | from json | get $get
|
||||||
let section_start = ($section | get addr)
|
|
||||||
let section_end = ($section_start + ($section | get size))
|
|
||||||
|
|
||||||
$symbols | where addr >= $section_start and addr < $section_end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user