Skip to content

Instantly share code, notes, and snippets.

View jarkkojs's full-sized avatar

Jarkko Sakkinen jarkkojs

View GitHub Profile
#!/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)
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)
find $PWD -name ".git" | sed 's/\/\.git//g' | xargs -I{} git -C {} clean -f -d -x
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)
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
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
)
function unzip-exe {
find -name "*.zip" -exec unzip -j {} "*.exe" \;
}
#!/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 \;
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
$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 `