Skip to content

Instantly share code, notes, and snippets.

View letian-jiang's full-sized avatar
🎯
Focusing

Letian Jiang letian-jiang

🎯
Focusing
  • Hangzhou, China
  • 18:53 (UTC +08:00)
View GitHub Profile
@letian-jiang
letian-jiang / install_openssl_newer_ubuntu.sh
Last active November 25, 2024 14:01 — forked from fabiomello/install_openssl_newer_ubuntu.sh
Install OpenSSL 1.0 On Ubuntu
mkdir openssl1.0
cd openssl1.0
wget http://archive.debian.org/debian/pool/main/o/openssl/libssl1.0.0_1.0.2l-1~bpo8+1_amd64.deb
wget http://archive.debian.org/debian/pool/main/o/openssl/libssl-dev_1.0.2l-1~bpo8+1_amd64.deb
wget http://archive.debian.org/debian/pool/main/o/openssl/openssl_1.0.2l-1~bpo8+1_amd64.deb
dpkg -x libssl-dev_1.0.2l-1~bpo8+1_amd64.deb .
dpkg -x libssl1.0.0_1.0.2l-1~bpo8+1_amd64.deb .
dpkg -x openssl_1.0.2l-1~bpo8+1_amd64.deb .
cd usr/lib/x86_64-linux-gnu/
DWARF has a clever (too clever?) VM representation for source line to asm mapping.
VM has state which represents virtual program and source line counters.
The DW_LNS_advance_pc instruction advances the program counter while the DW_LNS_advance_line instruction
advances the line counter. Both these instructions encode the "advance amount" value as a variably sized immediate operand.
The DW_LNS_copy instructions tells us that current VM pc and source counter states correspond together
both counter values can be copied to a array of line numbers and assembly addresses. When the VM reads a byte from the
instruction stream it compares this value with a VM specified "opcode base" variable. If the value is below the "opcode base"
then it represents an opcode for an instruction. If the value is above the "opcode base" then it represents the operand for
an implicit "instruction". This special implicit "instruction" advances both the program and source line counters at once
using this single byte value. But how
@letian-jiang
letian-jiang / a_minimal_example.c
Created October 12, 2024 09:43 — forked from yyny/a_minimal_example.c
GDB JIT Interface -- Minimal Example
/* I spent an entire evening getting JIT debug symbols to work in GDB.
* Here is a minimal example to get you started.
* Have fun!
*/
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@letian-jiang
letian-jiang / ptr_ownership_semantics.cpp
Created May 12, 2023 17:46 — forked from israelchen/ptr_ownership_semantics.cpp
Ownership semantics for pointers in C++
#include <iostream>
#include <memory>
using namespace std;
class Resource {
public:
Resource(string id) : _id(id) {
cout << "Resource::Resource(" << _id << ")" << endl;