system calls in assembler for GNU libc

system calls in assembler for GNU libc

Post by Tim Ad » Fri, 23 Jul 1993 22:01:33



The following is from glibc-1.05/sysdep/unix/sysdep.h:
 Machine-dependent sysdep.h files are expected to define the macro
 PSEUDO (function_name, syscall_name) to emit assembly code to define
 the C-callable function FUNCTION_NAME to do system call SYSCALL_NAME.

For example, say we want the C function __signal to do the system call
signal.

My guess would be

.globl ___signal:
        jbsr some_address
        rts

Is this right, and how do I find the address for each system call?
Disassembling the original libc.a (signal.o) looks hard.

My system is a Plexus P/75 68020 running UNIX Sys5.2, gcc 2.3.3, gas

Many thanks,
Tim.
_________________________________________________________________
Tim Adam, 3rd Yr B.Sc.(Math)/B.E.(Elec), Melbourne Uni, Australia

 
 
 

1. GNU assembler to Solaris assembler

I would like to covert one inline assembly function included in SPARC
Linux to Solaris assembler syntax. The function is written in GNU
assembler syntax.
Two syntax errors are reported due to pseudo operators when I compile
using gcc on Solaris.

inline void spin_lock(unsigned char *lock)
{
  __asm__ __volatile__("
1:  ldstub  [%0], %%g2
  orcc  %%g2, 0x0, %%g0
  bne,a 2f
   ldub [%0], %%g2
  .text 2                         <==
2:  orcc  %%g2, 0x0, %%g0
  bne,a 2b
   ldub [%0], %%g2
  b,a 1b
        .previous                       <==
" :
  : "r" (lock)
  : "g2", "memory", "cc");

/usr/ccs/bin/as: "/var/tmp/cc030Gpt.s", line 18: error: quoted-string operand required
/usr/ccs/bin/as: "/var/tmp/cc030Gpt.s", line 23: error: unknown opcode ".previous"
/usr/ccs/bin/as: "/var/tmp/cc030Gpt.s", line 23: error: statement syntax

How can I convert the function to Solaris assembler syntax? In
particular I cannot find '.previous' pseudo operator in GNU assembler
info manual.
I have confirmed that gcc + GNU assembler can compile this function on
Solaris.

    <--------->    Computational Science Laboratory
                   The Institute of Physics and Chemistry(RIKEN)
    >---------<    Susukita Ryutaro

2. Wie gebe ich ASCII code auf der Windows Nt2000 Maschine ein wenn ich auf solaris arbeite

3. ma600.c won't compile

4. assembler -> linux system calls

5. How to capture an SNMP trap

6. How are GNU-Libc and LINUX-Libc related?

7. pattern matching

8. xlC - linker error: unresolved system call BUT it is in libc

9. Catching & Redirecting libc/system calls

10. How I could add a new system call to linux or modify a system calls

11. How to use open system call in a new system call