public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Bulding syscall wrapper: how glibc determines if assembly or macro wrapper will generated?
@ 2021-07-19  9:26 Dmitrowski, Lukasz
  2021-07-19 12:51 ` Adhemerval Zanella
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitrowski, Lukasz @ 2021-07-19  9:26 UTC (permalink / raw)
  To: libc-help

Hello,

I create a documentation describing how glibc builds syscall wrappers. I am currently limited to Linux x86_64 architecture only and base on https://sourceware.org/glibc/wiki/SyscallWrappers + source code analysis.

I want to to know how glibc build system decides what type of syscall wrapper will be generated, assembly wrapper or macro wrapper. I have troubles trying to figure out how the glibc build system works on this level.

1. make-syscall.sh produces sysd-syscalls, that contains build formulas for assembly wrappers.
How sysd-syscalls is used by the build system after it is generated?

2. I found out that if sysd-syscalls contains a build formula for assembly wrapper then this formula is always used when building glibc, but in some cases sysd-syscalls also shows that a *.c wrapper exists, even that it contains assembly wrapper formula. This is because make-syscall.sh searches multiple syscalls.list files and multiple related sysdirs for *.c wrappers, so sometimes *.c wrapper exists in such relation and sometimes not. Both are included into sysd-syscalls.

Example:
#### DIRECTORY = sysdeps/unix/sysv/linux/x86_64
#### SYSDIRS = sysdeps/unix/sysv/linux/x86_64/64
...
#### CALL=socket NUMBER=41 ARGS=i:iii SOURCE=-
ifeq (,$(filter socket,$(unix-syscalls)))
unix-syscalls += socket
$(foreach p,$(sysd-rules-targets),$(foreach o,$(object-suffixes),$(objpfx)$(patsubst %,$p,socket)$o)): \
                $(..)sysdeps/unix/make-syscalls.sh
        $(make-target-directory)
        (echo '#define SYSCALL_NAME socket'; \
         echo '#define SYSCALL_NARGS 3'; \
         echo '#define SYSCALL_SYMBOL __socket'; \
         echo '#define SYSCALL_CANCELLABLE 0'; \
         echo '#define SYSCALL_NOERRNO 0'; \
         echo '#define SYSCALL_ERRVAL 0'; \
         echo '#include <syscall-template.S>'; \
         echo 'weak_alias (__socket, socket)'; \
         echo 'hidden_weak (socket)'; \
        ) | $(compile-syscall) $(foreach p,$(patsubst %socket,%,$(basename $(@F))),$($(p)CPPFLAGS))
endif

...

#### DIRECTORY = sysdeps/unix
#### SYSDIRS = sysdeps/unix/sysv/linux/x86_64/64 sysdeps/unix/sysv/linux/x86_64 sysdeps/unix/sysv/linux/x86 sysdeps/x86/nptl sysdeps/unix/sysv/linux/wordsize-64 sysdeps/x86_64/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/x86_64
...
#### CALL=socket NUMBER=41 ARGS=i:iii SOURCE=sysdeps/unix/sysv/linux/socket.c

--
Where is the exact point in the build system that decides if assembly wrapper (from template-syscall.S) or macro wrapper (from *.c file) will be generated?

3. If syscall wrapper is generated from *.c file, where can I find how the build formula is prepared by the build system?

4. How glibc determines a set of directories where make-syscall.sh looks for syscalls.list and *.c syscall wrappers? ($thisdir and $sysdirs variables in make-syscalls.sh)

Will be greateful for help or reference to some docs. Thank you in advance!


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-19 12:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19  9:26 Bulding syscall wrapper: how glibc determines if assembly or macro wrapper will generated? Dmitrowski, Lukasz
2021-07-19 12:51 ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).