public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Adding Flags to Compilation of rtld-libc.a
@ 2024-05-13 18:41 Vance Raiti
  2024-05-14  7:56 ` Florian Weimer
  0 siblings, 1 reply; 2+ messages in thread
From: Vance Raiti @ 2024-05-13 18:41 UTC (permalink / raw)
  To: libc-help

[-- Attachment #1: Type: text/plain, Size: 2642 bytes --]

Hello,

This is Vance again from the Unikernel Linux dynamic linkage project. I'm
writing today to ask how to change the compiler flags on members of
rtld-libc.a

Unikernel Linux defines a "bypass mode" where glibc can call a number of
kernel symbols directly instead of going through the full syscall path when
making system calls in order to improve the performance of critical code
paths. e.g.:

#ifdef UKL_BP
#define internal_syscall0(name, number, err, dummy...)          \
({                                                              \
    unsigned long int resultvar;                                \
    if(get_bypass_syscall()){                                   \
        long int bp_##name(void);                               \
        resultvar = bp_##name();                                \
    } else {                                                    \
... \
    }                                                           \
    (long int) resultvar;                                       \
})
#endif

Where bp_##name might resolve to something like bp_open, which would then
be an alias for something like ksys_open in the Kernel. Currently, there
are about 120 of these bp_##name symbols available.

While these symbols can easily be provided to the regular libc shared
objects by linking them with another shared object generated by the kernel,
ld.so cannot have dynamic dependencies so these symbols remain unresolved.
Since we don't particularly care about the performance of the dynamic
linker, it would be easier to avoid using this bypass mode altogether when
it's running.

All of the references to these bp_##name symbols occur in the members of
rtld-libc.a, and they will only occur if the preprocessor macro UKL_BP is
defined. I noticed in `glibc/elf/Makefile` that it says that all the
members of rtld-libc.a are recompiled with "special flags":

# Link together the dynamic linker into a single relocatable object.
# First we do a link against libc_pic.a just to get a link map,
# and discard the object produced by that link.  From the link map
# we can glean all the libc modules that need to go into the dynamic
# linker.  Then we do a recursive make that goes into all the subdirs
# those modules come from and builds special rtld-foo.os versions that
# are compiled with special flags, and puts these modules into rtld-libc.a
# for us.  Then we do the real link using rtld-libc.a instead of libc_pic.a.

It's not clear to me where these special flags are set (perhaps it's
CFLAGS-.os?), so if I wanted to compile the members of rtld-libc.a with
-UUKL_BP, where could I add it?

Thank you,
Vance Raiti

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

* Re: Adding Flags to Compilation of rtld-libc.a
  2024-05-13 18:41 Adding Flags to Compilation of rtld-libc.a Vance Raiti
@ 2024-05-14  7:56 ` Florian Weimer
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2024-05-14  7:56 UTC (permalink / raw)
  To: Vance Raiti via Libc-help; +Cc: Vance Raiti

* Vance Raiti via Libc-help:

> It's not clear to me where these special flags are set (perhaps it's
> CFLAGS-.os?), so if I wanted to compile the members of rtld-libc.a with
> -UUKL_BP, where could I add it?

You can use #if IS_IN (rtld), presumably in <sysdep.h>, where the system
call interface is defined.

Thanks,
Florian


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

end of thread, other threads:[~2024-05-14  7:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-13 18:41 Adding Flags to Compilation of rtld-libc.a Vance Raiti
2024-05-14  7:56 ` Florian Weimer

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).