flat assembler
Message board for the users of flat assembler.

Index > Linux > Linux console programs - What do they expect from the OS?

Author
Thread Post new topic Reply to topic
axlucas



Joined: 02 May 2014
Posts: 66
Location: Argentina
axlucas
Hi! I am really very new about assembly for Linux. My question is this:

Say we have a simple console program for Linux, a binary, that does not use any shared object... just a static binary program. What does it expect from the Linux environment in order to run? Only the int 80h API? I understand that some particular program might poke into environment variables and other very specific things, but I mean, most of the time.
Asked differently: if I am able to run an ELF program like the one described and provide the whole int 80h set of services and nothing more than that. Is the program more likely to run or fail? If fail, what could be a typical cause?
Post 06 May 2014, 22:01
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
Linux programs need only int 80h system calls. Nothing else. Using libraries is optional and only if you need function, you do not want to implement yourself.
Post 06 May 2014, 22:21
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 212
Location: Budapest, Hungary
Endre
I guess, int 0x80 is also optional, but of course without it your program won't be too verbose Wink. Nevertheless if you just want to write a beautiful infinite loop program (e.g. when testing the scheduler of the kernel) than you need even no system-calls. Or if you don't like infinite loops then you can exit your program for instance through an intentionally generated segmentation fault Smile . This latter method is my favorite. Every developer uses it fairly often, of course not always intentionally, but it does not count . Smile
Post 08 May 2014, 09:28
View user's profile Send private message Reply with quote
axlucas



Joined: 02 May 2014
Posts: 66
Location: Argentina
axlucas
Thank you, guys. I'm reviving this to ask basically the same question in a more specific way, now that I've been reading some more.

What I would like to do is compile a Linux kernel with a few more things, but without any library at all, that is, not even the GNU C Library. Then create my own command line interpreter. I understand that almost no GNU/Linux application will be able to run in an OS like that, but I can write programs that only use int 80h to access everything and these programs would be able to run on this bare system as well as on any Linux distro without the need of any dependencies. Am I right?

One more thing. I could get the modular part of ALSA, for example, and add it to the kernel, but access it through int 80h, just the device, and leave out the ALSA library and I would have sound without needing the GLIBC. Am I right at this?

Thanks in advance again! Smile
Post 11 Oct 2014, 04:12
View user's profile Send private message Reply with quote
gens



Joined: 18 Feb 2013
Posts: 161
gens
yes
but you would have to use alsa's kernel api
it's not documented much, so gl
Post 11 Oct 2014, 21:36
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.