Articles tagged #rust
More ELF relocations
In our last installment of
“Making our own executable packer”, we did some code cleanups. We got rid of
a bunch of unsafe code, and found a way to represent memory-mapped data
structures safely.
But that article was merely a break in our otherwise colorful saga of “trying
to get as many executables to run with our own dynamic loader”. The last thing
we got running was the ifunc-nolibc program.
Safer memory-mapped structures
Welcome back to the “Making our own executable packer” series, where digressions are our bread and butter.
Last time, we implemented indirect functions in a no-libc C program. Of course, we got lost on the way and accidentally implemented a couple of useful elk-powered GDB functions - with only the minimal required amount of Python code.
The article got pretty long, and we could use a nice distraction. And I have just the thing! A little while ago, a member of the Rust compiler team stumbled upon this series and gave me some feedback.
GDB scripting and Indirect functions
Working with strings in Rust
There’s a question that always comes up when people pick up the
Rust programming language: why are there two
string types? Why is there String, and &str?
My Declarative Memory Management article answers the question partially, but there is a lot more to say about it, so let’s run a few experiments and see if we can conjure up a thorough defense of Rust’s approach over, say, C’s.
Dynamic symbol resolution
A half-hour to learn Rust
In order to increase fluency in a programming language, one has to read a lot of it.
But how can you read a lot of it if you don’t know what it means?
In this article, instead of focusing on one or two concepts, I’ll try to go through as many Rust snippets as I can, and explain what the keywords and symbols they contain mean.
Ready? Go!
Variable bindings
Loading multiple ELF objects
Up until now, we’ve been loading a single ELF file, and there wasn’t much
structure to how we did it: everyhing just kinda happened in main, in no
particular order.
But now that shared libraries are in the picture, we have to load multiple ELF files, with search paths, and keep them around so we can resolve symbols, and apply relocations across different objects.
The simplest shared library
In our last article, we managed to load and execute a PIE (position-independent executable) compiled from the following code:
; in `samples/hello-pie.asm`
global _start
section .text
_start: mov rdi, 1 ; stdout fd
lea rsi, [rel msg]
mov rdx, 9 ; 8 chars + newline
mov rax, 1 ; write syscall
syscall
xor rdi, rdi ; return code 0
mov rax, 60 ; exit syscall
syscall
section .data
msg: db "hi there", 10
Go back to the homepage.