Articles tagged #rust

Pin and suffering

I’d like to think that my understanding of “async Rust” has increased over the past year or so. I’m 100% onboard with the basic principle: I would like to handle thousands of concurrent tasks using a handful of threads. That sounds great!

And to become proficient with async Rust, I’ve accepted a lot of things. There are blue functions and red functions, and red (async) functions are contagious.

Running a self-relocatable ELF from memory

Welcome back!

In the last article, we did foundational work on minipak, our ELF packer.

It is now able to receive command-line arguments, environment variables, and auxiliary vectors. It can parse those command-line arguments into a set of options. It can make an ELF file smaller using the LZ4 compression algorithm, and pack it together with stage1, our launcher.

Everything but ELF

And we’re back!

In the last article, we thanked our old code and bade it adieu, for it did not spark joy. And then we made a new, solid foundation, on which we planned to actually make an executable packer.

As part of this endeavor, we’ve made a crate called encore, which only depends on libcore, and provides some of the things libstd would give us, but which we cannot have, because we do not want to rely on a libc.

Between libcore and libstd

You’re still here! Fantastic.

I have good news, and bad news. The good news is, we’re actually going to make an executable packer now!

Cool bear

Hurray!

I know right? No lie, we’re actually really going to start working on the final product from this point onwards.

Cool bear

What uhhh what about the previous fourteen parts?

Ah, yes, the previous fourteen parts. Well, we had fun, didn’t we? And we learned a lot about ELF, how it’s basically a database format that different tools look at in different ways, how it’s mapped in memory (more or less), what we really need to set up before starting up another executable, all that good stuff.

In the bowels of glibc

Good morning, and welcome back to “how many executables can we run with our custom dynamic loader before things get really out of control”.

In Part 13, we “implemented” thread-local storage. I’m using scare quotes because, well, we spent most of the article blabbering about Addressing Memory Through The Ages, And Other Fun Tidbits.

But that was then, and this is now, which is, uh, nine months later. Not only am I wiser and more productive, I’m also finally done updating all the previous thirteen parts of this series to fix some inconsistencies, upgrade crate versions, and redo all the diagrams as SVG.

Making our own executable packer

In this series, we’ll attempt to understand how Linux executables are organized, how they are executed, and how to make a program that takes an executable fresh off the linker and compresses it - just because we can.

Day 14 (Advent of Code 2020)

It’s time for the Day 14 problem!

After the hassle that was Day 13, I hope this time we’ll have a relatively chill time. And, at least for Part 1, that is true.

Our input looks something like this:

mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X mem[8] = 11 mem[7] = 101 mem[8] = 0

mem is our memory. Our addresses are 36-bit wide, but as you’ll see, that doesn’t matter much.

Day 13 (Advent of Code 2020)

In the Day 13 problem, we’re trying to take the bus.

Our input looks like this:

939 7,13,x,x,59,x,31,19

The first line indicates the earliest minute we can leave from the bus terminal, and the second line indicates the “identifier” of the buses that are active.

Each bus departs every “bus ID” minutes - bus 7 leaves at minute 0, minute 7, minute 14, minute 21, etc. The question is: which bus can we take first (apparently they either all go to the same destination, or we don’t really care where we’re going), and how long do we have to wait for it?

Go back to the homepage.