This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: "call Puts / int80"
- From: Brian Dessent <brian at dessent dot net>
- To: Erich_B at gmx dot de
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 26 May 2007 13:37:53 -0700
- Subject: Re: "call Puts / int80"
- References: <20070526115625.93000@gmx.net>
- Reply-to: gcc-help at gcc dot gnu dot org
Erich_B@gmx.de wrote:
> I´m trying a little bit around with assembler and linux, and I have some questions...
>
> To use some "Linux-API" for example to print a message on the terminal its possible to call int 80 to do this in assembler.
>
> If i write a little "Hello World" Programm in C and have a look on it with an hex-editor/disassembler i can see, that gcc don`t use int80...
> and if i had a look on the temporary assembler code which gcc gives me I see that gcc use some C-Function Puts (in assembler ... "call Puts" ...)
>
> So there must be another way to use "Linux-API".
>
> My question is, does anyone know the assembler code that gcc use to print a message on the terminal ?
gcc doesn't know anything about int 80. It just emits a library call to
the puts() function. The C library (libc), which in the case of Linux
is glibc, is responsible for implementing puts() as the appropriate
syscall. It would be insane for the compiler to try to implement an
entire C library inline because many functions do not translate into
simple syscalls, they involve significant processing. Look at the size
of libc and you'll see that is is huge library, meaning that there is a
great deal of code necessary to implement the functionality between the
C API level and the syscall kernel level. In short, this is the entire
reason why the C library exists -- layering and abstraction.
Brian