Live data from Hacker News

Manually creating an ELF executable

negrebskoh.net

1–10 of 38 posts

Re: Manually creating an ELF executable

#2
So essentially, this is writing an application in machine code?

This is so fascinating I'm starting to get palpitations. I've always wanted to know how to program in machine code. I've looked through the web countless times in search of something like this, and haven't ever found it, until now.

Thanks for the great insight. This kind of stuff makes C/C++ look like stuff for total newbies. Getting this close to the hardware really is quite mind-boggling.

Re: Manually creating an ELF executable

#4
post #2

So essentially, this is writing an application in machine code? This is so fascinating I'm starting to get palpitations. I've always wanted to know how to program in machine code. I've looked through the web countless times in search of something like this, and haven't ever found it, until now. Thanks for the great insight. This kind of stuff makes C/C++ look like stuff for total newbies. Getting this close to the ha…

Here's another article which starts with a .c program and refines it through a series of improvements to end up with a very tiny elf executable:

http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm...

Manually picking out hex opcodes is maybe a bit over the top. A nice assembler like nasm should be "low level enough" while still providing a lot more convenience and flexibility.

Re: Manually creating an ELF executable

#5
One of the cool things about "personal computers", when they were not synonymous with "IBM PC" or x86 box, was that you had total control over every bit and byte that went into them. Sometimes you had to use switches to manually set memory contents, sometimes there was a hard coded 'boot loader' which would do that for you. The coolest demo I think I've seen in this space was an FPGA computer design where the first download into the FPGA made it a serial device that could write memory, and then you erased that and loaded a computer which would then read that memory and execute it.

I believe that one of the reasons the Arduino has the appeal it does is because you can know everything there is to know about the program it is running. That is a lot of fun for a technologist.

It would be fun to have this blog posting written from within a debugger. I always found it intriguing to 'debug a program into existence' as it were.

Re: Manually creating an ELF executable

#8
I am voiceless: why would the f*ck would someone loose such that much time on a trivial, yet annoying task?

That is the first lesson you have in assembly language: program in assembly language, then in C because it spares you the time (and the mistakes involved in the process) to do such a thing.

Thousands of men year efforts and wisdom ruined in a post, showing how people have too much time on their hands, and so few imaginations (well he could have written something interesting on how to display p0rn pictures in ASCII art at least).

Re: Manually creating an ELF executable

#9

I am voiceless: why would the f*ck would someone loose such that much time on a trivial, yet annoying task? That is the first lesson you have in assembly language: program in assembly language, then in C because it spares you the time (and the mistakes involved in the process) to do such a thing. Thousands of men year efforts and wisdom ruined in a post, showing how people have too much time on their hands, and so fe…

Having spent my years climbing up and down the ladder of abstraction, I think your analysis is way off the mark. This is a great way to learn how ELF works (and binaries in general), learn how machine code is formed, etc. Is it an actually 'useful' task, that produces a useful end product? Yes: knowledge. Knowledge that isn't easy to acquire.

You won't ever do this in the Real World (TM), but it's a fantastic way to get into things.

Re: Manually creating an ELF executable

#10
post #6

We used to do it with toggle switches, back in the day (long before ELF binaries existed, though).

Well, only the boot loader. You could use paper tape after you had that keyed in :)

My favourite boot-loader story was told to me by one of the old-hands on the Jindalee Radar, when it was still a research project. Jindalee had a manned receiver station and a remote transmitter station, about 100km away. They were connected via a radio link, and to start with, the PDP at the remote site had to be booted by keying in the boot-loader over the radio link. If you lost the radio link, you had to start again...and again... and again...
Post reply on HN