Compare commits

..

2 Commits

Author SHA1 Message Date
b62238086b nushell: Add zoxide 2022-12-14 17:06:05 +01:00
cb8d9add96 Add readelf nu script 2022-12-14 17:05:41 +01:00
3 changed files with 44 additions and 0 deletions

View File

@ -545,4 +545,11 @@ alias gpu = git push -u origin
alias gsta = git stash push alias gsta = git stash push
alias gstp = git stash pop alias gstp = git stash pop
# random scripts
source ~/.local/nu/readelf.nu
# init zoxide
source ~/.cache/zoxide.nu
# init starship prompt
source ~/.cache/starship/init.nu source ~/.cache/starship/init.nu

View File

@ -63,3 +63,4 @@ let-env NU_PLUGIN_DIRS = [
mkdir ~/.cache/starship mkdir ~/.cache/starship
starship init nu | save ~/.cache/starship/init.nu starship init nu | save ~/.cache/starship/init.nu
zoxide init nushell | save ~/.cache/zoxide.nu

36
tree/.local/nu/readelf.nu Executable file
View File

@ -0,0 +1,36 @@
#!/bin/env nu
def elf-sections [
elf: string # ELF-file to inspect
] {
LANG=C readelf --wide --sections $elf |
parse -r " +\\[ *\\S+\\] +(?<name>\\.\\S+) +(?<type>\\S+) +0*(?<addr>\\S+) +0*(?<off>\\S+) +0*(?<size>\\S+).*" |
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 {
let section = (elf-sections $elf | where name == $section | first)
let section_start = ($section | get addr)
let section_end = ($section_start + ($section | get size))
$symbols | where addr >= $section_start && addr < $section_end
}
}