Changeset View
Standalone View
libexec/rtld-elf/rtld-libc/Makefile.inc
- This file was added.
# $FreeBSD$ | |||||
.include <bsd.compiler.mk> | |||||
# Add the necessary libc dependencies for RTLD without pulling in all of the | |||||
# complex libc bits such as locales, etc. | |||||
CFLAGS+= -I${SRCTOP}/libexec/rtld-elf/rtld-libc | |||||
# Build all the files that use __libc_interposing here with -DIN_RTLD. With that | |||||
# define they avoid the use of __libc_interposing and call the syscall directly. | |||||
.PATH: ${SRCTOP}/lib/libc/gen | |||||
SRCS+= opendir.c closedir.c readdir.c telldir.c | |||||
# Avoid further dependencies by providing simple implementations of libc | |||||
# functions such as __error(), etc. | |||||
.PATH: ${SRCTOP}/libexec/rtld-elf/rtld-libc | |||||
SRCS+= rtld_libc.c | |||||
kib: Is this needed ? | |||||
Done Inline ActionsThis is needed for CHERI where we convert the variadic system call to always pass the optional argument (since the variadic calling convention is different and passes all arguments on the stack. I forgot to remove that part of the diff and will only add it to CheriBSD. arichardson: This is needed for CHERI where we convert the variadic system call to always pass the optional… | |||||
Done Inline ActionsIs that happens due to -DIN_RTLD or because of rtld-hacked namespace.h ? kib: Is that happens due to -DIN_RTLD or because of rtld-hacked namespace.h ? | |||||
Done Inline ActionsI'm afraid I don't understand the question. Are you asking why we need those files for CHERI? For all non-CHERI arichardson: I'm afraid I don't understand the question. Are you asking why we need those files for CHERI? | |||||
Done Inline ActionsNo, I am asking, what magic gets rid of the interposing calls. Your comment claims that this is because of -DIN_RTLD defined while *dir.c files are compiled, but IMO it happens because you provide different namespace.h which directs interposed calls to non-interposed functions. kib: No, I am asking, what magic gets rid of the interposing calls. Your comment claims that this… | |||||
Done Inline ActionsYes, it is a combination of the two. For opendir.o it's both the ifdefs and the macros that redirect to __sys_foo arichardson: Yes, it is a combination of the two. For opendir.o it's both the ifdefs and the macros that… | |||||
Not Done Inline ActionsWhich specific #ifdef do you mean there ? kib: Which specific #ifdef do you mean there ? | |||||
Done Inline Actions-DIN_RTLD arichardson: -DIN_RTLD | |||||
Not Done Inline ActionsI should be extremely explicit. Please give me the line number in opendir.c which contains that #ifdef. kib: I should be extremely explicit. Please give me the line number in opendir.c which contains… | |||||
Done Inline ActionsSorry I got confused here. -DIN_RTLD only affects the CheriBSD-specific compiles of fctnl.c and open.c. In this patch it doesn't actually change anything in opendir. The changes in opendir are due to the defines at the start of rtld_libc.h to avoid calling pthreads functions. arichardson: Sorry I got confused here. -DIN_RTLD only affects the CheriBSD-specific compiles of fctnl.c and… | |||||
Not Done Inline ActionsSo the comment is misleading, which is why I am so attached to this point. It is not -DIN_RTLD which avoids interposing for FreeBSD. kib: So the comment is misleading, which is why I am so attached to this point. It is not -DIN_RTLD… | |||||
# Now build the remaining files from libc: | |||||
.PATH: ${SRCTOP}/lib/libc/stdlib | |||||
SRCS+= reallocf.c realpath.c getenv.c merge.c reallocarray.c | |||||
# TODO: fix merge.c to build with WARNS=6 | |||||
.if ${COMPILER_TYPE} == "clang" | |||||
CFLAGS.merge.c+=-Wno-error=null-pointer-arithmetic | |||||
.endif | |||||
Not Done Inline ActionsIs this a stray comment ? kib: Is this a stray comment ? | |||||
Done Inline ActionsI could keep this in under .ifdef DEBUG_RTLD_LIBC_DEPENDENCIES so that we can check that other architectures don't accidentally pull in more files (I only tested MIPS and x86). arichardson: I could keep this in under `.ifdef DEBUG_RTLD_LIBC_DEPENDENCIES` so that we can check that… | |||||
.PATH: ${SRCTOP}/lib/libc/gen | |||||
SRCS+= errlst.c getcwd.c getprogname.c raise.c sigsetops.c sysctlnametomib.c \ | |||||
__xuname.c | |||||
# Use the string and memory .o files from libc instead of rebuilding them (they | |||||
# might be using optimized assembly and duplicating that logic here is awkward). | |||||
_libc_string_objects= bcopy memchr memcmp memcpy memmove stpncpy strcat \ | |||||
strchr strcmp stpcpy strcpy strcspn strdup strlcat strlcpy strlen strncmp \ | |||||
strncpy strrchr strsep strspn strstr strtok | |||||
# Also use all the syscall .o files from libc_nossp_pic: | |||||
_libc_sycall_objects= sigsetjmp lstat stat fstat fstatat fstatfs syscall \ | |||||
cerror geteuid getegid munmap mprotect sysarch __sysctl issetugid __getcwd \ | |||||
utrace thr_self thr_kill pread mmap lseek _exit _fstat _fstatat _fstatfs \ | |||||
getdirentries _getdirentries _close _fcntl _open _openat _read \ | |||||
_sigprocmask _write readlink _setjmp setjmp setjmperr | |||||
# Extract all the .o files from libc_nossp_pic.a. This ensures that | |||||
# we don't accidentally pull in the interposing table or similar by linking | |||||
# directly against libc_nossp_pic.a | |||||
_rtld_libc_objs= | |||||
.for _obj in ${_libc_sycall_objects} ${_libc_string_objects} | |||||
_rtld_libc_objs+=${_obj}.nossppico | |||||
CLEANFILES+=${_obj}.nossppico | |||||
# LDFLAGS+= -Wl,--trace-symbol=${_obj} | |||||
.endfor | |||||
# LDFLAGS+= -Wl,--trace | |||||
# We insert all the .o files from libc_nossp_pic.a into a new rtld_libc.a file | |||||
# to ensure that only .o files that are actually used end up being included. | |||||
rtld_libc.a: ${LIBC_NOSSP_PIC} | |||||
${AR} x ${LIBC_NOSSP_PIC} ${_rtld_libc_objs} | |||||
${AR} cr ${.OBJDIR}/${.TARGET} ${_rtld_libc_objs} | |||||
CLEANFILES+=rtld_libc.a | |||||
LDADD+=${.OBJDIR}/rtld_libc.a | |||||
${PROG}: rtld_libc.a | |||||
Done Inline ActionsFIXME ? kib: FIXME ? |
Is this needed ?