This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: making changes in libc


* asenat dadon:

> im sending to you this email since the message i sent to the
> libc-alpha mail returned several times

Sorry about that.  Usually, that happens if it is an HTML-only message.

> in my research I would like to make some changes in the libc.
> specifically I would like to be able to add and modify some
> functionality.
>
> In general I need to perform some actions on several libc wrapper
> functions, before calling them. for example i would like to send a
> message to some entity before calling to the exec family calls, write,
> read and so on.

Do you need to wrap these functions just when they are called by
applications, or do you need to intercept internal calls as well (e.g.,
when putpwent writes to a file)?

> during my search for the code of the libc i found this site:
> https://code.woboq.org/userspace/glibc. nevertheless I don't know how
> to relate to it. specifically, I find the code of the exec functions
> but i could not find where the sysentry interrupt is performed.

On Linux, the function which wraps the execve system call is
auto-generated, from this entry in sysdeps/unix/sysv/linux/syscalls.list:

execve          -       execve          i:spp   __execve        execve

If you want to do something else instead, you can add an implementation
to a file sysdeps/unix/sysv/linux/execve.c, and the automatically
generated wrapper will no longer be built.

> I would appreciate it very much if you could advise me on how to find
> the required functions, such as exec, open etc.

Other system call wrappers have explicit implementations in
sysdeps/unix/sysv/linux and its subdirectories.  The actual system call
is performed via INLINE_SYSCALL_CALL or INTERNAL_SYSCALL.  (For
cancellation points, there are variants of these macros called
SYSCALL_CANCEL and INTERNAL_SYSCALL_CANCEL.)  These macros eventually
expand to inline assembly performing system calls.

Depending on what you are trying to do, it may be helpful to look at the
LibraryOS patch series for inspiration:

  <https://sourceware.org/ml/libc-alpha/2019-09/msg00188.html>

(These patches have not been merged, and it is unclear if and when this
will happen.)

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]