Skip to content

Instantly share code, notes, and snippets.

View jarkkojs's full-sized avatar

Jarkko Sakkinen jarkkojs

View GitHub Profile
@jarkkojs
jarkkojs / gist:00d4fb05474d00bd64df51b4b0028a3b
Created November 30, 2025 17:15
bootstrap-linux-clangs.sh
#!/usr/bin/env bash
set -e
CONFIG_SCRIPT="$PWD/scripts/config"
GEN_COMPILE_COMMANDS="$PWD/scripts/clang-tools/gen_compile_commands.py"
config_disable() {
"$CONFIG_SCRIPT" --disable "$1"
}
#!/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 --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