This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
from elftools.elf.elffile import ELFFile | |
R_RISCV_ADD32 = 35 | |
R_RISCV_SUB32 = 39 | |
def main(): | |
if len(sys.argv) != 2: | |
sys.exit(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raw = open('/home/jarkko/work/nnn/nnn', 'rb') | |
from elftools.elf.elffile import ELFFile | |
elf = ELFFile(raw) | |
symtab = {s.name: s for s in (elf.get_section_by_name('.symtab')).iter_symbols()} | |
sym = symtab.get('move_cursor') | |
addr = sym['st_value'] | |
size = sym['st_size'] | |
text = elf.get_section_by_name('.text') | |
offset = addr - text['sh_addr'] + text['sh_offset'] | |
raw.seek(offset) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find $PWD -name ".git" | sed 's/\/\.git//g' | xargs -I{} git -C {} clean -f -d -x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raw = open('/home/jarkko/work/nnn/nnn', 'rb') | |
from elftools.elf.elffile import ELFFile | |
elf = ELFFile(raw) | |
symtab = {s.name: s for s in (elf.get_section_by_name('.symtab')).iter_symbols()} | |
sym = symtab.get('move_cursor') | |
addr = sym['st_value'] | |
size = sym['st_size'] | |
text = elf.get_section_by_name('.text') | |
offset = addr - text['sh_addr'] + text['sh_offset'] | |
raw.seek(offset) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set history filename ~/.gdb_history | |
set history save on | |
set logging enabled on | |
set logging file ~/.gdb_log | |
set pagination off | |
define step_program | |
starti | |
while (1) | |
stepi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro(bin2elf Path Name) | |
set(objcopy_flags -I binary -O elf64-littleriscv -B riscv --rename-section .data=.rodata,alloc,load,readonly,data,contents) | |
string(MAKE_C_IDENTIFIER ${Path} unstripped) | |
add_custom_command( | |
OUTPUT ${Path}.o | |
COMMAND ${CMAKE_OBJCOPY} ${objcopy_flags} ${Path} ${Path}.o | |
COMMAND ${CMAKE_OBJCOPY} --redefine-sym _binary_${unstripped}_start=${Name}_start ${Path}.o | |
COMMAND ${CMAKE_OBJCOPY} --redefine-sym _binary_${unstripped}_end=${Name}_end ${Path}.o | |
COMMAND ${CMAKE_OBJCOPY} --redefine-sym _binary_${unstripped}_size=${Name}_size ${Path}.o | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function unzip-exe { | |
find -name "*.zip" -exec unzip -j {} "*.exe" \; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
wget -q --show-progress -r -np -nd -l1 -A tar.xz https://uhe-dl.b-cdn.net/releases/ -P dl/ && \ | |
mkdir staging && \ | |
(pv dl/*.tar.xz | tar Jxf - -i -C staging/) && \ | |
find -name install.sh -exec {} --quiet \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gpg --export --export-options backup --output public.gpg | |
gpg --export-ownertrust > trust.gpg | |
gpg --export-secret-keys --export-options backup --output private.gpg --pinentry-mode loopback |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$wsl_netif_index = (Get-NetAdapter | Where-Object -Property Name -Match "WSL").InterfaceIndex | |
$wsl_ip = (Get-NetIPAddress -InterfaceIndex $wsl_netif_index -AddressFamily IPv4).IPAddress | |
Write-Output 'WSL IP address: ' $wsl_ip | |
if ((Get-NetFirewallRule | Where-Object -Property DisplayName -eq wsl_ssh).count -eq 0) | |
{ | |
Write-Output 'Creating''wsl_ssh'' firewall rule' | |
New-NetFirewallRule -DisplayName wsl_ssh ` | |
-Direction Inbound ` |
NewerOlder