Live data from Hacker News

Manually creating an ELF executable

negrebskoh.net

11–20 of 38 posts

Re: Manually creating an ELF executable

#11
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…

Hi, I'm the author. In this particular example, I basically skipped the compiler and linker to create an executable directly, yes. It's certainly a lot of fun, but if you're really trying to become proficient at programming in assembly language, I would recommend reading Assembly Language Step-by-Step: Programming with Linux.

Re: Manually creating an ELF executable

#12

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…

Author here: I'm sorry to hear you didn't like the post. I'll make sure to include nudity in the next version.

Re: Manually creating an ELF executable

#13
If you liked this, you'll probably like even more "A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux" (http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm...). Last time I checked, the teensy executable had stopped working around Linux 2.6.26 or 2.6.27, and I don't know why.

Relatedly, I wrote a tiny quasi-Forth in itself that generates ELF executables directly at https://github.com/kragen/stoneknifeforth. Its executables also stopped running around Linux 2.6.27, and I still haven't bothered to figure out why.

Re: Manually creating an ELF executable

#14
post #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…

I studied physics, and I learnt actual programming and assembly language: I actually did this in the real world!

What do you learn in Computer Science then?!

Gibbering useless concepts that makes you non-sensical experts in the field of not delivering your software neither in time, nor in the frame of the specification? Or just

Re: Manually creating an ELF executable

#15
post #12

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…

Author here: I'm sorry to hear you didn't like the post. I'll make sure to include nudity in the next version.

Thanks, I always wondered how VLC was so efficient at translating pictures in colored ASCII art.

Re: Manually creating an ELF executable

#16
post #13

If you liked this, you'll probably like even more "A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux" ( http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm... ). Last time I checked, the teensy executable had stopped working around Linux 2.6.26 or 2.6.27, and I don't know why. Relatedly, I wrote a tiny quasi-Forth in itself that generates ELF executables directly at https://github.com/…

Agreed. I would heartily recommend reading the article you linked to, I certainly liked it a lot.

The project you've worked on looks interesting, too! It's a little late for me to be reading too much code, but I'll make sure to take a good look at it tomorrow. Thanks for the link.

Re: Manually creating an ELF executable

#17
post #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.

Well of course, nobody writes any applications in hex; it's more of a proof of concept, but a very interesting proof of concept.

Asm, at least for me, is still too low-level for me to do any sort of serious work. I make desktop/mobile apps, and don't really do any sort of kernel hacking, so currently, I'll stick with C++ and Java. It is a nice thing to know, however, I don't see myself learning it right now. It's inevitable that I'll have to learn it sometime in the future if I ever want to broaden my prospects, but it's nice to play around with, but isn't all too useful for me.

Re: Manually creating an ELF executable

#18
post #11
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…

Hi, I'm the author. In this particular example, I basically skipped the compiler and linker to create an executable directly, yes. It's certainly a lot of fun, but if you're really trying to become proficient at programming in assembly language, I would recommend reading Assembly Language Step-by-Step: Programming with Linux.

Thanks. I'll be sure to check it out when I get into programming asm.

Re: Manually creating an ELF executable

#19
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…

It is pretty fun. If you have a TI-83 or TI-84 calculator you can do the same thing a little bit easier.

In high school, I would print out 2 pages of all the Z80 opcodes and put them on my desk during class. The calculators let you directly input hex and then run your program with asm(), so I would write my program by hand on paper, and then next to each line translate it to machine code and put it into the calculator. A lot of TI routines are easily accessible with bcalls, so you don't have to reinvent the wheel with each program.

Plus Z80 is a lot easier than x86. (I still remember the return code: C9)

I had a lot of fun taking friend's calculators and disabling the LCD and power button in assembly :)

Re: Manually creating an ELF executable

#20
post #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 d…

It's kind of the same deal now with the Raspberry Pi, except for the fact that it uses RISC and not x86. It's a great tinkering platform.

Now, if only somebody would make a ring-0 OS for ARM... Now THAT would be fun.

Post reply on HN