├── debian ├── compat ├── dirs ├── source │ └── format ├── libfreebsd-glue-0.install ├── libfreebsd-glue-0-udeb.install ├── local │ └── scripts │ │ └── bmake ├── install ├── links ├── control ├── copyright ├── libfreebsd-glue-0.symbols ├── rules └── changelog ├── include ├── md5.h ├── vis.h ├── bsdxml.h ├── nlist.h ├── osreldate.h ├── sys │ ├── stdint.h │ ├── fcntl.h │ ├── sysctl.h │ ├── elf_common.h │ ├── stat.h │ ├── file.h │ ├── ttycom.h │ ├── _types.h │ ├── ioccom.h │ ├── limits.h │ ├── _stdint.h │ ├── errno.h │ ├── socket.h │ ├── user.h │ ├── types.h │ ├── proc.h │ ├── time.h │ ├── elf.h │ ├── param.h │ ├── cdefs.h │ ├── queue.h │ ├── endian.h │ ├── elf32.h │ └── elf64.h ├── db.h ├── netinet │ ├── ip.h │ ├── tcp.h │ ├── udp.h │ └── in.h ├── ndbm.h ├── termios.h ├── netinet6 │ └── in6.h ├── net │ ├── ethernet.h │ └── if_dl.h ├── limits.h ├── ctype.h ├── pthread_np.h ├── grp.h ├── libgen.h ├── stdint.h ├── fstab.h ├── string.h ├── stdio.h ├── aio.h ├── fcntl.h ├── netdb.h ├── linux │ ├── icmp.h │ └── sysctl.h ├── machine │ ├── endian.h │ ├── _types.h │ └── elf.h ├── asm │ └── stat.h ├── bits │ ├── stat.h │ ├── utmp.h │ └── utmpx.h ├── rpc │ └── xdr.h ├── timeconv.h ├── paths.h ├── stdlib.h ├── unistd.h ├── __want_lseek.h ├── readpassphrase.h ├── err.h └── embed │ └── sys │ └── elf_common.h ├── Makefile └── src ├── host_elf_arch.c ├── freebsd-glue ├── namespace.h ├── un-namespace.h ├── socket.c ├── disklabel.c ├── exec.c ├── login_class.c ├── sendfile.c ├── fstab.c ├── Makefile ├── cpuset.c ├── basename.c ├── random.c ├── getosreldate.c ├── getbootfile.c ├── mac_set.c ├── strnstr.c ├── capability.c ├── feature_present.c ├── sysarch.c ├── getbsize.c ├── linkaddr.c ├── getcap.c ├── subr_capability.c └── mac.c ├── Makefile ├── z ├── Makefile └── zopen.c ├── crypt ├── Makefile └── crypt.c ├── Makefile.inc └── get_elf_arch.c /debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /debian/dirs: -------------------------------------------------------------------------------- 1 | usr/lib/freebsd 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /include/md5.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/vis.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/bsdxml.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/nlist.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/osreldate.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/sys/stdint.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SUBDIR= src 2 | 3 | .include 4 | -------------------------------------------------------------------------------- /debian/libfreebsd-glue-0.install: -------------------------------------------------------------------------------- 1 | lib/libfreebsd-glue.so.* 2 | -------------------------------------------------------------------------------- /src/host_elf_arch.c: -------------------------------------------------------------------------------- 1 | int main (int argc, char **argv) { return 0; } 2 | -------------------------------------------------------------------------------- /debian/libfreebsd-glue-0-udeb.install: -------------------------------------------------------------------------------- 1 | debian/tmp-udeb/lib/libfreebsd-glue.so.* lib 2 | -------------------------------------------------------------------------------- /debian/local/scripts/bmake: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec /usr/bin/bmake -m /usr/share/mk-freebsd $@ 3 | -------------------------------------------------------------------------------- /src/freebsd-glue/namespace.h: -------------------------------------------------------------------------------- 1 | #ifndef _NAMESPACE_H_ 2 | #define _NAMESPACE_H_ 3 | #endif 4 | -------------------------------------------------------------------------------- /include/db.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_H_ 2 | #define _DB_H_ 3 | 4 | #include 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/freebsd-glue/un-namespace.h: -------------------------------------------------------------------------------- 1 | #ifndef _UN_NAMESPACE_H_ 2 | #define _UN_NAMESPACE_H_ 3 | #endif 4 | -------------------------------------------------------------------------------- /include/sys/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_FCNTL_H_ 2 | #define _SYS_FCNTL_H_ 3 | 4 | #include 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIR= \ 2 | freebsd-glue \ 3 | crypt \ 4 | z \ 5 | ${NULL} 6 | 7 | .include 8 | -------------------------------------------------------------------------------- /include/netinet/ip.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _NETINET_IP_H_ 4 | #define _NETINET_IP_H_ 5 | #endif 6 | -------------------------------------------------------------------------------- /include/ndbm.h: -------------------------------------------------------------------------------- 1 | #ifndef _NDBM_H_ 2 | #define _NDBM_H_ 3 | 4 | #include 5 | #include 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /src/z/Makefile: -------------------------------------------------------------------------------- 1 | LIB= z-freebsd 2 | SRCS= \ 3 | zopen.c \ 4 | ${NULL} 5 | 6 | LDADD= -lz 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /src/crypt/Makefile: -------------------------------------------------------------------------------- 1 | LIB= crypt-freebsd 2 | SRCS= \ 3 | crypt.c \ 4 | ${NULL} 5 | 6 | LDADD= -lcrypt 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /debian/install: -------------------------------------------------------------------------------- 1 | include/* usr/include/freebsd 2 | usr/lib/lib*.a 3 | usr/lib/libfreebsd-glue.so 4 | usr/lib/libbsdxml.so 5 | usr/lib/freebsd 6 | -------------------------------------------------------------------------------- /include/termios.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _TERMIOS_H_ 4 | #define _TERMIOS_H_ 5 | 6 | # include 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /include/netinet6/in6.h: -------------------------------------------------------------------------------- 1 | #ifndef _NETINET6_IN6_H_ 2 | #define _NETINET6_IN6_H_ 3 | 4 | /* For struct route_in6 */ 5 | #include 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /include/net/ethernet.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _NET_ETHERNET_H_ 4 | #define _NET_ETHERNET_H_ 5 | 6 | #include 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /include/limits.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _LIMITS_H_ 4 | #define _LIMITS_H_ 5 | 6 | #ifndef PATH_MAX 7 | #define PATH_MAX 1024 8 | #endif 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /include/netinet/tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef _NETINET_TCP_H_ 2 | #define _NETINET_TCP_H_ 3 | 4 | # define __FAVOR_BSD 1 5 | # include_next 6 | # undef __FAVOR_BSD 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /include/netinet/udp.h: -------------------------------------------------------------------------------- 1 | #ifndef _NETINET_UDP_H_ 2 | #define _NETINET_UDP_H_ 3 | 4 | # define __FAVOR_BSD 1 5 | # include_next 6 | # undef __FAVOR_BSD 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /include/sys/sysctl.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef __FREEBSD_GLUE_SYS_SYSCTL_H_ 4 | #define __FREEBSD_GLUE_SYS_SYSCTL_H_ 5 | 6 | #include 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/freebsd-glue/socket.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int 6 | setfib (int fib) 7 | { 8 | return syscall (SYS_setfib, fib); 9 | } 10 | -------------------------------------------------------------------------------- /include/ctype.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _CTYPE_H_ 4 | #define _CTYPE_H_ 5 | 6 | #ifndef isnumber 7 | #define isnumber(x) isdigit(x) 8 | #endif 9 | 10 | #endif /* !_CTYPE_H_ */ 11 | -------------------------------------------------------------------------------- /include/pthread_np.h: -------------------------------------------------------------------------------- 1 | #ifndef _PTHREAD_NP_H_ 2 | #define _PTHREAD_NP_H_ 3 | 4 | #include 5 | 6 | /* non-POSIX facilities are in */ 7 | #include 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /include/sys/elf_common.h: -------------------------------------------------------------------------------- 1 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 2 | #include_next 3 | #else 4 | #include 5 | #endif 6 | -------------------------------------------------------------------------------- /include/grp.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _GRP_H_ 4 | #define _GRP_H_ 5 | 6 | #include 7 | #include 8 | 9 | #define _PATH_GROUP "/etc/group" 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /src/freebsd-glue/disklabel.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct disklabel * 5 | getdiskbyname (const char *name) 6 | { 7 | /* We don't have disktab(5) */ 8 | return NULL; 9 | } 10 | -------------------------------------------------------------------------------- /src/Makefile.inc: -------------------------------------------------------------------------------- 1 | SHLIB_MAJOR ?= 0 2 | SHLIBDIR ?= /lib 3 | 4 | CFLAGS += -g -fPIC -D_GNU_SOURCE \ 5 | -Wall -Werror -Wno-error=maybe-uninitialized \ 6 | -isystem ${.CURDIR}/../../include \ 7 | -D__FREEBSD_LIBC \ 8 | ${NULL} 9 | -------------------------------------------------------------------------------- /include/sys/stat.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _SYS_STAT_H_ 4 | #define _SYS_STAT_H_ 5 | 6 | #include 7 | 8 | #ifndef S_ISTXT 9 | #define S_ISTXT S_ISVTX 10 | #endif 11 | 12 | #endif /* _SYS_STAT_H_ */ 13 | -------------------------------------------------------------------------------- /debian/links: -------------------------------------------------------------------------------- 1 | bin/dash usr/lib/freebsd/sh 2 | usr/bin/original-awk usr/lib/freebsd/awk 3 | usr/bin/make usr/lib/freebsd/gmake 4 | usr/bin/fmake usr/lib/freebsd/make 5 | usr/bin/fmtree usr/lib/freebsd/mtree 6 | usr/bin/byacc usr/lib/freebsd/yacc 7 | -------------------------------------------------------------------------------- /include/libgen.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _LIBGEN_H_ 4 | #define _LIBGEN_H_ 5 | 6 | #include 7 | 8 | __BEGIN_DECLS 9 | 10 | char *basename_r(const char *, char *); 11 | 12 | __END_DECLS 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/freebsd-glue/exec.c: -------------------------------------------------------------------------------- 1 | #include /* setenv */ 2 | #include /* execvp */ 3 | 4 | int 5 | execvP(const char *name, const char *path, char * const argv[]) 6 | { 7 | setenv ("PATH", path, 1); 8 | return execvp(name, argv); 9 | } 10 | -------------------------------------------------------------------------------- /include/sys/file.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 4 | #include 5 | #else 6 | #ifndef _SYS_FILE_H_ 7 | #define _SYS_FILE_H_ 8 | #endif 9 | #endif 10 | -------------------------------------------------------------------------------- /src/crypt/crypt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const char * 5 | crypt_get_format (void) 6 | { 7 | return "des"; 8 | } 9 | 10 | int 11 | crypt_set_format (const char *string) 12 | { 13 | return !strcmp (string, "des"); 14 | } 15 | -------------------------------------------------------------------------------- /include/sys/ttycom.h: -------------------------------------------------------------------------------- 1 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 2 | 3 | # include_next 4 | 5 | #else 6 | 7 | # ifndef _SYS_TTYCOM_H_ 8 | # define _SYS_TTYCOM_H_ 9 | # include 10 | # endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/net/if_dl.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _FREEBSD_NET_IF_DL_H_ 4 | #define _FREEBSD_NET_IF_DL_H_ 5 | 6 | __BEGIN_DECLS 7 | void link_addr(const char *, struct sockaddr_dl *); 8 | char *link_ntoa(const struct sockaddr_dl *); 9 | __END_DECLS 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /include/sys/_types.h: -------------------------------------------------------------------------------- 1 | #ifdef __FreeBSD_kernel__ 2 | 3 | #include_next 4 | 5 | #else 6 | 7 | #ifndef _SYS__TYPES_H_ 8 | #define _SYS__TYPES_H_ 9 | 10 | #include 11 | #include 12 | 13 | #endif /* !_SYS__TYPES_H_ */ 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/stdint.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _SYS_STDINT_H_ 4 | #define _SYS_STDINT_H_ 5 | 6 | #include 7 | 8 | #ifdef __FreeBSD_kernel__ 9 | #include 10 | #include 11 | #include 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/sys/ioccom.h: -------------------------------------------------------------------------------- 1 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 2 | 3 | # include_next 4 | 5 | #else 6 | 7 | # ifndef _SYS_IOCCOM_H_ 8 | # define _SYS_IOCCOM_H_ 9 | # include /* For ioctl() */ 10 | # endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/sys/limits.h: -------------------------------------------------------------------------------- 1 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 2 | #include_next 3 | #else 4 | #ifndef _SYS_LIMITS_H_ 5 | #define _SYS_LIMITS_H_ 6 | #include 7 | #include 8 | #endif 9 | #endif /* __FreeBSD_kernel__ */ 10 | -------------------------------------------------------------------------------- /include/fstab.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _FSTAB_H_ 4 | #define _FSTAB_H_ 5 | 6 | #include 7 | #define _PATH_FSTAB "/etc/fstab" 8 | 9 | __BEGIN_DECLS 10 | void setfstab(const char *); 11 | const char *getfstab (void); 12 | __END_DECLS 13 | 14 | #endif /* !_FSTAB_H_ */ 15 | -------------------------------------------------------------------------------- /include/sys/_stdint.h: -------------------------------------------------------------------------------- 1 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 2 | 3 | #include_next 4 | 5 | #else 6 | 7 | #ifndef _SYS__STDINT_H_ 8 | #define _SYS__STDINT_H_ 9 | 10 | #include 11 | 12 | #endif /* !_SYS__STDINT_H_ */ 13 | 14 | #endif /* __FreeBSD_kernel__ */ 15 | -------------------------------------------------------------------------------- /src/freebsd-glue/login_class.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int 6 | getloginclass (char *name, size_t len) 7 | { 8 | return syscall (SYS_getloginclass, name, len); 9 | } 10 | 11 | int 12 | setloginclass (const char *name) 13 | { 14 | return syscall (SYS_setloginclass, name); 15 | } 16 | -------------------------------------------------------------------------------- /include/string.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _STRING_H_ 4 | #define _STRING_H_ 5 | size_t strlcat(char * __restrict, const char * __restrict, size_t); 6 | size_t strlcpy(char * __restrict, const char * __restrict, size_t); 7 | void strmode(int, char *); 8 | char *strnstr(const char *big, const char *little, size_t len); 9 | #endif 10 | -------------------------------------------------------------------------------- /include/stdio.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _STDIO_H_ 4 | #define _STDIO_H_ 5 | 6 | #include_next 7 | 8 | /* FreeBSD has a few ugly kludges to declare a copy of 9 | functions which actually belong to . We do the same 10 | here. */ 11 | #include <__want_lseek.h> 12 | 13 | #include 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/freebsd-glue/sendfile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int 8 | bsd_sendfile (int fd, int s, off_t offset, size_t nbytes, 9 | struct sf_hdtr *hdtr, off_t *sbytes, int flags) 10 | { 11 | return syscall (SYS_sendfile, fd, s, offset, nbytes, hdtr, sbytes, flags); 12 | } 13 | -------------------------------------------------------------------------------- /include/sys/errno.h: -------------------------------------------------------------------------------- 1 | #ifdef _ERRNO_H 2 | 3 | /* We were included by in order to obtain the full list of 4 | errno codes. Fallback to the real thing. */ 5 | # include_next 6 | 7 | #else 8 | 9 | /* We were included by some FreeBSD program which just wanted 10 | and chose to use the unportable . */ 11 | # include_next 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/aio.h: -------------------------------------------------------------------------------- 1 | #if defined(__unused) && !defined(__DO_NOT_DEFINE_UNUSED) 2 | #define __DO_DEFINE_UNUSED_AT_THE_END_OF_AIO_H 3 | #endif 4 | 5 | #undef __unused 6 | #define __DO_NOT_DEFINE_UNUSED 7 | #include_next 8 | #undef __DO_NOT_DEFINE_UNUSED 9 | 10 | #ifdef __DO_DEFINE_UNUSED_AT_THE_END_OF_AIO_H 11 | #define __unused __attribute__((__unused__)) 12 | #undef __DO_DEFINE_UNUSED_AT_THE_END_OF_AIO_H 13 | #endif 14 | -------------------------------------------------------------------------------- /include/fcntl.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | #include 3 | 4 | #ifndef _FREEBSD_FCNTL_H_ 5 | #define _FREEBSD_FCNTL_H_ 6 | 7 | #ifdef __FREEBSD_LIBC 8 | /* On FreeBSD, these are hidden symbols provided by libc. We use 9 | macros to redirect them, but only them visible to freebsd-glue 10 | code. */ 11 | #define _open open 12 | #define _read read 13 | #define _close close 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/freebsd-glue/fstab.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include /* strerror */ 5 | #include 6 | 7 | void 8 | setfstab (const char *file) 9 | { 10 | /* NULL means /etc/fstab */ 11 | if (file != NULL) 12 | { 13 | errno = ENOSYS; 14 | warn ("setfstab"); 15 | } 16 | } 17 | 18 | const char *getfstab (void) 19 | { 20 | return _PATH_FSTAB; 21 | } 22 | -------------------------------------------------------------------------------- /include/netdb.h: -------------------------------------------------------------------------------- 1 | #if defined(__unused) && !defined(__DO_NOT_DEFINE_UNUSED) 2 | #define __DO_DEFINE_UNUSED_AT_THE_END_OF_NETDB_H 3 | #endif 4 | 5 | #undef __unused 6 | #define __DO_NOT_DEFINE_UNUSED 7 | #include_next 8 | #undef __DO_NOT_DEFINE_UNUSED 9 | 10 | #ifdef __DO_DEFINE_UNUSED_AT_THE_END_OF_NETDB_H 11 | #define __unused __attribute__((__unused__)) 12 | #undef __DO_DEFINE_UNUSED_AT_THE_END_OF_NETDB_H 13 | #endif 14 | -------------------------------------------------------------------------------- /include/linux/icmp.h: -------------------------------------------------------------------------------- 1 | #if defined(__unused) && !defined(__DO_NOT_DEFINE_UNUSED) 2 | #define __DO_DEFINE_UNUSED_AT_THE_END_OF_ICMP_H 3 | #endif 4 | 5 | #undef __unused 6 | #define __DO_NOT_DEFINE_UNUSED 7 | #include_next 8 | #undef __DO_NOT_DEFINE_UNUSED 9 | 10 | #ifdef __DO_DEFINE_UNUSED_AT_THE_END_OF_ICMP_H 11 | #define __unused __attribute__((__unused__)) 12 | #undef __DO_DEFINE_UNUSED_AT_THE_END_OF_ICMP_H 13 | #endif 14 | -------------------------------------------------------------------------------- /include/machine/endian.h: -------------------------------------------------------------------------------- 1 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 2 | /* We have . Use it. */ 3 | # include_next 4 | #else 5 | # ifndef _MACHINE_ENDIAN_H_ 6 | # define _MACHINE_ENDIAN_H_ 7 | # include_next 8 | # define _LITTLE_ENDIAN LITTLE_ENDIAN 9 | # define _BIG_ENDIAN BIG_ENDIAN 10 | # define _BYTE_ORDER BYTE_ORDER 11 | # endif 12 | #endif 13 | -------------------------------------------------------------------------------- /include/asm/stat.h: -------------------------------------------------------------------------------- 1 | #if defined(__unused) && !defined(__DO_NOT_DEFINE_UNUSED) 2 | #define __DO_DEFINE_UNUSED_AT_THE_END_OF_ASM_STAT_H 3 | #endif 4 | 5 | #undef __unused 6 | #define __DO_NOT_DEFINE_UNUSED 7 | #include_next 8 | #undef __DO_NOT_DEFINE_UNUSED 9 | 10 | #ifdef __DO_DEFINE_UNUSED_AT_THE_END_OF_ASM_STAT_H 11 | #define __unused __attribute__((__unused__)) 12 | #undef __DO_DEFINE_UNUSED_AT_THE_END_OF_ASM_STAT_H 13 | #endif 14 | -------------------------------------------------------------------------------- /include/bits/stat.h: -------------------------------------------------------------------------------- 1 | #if defined(__unused) && !defined(__DO_NOT_DEFINE_UNUSED) 2 | #define __DO_DEFINE_UNUSED_AT_THE_END_OF_BITS_STAT_H 3 | #endif 4 | 5 | #undef __unused 6 | #define __DO_NOT_DEFINE_UNUSED 7 | #include_next 8 | #undef __DO_NOT_DEFINE_UNUSED 9 | 10 | #ifdef __DO_DEFINE_UNUSED_AT_THE_END_OF_BITS_STAT_H 11 | #define __unused __attribute__((__unused__)) 12 | #undef __DO_DEFINE_UNUSED_AT_THE_END_OF_BITS_STAT_H 13 | #endif 14 | -------------------------------------------------------------------------------- /include/bits/utmp.h: -------------------------------------------------------------------------------- 1 | #if defined(__unused) && !defined(__DO_NOT_DEFINE_UNUSED) 2 | #define __DO_DEFINE_UNUSED_AT_THE_END_OF_BITS_UTMP_H 3 | #endif 4 | 5 | #undef __unused 6 | #define __DO_NOT_DEFINE_UNUSED 7 | #include_next 8 | #undef __DO_NOT_DEFINE_UNUSED 9 | 10 | #ifdef __DO_DEFINE_UNUSED_AT_THE_END_OF_BITS_UTMP_H 11 | #define __unused __attribute__((__unused__)) 12 | #undef __DO_DEFINE_UNUSED_AT_THE_END_OF_BITS_UTMP_H 13 | #endif 14 | -------------------------------------------------------------------------------- /include/bits/utmpx.h: -------------------------------------------------------------------------------- 1 | #if defined(__unused) && !defined(__DO_NOT_DEFINE_UNUSED) 2 | #define __DO_DEFINE_UNUSED_AT_THE_END_OF_BITS_UTMPX_H 3 | #endif 4 | 5 | #undef __unused 6 | #define __DO_NOT_DEFINE_UNUSED 7 | #include_next 8 | #undef __DO_NOT_DEFINE_UNUSED 9 | 10 | #ifdef __DO_DEFINE_UNUSED_AT_THE_END_OF_BITS_UTMPX_H 11 | #define __unused __attribute__((__unused__)) 12 | #undef __DO_DEFINE_UNUSED_AT_THE_END_OF_BITS_UTMPX_H 13 | #endif 14 | -------------------------------------------------------------------------------- /include/linux/sysctl.h: -------------------------------------------------------------------------------- 1 | #if defined(__unused) && !defined(__DO_NOT_DEFINE_UNUSED) 2 | #define __DO_DEFINE_UNUSED_AT_THE_END_OF_LINUX_SYSCTL_H 3 | #endif 4 | 5 | #undef __unused 6 | #define __DO_NOT_DEFINE_UNUSED 7 | #include_next 8 | #undef __DO_NOT_DEFINE_UNUSED 9 | 10 | #ifdef __DO_DEFINE_UNUSED_AT_THE_END_OF_LINUX_SYSCTL_H 11 | #define __unused __attribute__((__unused__)) 12 | #undef __DO_DEFINE_UNUSED_AT_THE_END_OF_LINUX_SYSCTL_H 13 | #endif 14 | -------------------------------------------------------------------------------- /include/sys/socket.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _FREEBSD_SYS_SOCKET_H_ 4 | #define _FREEBSD_SYS_SOCKET_H_ 5 | 6 | #include 7 | 8 | __BEGIN_DECLS 9 | int setfib(int fib); 10 | __END_DECLS 11 | 12 | #ifdef __FreeBSD_kernel__ 13 | /* bsd_sendfile prototype already in glibc. */ 14 | #define sendfile(fd, s, offset, nbytes, hdtr, sbytes, flags) \ 15 | bsd_sendfile((fd), (s), (offset), (nbytes), (hdtr), (sbytes), (flags)) 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/machine/_types.h: -------------------------------------------------------------------------------- 1 | #ifdef __FreeBSD_kernel__ 2 | 3 | /* GNU/kFreeBSD is patched to check for the GNU form 4 | (_SYS_CDEFS_H) instead of BSD form (_SYS_CDEFS_H_). */ 5 | #if defined(_SYS_CDEFS_H_) && !defined(_SYS_CDEFS_H) 6 | #define _SYS_CDEFS_H 7 | #endif 8 | 9 | #include_next 10 | 11 | #else 12 | 13 | #ifndef _MACHINE__TYPES_H_ 14 | #define _MACHINE__TYPES_H_ 15 | 16 | typedef __builtin_va_list __va_list; /* internally known to gcc */ 17 | 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/rpc/xdr.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _FREEBSD_RPC_XDR_H 4 | #define _FREEBSD_RPC_XDR_H 5 | 6 | #include 7 | 8 | /* 9 | * These are XDR control operators 10 | */ 11 | 12 | #define XDR_GET_BYTES_AVAIL 1 13 | #define XDR_PEEK 2 14 | #define XDR_SKIPBYTES 3 15 | 16 | struct xdr_bytesrec { 17 | bool_t xc_is_last_record; 18 | size_t xc_num_avail; 19 | }; 20 | 21 | typedef struct xdr_bytesrec xdr_bytesrec; 22 | 23 | #define xdr_control(xdrs, req, op) XDR_CONTROL(xdrs, req, op) 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/get_elf_arch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int 7 | main (int argc, char **argv) 8 | { 9 | int fd; 10 | Elf32_Ehdr ehdr; 11 | 12 | fd = open (argv[1], O_RDONLY); 13 | if (fd == -1) 14 | perror ("open"); 15 | 16 | if (read (fd, &ehdr, sizeof (ehdr)) != sizeof (ehdr)) 17 | perror ("read"); 18 | 19 | printf ("#define ELF_ARCH %u\n", ehdr.e_machine); 20 | printf ("#define __ELF_WORD_SIZE %u\n", ehdr.e_ident[EI_CLASS] == ELFCLASS64 ? 64 : 32); 21 | 22 | close (fd); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /src/freebsd-glue/Makefile: -------------------------------------------------------------------------------- 1 | LIB= freebsd-glue 2 | SRCS= \ 3 | basename.c \ 4 | exec.c \ 5 | feature_present.c \ 6 | fstab.c \ 7 | getbsize.c \ 8 | getcap.c \ 9 | getosreldate.c \ 10 | random.c \ 11 | strnstr.c \ 12 | ${NULL} 13 | 14 | LDADD= -lbsd 15 | 16 | SYS!= dpkg-architecture -qDEB_HOST_GNU_SYSTEM 17 | 18 | .if ${SYS} == "kfreebsd-gnu" 19 | SRCS+= \ 20 | capability.c subr_capability.c \ 21 | cpuset.c \ 22 | disklabel.c \ 23 | getbootfile.c \ 24 | linkaddr.c \ 25 | login_class.c \ 26 | mac.c \ 27 | mac_set.c \ 28 | socket.c \ 29 | sendfile.c \ 30 | sysarch.c \ 31 | ${NULL} 32 | .endif 33 | 34 | .include 35 | -------------------------------------------------------------------------------- /include/sys/user.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _FREEBSD_SYS_USER_H_ 4 | #define _FREEBSD_SYS_USER_H_ 5 | 6 | #ifdef __FreeBSD_kernel__ 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /include/timeconv.h: -------------------------------------------------------------------------------- 1 | #ifndef _TIMECONV_H_ 2 | #define _TIMECONV_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #define __need_time_t 9 | #include 10 | 11 | static inline int32_t 12 | _time_to_time32 (time_t t) 13 | { 14 | return((int32_t) t); 15 | } 16 | 17 | static inline int64_t 18 | _time_to_time64(time_t t) 19 | { 20 | return((int64_t) t); 21 | } 22 | 23 | static inline time_t 24 | _time64_to_time(int64_t t64) 25 | { 26 | return((time_t) t64); 27 | } 28 | 29 | static inline time_t 30 | _time32_to_time(int32_t t32) 31 | { 32 | return((time_t) t32); 33 | } 34 | 35 | #endif /* _TIMECONV_H_ */ 36 | -------------------------------------------------------------------------------- /include/sys/types.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | # if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 4 | # include 5 | # else 6 | # ifndef _SYS_TYPES_H_ 7 | # define _SYS_TYPES_H_ 8 | # include 9 | # include /* uintXX_t */ 10 | 11 | /* Emulate implicit includes on FreeBSD */ 12 | # include 13 | # include 14 | 15 | /* FreeBSD has a few ugly kludges to declare a copy of 16 | functions which actually belong to . We do the same 17 | here. */ 18 | # include <__want_lseek.h> 19 | 20 | #endif /* _SYS_TYPES_H_ */ 21 | 22 | #endif /* __FreeBSD_kernel__ */ 23 | -------------------------------------------------------------------------------- /include/netinet/in.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _NETINET_IN_H_ 4 | #define _NETINET_IN_H_ 5 | 6 | #include 7 | 8 | #ifdef __FreeBSD_kernel__ 9 | 10 | #ifndef IPPORT_MAX 11 | #define IPPORT_MAX 65535 12 | #endif 13 | 14 | #endif 15 | 16 | #ifndef INADDR_ALLRPTS_GROUP 17 | #define INADDR_ALLRPTS_GROUP (u_int32_t)0xe0000016 /* 224.0.0.22, IGMPv3 */ 18 | #endif 19 | #ifndef INADDR_CARP_GROUP 20 | #define INADDR_CARP_GROUP (u_int32_t)0xe0000012 /* 224.0.0.18 */ 21 | #endif 22 | #ifndef INADDR_PFSYNC_GROUP 23 | #define INADDR_PFSYNC_GROUP (u_int32_t)0xe00000f0 /* 224.0.0.240 */ 24 | #endif 25 | #ifndef INADDR_ALLMDNS_GROUP 26 | #define INADDR_ALLMDNS_GROUP (u_int32_t)0xe00000fb /* 224.0.0.251 */ 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /include/sys/proc.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _FREEBSD_SYS_PROC_H_ 4 | #define _FREEBSD_SYS_PROC_H_ 5 | 6 | #ifdef __FreeBSD_kernel__ 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /include/paths.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _FREEBSD_PATHS_H_ 4 | #define _FREEBSD_PATHS_H_ 5 | 6 | #include 7 | 8 | #define _PATH_DEVZERO "/dev/zero" 9 | #define _PATH_ETC "/etc" 10 | #define _PATH_SYSPATH "/sbin:/usr/sbin" 11 | #define _PATH_IFCONFIG "/sbin/ifconfig" 12 | #define _PATH_MOUNT "/sbin/mount" 13 | #define _PATH_UUCPLOCK "/var/lock/" /* as per FHS, section 5 */ 14 | 15 | #ifdef __FreeBSD_kernel__ 16 | #define _PATH_FWMEM "/dev/fwmem" 17 | #define _PATH_UFSSUSPEND "/dev/ufssuspend" 18 | #define _PATH_GBDE "/sbin/gbde" 19 | #define _PATH_GELI "/sbin/geli" 20 | #define _PATH_MDCONFIG "/sbin/mdconfig" 21 | #endif 22 | 23 | __BEGIN_DECLS 24 | #ifdef __FreeBSD_kernel__ 25 | const char *getbootfile(void); 26 | #endif 27 | __END_DECLS 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /include/machine/elf.h: -------------------------------------------------------------------------------- 1 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 2 | #include_next 3 | #else 4 | 5 | #ifndef _MACHINE_ELF_H_ 6 | #define _MACHINE_ELF_H_ 1 7 | 8 | #include 9 | #include 10 | 11 | #ifndef ELF_ARCH 12 | #include /* ELF_ARCH */ 13 | #endif 14 | 15 | #ifndef ELF_TARG_DATA 16 | #include 17 | #if __BYTE_ORDER == __LITTLE_ENDIAN 18 | # define ELF_TARG_DATA ELFDATA2LSB 19 | #elif __BYTE_ORDER == __BIG_ENDIAN 20 | # define ELF_TARG_DATA ELFDATA2MSB 21 | #else 22 | # error wtf?? 23 | #endif 24 | #endif 25 | 26 | #ifndef ELF_TARG_CLASS 27 | #include 28 | #if __ELF_NATIVE_CLASS == 32 29 | # define ELF_TARG_CLASS ELFCLASS32 30 | #elif __ELF_NATIVE_CLASS == 64 31 | # define ELF_TARG_CLASS ELFCLASS64 32 | #else 33 | # error wtf?? 34 | #endif 35 | #endif 36 | 37 | #endif 38 | 39 | #endif /* __FreeBSD_kernel__ */ 40 | -------------------------------------------------------------------------------- /src/freebsd-glue/cpuset.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int 7 | cpuset (cpusetid_t *setid) 8 | { 9 | return syscall (SYS_cpuset, setid); 10 | } 11 | 12 | int 13 | cpuset_setid (cpuwhich_t which, id_t id, cpusetid_t setid) 14 | { 15 | return syscall (SYS_cpuset_setid, which, id, setid); 16 | } 17 | 18 | int 19 | cpuset_getid (cpulevel_t level, cpuwhich_t which, id_t id, cpusetid_t *setid) 20 | { 21 | return syscall (SYS_cpuset_getid, level, which, id, setid); 22 | } 23 | 24 | int 25 | cpuset_getaffinity (cpulevel_t level, cpuwhich_t which, id_t id, size_t setsize, cpuset_t *mask) 26 | { 27 | return syscall (SYS_cpuset_getaffinity, level, which, id, setsize, mask); 28 | } 29 | 30 | int 31 | cpuset_setaffinity (cpulevel_t level, cpuwhich_t which, id_t id, size_t setsize, const cpuset_t *mask) 32 | { 33 | return syscall (SYS_cpuset_setaffinity, level, which, id, setsize, mask); 34 | } 35 | -------------------------------------------------------------------------------- /include/stdlib.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _STDLIB_H_ 4 | #define _STDLIB_H_ 5 | 6 | #include 7 | 8 | __BEGIN_DECLS 9 | 10 | u_int32_t arc4random (void); 11 | void arc4random_stir (void); 12 | void arc4random_buf (void *, size_t); 13 | 14 | const char *getprogname(void); 15 | void setprogname (const char *); 16 | void *reallocf(void *ptr, size_t size); 17 | void srandomdev (void); 18 | long long strtonum (const char *nptr, long long minval, long long maxval, const char **errstr); 19 | char *getbsize(int *, long *); 20 | 21 | char *cgetcap(char *, const char *, int); 22 | int cgetclose(void); 23 | int cgetent(char **, char **, const char *); 24 | int cgetfirst(char **, char **); 25 | int cgetmatch(const char *, const char *); 26 | int cgetnext(char **, char **); 27 | int cgetnum(char *, const char *, long *); 28 | int cgetset(const char *); 29 | int cgetstr(char *, const char *, char **); 30 | int cgetustr(char *, const char *, char **); 31 | 32 | __END_DECLS 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/z/zopen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Public domain stdio wrapper for libz, written by Johan Danielsson. 3 | */ 4 | 5 | #include 6 | __FBSDID("$FreeBSD: head/lib/libz/zopen.c 84228 2001-09-30 22:39:00Z dillon $"); 7 | 8 | #include 9 | #include 10 | 11 | FILE *zopen(const char *fname, const char *mode); 12 | 13 | /* convert arguments */ 14 | static int 15 | xgzread(void *cookie, char *data, int size) 16 | { 17 | return gzread(cookie, data, size); 18 | } 19 | 20 | static int 21 | xgzwrite(void *cookie, const char *data, int size) 22 | { 23 | return gzwrite(cookie, (void*)data, size); 24 | } 25 | 26 | static int 27 | xgzclose(void *cookie) 28 | { 29 | return gzclose(cookie); 30 | } 31 | 32 | FILE * 33 | zopen(const char *fname, const char *mode) 34 | { 35 | gzFile gz = gzopen(fname, mode); 36 | if(gz == NULL) 37 | return NULL; 38 | 39 | if(*mode == 'r') 40 | return (funopen(gz, xgzread, NULL, NULL, xgzclose)); 41 | else 42 | return (funopen(gz, NULL, xgzwrite, NULL, xgzclose)); 43 | } 44 | -------------------------------------------------------------------------------- /include/sys/time.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | # if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 4 | # include 5 | # else 6 | #ifndef _SYS_TIME_H_ 7 | # define _SYS_TIME_H_ 8 | 9 | /* On FreeBSD, is expected to CLOCK_MONOTONIC, etc, 10 | which on Glibc are defined in . Glibc's 11 | doesn't include in full mode, but Glibc's 12 | does. */ 13 | # include 14 | 15 | /* FreeBSD code expects that this file includes... */ 16 | # include 17 | 18 | /* FreeBSD-specific clocks. Attempt to map them to portable macros (but 19 | make sure the calls fail when this mapping would not be reliable) */ 20 | #define CLOCK_UPTIME (-1) 21 | #define CLOCK_UPTIME_PRECISE (-1) 22 | #define CLOCK_UPTIME_FAST (-1) 23 | #define CLOCK_REALTIME_PRECISE CLOCK_REALTIME 24 | #define CLOCK_REALTIME_FAST CLOCK_REALTIME_COARSE 25 | #define CLOCK_MONOTONIC_PRECISE CLOCK_MONOTONIC 26 | #define CLOCK_MONOTONIC_FAST CLOCK_MONOTONIC_COARSE 27 | #define CLOCK_SECOND (-1) 28 | 29 | #endif /* _SYS_TIME_H_ */ 30 | 31 | #endif /* __FreeBSD_kernel__ */ 32 | -------------------------------------------------------------------------------- /include/unistd.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | #ifndef _UNISTD_H_ 4 | #define _UNISTD_H_ 5 | 6 | #include /* initgroups */ 7 | #include /* crypt */ 8 | 9 | #ifdef __FreeBSD_kernel__ 10 | #include 11 | #include /* size_t */ 12 | #endif 13 | 14 | #define getopt(argc, argv, options) bsd_getopt(argc, argv, options) 15 | 16 | __BEGIN_DECLS 17 | 18 | int bsd_getopt(int argc, char *const *argv, const char *options); 19 | extern int optreset; 20 | 21 | #ifdef __FreeBSD_kernel__ 22 | 23 | static inline int 24 | nfssvc (int a, void *b) 25 | { 26 | return syscall (SYS_nfssvc, a, b); 27 | } 28 | 29 | #ifndef SYS_closefrom 30 | #define SYS_closefrom 509 31 | #endif 32 | 33 | static inline void 34 | closefrom (int lowfd) 35 | { 36 | syscall (SYS_closefrom, lowfd); 37 | } 38 | 39 | int getosreldate(void); 40 | int feature_present(const char *); 41 | int execvP(const char *, const char *, char * const[]); 42 | 43 | mode_t getmode(const void *, mode_t); 44 | void *setmode(const char *); 45 | 46 | #ifndef SYS_nlm_syscall 47 | #define SYS_nlm_syscall 154 48 | #endif 49 | 50 | static inline int 51 | nlm_syscall (int a, int b, int c, char **d) 52 | { 53 | return syscall (SYS_nlm_syscall, a, b, c, d); 54 | } 55 | 56 | int getloginclass (char *name, size_t len); 57 | int setloginclass (const char *name); 58 | 59 | int getpeereid (int, uid_t *, gid_t *); 60 | 61 | int swapon (const char *); 62 | int swapoff (const char *); 63 | 64 | #endif /* __FreeBSD_kernel__ */ 65 | 66 | void setproctitle(const char *fmt, ...); 67 | 68 | const char *crypt_get_format (void); 69 | int crypt_set_format (const char *string); 70 | 71 | __END_DECLS 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/freebsd-glue/basename.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Robert Millan 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | char * 32 | basename_r (const char *path, char *bname) 33 | { 34 | strncpy (bname, path, MAXPATHLEN); 35 | return __xpg_basename (bname); 36 | } 37 | -------------------------------------------------------------------------------- /include/sys/elf.h: -------------------------------------------------------------------------------- 1 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 2 | #include_next 3 | #else 4 | 5 | /*- 6 | * Copyright (c) 2001 David E. O'Brien. 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | * 30 | * $FreeBSD$ 31 | */ 32 | 33 | /* 34 | * This is a Solaris compatibility header 35 | */ 36 | 37 | #ifndef _SYS_ELF_H_ 38 | #define _SYS_ELF_H_ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #endif /* !_SYS_ELF_H_ */ 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/__want_lseek.h: -------------------------------------------------------------------------------- 1 | #ifndef _LSEEK_DECLARED 2 | #define _LSEEK_DECLARED 3 | /* Copyright (C) 1991-2009, 2010 Free Software Foundation, Inc. 4 | This file is part of the GNU C Library. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, write to the Free 18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | 02111-1307 USA. */ 20 | 21 | /* 22 | * POSIX Standard: 2.10 Symbolic Constants 23 | */ 24 | 25 | #include 26 | 27 | __BEGIN_DECLS 28 | 29 | /* Move FD's file position to OFFSET bytes from the 30 | beginning of the file (if WHENCE is SEEK_SET), 31 | the current position (if WHENCE is SEEK_CUR), 32 | or the end of the file (if WHENCE is SEEK_END). 33 | Return the new file position. */ 34 | #ifndef __USE_FILE_OFFSET64 35 | extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW; 36 | #else 37 | # ifdef __REDIRECT_NTH 38 | extern __off64_t __REDIRECT_NTH (lseek, 39 | (int __fd, __off64_t __offset, int __whence), 40 | lseek64); 41 | # else 42 | # define lseek lseek64 43 | # endif 44 | #endif 45 | #ifdef __USE_LARGEFILE64 46 | extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence) 47 | __THROW; 48 | #endif 49 | 50 | __END_DECLS 51 | #endif /* _LSEEK_DECLARED */ 52 | -------------------------------------------------------------------------------- /src/freebsd-glue/random.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2013 Robert Millan 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | */ 26 | 27 | #define _GNU_SOURCE 1 /* srandom() */ 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | void 35 | srandomdev (void) 36 | { 37 | int fd; 38 | unsigned long seed; 39 | 40 | fd = open ("/dev/random", O_RDONLY); 41 | if (fd == -1) 42 | error (1, errno, "open"); 43 | 44 | if (read (fd, &seed, sizeof (seed)) != sizeof (seed)) 45 | error (1, errno, "read"); 46 | 47 | srandom (seed); 48 | 49 | close (fd); 50 | } 51 | -------------------------------------------------------------------------------- /include/readpassphrase.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: readpassphrase.h,v 1.5 2003/06/17 21:56:23 millert Exp $ */ 2 | /* $FreeBSD$ */ 3 | 4 | /* 5 | * Copyright (c) 2000, 2002 Todd C. Miller 6 | * 7 | * Permission to use, copy, modify, and distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | * 19 | * Sponsored in part by the Defense Advanced Research Projects 20 | * Agency (DARPA) and Air Force Research Laboratory, Air Force 21 | * Materiel Command, USAF, under agreement number F39502-99-1-0512. 22 | */ 23 | 24 | #ifndef _READPASSPHRASE_H_ 25 | #define _READPASSPHRASE_H_ 26 | 27 | #define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */ 28 | #define RPP_ECHO_ON 0x01 /* Leave echo on. */ 29 | #define RPP_REQUIRE_TTY 0x02 /* Fail if there is no tty. */ 30 | #define RPP_FORCELOWER 0x04 /* Force input to lower case. */ 31 | #define RPP_FORCEUPPER 0x08 /* Force input to upper case. */ 32 | #define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */ 33 | #define RPP_STDIN 0x20 /* Read from stdin, not /dev/tty */ 34 | 35 | #include 36 | #include 37 | 38 | #ifndef _SIZE_T_DECLARED 39 | typedef __size_t size_t; 40 | #define _SIZE_T_DECLARED 41 | #endif 42 | 43 | __BEGIN_DECLS 44 | char * readpassphrase(const char *, char *, size_t, int); 45 | __END_DECLS 46 | 47 | #endif /* !_READPASSPHRASE_H_ */ 48 | -------------------------------------------------------------------------------- /src/freebsd-glue/getosreldate.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1989, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 4. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #include 31 | #include 32 | 33 | #ifdef __FreeBSD_kernel__ 34 | #include 35 | #endif 36 | 37 | int 38 | getosreldate(void) 39 | { 40 | int value; 41 | char *temp; 42 | 43 | if ((temp = getenv("OSVERSION"))) { 44 | value = atoi(temp); 45 | return (value); 46 | } 47 | 48 | #ifdef __FreeBSD_kernel__ 49 | int mib[2]; 50 | size_t size; 51 | mib[0] = CTL_KERN; 52 | mib[1] = KERN_OSRELDATE; 53 | size = sizeof value; 54 | if (sysctl(mib, 2, &value, &size, NULL, 0) == -1) 55 | return (-1); 56 | return (value); 57 | #else 58 | return 0; 59 | #endif 60 | } 61 | -------------------------------------------------------------------------------- /src/freebsd-glue/getbootfile.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1989, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 4. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #if defined(LIBC_SCCS) && !defined(lint) 31 | static char sccsid[] = "From: @(#)gethostname.c 8.1 (Berkeley) 6/4/93"; 32 | #endif /* LIBC_SCCS and not lint */ 33 | #include 34 | __FBSDID("$FreeBSD$"); 35 | 36 | #include 37 | #include 38 | 39 | #include 40 | 41 | const char * 42 | getbootfile(void) 43 | { 44 | static char name[MAXPATHLEN]; 45 | size_t size = sizeof name; 46 | int mib[2]; 47 | 48 | mib[0] = CTL_KERN; 49 | mib[1] = KERN_BOOTFILE; 50 | if (sysctl(mib, 2, name, &size, NULL, 0) == -1) 51 | return ("/boot/kernel/kernel"); 52 | return (name); 53 | } 54 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: freebsd-glue 2 | Section: devel 3 | Priority: extra 4 | Maintainer: GNU/kFreeBSD Maintainers 5 | Uploaders: 6 | Robert Millan , 7 | Steven Chamberlain , 8 | Build-Depends: 9 | debhelper (>= 8.0), 10 | kfreebsd-kernel-headers (>= 10.0~3) [kfreebsd-any], 11 | freebsd-mk, 12 | bmake, 13 | libbsd-dev, 14 | libdb-dev, 15 | zlib1g-dev, 16 | Standards-Version: 3.9.7 17 | Vcs-Browser: https://salsa.debian.org/kfreebsd-team/freebsd-glue 18 | Vcs-Git: https://salsa.debian.org/kfreebsd-team/freebsd-glue.git 19 | 20 | Package: freebsd-glue 21 | Architecture: any 22 | Depends: ${shlibs:Depends}, ${misc:Depends}, 23 | libfreebsd-glue-0 (= ${binary:Version}), 24 | original-awk, 25 | libbsd-dev (>= 0.7.0-1~), 26 | libdb-dev, 27 | zlib1g-dev, 28 | libexpat-dev, 29 | libgdbm-dev, 30 | byacc, 31 | Recommends: 32 | # Can't put this in Depends because it would introduce a circular dependency 33 | # (see #674806). 34 | freebsd-buildutils, 35 | Conflicts: kfreebsd-kernel-headers (<< 0.80) 36 | Replaces: 37 | freebsd-buildutils (<< 10.0~svn259404-4~), 38 | Breaks: freebsd-buildutils (<< 9.0-10) 39 | Description: Emulate a FreeBSD build environment 40 | This package provides a set of glue headers and symbolic links to emulate 41 | a FreeBSD build environment. 42 | . 43 | Its goal is to make it as easy as possible to build source code written for 44 | FreeBSD on Debian, by adding the necessary glue so that equivalent interfaces 45 | in packages like freebsd-buildutils, libbsd-dev or libexpat-dev are directly 46 | available to pristine FreeBSD code. 47 | . 48 | freebsd-glue strives for bug-for-bug compatibility and will even attempt 49 | to accommodate for unspecified features (such as implicit header inclusion), 50 | as long as this doesn't cause breakage in other areas. 51 | 52 | Package: libfreebsd-glue-0 53 | Architecture: any 54 | Depends: ${shlibs:Depends}, ${misc:Depends} 55 | Description: FreeBSD glue environment (shared objects) 56 | Shared objects for the FreeBSD glue environment. 57 | 58 | Package: libfreebsd-glue-0-udeb 59 | Package-Type: udeb 60 | Section: debian-installer 61 | Architecture: kfreebsd-any 62 | Depends: ${shlibs:Depends}, ${misc:Depends} 63 | Description: FreeBSD glue environment (udeb) 64 | Shared objects for the FreeBSD glue environment. 65 | . 66 | This is a minimal package for use in debian-installer. 67 | -------------------------------------------------------------------------------- /src/freebsd-glue/mac_set.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson 3 | * All rights reserved. 4 | * 5 | * This software was developed by Robert Watson for the TrustedBSD Project. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The names of the authors may not be used to endorse or promote 16 | * products derived from this software without specific prior written 17 | * permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | __FBSDID("$FreeBSD$"); 34 | 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | int 42 | mac_set_fd(int fd, struct mac *label) 43 | { 44 | 45 | return (syscall(SYS___mac_set_fd, fd, label)); 46 | } 47 | 48 | int 49 | mac_set_file(const char *path, struct mac *label) 50 | { 51 | 52 | return (syscall(SYS___mac_set_file, path, label)); 53 | } 54 | 55 | int 56 | mac_set_link(const char *path, struct mac *label) 57 | { 58 | 59 | return (syscall(SYS___mac_set_link, path, label)); 60 | } 61 | 62 | int 63 | mac_set_proc(struct mac *label) 64 | { 65 | 66 | return (syscall(SYS___mac_set_proc, label)); 67 | } 68 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Name: FreeBSD glue build environment 2 | Author: Robert Millan 3 | 4 | Files: * 5 | Copyright: 2012, 2013, Robert Millan 6 | License: LGPL-3+ 7 | 8 | Files: include/err.h 9 | include/sys/cdefs.h 10 | include/sys/queue.h 11 | src/freebsd-glue/getbootfile.c 12 | src/freebsd-glue/getbsize.c 13 | src/freebsd-glue/getcap.c 14 | src/freebsd-glue/getosreldate.c 15 | src/freebsd-glue/linkaddr.c 16 | Copyright: 1989, 1990, 1991, 1992, 1993, The Regents of the University of California 17 | License: BSD (3 clause) 18 | 19 | Files: include/sys/elf32.h 20 | include/sys/elf64.h 21 | Copyright: 1996-1998, John D. Polstra 22 | License: BSD (2 clause) 23 | 24 | Files: include/embed/sys/elf_common.h 25 | Copyright: 1998, John D. Polstra 26 | 2000-2001, 2008, 2011, David E. O'Brien 27 | License: BSD (2 clause) 28 | 29 | Files: include/sys/elf.h 30 | Copyright: 2001, David E. O'Brien 31 | License: BSD (2 clause) 32 | 33 | Files: src/freebsd-glue/mac.c 34 | src/freebsd-glue/mac_set.c 35 | Copyright: 1999-2002, Robert N. M. Watson 36 | 2002-2003, Networks Associates Technology, Inc 37 | License: BSD (2 clause) 38 | 39 | Files: src/freebsd-glue/random.c 40 | src/freebsd-glue/sysarch.c 41 | src/freebsd-glue/basename.c 42 | src/freebsd-glue/capability.c 43 | Copyright: 2013, 2014, Robert Millan 44 | License: BSD (2 clause) 45 | 46 | Files: src/freebsd-glue/subr_capability.c 47 | Copyright: 2013, FreeBSD Foundation 48 | License: BSD (2 clause) 49 | 50 | Files: include/sys/endian.h 51 | Copyright: 2002, Thomas Moestl 52 | License: BSD (2 clause) 53 | 54 | Files: src/freebsd-glue/feature_present.c 55 | Copyright: 2008, Yahoo!, Inc 56 | License: BSD (2 clause) 57 | 58 | Files: src/freebsd-glue/strnstr.c 59 | Copyright: 1990, 1993, 2001, Mike Barcroft 60 | License: BSD (3 clause) 61 | 62 | Files: include/sys/param.h 63 | Copyright: 1982, 1986, 1989, 1993 64 | UNIX System Laboratories, Inc 65 | License: BSD (3 clause) 66 | 67 | Files: include/readpassphrase.h 68 | Copyright: 2000, 2002 Todd C. Miller 69 | License: ISC 70 | 71 | Files: include/__want_lseek.h 72 | Copyright: 1991-2010, Free Software Foundation, Inc 73 | License: LGPL-2.1+ 74 | 75 | Files: src/zopen.c 76 | Copyright: Johan Danielsson 77 | License: Public domain 78 | 79 | License: LGPL-3+ 80 | On Debian systems the full text of the GNU Lesser General Public 81 | License can be found in the `/usr/share/common-licenses/LGPL' 82 | file. 83 | -------------------------------------------------------------------------------- /src/freebsd-glue/strnstr.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 Mike Barcroft 3 | * Copyright (c) 1990, 1993 4 | * The Regents of the University of California. All rights reserved. 5 | * 6 | * This code is derived from software contributed to Berkeley by 7 | * Chris Torek. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 3. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | */ 33 | 34 | #if defined(LIBC_SCCS) && !defined(lint) 35 | static char sccsid[] = "@(#)strstr.c 8.1 (Berkeley) 6/4/93"; 36 | #endif /* LIBC_SCCS and not lint */ 37 | #include 38 | __FBSDID("$FreeBSD$"); 39 | 40 | #include 41 | 42 | /* 43 | * Find the first occurrence of find in s, where the search is limited to the 44 | * first slen characters of s. 45 | */ 46 | char * 47 | strnstr(const char *s, const char *find, size_t slen) 48 | { 49 | char c, sc; 50 | size_t len; 51 | 52 | if ((c = *find++) != '\0') { 53 | len = strlen(find); 54 | do { 55 | do { 56 | if (slen-- < 1 || (sc = *s++) == '\0') 57 | return (NULL); 58 | } while (sc != c); 59 | if (len > slen) 60 | return (NULL); 61 | } while (strncmp(s, find, len) != 0); 62 | s--; 63 | } 64 | return ((char *)s); 65 | } 66 | -------------------------------------------------------------------------------- /src/freebsd-glue/capability.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Robert Millan 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #ifndef SYS___cap_rights_get 32 | #define SYS___cap_rights_get SYS_cap_rights_get 33 | #endif 34 | 35 | int 36 | cap_enter(void) 37 | { 38 | return syscall (SYS_cap_enter); 39 | } 40 | 41 | int 42 | cap_getmode(u_int *modep) 43 | { 44 | return syscall (SYS_cap_getmode, modep); 45 | } 46 | 47 | int 48 | cap_rights_limit(int fd, const cap_rights_t *rights) 49 | { 50 | return syscall (SYS_cap_rights_limit, fd, rights); 51 | } 52 | 53 | int 54 | __cap_rights_get(int version, int fd, cap_rights_t *rights) 55 | { 56 | return syscall (SYS___cap_rights_get, version, fd, rights); 57 | } 58 | 59 | int 60 | cap_ioctls_limit(int fd, const unsigned long *cmds, size_t ncmds) 61 | { 62 | return syscall (SYS_cap_ioctls_limit, fd, cmds, ncmds); 63 | } 64 | 65 | ssize_t 66 | cap_ioctls_get(int fd, unsigned long *cmds, size_t maxcmds) 67 | { 68 | return syscall (SYS_cap_ioctls_get, fd, cmds, maxcmds); 69 | } 70 | 71 | int 72 | cap_fcntls_limit(int fd, uint32_t fcntlrights) 73 | { 74 | return syscall (SYS_cap_fcntls_limit, fd, fcntlrights); 75 | } 76 | 77 | int 78 | cap_fcntls_get(int fd, uint32_t *fcntlrightsp) 79 | { 80 | return syscall (SYS_cap_fcntls_get, fd, fcntlrightsp); 81 | } 82 | -------------------------------------------------------------------------------- /src/freebsd-glue/feature_present.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008 Yahoo!, Inc. 3 | * All rights reserved. 4 | * Written by: John Baldwin 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the author nor the names of any co-contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #ifdef __FreeBSD_kernel__ 39 | #include 40 | #endif 41 | 42 | /* 43 | * Returns true if the named feature is present in the currently 44 | * running kernel. A feature's presence is indicated by an integer 45 | * sysctl node called kern.feature. that is non-zero. 46 | */ 47 | int 48 | feature_present(const char *feature) 49 | { 50 | #ifdef __FreeBSD_kernel__ 51 | char *mib; 52 | size_t len; 53 | int i; 54 | 55 | if ((!strcmp(feature, "inet") || !strcmp(feature, "inet6")) && getosreldate() <= 900038) 56 | return (1); 57 | 58 | if (asprintf(&mib, "kern.features.%s", feature) < 0) 59 | return (0); 60 | len = sizeof(i); 61 | if (sysctlbyname(mib, &i, &len, NULL, 0) < 0) { 62 | free(mib); 63 | return (0); 64 | } 65 | free(mib); 66 | if (len != sizeof(i)) 67 | return (0); 68 | return (i != 0); 69 | #else 70 | return (0); 71 | #endif 72 | } 73 | -------------------------------------------------------------------------------- /include/sys/param.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1982, 1986, 1989, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * (c) UNIX System Laboratories, Inc. 5 | * All or some portions of this file are derived from material licensed 6 | * to the University of California by American Telephone and Telegraph 7 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 | * the permission of UNIX System Laboratories, Inc. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 4. Neither the name of the University nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | * 34 | * @(#)param.h 8.3 (Berkeley) 4/4/95 35 | * $FreeBSD$ 36 | */ 37 | 38 | #include_next 39 | 40 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 41 | 42 | #include 43 | #if !defined(__FreeBSD_version) && defined(__FreeBSD_kernel_version) 44 | #define __FreeBSD_version __FreeBSD_kernel_version 45 | #endif 46 | 47 | #else 48 | 49 | #ifndef _SYS_PARAM_H_ 50 | #define _SYS_PARAM_H_ 51 | 52 | #undef __FreeBSD_version 53 | #define __FreeBSD_version 1000010 54 | 55 | #include /* For SIG* */ 56 | #include /* for PATH_MAX */ 57 | 58 | #include 59 | 60 | # ifndef roundup2 61 | # define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ 62 | # endif 63 | 64 | #ifndef MAXPATHLEN 65 | #define MAXPATHLEN PATH_MAX 66 | #endif 67 | 68 | #ifndef MAXHOSTNAMELEN 69 | #define MAXHOSTNAMELEN 256 70 | #endif 71 | 72 | #endif /* _SYS_PARAM_H_ */ 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /include/err.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)err.h 8.1 (Berkeley) 6/2/93 30 | * $FreeBSD$ 31 | */ 32 | 33 | #ifndef _ERR_H_ 34 | #define _ERR_H_ 35 | 36 | /* 37 | * Don't use va_list in the err/warn prototypes. Va_list is typedef'd in two 38 | * places ( and ), so if we include one 39 | * of them here we may collide with the utility's includes. It's unreasonable 40 | * for utilities to have to include one of them to include err.h, so we get 41 | * __va_list from and use it. 42 | */ 43 | #include 44 | #include 45 | 46 | __BEGIN_DECLS 47 | void err(int, const char *, ...) __dead2 __printf0like(2, 3); 48 | void verr(int, const char *, __va_list) __dead2 __printf0like(2, 0); 49 | void errc(int, int, const char *, ...) __dead2 __printf0like(3, 4); 50 | void verrc(int, int, const char *, __va_list) __dead2 51 | __printf0like(3, 0); 52 | void errx(int, const char *, ...) __dead2 __printf0like(2, 3); 53 | void verrx(int, const char *, __va_list) __dead2 __printf0like(2, 0); 54 | void warn(const char *, ...) __printf0like(1, 2); 55 | void vwarn(const char *, __va_list) __printf0like(1, 0); 56 | void warnc(int, const char *, ...) __printf0like(2, 3); 57 | void vwarnc(int, const char *, __va_list) __printf0like(2, 0); 58 | void warnx(const char *, ...) __printflike(1, 2); 59 | void vwarnx(const char *, __va_list) __printflike(1, 0); 60 | void err_set_file(void *); 61 | void err_set_exit(void (*)(int)); 62 | __END_DECLS 63 | 64 | #endif /* !_ERR_H_ */ 65 | -------------------------------------------------------------------------------- /debian/libfreebsd-glue-0.symbols: -------------------------------------------------------------------------------- 1 | libfreebsd-glue.so.0 libfreebsd-glue-0 #MINVER# 2 | (arch=kfreebsd-any)__cap_rights_clear@Base 0.2.17 3 | (arch=kfreebsd-any)__cap_rights_get@Base 0.2.17 4 | (arch=kfreebsd-any)__cap_rights_init@Base 0.2.17 5 | (arch=kfreebsd-any)__cap_rights_is_set@Base 0.2.17 6 | (arch=kfreebsd-any)__cap_rights_set@Base 0.2.17 7 | (arch=kfreebsd-amd64)amd64_get_fsbase@Base 0.2.8 8 | (arch=kfreebsd-amd64)amd64_get_gsbase@Base 0.2.8 9 | (arch=kfreebsd-amd64)amd64_set_fsbase@Base 0.2.8 10 | (arch=kfreebsd-amd64)amd64_set_gsbase@Base 0.2.8 11 | (arch=kfreebsd-i386)i386_get_fsbase@Base 0.2.8 12 | (arch=kfreebsd-i386)i386_get_gsbase@Base 0.2.8 13 | (arch=kfreebsd-i386)i386_set_fsbase@Base 0.2.8 14 | (arch=kfreebsd-i386)i386_set_gsbase@Base 0.2.8 15 | basename_r@Base 0.2.17 16 | (arch=kfreebsd-any)bsd_sendfile@Base 0.2.6 17 | (arch=kfreebsd-any)cap_enter@Base 0.2.17 18 | (arch=kfreebsd-any)cap_fcntls_get@Base 0.2.17 19 | (arch=kfreebsd-any)cap_fcntls_limit@Base 0.2.17 20 | (arch=kfreebsd-any)cap_getmode@Base 0.2.17 21 | (arch=kfreebsd-any)cap_ioctls_get@Base 0.2.17 22 | (arch=kfreebsd-any)cap_ioctls_limit@Base 0.2.17 23 | (arch=kfreebsd-any)cap_rights_contains@Base 0.2.17 24 | (arch=kfreebsd-any)cap_rights_is_valid@Base 0.2.17 25 | (arch=kfreebsd-any)cap_rights_limit@Base 0.2.17 26 | (arch=kfreebsd-any)cap_rights_merge@Base 0.2.17 27 | (arch=kfreebsd-any)cap_rights_remove@Base 0.2.17 28 | cgetcap@Base 0.1.15 29 | cgetclose@Base 0.1.15 30 | cgetent@Base 0.1.15 31 | cgetfirst@Base 0.1.15 32 | cgetmatch@Base 0.1.15 33 | cgetnext@Base 0.1.15 34 | cgetnum@Base 0.1.15 35 | cgetset@Base 0.1.15 36 | cgetstr@Base 0.1.15 37 | cgetustr@Base 0.1.15 38 | (arch=kfreebsd-any)cpuset@Base 0.1.15 39 | (arch=kfreebsd-any)cpuset_getaffinity@Base 0.1.15 40 | (arch=kfreebsd-any)cpuset_getid@Base 0.1.15 41 | (arch=kfreebsd-any)cpuset_setaffinity@Base 0.1.15 42 | (arch=kfreebsd-any)cpuset_setid@Base 0.1.15 43 | execvP@Base 0.1.15 44 | feature_present@Base 0.1.15 45 | (arch=kfreebsd-any)getbootfile@Base 0.1.15 46 | getbsize@Base 0.2.17 47 | (arch=kfreebsd-any)getdiskbyname@Base 0.1.15 48 | getfstab@Base 0.1.15 49 | (arch=kfreebsd-any)getloginclass@Base 0.1.15 50 | getosreldate@Base 0.1.15 51 | (arch=kfreebsd-any)link_addr@Base 0.1.15 52 | (arch=kfreebsd-any)link_ntoa@Base 0.1.15 53 | (arch=kfreebsd-any)mac_free@Base 0.1.15 54 | (arch=kfreebsd-any)mac_from_text@Base 0.1.15 55 | (arch=kfreebsd-any)mac_is_present@Base 0.1.15 56 | (arch=kfreebsd-any)mac_prepare@Base 0.1.15 57 | (arch=kfreebsd-any)mac_prepare_file_label@Base 0.1.15 58 | (arch=kfreebsd-any)mac_prepare_ifnet_label@Base 0.1.15 59 | (arch=kfreebsd-any)mac_prepare_packet_label@Base 0.1.15 60 | (arch=kfreebsd-any)mac_prepare_process_label@Base 0.1.15 61 | (arch=kfreebsd-any)mac_prepare_type@Base 0.1.15 62 | (arch=kfreebsd-any)mac_reload@Base 0.1.15 63 | (arch=kfreebsd-any)mac_set_fd@Base 0.1.15 64 | (arch=kfreebsd-any)mac_set_file@Base 0.1.15 65 | (arch=kfreebsd-any)mac_set_link@Base 0.1.15 66 | (arch=kfreebsd-any)mac_set_proc@Base 0.1.15 67 | (arch=kfreebsd-any)mac_to_text@Base 0.1.15 68 | (arch=kfreebsd-any)setfib@Base 0.1.15 69 | setfstab@Base 0.1.15 70 | (arch=kfreebsd-any)setloginclass@Base 0.1.15 71 | srandomdev@Base 0.1.15 72 | strnstr@Base 0.2.2 73 | -------------------------------------------------------------------------------- /src/freebsd-glue/sysarch.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Robert Millan 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | */ 26 | 27 | /* Temporary kludge to avoid conflicting declarations (static inline) in certain 28 | versions of */ 29 | 30 | #define amd64_get_fsbase __disabled_amd64_get_fsbase 31 | #define amd64_get_gsbase __disabled_amd64_get_gsbase 32 | #define amd64_set_fsbase __disabled_amd64_set_fsbase 33 | #define amd64_set_gsbase __disabled_amd64_set_gsbase 34 | #define i386_get_fsbase __disabled_i386_get_fsbase 35 | #define i386_get_gsbase __disabled_i386_get_gsbase 36 | #define i386_set_fsbase __disabled_i386_set_fsbase 37 | #define i386_set_gsbase __disabled_i386_set_gsbase 38 | 39 | #include 40 | 41 | #undef amd64_get_fsbase 42 | #undef amd64_get_gsbase 43 | #undef amd64_set_fsbase 44 | #undef amd64_set_gsbase 45 | #undef i386_get_fsbase 46 | #undef i386_get_gsbase 47 | #undef i386_set_fsbase 48 | #undef i386_set_gsbase 49 | 50 | #if defined(__amd64__) 51 | int 52 | amd64_get_fsbase (void **addr) 53 | { 54 | return sysarch (AMD64_GET_FSBASE, addr); 55 | } 56 | 57 | int 58 | amd64_get_gsbase (void **addr) 59 | { 60 | return sysarch (AMD64_GET_GSBASE, addr); 61 | } 62 | 63 | int 64 | amd64_set_fsbase (void *addr) 65 | { 66 | return sysarch (AMD64_SET_FSBASE, &addr); 67 | } 68 | 69 | int 70 | amd64_set_gsbase (void *addr) 71 | { 72 | return sysarch (AMD64_SET_GSBASE, &addr); 73 | } 74 | 75 | #elif defined(__i386__) 76 | 77 | int 78 | i386_get_fsbase (void **addr) 79 | { 80 | return sysarch (I386_GET_FSBASE, addr); 81 | } 82 | 83 | int 84 | i386_get_gsbase (void **addr) 85 | { 86 | return sysarch (I386_GET_GSBASE, addr); 87 | } 88 | 89 | int 90 | i386_set_fsbase (void *addr) 91 | { 92 | return sysarch (I386_SET_FSBASE, &addr); 93 | } 94 | 95 | int 96 | i386_set_gsbase (void *addr) 97 | { 98 | return sysarch (I386_SET_GSBASE, &addr); 99 | } 100 | #endif 101 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS) 5 | 6 | # Determine host architecture compiler 7 | DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) 8 | ifeq ($(origin CC),default) 9 | CC := $(DEB_HOST_GNU_TYPE)-gcc 10 | endif 11 | 12 | # Determine build architecture compiler 13 | DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) 14 | NATIVE_CC ?= $(DEB_BUILD_GNU_TYPE)-gcc 15 | 16 | export SHELL = bash 17 | 18 | ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) 19 | NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) 20 | 21 | # Do not mess with MAKEFLAGS until we transfer control to BSD make (see below) 22 | BSD_MAKEFLAGS += -j$(NUMJOBS) 23 | endif 24 | 25 | DESTDIR = $(CURDIR)/debian/tmp 26 | PATH := /usr/lib/freebsd:$(PATH) 27 | PMAKE := \ 28 | MAKEFLAGS=$(BSD_MAKEFLAGS) \ 29 | MAKEOBJDIRPREFIX=$(CURDIR)/obj-deb \ 30 | CFLAGS="$(CFLAGS) -O2" \ 31 | DESTDIR="$(DESTDIR)" \ 32 | bmake -m /usr/share/mk-freebsd \ 33 | CC=$(CC) \ 34 | $(NULL) 35 | PMAKE_UDEB := \ 36 | MAKEFLAGS=$(BSD_MAKEFLAGS) \ 37 | MAKEOBJDIRPREFIX=$(CURDIR)/obj-udeb \ 38 | CFLAGS="$(CFLAGS) -Os" \ 39 | DESTDIR="$(DESTDIR)-udeb" \ 40 | bmake -m /usr/share/mk-freebsd \ 41 | CC=$(CC) \ 42 | RESCUE=yes \ 43 | $(NULL) 44 | 45 | clean: 46 | dh_testdir 47 | rm -rf obj-{deb,udeb} debian/tmp-udeb 48 | rm -f include/machine/__get_elf_arch.h src/get_elf_arch src/host_elf_arch 49 | dh_clean 50 | 51 | # Build this for the build architecture, as it is executed during build 52 | # to examine host_elf_arch 53 | src/get_elf_arch: 54 | $(NATIVE_CC) src/get_elf_arch.c -o src/get_elf_arch 55 | # Build this for the host architecture. 56 | src/host_elf_arch: src/host_elf_arch.c 57 | include/machine/__get_elf_arch.h: src/get_elf_arch src/host_elf_arch 58 | $^ src/host_elf_arch > $@ 59 | 60 | build: build-arch 61 | build-arch: build-deb build-udeb 62 | 63 | build-deb: include/machine/__get_elf_arch.h 64 | $(PMAKE) obj 65 | $(PMAKE) 66 | 67 | build-udeb: include/machine/__get_elf_arch.h 68 | $(PMAKE_UDEB) obj 69 | $(PMAKE_UDEB) 70 | 71 | build-indep: 72 | : 73 | 74 | install-arch: build-arch 75 | dh_testdir 76 | dh_testroot 77 | dh_prep -a 78 | dh_installdirs -a 79 | mkdir -p $(DESTDIR){,-udeb}/{usr/,}lib 80 | 81 | $(PMAKE) install 82 | $(PMAKE_UDEB) install 83 | 84 | echo "GROUP( libexpat.so )" > \ 85 | $(DESTDIR)/usr/lib/libbsdxml.so 86 | ln -s $(DEB_HOST_GNU_TYPE)/libexpat.a \ 87 | $(DESTDIR)/usr/lib/libbsdxml.a 88 | 89 | mkdir -p $(DESTDIR)/usr/lib/freebsd 90 | install -m755 debian/local/scripts/bmake $(DESTDIR)/usr/lib/freebsd/ 91 | 92 | dh_install -a --list-missing 93 | 94 | binary: binary-arch binary-indep 95 | binary-arch: install-arch 96 | dh_testdir 97 | dh_testroot 98 | dh_installchangelogs -a 99 | dh_installdocs -a 100 | # dh_installexamples 101 | # dh_installinit 102 | # dh_installcron 103 | # dh_installinfo 104 | # dh_installman 105 | dh_link -a 106 | dh_strip -a 107 | dh_compress -a 108 | dh_fixperms -a 109 | # dh_perl 110 | # dh_python 111 | dh_makeshlibs -a 112 | ifeq ($(DEB_HOST_ARCH_OS), kfreebsd) 113 | dh_makeshlibs -plibfreebsd-glue-0 --add-udeb=libfreebsd-glue-0-udeb 114 | endif 115 | dh_installdeb -a 116 | dh_shlibdeps -a 117 | dh_gencontrol -a 118 | dh_md5sums -a 119 | dh_builddeb -a 120 | 121 | binary-indep: 122 | : 123 | -------------------------------------------------------------------------------- /include/sys/cdefs.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | 3 | /*- 4 | * Copyright (c) 1991, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * This code is derived from software contributed to Berkeley by 8 | * Berkeley Software Design, Inc. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 4. Neither the name of the University nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | * 34 | * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 35 | * $FreeBSD$ 36 | */ 37 | 38 | #ifndef _SYS_CDEFS_H_ 39 | #define _SYS_CDEFS_H_ 40 | 41 | #define __dead2 __attribute__((__noreturn__)) 42 | #define __pure2 __attribute__((__const__)) 43 | #ifndef __DO_NOT_DEFINE_UNUSED /* See et al */ 44 | #define __unused __attribute__((__unused__)) 45 | #endif 46 | #define __used __attribute__((__used__)) 47 | #define __packed __attribute__((__packed__)) 48 | #define __aligned(x) __attribute__((__aligned__(x))) 49 | #define __section(x) __attribute__((__section__(x))) 50 | 51 | #define __offsetof(type, field) __builtin_offsetof(type, field) 52 | #define __printflike(fmtarg, firstvararg) \ 53 | __attribute__((__format__ (__printf__, fmtarg, firstvararg))) 54 | 55 | #define __containerof(x, s, m) ({ \ 56 | const volatile __typeof(((s *)0)->m) *__x = (x); \ 57 | __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\ 58 | }) 59 | 60 | /* Requires freebsd-gcc extensions */ 61 | #define __printf0like(fmtarg, firstvararg) 62 | 63 | #define __FBSDID(s) struct __hack 64 | #define __RCSID(s) struct __hack 65 | #define __RCSID_SOURCE(s) struct __hack 66 | #define __SCCSID(s) struct __hack 67 | #define __COPYRIGHT(s) struct __hack 68 | 69 | #ifndef __DECONST 70 | #define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var)) 71 | #endif 72 | 73 | #ifndef __DEVOLATILE 74 | #define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var)) 75 | #endif 76 | 77 | #ifndef __DEQUALIFY 78 | #define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) 79 | #endif 80 | 81 | /* Fix for nested __CONCAT as used in . */ 82 | #undef __CONCAT 83 | #define __CONCAT1(x,y) x ## y 84 | #define __CONCAT(x,y) __CONCAT1(x,y) 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /src/freebsd-glue/getbsize.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1991, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 4. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #if defined(LIBC_SCCS) && !defined(lint) 31 | static char sccsid[] = "@(#)getbsize.c 8.1 (Berkeley) 6/4/93"; 32 | #endif /* LIBC_SCCS and not lint */ 33 | #include 34 | __FBSDID("$FreeBSD$"); 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | char * 42 | getbsize(headerlenp, blocksizep) 43 | int *headerlenp; 44 | long *blocksizep; 45 | { 46 | static char header[20]; 47 | long n, max, mul, blocksize; 48 | char *ep, *p; 49 | const char *form; 50 | 51 | #define KB (1024L) 52 | #define MB (1024L * 1024L) 53 | #define GB (1024L * 1024L * 1024L) 54 | #define MAXB GB /* No tera, peta, nor exa. */ 55 | form = ""; 56 | if ((p = getenv("BLOCKSIZE")) != NULL && *p != '\0') { 57 | if ((n = strtol(p, &ep, 10)) < 0) 58 | goto underflow; 59 | if (n == 0) 60 | n = 1; 61 | if (*ep && ep[1]) 62 | goto fmterr; 63 | switch (*ep) { 64 | case 'G': case 'g': 65 | form = "G"; 66 | max = MAXB / GB; 67 | mul = GB; 68 | break; 69 | case 'K': case 'k': 70 | form = "K"; 71 | max = MAXB / KB; 72 | mul = KB; 73 | break; 74 | case 'M': case 'm': 75 | form = "M"; 76 | max = MAXB / MB; 77 | mul = MB; 78 | break; 79 | case '\0': 80 | max = MAXB; 81 | mul = 1; 82 | break; 83 | default: 84 | fmterr: warnx("%s: unknown blocksize", p); 85 | n = 512; 86 | max = MAXB; 87 | mul = 1; 88 | break; 89 | } 90 | if (n > max) { 91 | warnx("maximum blocksize is %ldG", MAXB / GB); 92 | n = max; 93 | } 94 | if ((blocksize = n * mul) < 512) { 95 | underflow: warnx("minimum blocksize is 512"); 96 | form = ""; 97 | blocksize = n = 512; 98 | } 99 | } else 100 | blocksize = n = 512; 101 | 102 | (void)snprintf(header, sizeof(header), "%ld%s-blocks", n, form); 103 | *headerlenp = strlen(header); 104 | *blocksizep = blocksize; 105 | return (header); 106 | } 107 | -------------------------------------------------------------------------------- /include/sys/queue.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1991, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 4. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)queue.h 8.5 (Berkeley) 8/20/94 30 | * $FreeBSD$ 31 | */ 32 | 33 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 34 | #include_next /* Supply disabled macros using the Glibc version */ 35 | #include 36 | #else 37 | #include_next 38 | #include 39 | 40 | /* Currently, Debian eglibc only defines these on kfreebsd-* platforms. */ 41 | 42 | #ifndef LIST_FOREACH_SAFE 43 | #define LIST_FOREACH_SAFE(var, head, field, tvar) \ 44 | for ((var) = ((head)->lh_first); \ 45 | (var) && ((tvar) = ((var)->field.le_next), 1); \ 46 | (var) = (tvar)) 47 | #endif 48 | 49 | #ifndef SLIST_FOREACH_SAFE 50 | #define SLIST_FOREACH_SAFE(var, head, field, tvar) \ 51 | for ((var) = SLIST_FIRST((head)); \ 52 | (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ 53 | (var) = (tvar)) 54 | #endif 55 | 56 | #ifndef SLIST_FOREACH_PREVPTR 57 | #define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ 58 | for ((varp) = &SLIST_FIRST((head)); \ 59 | ((var) = *(varp)) != NULL; \ 60 | (varp) = &SLIST_NEXT((var), field)) 61 | #endif 62 | 63 | #ifndef STAILQ_REMOVE_HEAD_UNTIL 64 | #define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \ 65 | if (((head)->stqh_first = ((elm)->field.stqe_next)) == NULL) \ 66 | (head)->stqh_last = &((head)->stqh_first); \ 67 | } while (/*CONSTCOND*/0) 68 | #endif 69 | 70 | #ifndef STAILQ_FOREACH_SAFE 71 | #define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ 72 | for ((var) = ((head)->stqh_first); \ 73 | (var) && ((tvar) = ((var)->field.stqe_next), 1); \ 74 | (var) = (tvar)) 75 | #endif 76 | 77 | #ifndef STAILQ_LAST 78 | #define STAILQ_LAST(head, type, field) \ 79 | (STAILQ_EMPTY((head)) ? \ 80 | NULL : \ 81 | ((struct type *)(void *) \ 82 | ((char *)((head)->stqh_last) - __offsetof(struct type, field)))) 83 | #endif 84 | 85 | #ifndef TAILQ_FOREACH_SAFE 86 | #define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ 87 | for ((var) = ((head)->tqh_first); \ 88 | (var) && ((tvar) = ((var)->field.tqe_next), 1); \ 89 | (var) = (tvar)) 90 | #endif 91 | 92 | #endif 93 | 94 | 95 | #ifdef TAILQ_FOREACH_REVERSE_SAFE 96 | #undef TAILQ_FOREACH_REVERSE_SAFE 97 | #define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ 98 | for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ 99 | (var) && ((tvar) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)), 1); \ 100 | (var) = (tvar)) 101 | #endif 102 | -------------------------------------------------------------------------------- /include/sys/endian.h: -------------------------------------------------------------------------------- 1 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 2 | /* We have . Use it. */ 3 | # include_next 4 | #else 5 | /*- 6 | * Copyright (c) 2002 Thomas Moestl 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | * 30 | * $FreeBSD$ 31 | */ 32 | 33 | #ifndef _SYS_ENDIAN_H_ 34 | #define _SYS_ENDIAN_H_ 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | /* Alignment-agnostic encode/decode bytestream to/from little/big endian. */ 41 | 42 | static __inline uint16_t 43 | be16dec(const void *pp) 44 | { 45 | uint8_t const *p = (uint8_t const *)pp; 46 | 47 | return ((p[0] << 8) | p[1]); 48 | } 49 | 50 | static __inline uint32_t 51 | be32dec(const void *pp) 52 | { 53 | uint8_t const *p = (uint8_t const *)pp; 54 | 55 | return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); 56 | } 57 | 58 | static __inline uint64_t 59 | be64dec(const void *pp) 60 | { 61 | uint8_t const *p = (uint8_t const *)pp; 62 | 63 | return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4)); 64 | } 65 | 66 | static __inline uint16_t 67 | le16dec(const void *pp) 68 | { 69 | uint8_t const *p = (uint8_t const *)pp; 70 | 71 | return ((p[1] << 8) | p[0]); 72 | } 73 | 74 | static __inline uint32_t 75 | le32dec(const void *pp) 76 | { 77 | uint8_t const *p = (uint8_t const *)pp; 78 | 79 | return (((unsigned)p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]); 80 | } 81 | 82 | static __inline uint64_t 83 | le64dec(const void *pp) 84 | { 85 | uint8_t const *p = (uint8_t const *)pp; 86 | 87 | return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p)); 88 | } 89 | 90 | static __inline void 91 | be16enc(void *pp, uint16_t u) 92 | { 93 | uint8_t *p = (uint8_t *)pp; 94 | 95 | p[0] = (u >> 8) & 0xff; 96 | p[1] = u & 0xff; 97 | } 98 | 99 | static __inline void 100 | be32enc(void *pp, uint32_t u) 101 | { 102 | uint8_t *p = (uint8_t *)pp; 103 | 104 | p[0] = (u >> 24) & 0xff; 105 | p[1] = (u >> 16) & 0xff; 106 | p[2] = (u >> 8) & 0xff; 107 | p[3] = u & 0xff; 108 | } 109 | 110 | static __inline void 111 | be64enc(void *pp, uint64_t u) 112 | { 113 | uint8_t *p = (uint8_t *)pp; 114 | 115 | be32enc(p, (uint32_t)(u >> 32)); 116 | be32enc(p + 4, (uint32_t)(u & 0xffffffffU)); 117 | } 118 | 119 | static __inline void 120 | le16enc(void *pp, uint16_t u) 121 | { 122 | uint8_t *p = (uint8_t *)pp; 123 | 124 | p[0] = u & 0xff; 125 | p[1] = (u >> 8) & 0xff; 126 | } 127 | 128 | static __inline void 129 | le32enc(void *pp, uint32_t u) 130 | { 131 | uint8_t *p = (uint8_t *)pp; 132 | 133 | p[0] = u & 0xff; 134 | p[1] = (u >> 8) & 0xff; 135 | p[2] = (u >> 16) & 0xff; 136 | p[3] = (u >> 24) & 0xff; 137 | } 138 | 139 | static __inline void 140 | le64enc(void *pp, uint64_t u) 141 | { 142 | uint8_t *p = (uint8_t *)pp; 143 | 144 | le32enc(p, (uint32_t)(u & 0xffffffffU)); 145 | le32enc(p + 4, (uint32_t)(u >> 32)); 146 | } 147 | 148 | #endif /* _SYS_ENDIAN_H_ */ 149 | #endif 150 | -------------------------------------------------------------------------------- /src/freebsd-glue/linkaddr.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 4. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #if defined(LIBC_SCCS) && !defined(lint) 31 | static char sccsid[] = "@(#)linkaddr.c 8.1 (Berkeley) 6/4/93"; 32 | #endif /* LIBC_SCCS and not lint */ 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | /* States*/ 41 | #define NAMING 0 42 | #define GOTONE 1 43 | #define GOTTWO 2 44 | #define RESET 3 45 | /* Inputs */ 46 | #define DIGIT (4*0) 47 | #define END (4*1) 48 | #define DELIM (4*2) 49 | #define LETTER (4*3) 50 | 51 | void 52 | link_addr(addr, sdl) 53 | const char *addr; 54 | struct sockaddr_dl *sdl; 55 | { 56 | char *cp = sdl->sdl_data; 57 | char *cplim = sdl->sdl_len + (char *)sdl; 58 | int byte = 0, state = NAMING, new; 59 | 60 | bzero((char *)&sdl->sdl_family, sdl->sdl_len - 1); 61 | sdl->sdl_family = AF_LINK; 62 | do { 63 | state &= ~LETTER; 64 | if ((*addr >= '0') && (*addr <= '9')) { 65 | new = *addr - '0'; 66 | } else if ((*addr >= 'a') && (*addr <= 'f')) { 67 | new = *addr - 'a' + 10; 68 | } else if ((*addr >= 'A') && (*addr <= 'F')) { 69 | new = *addr - 'A' + 10; 70 | } else if (*addr == 0) { 71 | state |= END; 72 | } else if (state == NAMING && 73 | (((*addr >= 'A') && (*addr <= 'Z')) || 74 | ((*addr >= 'a') && (*addr <= 'z')))) 75 | state |= LETTER; 76 | else 77 | state |= DELIM; 78 | addr++; 79 | switch (state /* | INPUT */) { 80 | case NAMING | DIGIT: 81 | case NAMING | LETTER: 82 | *cp++ = addr[-1]; 83 | continue; 84 | case NAMING | DELIM: 85 | state = RESET; 86 | sdl->sdl_nlen = cp - sdl->sdl_data; 87 | continue; 88 | case GOTTWO | DIGIT: 89 | *cp++ = byte; 90 | /* FALLTHROUGH */ 91 | case RESET | DIGIT: 92 | state = GOTONE; 93 | byte = new; 94 | continue; 95 | case GOTONE | DIGIT: 96 | state = GOTTWO; 97 | byte = new + (byte << 4); 98 | continue; 99 | default: /* | DELIM */ 100 | state = RESET; 101 | *cp++ = byte; 102 | byte = 0; 103 | continue; 104 | case GOTONE | END: 105 | case GOTTWO | END: 106 | *cp++ = byte; 107 | /* FALLTHROUGH */ 108 | case RESET | END: 109 | break; 110 | } 111 | break; 112 | } while (cp < cplim); 113 | sdl->sdl_alen = cp - LLADDR(sdl); 114 | new = cp - (char *)sdl; 115 | if (new > sizeof(*sdl)) 116 | sdl->sdl_len = new; 117 | return; 118 | } 119 | 120 | static char hexlist[] = "0123456789abcdef"; 121 | 122 | char * 123 | link_ntoa(sdl) 124 | const struct sockaddr_dl *sdl; 125 | { 126 | static char obuf[64]; 127 | char *out = obuf; 128 | int i; 129 | u_char *in = (u_char *)LLADDR(sdl); 130 | u_char *inlim = in + sdl->sdl_alen; 131 | int firsttime = 1; 132 | 133 | if (sdl->sdl_nlen) { 134 | bcopy(sdl->sdl_data, obuf, sdl->sdl_nlen); 135 | out += sdl->sdl_nlen; 136 | if (sdl->sdl_alen) 137 | *out++ = ':'; 138 | } 139 | while (in < inlim) { 140 | if (firsttime) 141 | firsttime = 0; 142 | else 143 | *out++ = '.'; 144 | i = *in++; 145 | if (i > 0xf) { 146 | out[1] = hexlist[i & 0xf]; 147 | i >>= 4; 148 | out[0] = hexlist[i]; 149 | out += 2; 150 | } else 151 | *out++ = hexlist[i]; 152 | } 153 | *out = 0; 154 | return (obuf); 155 | } 156 | -------------------------------------------------------------------------------- /src/freebsd-glue/getcap.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1992, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * This code is derived from software contributed to Berkeley by 6 | * Casey Leedom of Lawrence Livermore National Laboratory. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 4. Neither the name of the University nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #if defined(LIBC_SCCS) && !defined(lint) 34 | static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94"; 35 | #endif /* LIBC_SCCS and not lint */ 36 | #include 37 | __FBSDID("$FreeBSD$"); 38 | 39 | #include "namespace.h" 40 | #include 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include "un-namespace.h" 51 | 52 | #define BFRAG 1024 53 | #define BSIZE 1024 54 | #define ESC ('[' & 037) /* ASCII ESC */ 55 | #define MAX_RECURSION 32 /* maximum getent recursion */ 56 | #define SFRAG 100 /* cgetstr mallocs in SFRAG chunks */ 57 | 58 | #define RECOK (char)0 59 | #define TCERR (char)1 60 | #define SHADOW (char)2 61 | 62 | /* 63 | * Cgetset() allows the addition of a user specified buffer to be added 64 | * to the database array, in effect "pushing" the buffer on top of the 65 | * virtual database. 0 is returned on success, -1 on failure. 66 | */ 67 | int 68 | cgetset(const char *ent) 69 | { 70 | errno = ENOSYS; 71 | return -1; 72 | } 73 | 74 | /* 75 | * Cgetcap searches the capability record buf for the capability cap with 76 | * type `type'. A pointer to the value of cap is returned on success, NULL 77 | * if the requested capability couldn't be found. 78 | * 79 | * Specifying a type of ':' means that nothing should follow cap (:cap:). 80 | * In this case a pointer to the terminating ':' or NUL will be returned if 81 | * cap is found. 82 | * 83 | * If (cap, '@') or (cap, terminator, '@') is found before (cap, terminator) 84 | * return NULL. 85 | */ 86 | char * 87 | cgetcap(char *buf, const char *cap, int type) 88 | { 89 | errno = ENOSYS; 90 | return NULL; 91 | } 92 | 93 | /* 94 | * Cgetent extracts the capability record name from the NULL terminated file 95 | * array db_array and returns a pointer to a malloc'd copy of it in buf. 96 | * Buf must be retained through all subsequent calls to cgetcap, cgetnum, 97 | * cgetflag, and cgetstr, but may then be free'd. 0 is returned on success, 98 | * -1 if the requested record couldn't be found, -2 if a system error was 99 | * encountered (couldn't open/read a file, etc.), and -3 if a potential 100 | * reference loop is detected. 101 | */ 102 | int 103 | cgetent(char **buf, char **db_array, const char *name) 104 | { 105 | errno = ENOSYS; 106 | return -2; 107 | } 108 | 109 | /* 110 | * Cgetmatch will return 0 if name is one of the names of the capability 111 | * record buf, -1 if not. 112 | */ 113 | int 114 | cgetmatch(const char *buf, const char *name) 115 | { 116 | return -1; 117 | } 118 | 119 | int 120 | cgetfirst(char **buf, char **db_array) 121 | { 122 | errno = ENOSYS; 123 | return (-1); 124 | } 125 | 126 | int 127 | cgetclose(void) 128 | { 129 | return(0); 130 | } 131 | 132 | /* 133 | * Cgetnext() gets either the first or next entry in the logical database 134 | * specified by db_array. It returns 0 upon completion of the database, 1 135 | * upon returning an entry with more remaining, and -1 if an error occurs. 136 | */ 137 | int 138 | cgetnext(char **bp, char **db_array) 139 | { 140 | errno = ENOSYS; 141 | return (-1); 142 | } 143 | 144 | /* 145 | * Cgetstr retrieves the value of the string capability cap from the 146 | * capability record pointed to by buf. A pointer to a decoded, NUL 147 | * terminated, malloc'd copy of the string is returned in the char * 148 | * pointed to by str. The length of the string not including the trailing 149 | * NUL is returned on success, -1 if the requested string capability 150 | * couldn't be found, -2 if a system error was encountered (storage 151 | * allocation failure). 152 | */ 153 | int 154 | cgetstr(char *buf, const char *cap, char **str) 155 | { 156 | errno = ENOSYS; 157 | return (-1); 158 | } 159 | 160 | /* 161 | * Cgetustr retrieves the value of the string capability cap from the 162 | * capability record pointed to by buf. The difference between cgetustr() 163 | * and cgetstr() is that cgetustr does not decode escapes but rather treats 164 | * all characters literally. A pointer to a NUL terminated malloc'd 165 | * copy of the string is returned in the char pointed to by str. The 166 | * length of the string not including the trailing NUL is returned on success, 167 | * -1 if the requested string capability couldn't be found, -2 if a system 168 | * error was encountered (storage allocation failure). 169 | */ 170 | int 171 | cgetustr(char *buf, const char *cap, char **str) 172 | { 173 | errno = ENOSYS; 174 | return (-1); 175 | } 176 | 177 | /* 178 | * Cgetnum retrieves the value of the numeric capability cap from the 179 | * capability record pointed to by buf. The numeric value is returned in 180 | * the long pointed to by num. 0 is returned on success, -1 if the requested 181 | * numeric capability couldn't be found. 182 | */ 183 | int 184 | cgetnum(char *buf, const char *cap, long *num) 185 | { 186 | errno = ENOSYS; 187 | return (-1); 188 | } 189 | -------------------------------------------------------------------------------- /include/sys/elf32.h: -------------------------------------------------------------------------------- 1 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 2 | #include_next 3 | #else 4 | /*- 5 | * Copyright (c) 1996-1998 John D. Polstra. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * $FreeBSD$ 30 | */ 31 | 32 | #ifndef _SYS_ELF32_H_ 33 | #define _SYS_ELF32_H_ 1 34 | 35 | #include 36 | #include 37 | 38 | /* 39 | * ELF definitions common to all 32-bit architectures. 40 | */ 41 | 42 | #if 0 43 | typedef uint32_t Elf32_Addr; 44 | typedef uint16_t Elf32_Half; 45 | typedef uint32_t Elf32_Off; 46 | typedef int32_t Elf32_Sword; 47 | typedef uint32_t Elf32_Word; 48 | #endif 49 | typedef uint64_t Elf32_Lword; 50 | 51 | typedef Elf32_Word Elf32_Hashelt; 52 | 53 | /* Non-standard class-dependent datatype used for abstraction. */ 54 | typedef Elf32_Word Elf32_Size; 55 | typedef Elf32_Sword Elf32_Ssize; 56 | 57 | #if 0 58 | /* 59 | * ELF header. 60 | */ 61 | 62 | typedef struct { 63 | unsigned char e_ident[EI_NIDENT]; /* File identification. */ 64 | Elf32_Half e_type; /* File type. */ 65 | Elf32_Half e_machine; /* Machine architecture. */ 66 | Elf32_Word e_version; /* ELF format version. */ 67 | Elf32_Addr e_entry; /* Entry point. */ 68 | Elf32_Off e_phoff; /* Program header file offset. */ 69 | Elf32_Off e_shoff; /* Section header file offset. */ 70 | Elf32_Word e_flags; /* Architecture-specific flags. */ 71 | Elf32_Half e_ehsize; /* Size of ELF header in bytes. */ 72 | Elf32_Half e_phentsize; /* Size of program header entry. */ 73 | Elf32_Half e_phnum; /* Number of program header entries. */ 74 | Elf32_Half e_shentsize; /* Size of section header entry. */ 75 | Elf32_Half e_shnum; /* Number of section header entries. */ 76 | Elf32_Half e_shstrndx; /* Section name strings section. */ 77 | } Elf32_Ehdr; 78 | 79 | /* 80 | * Section header. 81 | */ 82 | 83 | typedef struct { 84 | Elf32_Word sh_name; /* Section name (index into the 85 | section header string table). */ 86 | Elf32_Word sh_type; /* Section type. */ 87 | Elf32_Word sh_flags; /* Section flags. */ 88 | Elf32_Addr sh_addr; /* Address in memory image. */ 89 | Elf32_Off sh_offset; /* Offset in file. */ 90 | Elf32_Word sh_size; /* Size in bytes. */ 91 | Elf32_Word sh_link; /* Index of a related section. */ 92 | Elf32_Word sh_info; /* Depends on section type. */ 93 | Elf32_Word sh_addralign; /* Alignment in bytes. */ 94 | Elf32_Word sh_entsize; /* Size of each entry in section. */ 95 | } Elf32_Shdr; 96 | 97 | /* 98 | * Program header. 99 | */ 100 | 101 | typedef struct { 102 | Elf32_Word p_type; /* Entry type. */ 103 | Elf32_Off p_offset; /* File offset of contents. */ 104 | Elf32_Addr p_vaddr; /* Virtual address in memory image. */ 105 | Elf32_Addr p_paddr; /* Physical address (not used). */ 106 | Elf32_Word p_filesz; /* Size of contents in file. */ 107 | Elf32_Word p_memsz; /* Size of contents in memory. */ 108 | Elf32_Word p_flags; /* Access permission flags. */ 109 | Elf32_Word p_align; /* Alignment in memory and file. */ 110 | } Elf32_Phdr; 111 | 112 | /* 113 | * Dynamic structure. The ".dynamic" section contains an array of them. 114 | */ 115 | 116 | typedef struct { 117 | Elf32_Sword d_tag; /* Entry type. */ 118 | union { 119 | Elf32_Word d_val; /* Integer value. */ 120 | Elf32_Addr d_ptr; /* Address value. */ 121 | } d_un; 122 | } Elf32_Dyn; 123 | 124 | /* 125 | * Relocation entries. 126 | */ 127 | 128 | /* Relocations that don't need an addend field. */ 129 | typedef struct { 130 | Elf32_Addr r_offset; /* Location to be relocated. */ 131 | Elf32_Word r_info; /* Relocation type and symbol index. */ 132 | } Elf32_Rel; 133 | 134 | /* Relocations that need an addend field. */ 135 | typedef struct { 136 | Elf32_Addr r_offset; /* Location to be relocated. */ 137 | Elf32_Word r_info; /* Relocation type and symbol index. */ 138 | Elf32_Sword r_addend; /* Addend. */ 139 | } Elf32_Rela; 140 | 141 | /* Macros for accessing the fields of r_info. */ 142 | #define ELF32_R_SYM(info) ((info) >> 8) 143 | #define ELF32_R_TYPE(info) ((unsigned char)(info)) 144 | 145 | /* Macro for constructing r_info from field values. */ 146 | #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) 147 | 148 | /* 149 | * Note entry header 150 | */ 151 | typedef Elf_Note Elf32_Nhdr; 152 | 153 | /* 154 | * Move entry 155 | */ 156 | typedef struct { 157 | Elf32_Lword m_value; /* symbol value */ 158 | Elf32_Word m_info; /* size + index */ 159 | Elf32_Word m_poffset; /* symbol offset */ 160 | Elf32_Half m_repeat; /* repeat count */ 161 | Elf32_Half m_stride; /* stride info */ 162 | } Elf32_Move; 163 | 164 | /* 165 | * The macros compose and decompose values for Move.r_info 166 | * 167 | * sym = ELF32_M_SYM(M.m_info) 168 | * size = ELF32_M_SIZE(M.m_info) 169 | * M.m_info = ELF32_M_INFO(sym, size) 170 | */ 171 | #define ELF32_M_SYM(info) ((info)>>8) 172 | #define ELF32_M_SIZE(info) ((unsigned char)(info)) 173 | #define ELF32_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size)) 174 | 175 | #endif 176 | 177 | /* 178 | * Hardware/Software capabilities entry 179 | */ 180 | typedef struct { 181 | Elf32_Word c_tag; /* how to interpret value */ 182 | union { 183 | Elf32_Word c_val; 184 | Elf32_Addr c_ptr; 185 | } c_un; 186 | } Elf32_Cap; 187 | 188 | #if 0 189 | /* 190 | * Symbol table entries. 191 | */ 192 | 193 | typedef struct { 194 | Elf32_Word st_name; /* String table index of name. */ 195 | Elf32_Addr st_value; /* Symbol value. */ 196 | Elf32_Word st_size; /* Size of associated object. */ 197 | unsigned char st_info; /* Type and binding information. */ 198 | unsigned char st_other; /* Reserved (not used). */ 199 | Elf32_Half st_shndx; /* Section index of symbol. */ 200 | } Elf32_Sym; 201 | 202 | /* Macros for accessing the fields of st_info. */ 203 | #define ELF32_ST_BIND(info) ((info) >> 4) 204 | #define ELF32_ST_TYPE(info) ((info) & 0xf) 205 | 206 | /* Macro for constructing st_info from field values. */ 207 | #define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) 208 | 209 | /* Macro for accessing the fields of st_other. */ 210 | #define ELF32_ST_VISIBILITY(oth) ((oth) & 0x3) 211 | 212 | /* Structures used by Sun & GNU symbol versioning. */ 213 | typedef struct 214 | { 215 | Elf32_Half vd_version; 216 | Elf32_Half vd_flags; 217 | Elf32_Half vd_ndx; 218 | Elf32_Half vd_cnt; 219 | Elf32_Word vd_hash; 220 | Elf32_Word vd_aux; 221 | Elf32_Word vd_next; 222 | } Elf32_Verdef; 223 | 224 | typedef struct 225 | { 226 | Elf32_Word vda_name; 227 | Elf32_Word vda_next; 228 | } Elf32_Verdaux; 229 | 230 | typedef struct 231 | { 232 | Elf32_Half vn_version; 233 | Elf32_Half vn_cnt; 234 | Elf32_Word vn_file; 235 | Elf32_Word vn_aux; 236 | Elf32_Word vn_next; 237 | } Elf32_Verneed; 238 | 239 | typedef struct 240 | { 241 | Elf32_Word vna_hash; 242 | Elf32_Half vna_flags; 243 | Elf32_Half vna_other; 244 | Elf32_Word vna_name; 245 | Elf32_Word vna_next; 246 | } Elf32_Vernaux; 247 | #endif 248 | 249 | typedef Elf32_Half Elf32_Versym; 250 | 251 | #if 0 252 | typedef struct { 253 | Elf32_Half si_boundto; /* direct bindings - symbol bound to */ 254 | Elf32_Half si_flags; /* per symbol flags */ 255 | } Elf32_Syminfo; 256 | #endif 257 | 258 | #endif /* !_SYS_ELF32_H_ */ 259 | 260 | #endif /* __FreeBSD_kernel__ */ 261 | -------------------------------------------------------------------------------- /src/freebsd-glue/subr_capability.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2013 FreeBSD Foundation 3 | * All rights reserved. 4 | * 5 | * This software was developed by Pawel Jakub Dawidek under sponsorship from 6 | * the FreeBSD Foundation. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #include 31 | __FBSDID("$FreeBSD$"); 32 | 33 | /* 34 | * Note that this file is compiled into the kernel and into libc. 35 | */ 36 | 37 | #ifdef _KERNEL 38 | #include 39 | #include 40 | #include 41 | 42 | #include 43 | #else /* !_KERNEL */ 44 | #include 45 | #include 46 | 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #endif 53 | 54 | #ifdef _KERNEL 55 | #define assert(exp) KASSERT((exp), ("%s:%u", __func__, __LINE__)) 56 | #endif 57 | 58 | #define CAPARSIZE_MIN (CAP_RIGHTS_VERSION_00 + 2) 59 | #define CAPARSIZE_MAX (CAP_RIGHTS_VERSION + 2) 60 | 61 | static __inline int 62 | right_to_index(uint64_t right) 63 | { 64 | static const int bit2idx[] = { 65 | -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 66 | 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 67 | }; 68 | int idx; 69 | 70 | idx = CAPIDXBIT(right); 71 | assert(idx >= 0 && idx < sizeof(bit2idx) / sizeof(bit2idx[0])); 72 | return (bit2idx[idx]); 73 | } 74 | 75 | static void 76 | cap_rights_vset(cap_rights_t *rights, va_list ap) 77 | { 78 | uint64_t right; 79 | int i, n; 80 | 81 | assert(CAPVER(rights) == CAP_RIGHTS_VERSION_00); 82 | 83 | n = CAPARSIZE(rights); 84 | assert(n >= CAPARSIZE_MIN && n <= CAPARSIZE_MAX); 85 | 86 | for (;;) { 87 | right = (uint64_t)va_arg(ap, unsigned long long); 88 | if (right == 0) 89 | break; 90 | assert(CAPRVER(right) == 0); 91 | i = right_to_index(right); 92 | assert(i >= 0); 93 | assert(i < n); 94 | assert(CAPIDXBIT(rights->cr_rights[i]) == CAPIDXBIT(right)); 95 | rights->cr_rights[i] |= right; 96 | assert(CAPIDXBIT(rights->cr_rights[i]) == CAPIDXBIT(right)); 97 | } 98 | } 99 | 100 | static void 101 | cap_rights_vclear(cap_rights_t *rights, va_list ap) 102 | { 103 | uint64_t right; 104 | int i, n; 105 | 106 | assert(CAPVER(rights) == CAP_RIGHTS_VERSION_00); 107 | 108 | n = CAPARSIZE(rights); 109 | assert(n >= CAPARSIZE_MIN && n <= CAPARSIZE_MAX); 110 | 111 | for (;;) { 112 | right = (uint64_t)va_arg(ap, unsigned long long); 113 | if (right == 0) 114 | break; 115 | assert(CAPRVER(right) == 0); 116 | i = right_to_index(right); 117 | assert(i >= 0); 118 | assert(i < n); 119 | assert(CAPIDXBIT(rights->cr_rights[i]) == CAPIDXBIT(right)); 120 | rights->cr_rights[i] &= ~(right & 0x01FFFFFFFFFFFFFFULL); 121 | assert(CAPIDXBIT(rights->cr_rights[i]) == CAPIDXBIT(right)); 122 | } 123 | } 124 | 125 | static bool 126 | cap_rights_is_vset(const cap_rights_t *rights, va_list ap) 127 | { 128 | uint64_t right; 129 | int i, n; 130 | 131 | assert(CAPVER(rights) == CAP_RIGHTS_VERSION_00); 132 | 133 | n = CAPARSIZE(rights); 134 | assert(n >= CAPARSIZE_MIN && n <= CAPARSIZE_MAX); 135 | 136 | for (;;) { 137 | right = (uint64_t)va_arg(ap, unsigned long long); 138 | if (right == 0) 139 | break; 140 | assert(CAPRVER(right) == 0); 141 | i = right_to_index(right); 142 | assert(i >= 0); 143 | assert(i < n); 144 | assert(CAPIDXBIT(rights->cr_rights[i]) == CAPIDXBIT(right)); 145 | if ((rights->cr_rights[i] & right) != right) 146 | return (false); 147 | } 148 | 149 | return (true); 150 | } 151 | 152 | cap_rights_t * 153 | __cap_rights_init(int version, cap_rights_t *rights, ...) 154 | { 155 | unsigned int n; 156 | va_list ap; 157 | 158 | assert(version == CAP_RIGHTS_VERSION_00); 159 | 160 | n = version + 2; 161 | assert(n >= CAPARSIZE_MIN && n <= CAPARSIZE_MAX); 162 | memset(rights->cr_rights, 0, sizeof(rights->cr_rights[0]) * n); 163 | CAP_NONE(rights); 164 | va_start(ap, rights); 165 | cap_rights_vset(rights, ap); 166 | va_end(ap); 167 | 168 | return (rights); 169 | } 170 | 171 | cap_rights_t * 172 | __cap_rights_set(cap_rights_t *rights, ...) 173 | { 174 | va_list ap; 175 | 176 | assert(CAPVER(rights) == CAP_RIGHTS_VERSION_00); 177 | 178 | va_start(ap, rights); 179 | cap_rights_vset(rights, ap); 180 | va_end(ap); 181 | 182 | return (rights); 183 | } 184 | 185 | cap_rights_t * 186 | __cap_rights_clear(cap_rights_t *rights, ...) 187 | { 188 | va_list ap; 189 | 190 | assert(CAPVER(rights) == CAP_RIGHTS_VERSION_00); 191 | 192 | va_start(ap, rights); 193 | cap_rights_vclear(rights, ap); 194 | va_end(ap); 195 | 196 | return (rights); 197 | } 198 | 199 | bool 200 | __cap_rights_is_set(const cap_rights_t *rights, ...) 201 | { 202 | va_list ap; 203 | bool ret; 204 | 205 | assert(CAPVER(rights) == CAP_RIGHTS_VERSION_00); 206 | 207 | va_start(ap, rights); 208 | ret = cap_rights_is_vset(rights, ap); 209 | va_end(ap); 210 | 211 | return (ret); 212 | } 213 | 214 | bool 215 | cap_rights_is_valid(const cap_rights_t *rights) 216 | { 217 | cap_rights_t allrights; 218 | int i, j; 219 | 220 | if (CAPVER(rights) != CAP_RIGHTS_VERSION_00) 221 | return (false); 222 | if (CAPARSIZE(rights) < CAPARSIZE_MIN || 223 | CAPARSIZE(rights) > CAPARSIZE_MAX) { 224 | return (false); 225 | } 226 | CAP_ALL(&allrights); 227 | if (!cap_rights_contains(&allrights, rights)) 228 | return (false); 229 | for (i = 0; i < CAPARSIZE(rights); i++) { 230 | j = right_to_index(rights->cr_rights[i]); 231 | if (i != j) 232 | return (false); 233 | if (i > 0) { 234 | if (CAPRVER(rights->cr_rights[i]) != 0) 235 | return (false); 236 | } 237 | } 238 | 239 | return (true); 240 | } 241 | 242 | cap_rights_t * 243 | cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src) 244 | { 245 | unsigned int i, n; 246 | 247 | assert(CAPVER(dst) == CAP_RIGHTS_VERSION_00); 248 | assert(CAPVER(src) == CAP_RIGHTS_VERSION_00); 249 | assert(CAPVER(dst) == CAPVER(src)); 250 | assert(cap_rights_is_valid(src)); 251 | assert(cap_rights_is_valid(dst)); 252 | 253 | n = CAPARSIZE(dst); 254 | assert(n >= CAPARSIZE_MIN && n <= CAPARSIZE_MAX); 255 | 256 | for (i = 0; i < n; i++) 257 | dst->cr_rights[i] |= src->cr_rights[i]; 258 | 259 | assert(cap_rights_is_valid(src)); 260 | assert(cap_rights_is_valid(dst)); 261 | 262 | return (dst); 263 | } 264 | 265 | cap_rights_t * 266 | cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src) 267 | { 268 | unsigned int i, n; 269 | 270 | assert(CAPVER(dst) == CAP_RIGHTS_VERSION_00); 271 | assert(CAPVER(src) == CAP_RIGHTS_VERSION_00); 272 | assert(CAPVER(dst) == CAPVER(src)); 273 | assert(cap_rights_is_valid(src)); 274 | assert(cap_rights_is_valid(dst)); 275 | 276 | n = CAPARSIZE(dst); 277 | assert(n >= CAPARSIZE_MIN && n <= CAPARSIZE_MAX); 278 | 279 | for (i = 0; i < n; i++) { 280 | dst->cr_rights[i] &= 281 | ~(src->cr_rights[i] & 0x01FFFFFFFFFFFFFFULL); 282 | } 283 | 284 | assert(cap_rights_is_valid(src)); 285 | assert(cap_rights_is_valid(dst)); 286 | 287 | return (dst); 288 | } 289 | 290 | bool 291 | cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little) 292 | { 293 | unsigned int i, n; 294 | 295 | assert(CAPVER(big) == CAP_RIGHTS_VERSION_00); 296 | assert(CAPVER(little) == CAP_RIGHTS_VERSION_00); 297 | assert(CAPVER(big) == CAPVER(little)); 298 | 299 | n = CAPARSIZE(big); 300 | assert(n >= CAPARSIZE_MIN && n <= CAPARSIZE_MAX); 301 | 302 | for (i = 0; i < n; i++) { 303 | if ((big->cr_rights[i] & little->cr_rights[i]) != 304 | little->cr_rights[i]) { 305 | return (false); 306 | } 307 | } 308 | 309 | return (true); 310 | } 311 | -------------------------------------------------------------------------------- /include/sys/elf64.h: -------------------------------------------------------------------------------- 1 | #if defined(__FreeBSD_kernel__) && !defined(__FREEBSD_GLUE_USE_EMBEDDED_HEADERS) 2 | #include_next 3 | #else 4 | /*- 5 | * Copyright (c) 1996-1998 John D. Polstra. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * $FreeBSD$ 30 | */ 31 | 32 | #ifndef _SYS_ELF64_H_ 33 | #define _SYS_ELF64_H_ 1 34 | 35 | #include 36 | #include 37 | 38 | /* 39 | * ELF definitions common to all 64-bit architectures. 40 | */ 41 | 42 | #if 0 43 | typedef uint64_t Elf64_Addr; 44 | typedef uint16_t Elf64_Half; 45 | typedef uint64_t Elf64_Off; 46 | typedef int32_t Elf64_Sword; 47 | typedef int64_t Elf64_Sxword; 48 | typedef uint32_t Elf64_Word; 49 | #endif 50 | typedef uint64_t Elf64_Lword; 51 | #if 0 52 | typedef uint64_t Elf64_Xword; 53 | #endif 54 | 55 | /* 56 | * Types of dynamic symbol hash table bucket and chain elements. 57 | * 58 | * This is inconsistent among 64 bit architectures, so a machine dependent 59 | * typedef is required. 60 | */ 61 | 62 | typedef Elf64_Word Elf64_Hashelt; 63 | 64 | /* Non-standard class-dependent datatype used for abstraction. */ 65 | typedef Elf64_Xword Elf64_Size; 66 | typedef Elf64_Sxword Elf64_Ssize; 67 | 68 | #if 0 69 | /* 70 | * ELF header. 71 | */ 72 | 73 | typedef struct { 74 | unsigned char e_ident[EI_NIDENT]; /* File identification. */ 75 | Elf64_Half e_type; /* File type. */ 76 | Elf64_Half e_machine; /* Machine architecture. */ 77 | Elf64_Word e_version; /* ELF format version. */ 78 | Elf64_Addr e_entry; /* Entry point. */ 79 | Elf64_Off e_phoff; /* Program header file offset. */ 80 | Elf64_Off e_shoff; /* Section header file offset. */ 81 | Elf64_Word e_flags; /* Architecture-specific flags. */ 82 | Elf64_Half e_ehsize; /* Size of ELF header in bytes. */ 83 | Elf64_Half e_phentsize; /* Size of program header entry. */ 84 | Elf64_Half e_phnum; /* Number of program header entries. */ 85 | Elf64_Half e_shentsize; /* Size of section header entry. */ 86 | Elf64_Half e_shnum; /* Number of section header entries. */ 87 | Elf64_Half e_shstrndx; /* Section name strings section. */ 88 | } Elf64_Ehdr; 89 | 90 | /* 91 | * Section header. 92 | */ 93 | 94 | typedef struct { 95 | Elf64_Word sh_name; /* Section name (index into the 96 | section header string table). */ 97 | Elf64_Word sh_type; /* Section type. */ 98 | Elf64_Xword sh_flags; /* Section flags. */ 99 | Elf64_Addr sh_addr; /* Address in memory image. */ 100 | Elf64_Off sh_offset; /* Offset in file. */ 101 | Elf64_Xword sh_size; /* Size in bytes. */ 102 | Elf64_Word sh_link; /* Index of a related section. */ 103 | Elf64_Word sh_info; /* Depends on section type. */ 104 | Elf64_Xword sh_addralign; /* Alignment in bytes. */ 105 | Elf64_Xword sh_entsize; /* Size of each entry in section. */ 106 | } Elf64_Shdr; 107 | 108 | /* 109 | * Program header. 110 | */ 111 | 112 | typedef struct { 113 | Elf64_Word p_type; /* Entry type. */ 114 | Elf64_Word p_flags; /* Access permission flags. */ 115 | Elf64_Off p_offset; /* File offset of contents. */ 116 | Elf64_Addr p_vaddr; /* Virtual address in memory image. */ 117 | Elf64_Addr p_paddr; /* Physical address (not used). */ 118 | Elf64_Xword p_filesz; /* Size of contents in file. */ 119 | Elf64_Xword p_memsz; /* Size of contents in memory. */ 120 | Elf64_Xword p_align; /* Alignment in memory and file. */ 121 | } Elf64_Phdr; 122 | 123 | /* 124 | * Dynamic structure. The ".dynamic" section contains an array of them. 125 | */ 126 | 127 | typedef struct { 128 | Elf64_Sxword d_tag; /* Entry type. */ 129 | union { 130 | Elf64_Xword d_val; /* Integer value. */ 131 | Elf64_Addr d_ptr; /* Address value. */ 132 | } d_un; 133 | } Elf64_Dyn; 134 | 135 | /* 136 | * Relocation entries. 137 | */ 138 | 139 | /* Relocations that don't need an addend field. */ 140 | typedef struct { 141 | Elf64_Addr r_offset; /* Location to be relocated. */ 142 | Elf64_Xword r_info; /* Relocation type and symbol index. */ 143 | } Elf64_Rel; 144 | 145 | /* Relocations that need an addend field. */ 146 | typedef struct { 147 | Elf64_Addr r_offset; /* Location to be relocated. */ 148 | Elf64_Xword r_info; /* Relocation type and symbol index. */ 149 | Elf64_Sxword r_addend; /* Addend. */ 150 | } Elf64_Rela; 151 | 152 | /* Macros for accessing the fields of r_info. */ 153 | #define ELF64_R_SYM(info) ((info) >> 32) 154 | #define ELF64_R_TYPE(info) ((info) & 0xffffffffL) 155 | 156 | /* Macro for constructing r_info from field values. */ 157 | #define ELF64_R_INFO(sym, type) (((sym) << 32) + ((type) & 0xffffffffL)) 158 | 159 | #define ELF64_R_TYPE_DATA(info) (((Elf64_Xword)(info)<<32)>>40) 160 | #define ELF64_R_TYPE_ID(info) (((Elf64_Xword)(info)<<56)>>56) 161 | #define ELF64_R_TYPE_INFO(data, type) \ 162 | (((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type)) 163 | 164 | /* 165 | * Note entry header 166 | */ 167 | typedef Elf_Note Elf64_Nhdr; 168 | 169 | /* 170 | * Move entry 171 | */ 172 | typedef struct { 173 | Elf64_Lword m_value; /* symbol value */ 174 | Elf64_Xword m_info; /* size + index */ 175 | Elf64_Xword m_poffset; /* symbol offset */ 176 | Elf64_Half m_repeat; /* repeat count */ 177 | Elf64_Half m_stride; /* stride info */ 178 | } Elf64_Move; 179 | 180 | #define ELF64_M_SYM(info) ((info)>>8) 181 | #define ELF64_M_SIZE(info) ((unsigned char)(info)) 182 | #define ELF64_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size)) 183 | 184 | #endif 185 | 186 | /* 187 | * Hardware/Software capabilities entry 188 | */ 189 | typedef struct { 190 | Elf64_Xword c_tag; /* how to interpret value */ 191 | union { 192 | Elf64_Xword c_val; 193 | Elf64_Addr c_ptr; 194 | } c_un; 195 | } Elf64_Cap; 196 | 197 | #if 0 198 | /* 199 | * Symbol table entries. 200 | */ 201 | 202 | typedef struct { 203 | Elf64_Word st_name; /* String table index of name. */ 204 | unsigned char st_info; /* Type and binding information. */ 205 | unsigned char st_other; /* Reserved (not used). */ 206 | Elf64_Half st_shndx; /* Section index of symbol. */ 207 | Elf64_Addr st_value; /* Symbol value. */ 208 | Elf64_Xword st_size; /* Size of associated object. */ 209 | } Elf64_Sym; 210 | 211 | /* Macros for accessing the fields of st_info. */ 212 | #define ELF64_ST_BIND(info) ((info) >> 4) 213 | #define ELF64_ST_TYPE(info) ((info) & 0xf) 214 | 215 | /* Macro for constructing st_info from field values. */ 216 | #define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) 217 | 218 | /* Macro for accessing the fields of st_other. */ 219 | #define ELF64_ST_VISIBILITY(oth) ((oth) & 0x3) 220 | 221 | /* Structures used by Sun & GNU-style symbol versioning. */ 222 | typedef struct { 223 | Elf64_Half vd_version; 224 | Elf64_Half vd_flags; 225 | Elf64_Half vd_ndx; 226 | Elf64_Half vd_cnt; 227 | Elf64_Word vd_hash; 228 | Elf64_Word vd_aux; 229 | Elf64_Word vd_next; 230 | } Elf64_Verdef; 231 | 232 | typedef struct { 233 | Elf64_Word vda_name; 234 | Elf64_Word vda_next; 235 | } Elf64_Verdaux; 236 | 237 | typedef struct { 238 | Elf64_Half vn_version; 239 | Elf64_Half vn_cnt; 240 | Elf64_Word vn_file; 241 | Elf64_Word vn_aux; 242 | Elf64_Word vn_next; 243 | } Elf64_Verneed; 244 | 245 | typedef struct { 246 | Elf64_Word vna_hash; 247 | Elf64_Half vna_flags; 248 | Elf64_Half vna_other; 249 | Elf64_Word vna_name; 250 | Elf64_Word vna_next; 251 | } Elf64_Vernaux; 252 | #endif 253 | 254 | typedef Elf64_Half Elf64_Versym; 255 | 256 | #if 0 257 | typedef struct { 258 | Elf64_Half si_boundto; /* direct bindings - symbol bound to */ 259 | Elf64_Half si_flags; /* per symbol flags */ 260 | } Elf64_Syminfo; 261 | #endif 262 | 263 | #endif /* !_SYS_ELF64_H_ */ 264 | 265 | #endif /* __FreeBSD_kernel__ */ 266 | -------------------------------------------------------------------------------- /src/freebsd-glue/mac.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson 3 | * Copyright (c) 2002, 2003 Networks Associates Technology, Inc. 4 | * All rights reserved. 5 | * 6 | * This software was developed by Robert Watson for the TrustedBSD Project. 7 | * 8 | * This software was developed for the FreeBSD Project in part by Network 9 | * Associates Laboratories, the Security Research Division of Network 10 | * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), 11 | * as part of the DARPA CHATS research program. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions 15 | * are met: 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright 19 | * notice, this list of conditions and the following disclaimer in the 20 | * documentation and/or other materials provided with the distribution. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | #include 36 | __FBSDID("$FreeBSD$"); 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | #include 51 | 52 | static int internal_initialized; 53 | 54 | /* 55 | * Maintain a list of default label preparations for various object 56 | * types. Each name will appear only once in the list. 57 | * 58 | * XXXMAC: Not thread-safe. 59 | */ 60 | static LIST_HEAD(, label_default) label_default_head; 61 | struct label_default { 62 | char *ld_name; 63 | char *ld_labels; 64 | LIST_ENTRY(label_default) ld_entries; 65 | }; 66 | 67 | static void 68 | mac_destroy_labels(void) 69 | { 70 | struct label_default *ld; 71 | 72 | while ((ld = LIST_FIRST(&label_default_head))) { 73 | free(ld->ld_name); 74 | free(ld->ld_labels); 75 | LIST_REMOVE(ld, ld_entries); 76 | free(ld); 77 | } 78 | } 79 | 80 | static void 81 | mac_destroy_internal(void) 82 | { 83 | 84 | mac_destroy_labels(); 85 | 86 | internal_initialized = 0; 87 | } 88 | 89 | static int 90 | mac_add_type(const char *name, const char *labels) 91 | { 92 | struct label_default *ld, *ld_new; 93 | char *name_dup, *labels_dup; 94 | 95 | /* 96 | * Speculatively allocate all the memory now to avoid allocating 97 | * later when we will someday hold a mutex. 98 | */ 99 | name_dup = strdup(name); 100 | if (name_dup == NULL) { 101 | errno = ENOMEM; 102 | return (-1); 103 | } 104 | labels_dup = strdup(labels); 105 | if (labels_dup == NULL) { 106 | free(name_dup); 107 | errno = ENOMEM; 108 | return (-1); 109 | } 110 | ld_new = malloc(sizeof(*ld)); 111 | if (ld_new == NULL) { 112 | free(name_dup); 113 | free(labels_dup); 114 | errno = ENOMEM; 115 | return (-1); 116 | } 117 | 118 | /* 119 | * If the type is already present, replace the current entry 120 | * rather than add a new instance. 121 | */ 122 | for (ld = LIST_FIRST(&label_default_head); ld != NULL; 123 | ld = LIST_NEXT(ld, ld_entries)) { 124 | if (strcmp(name, ld->ld_name) == 0) 125 | break; 126 | } 127 | 128 | if (ld != NULL) { 129 | free(ld->ld_labels); 130 | ld->ld_labels = labels_dup; 131 | labels_dup = NULL; 132 | } else { 133 | ld = ld_new; 134 | ld->ld_name = name_dup; 135 | ld->ld_labels = labels_dup; 136 | 137 | ld_new = NULL; 138 | name_dup = NULL; 139 | labels_dup = NULL; 140 | 141 | LIST_INSERT_HEAD(&label_default_head, ld, ld_entries); 142 | } 143 | 144 | if (name_dup != NULL) 145 | free(name_dup); 146 | if (labels_dup != NULL) 147 | free(labels_dup); 148 | if (ld_new != NULL) 149 | free(ld_new); 150 | 151 | return (0); 152 | } 153 | 154 | static char * 155 | next_token(char **string) 156 | { 157 | char *token; 158 | 159 | token = strsep(string, " \t"); 160 | while (token != NULL && *token == '\0') 161 | token = strsep(string, " \t"); 162 | 163 | return (token); 164 | } 165 | 166 | static int 167 | mac_init_internal(int ignore_errors) 168 | { 169 | const char *filename; 170 | char line[LINE_MAX]; 171 | FILE *file; 172 | int error; 173 | 174 | error = 0; 175 | 176 | LIST_INIT(&label_default_head); 177 | 178 | if (!issetugid() && getenv("MAC_CONFFILE") != NULL) 179 | filename = getenv("MAC_CONFFILE"); 180 | else 181 | filename = MAC_CONFFILE; 182 | file = fopen(filename, "re"); 183 | if (file == NULL) 184 | return (0); 185 | 186 | while (fgets(line, LINE_MAX, file)) { 187 | char *comment, *parse, *statement; 188 | 189 | if (line[strlen(line)-1] == '\n') 190 | line[strlen(line)-1] = '\0'; 191 | else { 192 | if (ignore_errors) 193 | continue; 194 | fclose(file); 195 | error = EINVAL; 196 | goto just_return; 197 | } 198 | 199 | /* Remove any comment. */ 200 | comment = line; 201 | parse = strsep(&comment, "#"); 202 | 203 | /* Blank lines OK. */ 204 | statement = next_token(&parse); 205 | if (statement == NULL) 206 | continue; 207 | 208 | if (strcmp(statement, "default_labels") == 0) { 209 | char *name, *labels; 210 | 211 | name = next_token(&parse); 212 | labels = next_token(&parse); 213 | if (name == NULL || labels == NULL || 214 | next_token(&parse) != NULL) { 215 | if (ignore_errors) 216 | continue; 217 | error = EINVAL; 218 | fclose(file); 219 | goto just_return; 220 | } 221 | 222 | if (mac_add_type(name, labels) == -1) { 223 | if (ignore_errors) 224 | continue; 225 | fclose(file); 226 | goto just_return; 227 | } 228 | } else if (strcmp(statement, "default_ifnet_labels") == 0 || 229 | strcmp(statement, "default_file_labels") == 0 || 230 | strcmp(statement, "default_process_labels") == 0) { 231 | char *labels, *type; 232 | 233 | if (strcmp(statement, "default_ifnet_labels") == 0) 234 | type = "ifnet"; 235 | else if (strcmp(statement, "default_file_labels") == 0) 236 | type = "file"; 237 | else if (strcmp(statement, "default_process_labels") == 238 | 0) 239 | type = "process"; 240 | 241 | labels = next_token(&parse); 242 | if (labels == NULL || next_token(&parse) != NULL) { 243 | if (ignore_errors) 244 | continue; 245 | error = EINVAL; 246 | fclose(file); 247 | goto just_return; 248 | } 249 | 250 | if (mac_add_type(type, labels) == -1) { 251 | if (ignore_errors) 252 | continue; 253 | fclose(file); 254 | goto just_return; 255 | } 256 | } else { 257 | if (ignore_errors) 258 | continue; 259 | fclose(file); 260 | error = EINVAL; 261 | goto just_return; 262 | } 263 | } 264 | 265 | fclose(file); 266 | 267 | internal_initialized = 1; 268 | 269 | just_return: 270 | if (error != 0) 271 | mac_destroy_internal(); 272 | return (error); 273 | } 274 | 275 | static int 276 | mac_maybe_init_internal(void) 277 | { 278 | 279 | if (!internal_initialized) 280 | return (mac_init_internal(1)); 281 | else 282 | return (0); 283 | } 284 | 285 | int 286 | mac_reload(void) 287 | { 288 | 289 | if (internal_initialized) 290 | mac_destroy_internal(); 291 | return (mac_init_internal(0)); 292 | } 293 | 294 | int 295 | mac_free(struct mac *mac) 296 | { 297 | 298 | if (mac->m_string != NULL) 299 | free(mac->m_string); 300 | free(mac); 301 | 302 | return (0); 303 | } 304 | 305 | int 306 | mac_from_text(struct mac **mac, const char *text) 307 | { 308 | 309 | *mac = (struct mac *) malloc(sizeof(**mac)); 310 | if (*mac == NULL) 311 | return (ENOMEM); 312 | 313 | (*mac)->m_string = strdup(text); 314 | if ((*mac)->m_string == NULL) { 315 | free(*mac); 316 | *mac = NULL; 317 | return (ENOMEM); 318 | } 319 | 320 | (*mac)->m_buflen = strlen((*mac)->m_string)+1; 321 | 322 | return (0); 323 | } 324 | 325 | int 326 | mac_to_text(struct mac *mac, char **text) 327 | { 328 | 329 | *text = strdup(mac->m_string); 330 | if (*text == NULL) 331 | return (ENOMEM); 332 | return (0); 333 | } 334 | 335 | int 336 | mac_prepare(struct mac **mac, const char *elements) 337 | { 338 | 339 | if (strlen(elements) >= MAC_MAX_LABEL_BUF_LEN) 340 | return (EINVAL); 341 | 342 | *mac = (struct mac *) malloc(sizeof(**mac)); 343 | if (*mac == NULL) 344 | return (ENOMEM); 345 | 346 | (*mac)->m_string = malloc(MAC_MAX_LABEL_BUF_LEN); 347 | if ((*mac)->m_string == NULL) { 348 | free(*mac); 349 | *mac = NULL; 350 | return (ENOMEM); 351 | } 352 | 353 | strcpy((*mac)->m_string, elements); 354 | (*mac)->m_buflen = MAC_MAX_LABEL_BUF_LEN; 355 | 356 | return (0); 357 | } 358 | 359 | int 360 | mac_prepare_type(struct mac **mac, const char *name) 361 | { 362 | struct label_default *ld; 363 | int error; 364 | 365 | error = mac_maybe_init_internal(); 366 | if (error != 0) 367 | return (error); 368 | 369 | for (ld = LIST_FIRST(&label_default_head); ld != NULL; 370 | ld = LIST_NEXT(ld, ld_entries)) { 371 | if (strcmp(name, ld->ld_name) == 0) 372 | return (mac_prepare(mac, ld->ld_labels)); 373 | } 374 | 375 | errno = ENOENT; 376 | return (-1); /* XXXMAC: ENOLABEL */ 377 | } 378 | 379 | int 380 | mac_prepare_ifnet_label(struct mac **mac) 381 | { 382 | 383 | return (mac_prepare_type(mac, "ifnet")); 384 | } 385 | 386 | int 387 | mac_prepare_file_label(struct mac **mac) 388 | { 389 | 390 | return (mac_prepare_type(mac, "file")); 391 | } 392 | 393 | int 394 | mac_prepare_packet_label(struct mac **mac) 395 | { 396 | 397 | return (mac_prepare_type(mac, "packet")); 398 | } 399 | 400 | int 401 | mac_prepare_process_label(struct mac **mac) 402 | { 403 | 404 | return (mac_prepare_type(mac, "process")); 405 | } 406 | 407 | /* 408 | * Simply test whether the TrustedBSD/MAC MIB tree is present; if so, 409 | * return 1 to indicate that the system has MAC enabled overall or for 410 | * a given policy. 411 | */ 412 | int 413 | mac_is_present(const char *policyname) 414 | { 415 | int mib[5]; 416 | size_t siz; 417 | char *mibname; 418 | int error; 419 | 420 | if (policyname != NULL) { 421 | if (policyname[strcspn(policyname, ".=")] != '\0') { 422 | errno = EINVAL; 423 | return (-1); 424 | } 425 | mibname = malloc(sizeof("security.mac.") - 1 + 426 | strlen(policyname) + sizeof(".enabled")); 427 | if (mibname == NULL) 428 | return (-1); 429 | strcpy(mibname, "security.mac."); 430 | strcat(mibname, policyname); 431 | strcat(mibname, ".enabled"); 432 | siz = 5; 433 | error = sysctlnametomib(mibname, mib, &siz); 434 | free(mibname); 435 | } else { 436 | siz = 3; 437 | error = sysctlnametomib("security.mac", mib, &siz); 438 | } 439 | if (error == -1) { 440 | switch (errno) { 441 | case ENOTDIR: 442 | case ENOENT: 443 | return (0); 444 | default: 445 | return (error); 446 | } 447 | } 448 | return (1); 449 | } 450 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | freebsd-glue (0.2.22) unstable; urgency=medium 2 | 3 | * Actually use the proper build architecture compiler 4 | (thanks, Helmut Grohne!) 5 | * Drop freebsd-glue's seemingly unnecessary dependency on 'make' 6 | 7 | -- Steven Chamberlain Sat, 05 Mar 2016 00:48:23 +0000 8 | 9 | freebsd-glue (0.2.21) unstable; urgency=medium 10 | 11 | * Add myself to Uploaders. 12 | * No longer Build-Depends specifically on gcc-4.9 (gcc-5 and gcc-6 13 | are both fine). 14 | * Fixes for cross building: 15 | - don't override $CC (as explained by Helmut Grohne, it forced use 16 | of the build architecture compiler). 17 | - build get_elf_arch with the build architecture compiler, but 18 | examine a host arch binary (also suggested by Helmut Grohne, 19 | thanks!) 20 | * Now using Standards-Version 3.9.7 (no changes needed). 21 | 22 | -- Steven Chamberlain Wed, 02 Mar 2016 14:06:22 +0000 23 | 24 | freebsd-glue (0.2.20) unstable; urgency=low 25 | 26 | * Upload to unstable 27 | 28 | [ Steven Chamberlain ] 29 | * Switch to gcc-4.9 (Closes: #751309) 30 | * Remove funopen, fwopen and fropen definitions, now provided by libbsd 31 | (Closes: #759249) 32 | 33 | -- Christoph Egger Mon, 25 Aug 2014 13:17:44 -0700 34 | 35 | freebsd-glue (0.2.19) unstable; urgency=low 36 | 37 | * Add MAXHOSTNAMELEN fallback. 38 | * Add isnumber(). 39 | 40 | -- Robert Millan Sat, 22 Mar 2014 20:27:53 +0100 41 | 42 | freebsd-glue (0.2.18) experimental; urgency=low 43 | 44 | * Add PATH_MAX and MAXPATHLEN fallbacks for systems that lack them. 45 | * Uploading to experimental as kfreebsd-kernel-headers 10.0 (needed by 46 | capsicum) is only available there. 47 | 48 | -- Robert Millan Tue, 21 Jan 2014 12:48:14 +0100 49 | 50 | freebsd-glue (0.2.17) unstable; urgency=low 51 | 52 | * Remove dependency on libutil-freebsd-dev (it was only needed during 53 | transition of libutil.h). 54 | * Allow users to force use of embedded headers even when building 55 | natively, by setting __FREEBSD_GLUE_USE_EMBEDDED_HEADERS macro. This 56 | makes it possible to detect FTBFS errors that affect other platforms 57 | also on GNU/kFreeBSD. 58 | * Update embedded copy of . 59 | * Add getbsize(). 60 | * Add arc4random_buf() prototype to . 61 | * Add _PATH_GBDE, _PATH_GELI and _PATH_MDCONFIG to . 62 | * Add swapon() and swapoff() prototypes to . 63 | * Add basename_r(). 64 | * Add capsicum(4) family of functions. 65 | 66 | -- Robert Millan Mon, 20 Jan 2014 23:45:07 +0100 67 | 68 | freebsd-glue (0.2.16) unstable; urgency=low 69 | 70 | * Only include when needed (should fix FTBFS on 71 | hurd-i386). 72 | * Add __ELF_WORD_SIZE to . 73 | * Add a few FreeBSD-specific clocks on non-kFreeBSD systems. 74 | 75 | -- Robert Millan Wed, 08 Jan 2014 15:15:59 +0100 76 | 77 | freebsd-glue (0.2.15) unstable; urgency=low 78 | 79 | * Fix /usr/lib/freebsd/bmake permissions. 80 | * Make the libbsd-dev B-D explicit now that freebsd-buildutils doesn't 81 | pull it. 82 | 83 | -- Robert Millan Wed, 08 Jan 2014 02:09:59 +0100 84 | 85 | freebsd-glue (0.2.14) unstable; urgency=low 86 | 87 | * Add . 88 | * Switch to bmake, and finish breaking the circular build-dependency 89 | on freebsd-buildutils. 90 | 91 | -- Robert Millan Wed, 08 Jan 2014 01:30:59 +0100 92 | 93 | freebsd-glue (0.2.13) unstable; urgency=low 94 | 95 | * Explicitly request gcc-4.8 as sbuild can't handle build dependencies 96 | properly (sigh). 97 | 98 | -- Robert Millan Thu, 02 Jan 2014 20:15:04 +0100 99 | 100 | freebsd-glue (0.2.12) unstable; urgency=low 101 | 102 | * Invoke FreeBSD make explicitly as fmake. 103 | 104 | -- Robert Millan Thu, 02 Jan 2014 19:47:27 +0100 105 | 106 | freebsd-glue (0.2.11) unstable; urgency=low 107 | 108 | * Yet another attempt at fixing FTBFS with older freebsd-buildutils... 109 | 110 | -- Robert Millan Thu, 02 Jan 2014 18:41:42 +0100 111 | 112 | freebsd-glue (0.2.10) unstable; urgency=low 113 | 114 | * Attempt to use fmake, then fallback to make (in /usr/lib/freebsd). 115 | This garantees FreeBSD make no matter which freebsd-buildutils we're 116 | using. 117 | 118 | -- Robert Millan Thu, 02 Jan 2014 18:17:49 +0100 119 | 120 | freebsd-glue (0.2.9) unstable; urgency=low 121 | 122 | * sysarch.c: Avoid conflicting declarations in . 123 | * Require GCC 4.8 or later to fix FTBFS on ia64, powerpc and sparc. 124 | 125 | -- Robert Millan Thu, 02 Jan 2014 17:52:03 +0100 126 | 127 | freebsd-glue (0.2.8) unstable; urgency=low 128 | 129 | * Correctly setup BSD version of MAKEFLAGS to support parallel builds. 130 | * Provide legacy symlinks for make and mtree (for now, fmake and 131 | fmtree). 132 | * Add wrapper for bmake (force it to use /usr/share/mk-freebsd instead 133 | of its own /usr/share/mk). 134 | * Add a few sysarch-based functions: amd64_get_fsbase, 135 | amd64_get_gsbase, amd64_set_fsbase, amd64_set_gsbase, 136 | i386_get_fsbase, i386_get_gsbase, i386_set_fsbase and 137 | i386_set_gsbase. 138 | 139 | -- Robert Millan Thu, 02 Jan 2014 16:03:44 +0100 140 | 141 | freebsd-glue (0.2.7) unstable; urgency=low 142 | 143 | * Remove getpeereid(), use version from libbsd instead. 144 | 145 | -- Robert Millan Sun, 29 Dec 2013 00:53:25 +0100 146 | 147 | freebsd-glue (0.2.6) unstable; urgency=low 148 | 149 | * Use -O2 for normal build and -Os for udeb build. 150 | * Use MAKEOBJDIRPREFIX instead of MAKEOBJDIR, so that each library has 151 | its own object directory. 152 | * Provide bsd_sendfile() syscall stub, and map sendfile() to it in 153 | . 154 | * Convert cget* family of functions into dummy stubs. This gets rid of 155 | -ldb dependency, which isn't permissible outside of /usr. 156 | (Closes: #732617) 157 | * Add getpeereid(). 158 | 159 | -- Robert Millan Sun, 29 Dec 2013 00:30:03 +0100 160 | 161 | freebsd-glue (0.2.5) unstable; urgency=low 162 | 163 | * Include libbsdxml.so in freebsd-glue. 164 | * Split udeb build into a separate target. Exclude getcap.c from that 165 | build and its associated -ldb. (Closes: #731258) 166 | 167 | -- Robert Millan Tue, 03 Dec 2013 22:28:21 +0100 168 | 169 | freebsd-glue (0.2.4) unstable; urgency=low 170 | 171 | * Remove libutil glue code, depend on the real thing instead. 172 | 173 | -- Robert Millan Sun, 01 Dec 2013 12:58:10 +0100 174 | 175 | freebsd-glue (0.2.3) unstable; urgency=low 176 | 177 | * Only install *.so symlink for libfreebsd-glue. 178 | 179 | -- Robert Millan Sat, 30 Nov 2013 13:08:07 +0100 180 | 181 | freebsd-glue (0.2.2) unstable; urgency=low 182 | 183 | * Add strnstr(). 184 | * setfstab: Only fail when file != NULL. Set errno when failing. 185 | * Provide libbsdxml stubs (for libexpat). 186 | 187 | -- Robert Millan Sat, 30 Nov 2013 12:09:03 +0100 188 | 189 | freebsd-glue (0.2.1) unstable; urgency=low 190 | 191 | * Fix broken external references in mac_set.c. 192 | 193 | -- Robert Millan Fri, 29 Nov 2013 18:38:51 +0100 194 | 195 | freebsd-glue (0.2.0) experimental; urgency=low 196 | 197 | * Provide a shared version of libfreebsd-glue. 198 | 199 | -- Robert Millan Fri, 29 Nov 2013 14:05:57 +0100 200 | 201 | freebsd-glue (0.1.15) unstable; urgency=low 202 | 203 | * Add INADDR_ALLRPTS_GROUP, INADDR_CARP_GROUP, INADDR_PFSYNC_GROUP and 204 | INADDR_ALLMDNS_GROUP magic IPv4 addresses. 205 | * Add the mac_* family of functions (as defined by . 206 | * Move to . 207 | * Add (as #include stub). 208 | * Add _PATH_DEVZERO. 209 | * Split additions for libcrypt, libutil and libz into separate 210 | libraries. 211 | * Add getbootfile(). 212 | * Add stub (for libgdbm). 213 | * Add (stub for ). 214 | * Add and . 215 | * Add _PATH_UUCPLOCK (diverge from upstream as per FHS). 216 | * Add mac_set family of functions. 217 | * Update copyright information. 218 | 219 | -- Robert Millan Sun, 24 Nov 2013 14:22:23 +0100 220 | 221 | freebsd-glue (0.1.14) unstable; urgency=low 222 | 223 | * Redirect to native on kFreeBSD. 224 | * Build get_elf_arch.c using -Wall -Werror. Fix missing return and 225 | implicit declarations. 226 | 227 | -- Robert Millan Wed, 30 Oct 2013 00:04:50 +0100 228 | 229 | freebsd-glue (0.1.13) unstable; urgency=low 230 | 231 | * Disable kernel-specific paths on non-kFreeBSD. 232 | * Add and . 233 | * Add STAILQ_LAST() to . 234 | * Move CFLAGS to src/Makefile. 235 | * Expand and to support non-kFreeBSD 236 | platforms. 237 | * Add (with tricky build magic to generate ELF_ARCH). 238 | 239 | -- Robert Millan Mon, 28 Oct 2013 23:10:03 +0100 240 | 241 | freebsd-glue (0.1.12) unstable; urgency=low 242 | 243 | * Fix improper allocation in funopen(). (Closes: #726970) 244 | * Add _PATH_UFSSUSPEND. 245 | * Add arc4random_stir() prototype (for libbsd). 246 | * Work around broken macro argument in TAILQ_FOREACH_REVERSE_SAFE 247 | 248 | -- Robert Millan Sat, 26 Oct 2013 16:09:29 +0200 249 | 250 | freebsd-glue (0.1.11) unstable; urgency=low 251 | 252 | * Fix unresolved dependencies on libc hidden symbols (_open, _read, 253 | _close), libdb and cpuset family of functions. 254 | * Add zlib1g-dev to Build-Depends and Depends. 255 | * getosreldate.c: Move mib and size to kFreeBSD-specific area. 256 | 257 | -- Robert Millan Sun, 20 Oct 2013 15:14:22 +0200 258 | 259 | freebsd-glue (0.1.10) unstable; urgency=low 260 | 261 | * Add libdb-dev to Depends / Build-Depends. 262 | 263 | -- Robert Millan Sun, 20 Oct 2013 12:56:14 +0200 264 | 265 | freebsd-glue (0.1.9) unstable; urgency=low 266 | 267 | * Build with full -Werror. 268 | * Implement funopen(), fropen() and fwopen(). 269 | * Add zopen(). 270 | * New headers: grp.h, db.h (as stub). 271 | * Add _PATH_ETC. 272 | * Fix stdlib.h indirect load of libutil.h. 273 | * Add cget* family of functions. 274 | * Add getloginclass() and setloginclass() kernel calls. 275 | * Add dummy crypt_get_format() and crypt_set_format(). 276 | 277 | -- Robert Millan Sun, 20 Oct 2013 02:08:57 +0200 278 | 279 | freebsd-glue (0.1.8) unstable; urgency=low 280 | 281 | * Change header protectionin to avoid collision with 282 | glibc's. 283 | 284 | -- Robert Millan Sun, 06 Oct 2013 15:03:15 +0200 285 | 286 | freebsd-glue (0.1.7) unstable; urgency=low 287 | 288 | * Fix minor formatting error in setfstab(). 289 | * Add . 290 | 291 | -- Robert Millan Sun, 06 Oct 2013 14:37:43 +0200 292 | 293 | freebsd-glue (0.1.6) unstable; urgency=low 294 | 295 | * Define __FreeBSD_version as __FreeBSD_kernel_version when available. 296 | * Implement setfib, setfstab (as ENOSYS stub) and getfstab (with 297 | hardcoded return value). 298 | 299 | -- Robert Millan Thu, 03 Oct 2013 01:11:03 +0200 300 | 301 | freebsd-glue (0.1.5) unstable; urgency=low 302 | 303 | * Add include_next to sys/queue.h in order to bring back 304 | macros that were disabled in kernel headers. 305 | 306 | -- Robert Millan Mon, 09 Sep 2013 15:06:42 +0200 307 | 308 | freebsd-glue (0.1.4) unstable; urgency=low 309 | 310 | * Implement srandomdev(). 311 | * Implement getdiskbyname(). 312 | * Add stubs. 313 | 314 | -- Robert Millan Mon, 02 Sep 2013 20:48:37 +0200 315 | 316 | freebsd-glue (0.1.3) unstable; urgency=low 317 | 318 | * linkaddr.c is kFreeBSD-specific. 319 | 320 | -- Robert Millan Tue, 06 Aug 2013 18:14:14 +0200 321 | 322 | freebsd-glue (0.1.2) unstable; urgency=low 323 | 324 | * Add to fix buildability of . 325 | 326 | -- Robert Millan Tue, 06 Aug 2013 17:22:40 +0200 327 | 328 | freebsd-glue (0.1.1) unstable; urgency=low 329 | 330 | * Put includes of OUTSIDE the header protection (which 331 | they intentionally duplicate). 332 | * FreeBSD and have a kludge to declare 333 | lseek(). Duplicate the Glibc declaration here. 334 | * implicitly includes . 335 | * Add trimdomain, link_addr and link_ntoa. 336 | 337 | -- Robert Millan Sun, 04 Aug 2013 18:20:40 +0200 338 | 339 | freebsd-glue (0.1.0) unstable; urgency=low 340 | 341 | * Fix header pollution in by moving non-trivial inline 342 | functions into static objects of their own. 343 | * Add nlm_syscall() inline function. 344 | 345 | -- Robert Millan Sun, 04 Aug 2013 16:21:56 +0200 346 | 347 | freebsd-glue (0.0.10) unstable; urgency=low 348 | 349 | [ Guillem Jover ] 350 | * Switch to canonical Vcs URLs. 351 | 352 | [ Robert Millan ] 353 | * Add which includes (for 354 | ether_ntoa). 355 | 356 | -- Robert Millan Thu, 01 Aug 2013 21:17:17 +0200 357 | 358 | freebsd-glue (0.0.9) unstable; urgency=low 359 | 360 | * Make and usable on non-kFreeBSD. 361 | 362 | -- Robert Millan Mon, 22 Jul 2013 21:55:14 +0200 363 | 364 | freebsd-glue (0.0.8) unstable; urgency=low 365 | 366 | * Include in (for initgroups). 367 | * Add __containerof() to . 368 | * Add roundup2 in . It is no longer provided by glibc 369 | (??). 370 | 371 | -- Robert Millan Tue, 16 Jul 2013 15:21:09 +0200 372 | 373 | freebsd-glue (0.0.7) unstable; urgency=low 374 | 375 | * Replace versions of freebsd-buildutils which included their own 376 | yacc. (Closes: #715138) 377 | * Misc fixes to accomodate for FreeBSD 9.1. 378 | 379 | -- Robert Millan Tue, 09 Jul 2013 22:32:45 +0200 380 | 381 | freebsd-glue (0.0.6) unstable; urgency=low 382 | 383 | * Misc additions to simplify PPP patchset in freebsd-utils. 384 | * Add yacc -> byacc symlink. 385 | * Add _SAFE macros in . 386 | 387 | -- Robert Millan Fri, 05 Jul 2013 22:02:54 +0200 388 | 389 | freebsd-glue (0.0.5) unstable; urgency=low 390 | 391 | * Drag libbsd counterparts into and . 392 | 393 | -- Robert Millan Wed, 19 Jun 2013 21:05:20 +0200 394 | 395 | freebsd-glue (0.0.4) unstable; urgency=high 396 | 397 | * Add libutil.h and nlist.h. 398 | 399 | -- Robert Millan Thu, 21 Jun 2012 19:51:41 +0200 400 | 401 | freebsd-glue (0.0.3) unstable; urgency=low 402 | 403 | * Move freebsd-buildutils from Depends to Recommends to break circular 404 | dependency. (Closes: #674806) 405 | * Don't include on non-kFreeBSD. (Closes: #674803) 406 | 407 | -- Robert Millan Mon, 28 May 2012 11:02:56 +0200 408 | 409 | freebsd-glue (0.0.2) unstable; urgency=low 410 | 411 | * Add Vcs-* fields and set Maintainer to debian-bsd. 412 | * Add Breaks on freebsd-buildutils (<< 9.0-10). (Closes: #674528) 413 | * Include before feature_present(). 414 | * Make implicitly include . 415 | 416 | -- Robert Millan Fri, 25 May 2012 19:13:17 +0200 417 | 418 | freebsd-glue (0.0.1) unstable; urgency=low 419 | 420 | * Initial release. 421 | 422 | -- Robert Millan Sat, 19 May 2012 14:35:32 +0200 423 | -------------------------------------------------------------------------------- /include/embed/sys/elf_common.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2000, 2001, 2008, 2011, David E. O'Brien 3 | * Copyright (c) 1998 John D. Polstra. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | * 27 | * $FreeBSD$ 28 | */ 29 | 30 | #ifndef _SYS_ELF_COMMON_H_ 31 | #define _SYS_ELF_COMMON_H_ 1 32 | 33 | /* 34 | * ELF definitions that are independent of architecture or word size. 35 | */ 36 | 37 | /* 38 | * Note header. The ".note" section contains an array of notes. Each 39 | * begins with this header, aligned to a word boundary. Immediately 40 | * following the note header is n_namesz bytes of name, padded to the 41 | * next word boundary. Then comes n_descsz bytes of descriptor, again 42 | * padded to a word boundary. The values of n_namesz and n_descsz do 43 | * not include the padding. 44 | */ 45 | 46 | typedef struct { 47 | u_int32_t n_namesz; /* Length of name. */ 48 | u_int32_t n_descsz; /* Length of descriptor. */ 49 | u_int32_t n_type; /* Type of this note. */ 50 | } Elf_Note; 51 | 52 | /* 53 | * The header for GNU-style hash sections. 54 | */ 55 | 56 | typedef struct { 57 | u_int32_t gh_nbuckets; /* Number of hash buckets. */ 58 | u_int32_t gh_symndx; /* First visible symbol in .dynsym. */ 59 | u_int32_t gh_maskwords; /* #maskwords used in bloom filter. */ 60 | u_int32_t gh_shift2; /* Bloom filter shift count. */ 61 | } Elf_GNU_Hash_Header; 62 | 63 | /* Indexes into the e_ident array. Keep synced with 64 | http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ 65 | #define EI_MAG0 0 /* Magic number, byte 0. */ 66 | #define EI_MAG1 1 /* Magic number, byte 1. */ 67 | #define EI_MAG2 2 /* Magic number, byte 2. */ 68 | #define EI_MAG3 3 /* Magic number, byte 3. */ 69 | #define EI_CLASS 4 /* Class of machine. */ 70 | #define EI_DATA 5 /* Data format. */ 71 | #define EI_VERSION 6 /* ELF format version. */ 72 | #define EI_OSABI 7 /* Operating system / ABI identification */ 73 | #define EI_ABIVERSION 8 /* ABI version */ 74 | #define OLD_EI_BRAND 8 /* Start of architecture identification. */ 75 | #define EI_PAD 9 /* Start of padding (per SVR4 ABI). */ 76 | #define EI_NIDENT 16 /* Size of e_ident array. */ 77 | 78 | /* Values for the magic number bytes. */ 79 | #define ELFMAG0 0x7f 80 | #define ELFMAG1 'E' 81 | #define ELFMAG2 'L' 82 | #define ELFMAG3 'F' 83 | #define ELFMAG "\177ELF" /* magic string */ 84 | #define SELFMAG 4 /* magic string size */ 85 | 86 | /* Values for e_ident[EI_VERSION] and e_version. */ 87 | #define EV_NONE 0 88 | #define EV_CURRENT 1 89 | 90 | /* Values for e_ident[EI_CLASS]. */ 91 | #define ELFCLASSNONE 0 /* Unknown class. */ 92 | #define ELFCLASS32 1 /* 32-bit architecture. */ 93 | #define ELFCLASS64 2 /* 64-bit architecture. */ 94 | 95 | /* Values for e_ident[EI_DATA]. */ 96 | #define ELFDATANONE 0 /* Unknown data format. */ 97 | #define ELFDATA2LSB 1 /* 2's complement little-endian. */ 98 | #define ELFDATA2MSB 2 /* 2's complement big-endian. */ 99 | 100 | /* Values for e_ident[EI_OSABI]. */ 101 | #define ELFOSABI_NONE 0 /* UNIX System V ABI */ 102 | #define ELFOSABI_HPUX 1 /* HP-UX operating system */ 103 | #define ELFOSABI_NETBSD 2 /* NetBSD */ 104 | #define ELFOSABI_LINUX 3 /* GNU/Linux */ 105 | #define ELFOSABI_HURD 4 /* GNU/Hurd */ 106 | #define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ 107 | #define ELFOSABI_SOLARIS 6 /* Solaris */ 108 | #define ELFOSABI_AIX 7 /* AIX */ 109 | #define ELFOSABI_IRIX 8 /* IRIX */ 110 | #define ELFOSABI_FREEBSD 9 /* FreeBSD */ 111 | #define ELFOSABI_TRU64 10 /* TRU64 UNIX */ 112 | #define ELFOSABI_MODESTO 11 /* Novell Modesto */ 113 | #define ELFOSABI_OPENBSD 12 /* OpenBSD */ 114 | #define ELFOSABI_OPENVMS 13 /* Open VMS */ 115 | #define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ 116 | #define ELFOSABI_AROS 15 /* Amiga Research OS */ 117 | #define ELFOSABI_ARM 97 /* ARM */ 118 | #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ 119 | 120 | #define ELFOSABI_SYSV ELFOSABI_NONE /* symbol used in old spec */ 121 | #define ELFOSABI_MONTEREY ELFOSABI_AIX /* Monterey */ 122 | 123 | /* e_ident */ 124 | #define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ 125 | (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ 126 | (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ 127 | (ehdr).e_ident[EI_MAG3] == ELFMAG3) 128 | 129 | /* Values for e_type. */ 130 | #define ET_NONE 0 /* Unknown type. */ 131 | #define ET_REL 1 /* Relocatable. */ 132 | #define ET_EXEC 2 /* Executable. */ 133 | #define ET_DYN 3 /* Shared object. */ 134 | #define ET_CORE 4 /* Core file. */ 135 | #define ET_LOOS 0xfe00 /* First operating system specific. */ 136 | #define ET_HIOS 0xfeff /* Last operating system-specific. */ 137 | #define ET_LOPROC 0xff00 /* First processor-specific. */ 138 | #define ET_HIPROC 0xffff /* Last processor-specific. */ 139 | 140 | /* Values for e_machine. */ 141 | #define EM_NONE 0 /* Unknown machine. */ 142 | #define EM_M32 1 /* AT&T WE32100. */ 143 | #define EM_SPARC 2 /* Sun SPARC. */ 144 | #define EM_386 3 /* Intel i386. */ 145 | #define EM_68K 4 /* Motorola 68000. */ 146 | #define EM_88K 5 /* Motorola 88000. */ 147 | #define EM_860 7 /* Intel i860. */ 148 | #define EM_MIPS 8 /* MIPS R3000 Big-Endian only. */ 149 | #define EM_S370 9 /* IBM System/370. */ 150 | #define EM_MIPS_RS3_LE 10 /* MIPS R3000 Little-Endian. */ 151 | #define EM_PARISC 15 /* HP PA-RISC. */ 152 | #define EM_VPP500 17 /* Fujitsu VPP500. */ 153 | #define EM_SPARC32PLUS 18 /* SPARC v8plus. */ 154 | #define EM_960 19 /* Intel 80960. */ 155 | #define EM_PPC 20 /* PowerPC 32-bit. */ 156 | #define EM_PPC64 21 /* PowerPC 64-bit. */ 157 | #define EM_S390 22 /* IBM System/390. */ 158 | #define EM_V800 36 /* NEC V800. */ 159 | #define EM_FR20 37 /* Fujitsu FR20. */ 160 | #define EM_RH32 38 /* TRW RH-32. */ 161 | #define EM_RCE 39 /* Motorola RCE. */ 162 | #define EM_ARM 40 /* ARM. */ 163 | #define EM_SH 42 /* Hitachi SH. */ 164 | #define EM_SPARCV9 43 /* SPARC v9 64-bit. */ 165 | #define EM_TRICORE 44 /* Siemens TriCore embedded processor. */ 166 | #define EM_ARC 45 /* Argonaut RISC Core. */ 167 | #define EM_H8_300 46 /* Hitachi H8/300. */ 168 | #define EM_H8_300H 47 /* Hitachi H8/300H. */ 169 | #define EM_H8S 48 /* Hitachi H8S. */ 170 | #define EM_H8_500 49 /* Hitachi H8/500. */ 171 | #define EM_IA_64 50 /* Intel IA-64 Processor. */ 172 | #define EM_MIPS_X 51 /* Stanford MIPS-X. */ 173 | #define EM_COLDFIRE 52 /* Motorola ColdFire. */ 174 | #define EM_68HC12 53 /* Motorola M68HC12. */ 175 | #define EM_MMA 54 /* Fujitsu MMA. */ 176 | #define EM_PCP 55 /* Siemens PCP. */ 177 | #define EM_NCPU 56 /* Sony nCPU. */ 178 | #define EM_NDR1 57 /* Denso NDR1 microprocessor. */ 179 | #define EM_STARCORE 58 /* Motorola Star*Core processor. */ 180 | #define EM_ME16 59 /* Toyota ME16 processor. */ 181 | #define EM_ST100 60 /* STMicroelectronics ST100 processor. */ 182 | #define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ processor. */ 183 | #define EM_X86_64 62 /* Advanced Micro Devices x86-64 */ 184 | #define EM_AMD64 EM_X86_64 /* Advanced Micro Devices x86-64 (compat) */ 185 | #define EM_PDSP 63 /* Sony DSP Processor. */ 186 | #define EM_FX66 66 /* Siemens FX66 microcontroller. */ 187 | #define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 188 | microcontroller. */ 189 | #define EM_ST7 68 /* STmicroelectronics ST7 8-bit 190 | microcontroller. */ 191 | #define EM_68HC16 69 /* Motorola MC68HC16 microcontroller. */ 192 | #define EM_68HC11 70 /* Motorola MC68HC11 microcontroller. */ 193 | #define EM_68HC08 71 /* Motorola MC68HC08 microcontroller. */ 194 | #define EM_68HC05 72 /* Motorola MC68HC05 microcontroller. */ 195 | #define EM_SVX 73 /* Silicon Graphics SVx. */ 196 | #define EM_ST19 74 /* STMicroelectronics ST19 8-bit mc. */ 197 | #define EM_VAX 75 /* Digital VAX. */ 198 | #define EM_CRIS 76 /* Axis Communications 32-bit embedded 199 | processor. */ 200 | #define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded 201 | processor. */ 202 | #define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor. */ 203 | #define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor. */ 204 | #define EM_MMIX 80 /* Donald Knuth's educational 64-bit proc. */ 205 | #define EM_HUANY 81 /* Harvard University machine-independent 206 | object files. */ 207 | #define EM_PRISM 82 /* SiTera Prism. */ 208 | #define EM_AVR 83 /* Atmel AVR 8-bit microcontroller. */ 209 | #define EM_FR30 84 /* Fujitsu FR30. */ 210 | #define EM_D10V 85 /* Mitsubishi D10V. */ 211 | #define EM_D30V 86 /* Mitsubishi D30V. */ 212 | #define EM_V850 87 /* NEC v850. */ 213 | #define EM_M32R 88 /* Mitsubishi M32R. */ 214 | #define EM_MN10300 89 /* Matsushita MN10300. */ 215 | #define EM_MN10200 90 /* Matsushita MN10200. */ 216 | #define EM_PJ 91 /* picoJava. */ 217 | #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor. */ 218 | #define EM_ARC_A5 93 /* ARC Cores Tangent-A5. */ 219 | #define EM_XTENSA 94 /* Tensilica Xtensa Architecture. */ 220 | #define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor. */ 221 | #define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose 222 | Processor. */ 223 | #define EM_NS32K 97 /* National Semiconductor 32000 series. */ 224 | #define EM_TPC 98 /* Tenor Network TPC processor. */ 225 | #define EM_SNP1K 99 /* Trebia SNP 1000 processor. */ 226 | #define EM_ST200 100 /* STMicroelectronics ST200 microcontroller. */ 227 | #define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family. */ 228 | #define EM_MAX 102 /* MAX Processor. */ 229 | #define EM_CR 103 /* National Semiconductor CompactRISC 230 | microprocessor. */ 231 | #define EM_F2MC16 104 /* Fujitsu F2MC16. */ 232 | #define EM_MSP430 105 /* Texas Instruments embedded microcontroller 233 | msp430. */ 234 | #define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor. */ 235 | #define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors. */ 236 | #define EM_SEP 108 /* Sharp embedded microprocessor. */ 237 | #define EM_ARCA 109 /* Arca RISC Microprocessor. */ 238 | #define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd. 239 | and MPRC of Peking University */ 240 | 241 | /* Non-standard or deprecated. */ 242 | #define EM_486 6 /* Intel i486. */ 243 | #define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ 244 | #define EM_ALPHA_STD 41 /* Digital Alpha (standard value). */ 245 | #define EM_ALPHA 0x9026 /* Alpha (written in the absence of an ABI) */ 246 | 247 | /* Special section indexes. */ 248 | #define SHN_UNDEF 0 /* Undefined, missing, irrelevant. */ 249 | #define SHN_LORESERVE 0xff00 /* First of reserved range. */ 250 | #define SHN_LOPROC 0xff00 /* First processor-specific. */ 251 | #define SHN_HIPROC 0xff1f /* Last processor-specific. */ 252 | #define SHN_LOOS 0xff20 /* First operating system-specific. */ 253 | #define SHN_HIOS 0xff3f /* Last operating system-specific. */ 254 | #define SHN_ABS 0xfff1 /* Absolute values. */ 255 | #define SHN_COMMON 0xfff2 /* Common data. */ 256 | #define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere. */ 257 | #define SHN_HIRESERVE 0xffff /* Last of reserved range. */ 258 | 259 | /* sh_type */ 260 | #define SHT_NULL 0 /* inactive */ 261 | #define SHT_PROGBITS 1 /* program defined information */ 262 | #define SHT_SYMTAB 2 /* symbol table section */ 263 | #define SHT_STRTAB 3 /* string table section */ 264 | #define SHT_RELA 4 /* relocation section with addends */ 265 | #define SHT_HASH 5 /* symbol hash table section */ 266 | #define SHT_DYNAMIC 6 /* dynamic section */ 267 | #define SHT_NOTE 7 /* note section */ 268 | #define SHT_NOBITS 8 /* no space section */ 269 | #define SHT_REL 9 /* relocation section - no addends */ 270 | #define SHT_SHLIB 10 /* reserved - purpose unknown */ 271 | #define SHT_DYNSYM 11 /* dynamic symbol table section */ 272 | #define SHT_INIT_ARRAY 14 /* Initialization function pointers. */ 273 | #define SHT_FINI_ARRAY 15 /* Termination function pointers. */ 274 | #define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs. */ 275 | #define SHT_GROUP 17 /* Section group. */ 276 | #define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX). */ 277 | #define SHT_LOOS 0x60000000 /* First of OS specific semantics */ 278 | #define SHT_LOSUNW 0x6ffffff4 279 | #define SHT_SUNW_dof 0x6ffffff4 280 | #define SHT_SUNW_cap 0x6ffffff5 281 | #define SHT_SUNW_SIGNATURE 0x6ffffff6 282 | #define SHT_GNU_HASH 0x6ffffff6 283 | #define SHT_SUNW_ANNOTATE 0x6ffffff7 284 | #define SHT_SUNW_DEBUGSTR 0x6ffffff8 285 | #define SHT_SUNW_DEBUG 0x6ffffff9 286 | #define SHT_SUNW_move 0x6ffffffa 287 | #define SHT_SUNW_COMDAT 0x6ffffffb 288 | #define SHT_SUNW_syminfo 0x6ffffffc 289 | #define SHT_SUNW_verdef 0x6ffffffd 290 | #define SHT_GNU_verdef 0x6ffffffd /* Symbol versions provided */ 291 | #define SHT_SUNW_verneed 0x6ffffffe 292 | #define SHT_GNU_verneed 0x6ffffffe /* Symbol versions required */ 293 | #define SHT_SUNW_versym 0x6fffffff 294 | #define SHT_GNU_versym 0x6fffffff /* Symbol version table */ 295 | #define SHT_HISUNW 0x6fffffff 296 | #define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */ 297 | #define SHT_LOPROC 0x70000000 /* reserved range for processor */ 298 | #define SHT_AMD64_UNWIND 0x70000001 /* unwind information */ 299 | #define SHT_ARM_EXIDX 0x70000001 /* Exception index table. */ 300 | #define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking 301 | pre-emption map. */ 302 | #define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility 303 | attributes. */ 304 | #define SHT_ARM_DEBUGOVERLAY 0x70000004 /* See DBGOVL for details. */ 305 | #define SHT_ARM_OVERLAYSECTION 0x70000005 /* See DBGOVL for details. */ 306 | #define SHT_MIPS_REGINFO 0x70000006 307 | #define SHT_MIPS_OPTIONS 0x7000000d 308 | #define SHT_MIPS_DWARF 0x7000001e /* MIPS gcc uses MIPS_DWARF */ 309 | #define SHT_HIPROC 0x7fffffff /* specific section header types */ 310 | #define SHT_LOUSER 0x80000000 /* reserved range for application */ 311 | #define SHT_HIUSER 0xffffffff /* specific indexes */ 312 | 313 | /* Flags for sh_flags. */ 314 | #define SHF_WRITE 0x1 /* Section contains writable data. */ 315 | #define SHF_ALLOC 0x2 /* Section occupies memory. */ 316 | #define SHF_EXECINSTR 0x4 /* Section contains instructions. */ 317 | #define SHF_MERGE 0x10 /* Section may be merged. */ 318 | #define SHF_STRINGS 0x20 /* Section contains strings. */ 319 | #define SHF_INFO_LINK 0x40 /* sh_info holds section index. */ 320 | #define SHF_LINK_ORDER 0x80 /* Special ordering requirements. */ 321 | #define SHF_OS_NONCONFORMING 0x100 /* OS-specific processing required. */ 322 | #define SHF_GROUP 0x200 /* Member of section group. */ 323 | #define SHF_TLS 0x400 /* Section contains TLS data. */ 324 | #define SHF_MASKOS 0x0ff00000 /* OS-specific semantics. */ 325 | #define SHF_MASKPROC 0xf0000000 /* Processor-specific semantics. */ 326 | 327 | /* Values for p_type. */ 328 | #define PT_NULL 0 /* Unused entry. */ 329 | #define PT_LOAD 1 /* Loadable segment. */ 330 | #define PT_DYNAMIC 2 /* Dynamic linking information segment. */ 331 | #define PT_INTERP 3 /* Pathname of interpreter. */ 332 | #define PT_NOTE 4 /* Auxiliary information. */ 333 | #define PT_SHLIB 5 /* Reserved (not used). */ 334 | #define PT_PHDR 6 /* Location of program header itself. */ 335 | #define PT_TLS 7 /* Thread local storage segment */ 336 | #define PT_LOOS 0x60000000 /* First OS-specific. */ 337 | #define PT_SUNW_UNWIND 0x6464e550 /* amd64 UNWIND program header */ 338 | #define PT_GNU_EH_FRAME 0x6474e550 339 | #define PT_GNU_STACK 0x6474e551 340 | #define PT_GNU_RELRO 0x6474e552 341 | #define PT_LOSUNW 0x6ffffffa 342 | #define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ 343 | #define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */ 344 | #define PT_SUNWDTRACE 0x6ffffffc /* private */ 345 | #define PT_SUNWCAP 0x6ffffffd /* hard/soft capabilities segment */ 346 | #define PT_HISUNW 0x6fffffff 347 | #define PT_HIOS 0x6fffffff /* Last OS-specific. */ 348 | #define PT_LOPROC 0x70000000 /* First processor-specific type. */ 349 | #define PT_HIPROC 0x7fffffff /* Last processor-specific type. */ 350 | 351 | /* Values for p_flags. */ 352 | #define PF_X 0x1 /* Executable. */ 353 | #define PF_W 0x2 /* Writable. */ 354 | #define PF_R 0x4 /* Readable. */ 355 | #define PF_MASKOS 0x0ff00000 /* Operating system-specific. */ 356 | #define PF_MASKPROC 0xf0000000 /* Processor-specific. */ 357 | 358 | /* Extended program header index. */ 359 | #define PN_XNUM 0xffff 360 | 361 | /* Values for d_tag. */ 362 | #define DT_NULL 0 /* Terminating entry. */ 363 | #define DT_NEEDED 1 /* String table offset of a needed shared 364 | library. */ 365 | #define DT_PLTRELSZ 2 /* Total size in bytes of PLT relocations. */ 366 | #define DT_PLTGOT 3 /* Processor-dependent address. */ 367 | #define DT_HASH 4 /* Address of symbol hash table. */ 368 | #define DT_STRTAB 5 /* Address of string table. */ 369 | #define DT_SYMTAB 6 /* Address of symbol table. */ 370 | #define DT_RELA 7 /* Address of ElfNN_Rela relocations. */ 371 | #define DT_RELASZ 8 /* Total size of ElfNN_Rela relocations. */ 372 | #define DT_RELAENT 9 /* Size of each ElfNN_Rela relocation entry. */ 373 | #define DT_STRSZ 10 /* Size of string table. */ 374 | #define DT_SYMENT 11 /* Size of each symbol table entry. */ 375 | #define DT_INIT 12 /* Address of initialization function. */ 376 | #define DT_FINI 13 /* Address of finalization function. */ 377 | #define DT_SONAME 14 /* String table offset of shared object 378 | name. */ 379 | #define DT_RPATH 15 /* String table offset of library path. [sup] */ 380 | #define DT_SYMBOLIC 16 /* Indicates "symbolic" linking. [sup] */ 381 | #define DT_REL 17 /* Address of ElfNN_Rel relocations. */ 382 | #define DT_RELSZ 18 /* Total size of ElfNN_Rel relocations. */ 383 | #define DT_RELENT 19 /* Size of each ElfNN_Rel relocation. */ 384 | #define DT_PLTREL 20 /* Type of relocation used for PLT. */ 385 | #define DT_DEBUG 21 /* Reserved (not used). */ 386 | #define DT_TEXTREL 22 /* Indicates there may be relocations in 387 | non-writable segments. [sup] */ 388 | #define DT_JMPREL 23 /* Address of PLT relocations. */ 389 | #define DT_BIND_NOW 24 /* [sup] */ 390 | #define DT_INIT_ARRAY 25 /* Address of the array of pointers to 391 | initialization functions */ 392 | #define DT_FINI_ARRAY 26 /* Address of the array of pointers to 393 | termination functions */ 394 | #define DT_INIT_ARRAYSZ 27 /* Size in bytes of the array of 395 | initialization functions. */ 396 | #define DT_FINI_ARRAYSZ 28 /* Size in bytes of the array of 397 | termination functions. */ 398 | #define DT_RUNPATH 29 /* String table offset of a null-terminated 399 | library search path string. */ 400 | #define DT_FLAGS 30 /* Object specific flag values. */ 401 | #define DT_ENCODING 32 /* Values greater than or equal to DT_ENCODING 402 | and less than DT_LOOS follow the rules for 403 | the interpretation of the d_un union 404 | as follows: even == 'd_ptr', odd == 'd_val' 405 | or none */ 406 | #define DT_PREINIT_ARRAY 32 /* Address of the array of pointers to 407 | pre-initialization functions. */ 408 | #define DT_PREINIT_ARRAYSZ 33 /* Size in bytes of the array of 409 | pre-initialization functions. */ 410 | #define DT_MAXPOSTAGS 34 /* number of positive tags */ 411 | #define DT_LOOS 0x6000000d /* First OS-specific */ 412 | #define DT_SUNW_AUXILIARY 0x6000000d /* symbol auxiliary name */ 413 | #define DT_SUNW_RTLDINF 0x6000000e /* ld.so.1 info (private) */ 414 | #define DT_SUNW_FILTER 0x6000000f /* symbol filter name */ 415 | #define DT_SUNW_CAP 0x60000010 /* hardware/software */ 416 | #define DT_HIOS 0x6ffff000 /* Last OS-specific */ 417 | 418 | /* 419 | * DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the 420 | * Dyn.d_un.d_val field of the Elf*_Dyn structure. 421 | */ 422 | #define DT_VALRNGLO 0x6ffffd00 423 | #define DT_CHECKSUM 0x6ffffdf8 /* elf checksum */ 424 | #define DT_PLTPADSZ 0x6ffffdf9 /* pltpadding size */ 425 | #define DT_MOVEENT 0x6ffffdfa /* move table entry size */ 426 | #define DT_MOVESZ 0x6ffffdfb /* move table size */ 427 | #define DT_FEATURE_1 0x6ffffdfc /* feature holder */ 428 | #define DT_POSFLAG_1 0x6ffffdfd /* flags for DT_* entries, effecting */ 429 | /* the following DT_* entry. */ 430 | /* See DF_P1_* definitions */ 431 | #define DT_SYMINSZ 0x6ffffdfe /* syminfo table size (in bytes) */ 432 | #define DT_SYMINENT 0x6ffffdff /* syminfo entry size (in bytes) */ 433 | #define DT_VALRNGHI 0x6ffffdff 434 | 435 | /* 436 | * DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the 437 | * Dyn.d_un.d_ptr field of the Elf*_Dyn structure. 438 | * 439 | * If any adjustment is made to the ELF object after it has been 440 | * built, these entries will need to be adjusted. 441 | */ 442 | #define DT_ADDRRNGLO 0x6ffffe00 443 | #define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table */ 444 | #define DT_CONFIG 0x6ffffefa /* configuration information */ 445 | #define DT_DEPAUDIT 0x6ffffefb /* dependency auditing */ 446 | #define DT_AUDIT 0x6ffffefc /* object auditing */ 447 | #define DT_PLTPAD 0x6ffffefd /* pltpadding (sparcv9) */ 448 | #define DT_MOVETAB 0x6ffffefe /* move table */ 449 | #define DT_SYMINFO 0x6ffffeff /* syminfo table */ 450 | #define DT_ADDRRNGHI 0x6ffffeff 451 | 452 | #define DT_VERSYM 0x6ffffff0 /* Address of versym section. */ 453 | #define DT_RELACOUNT 0x6ffffff9 /* number of RELATIVE relocations */ 454 | #define DT_RELCOUNT 0x6ffffffa /* number of RELATIVE relocations */ 455 | #define DT_FLAGS_1 0x6ffffffb /* state flags - see DF_1_* defs */ 456 | #define DT_VERDEF 0x6ffffffc /* Address of verdef section. */ 457 | #define DT_VERDEFNUM 0x6ffffffd /* Number of elems in verdef section */ 458 | #define DT_VERNEED 0x6ffffffe /* Address of verneed section. */ 459 | #define DT_VERNEEDNUM 0x6fffffff /* Number of elems in verneed section */ 460 | 461 | #define DT_LOPROC 0x70000000 /* First processor-specific type. */ 462 | #define DT_DEPRECATED_SPARC_REGISTER 0x7000001 463 | #define DT_AUXILIARY 0x7ffffffd /* shared library auxiliary name */ 464 | #define DT_USED 0x7ffffffe /* ignored - same as needed */ 465 | #define DT_FILTER 0x7fffffff /* shared library filter name */ 466 | #define DT_HIPROC 0x7fffffff /* Last processor-specific type. */ 467 | 468 | /* Values for DT_FLAGS */ 469 | #define DF_ORIGIN 0x0001 /* Indicates that the object being loaded may 470 | make reference to the $ORIGIN substitution 471 | string */ 472 | #define DF_SYMBOLIC 0x0002 /* Indicates "symbolic" linking. */ 473 | #define DF_TEXTREL 0x0004 /* Indicates there may be relocations in 474 | non-writable segments. */ 475 | #define DF_BIND_NOW 0x0008 /* Indicates that the dynamic linker should 476 | process all relocations for the object 477 | containing this entry before transferring 478 | control to the program. */ 479 | #define DF_STATIC_TLS 0x0010 /* Indicates that the shared object or 480 | executable contains code using a static 481 | thread-local storage scheme. */ 482 | 483 | /* Values for DT_FLAGS_1 */ 484 | #define DF_1_BIND_NOW 0x00000001 /* Same as DF_BIND_NOW */ 485 | #define DF_1_GLOBAL 0x00000002 /* Set the RTLD_GLOBAL for object */ 486 | #define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */ 487 | #define DF_1_LOADFLTR 0x00000010 /* Immediate loading of filtees */ 488 | #define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */ 489 | #define DF_1_ORIGIN 0x00000080 /* Process $ORIGIN */ 490 | #define DF_1_INTERPOSE 0x00000400 /* Interpose all objects but main */ 491 | #define DF_1_NODEFLIB 0x00000800 /* Do not search default paths */ 492 | 493 | /* Values for n_type. Used in core files. */ 494 | #define NT_PRSTATUS 1 /* Process status. */ 495 | #define NT_FPREGSET 2 /* Floating point registers. */ 496 | #define NT_PRPSINFO 3 /* Process state info. */ 497 | #define NT_THRMISC 7 /* Thread miscellaneous info. */ 498 | #define NT_PROCSTAT_PROC 8 /* Procstat proc data. */ 499 | #define NT_PROCSTAT_FILES 9 /* Procstat files data. */ 500 | #define NT_PROCSTAT_VMMAP 10 /* Procstat vmmap data. */ 501 | #define NT_PROCSTAT_GROUPS 11 /* Procstat groups data. */ 502 | #define NT_PROCSTAT_UMASK 12 /* Procstat umask data. */ 503 | #define NT_PROCSTAT_RLIMIT 13 /* Procstat rlimit data. */ 504 | #define NT_PROCSTAT_OSREL 14 /* Procstat osreldate data. */ 505 | #define NT_PROCSTAT_PSSTRINGS 15 /* Procstat ps_strings data. */ 506 | #define NT_PROCSTAT_AUXV 16 /* Procstat auxv data. */ 507 | 508 | /* Symbol Binding - ELFNN_ST_BIND - st_info */ 509 | #define STB_LOCAL 0 /* Local symbol */ 510 | #define STB_GLOBAL 1 /* Global symbol */ 511 | #define STB_WEAK 2 /* like global - lower precedence */ 512 | #define STB_LOOS 10 /* Reserved range for operating system */ 513 | #define STB_HIOS 12 /* specific semantics. */ 514 | #define STB_LOPROC 13 /* reserved range for processor */ 515 | #define STB_HIPROC 15 /* specific semantics. */ 516 | 517 | /* Symbol type - ELFNN_ST_TYPE - st_info */ 518 | #define STT_NOTYPE 0 /* Unspecified type. */ 519 | #define STT_OBJECT 1 /* Data object. */ 520 | #define STT_FUNC 2 /* Function. */ 521 | #define STT_SECTION 3 /* Section. */ 522 | #define STT_FILE 4 /* Source file. */ 523 | #define STT_COMMON 5 /* Uninitialized common block. */ 524 | #define STT_TLS 6 /* TLS object. */ 525 | #define STT_NUM 7 526 | #define STT_LOOS 10 /* Reserved range for operating system */ 527 | #define STT_GNU_IFUNC 10 528 | #define STT_HIOS 12 /* specific semantics. */ 529 | #define STT_LOPROC 13 /* reserved range for processor */ 530 | #define STT_HIPROC 15 /* specific semantics. */ 531 | 532 | /* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */ 533 | #define STV_DEFAULT 0x0 /* Default visibility (see binding). */ 534 | #define STV_INTERNAL 0x1 /* Special meaning in relocatable objects. */ 535 | #define STV_HIDDEN 0x2 /* Not visible. */ 536 | #define STV_PROTECTED 0x3 /* Visible but not preemptible. */ 537 | #define STV_EXPORTED 0x4 538 | #define STV_SINGLETON 0x5 539 | #define STV_ELIMINATE 0x6 540 | 541 | /* Special symbol table indexes. */ 542 | #define STN_UNDEF 0 /* Undefined symbol index. */ 543 | 544 | /* Symbol versioning flags. */ 545 | #define VER_DEF_CURRENT 1 546 | #define VER_DEF_IDX(x) VER_NDX(x) 547 | 548 | #define VER_FLG_BASE 0x01 549 | #define VER_FLG_WEAK 0x02 550 | 551 | #define VER_NEED_CURRENT 1 552 | #define VER_NEED_WEAK (1u << 15) 553 | #define VER_NEED_HIDDEN VER_NDX_HIDDEN 554 | #define VER_NEED_IDX(x) VER_NDX(x) 555 | 556 | #define VER_NDX_LOCAL 0 557 | #define VER_NDX_GLOBAL 1 558 | #define VER_NDX_GIVEN 2 559 | 560 | #define VER_NDX_HIDDEN (1u << 15) 561 | #define VER_NDX(x) ((x) & ~(1u << 15)) 562 | 563 | #define CA_SUNW_NULL 0 564 | #define CA_SUNW_HW_1 1 /* first hardware capabilities entry */ 565 | #define CA_SUNW_SF_1 2 /* first software capabilities entry */ 566 | 567 | /* 568 | * Syminfo flag values 569 | */ 570 | #define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association */ 571 | /* to object containing defn. */ 572 | #define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ 573 | #define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ 574 | #define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be */ 575 | /* lazily-loaded */ 576 | #define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to */ 577 | /* object containing defn. */ 578 | #define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference */ 579 | /* directly bind to this symbol */ 580 | #define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ 581 | #define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ 582 | 583 | /* 584 | * Syminfo.si_boundto values. 585 | */ 586 | #define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ 587 | #define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ 588 | #define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ 589 | #define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ 590 | #define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ 591 | 592 | /* 593 | * Syminfo version values. 594 | */ 595 | #define SYMINFO_NONE 0 /* Syminfo version */ 596 | #define SYMINFO_CURRENT 1 597 | #define SYMINFO_NUM 2 598 | 599 | /* 600 | * Relocation types. 601 | * 602 | * All machine architectures are defined here to allow tools on one to 603 | * handle others. 604 | */ 605 | 606 | #define R_386_NONE 0 /* No relocation. */ 607 | #define R_386_32 1 /* Add symbol value. */ 608 | #define R_386_PC32 2 /* Add PC-relative symbol value. */ 609 | #define R_386_GOT32 3 /* Add PC-relative GOT offset. */ 610 | #define R_386_PLT32 4 /* Add PC-relative PLT offset. */ 611 | #define R_386_COPY 5 /* Copy data from shared object. */ 612 | #define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */ 613 | #define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */ 614 | #define R_386_RELATIVE 8 /* Add load address of shared object. */ 615 | #define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */ 616 | #define R_386_GOTPC 10 /* Add PC-relative GOT table address. */ 617 | #define R_386_TLS_TPOFF 14 /* Negative offset in static TLS block */ 618 | #define R_386_TLS_IE 15 /* Absolute address of GOT for -ve static TLS */ 619 | #define R_386_TLS_GOTIE 16 /* GOT entry for negative static TLS block */ 620 | #define R_386_TLS_LE 17 /* Negative offset relative to static TLS */ 621 | #define R_386_TLS_GD 18 /* 32 bit offset to GOT (index,off) pair */ 622 | #define R_386_TLS_LDM 19 /* 32 bit offset to GOT (index,zero) pair */ 623 | #define R_386_TLS_GD_32 24 /* 32 bit offset to GOT (index,off) pair */ 624 | #define R_386_TLS_GD_PUSH 25 /* pushl instruction for Sun ABI GD sequence */ 625 | #define R_386_TLS_GD_CALL 26 /* call instruction for Sun ABI GD sequence */ 626 | #define R_386_TLS_GD_POP 27 /* popl instruction for Sun ABI GD sequence */ 627 | #define R_386_TLS_LDM_32 28 /* 32 bit offset to GOT (index,zero) pair */ 628 | #define R_386_TLS_LDM_PUSH 29 /* pushl instruction for Sun ABI LD sequence */ 629 | #define R_386_TLS_LDM_CALL 30 /* call instruction for Sun ABI LD sequence */ 630 | #define R_386_TLS_LDM_POP 31 /* popl instruction for Sun ABI LD sequence */ 631 | #define R_386_TLS_LDO_32 32 /* 32 bit offset from start of TLS block */ 632 | #define R_386_TLS_IE_32 33 /* 32 bit offset to GOT static TLS offset entry */ 633 | #define R_386_TLS_LE_32 34 /* 32 bit offset within static TLS block */ 634 | #define R_386_TLS_DTPMOD32 35 /* GOT entry containing TLS index */ 635 | #define R_386_TLS_DTPOFF32 36 /* GOT entry containing TLS offset */ 636 | #define R_386_TLS_TPOFF32 37 /* GOT entry of -ve static TLS offset */ 637 | #define R_386_IRELATIVE 42 /* PLT entry resolved indirectly at runtime */ 638 | 639 | #define R_ARM_NONE 0 /* No relocation. */ 640 | #define R_ARM_PC24 1 641 | #define R_ARM_ABS32 2 642 | #define R_ARM_REL32 3 643 | #define R_ARM_PC13 4 644 | #define R_ARM_ABS16 5 645 | #define R_ARM_ABS12 6 646 | #define R_ARM_THM_ABS5 7 647 | #define R_ARM_ABS8 8 648 | #define R_ARM_SBREL32 9 649 | #define R_ARM_THM_PC22 10 650 | #define R_ARM_THM_PC8 11 651 | #define R_ARM_AMP_VCALL9 12 652 | #define R_ARM_SWI24 13 653 | #define R_ARM_THM_SWI8 14 654 | #define R_ARM_XPC25 15 655 | #define R_ARM_THM_XPC22 16 656 | /* TLS relocations */ 657 | #define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ 658 | #define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ 659 | #define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ 660 | #define R_ARM_COPY 20 /* Copy data from shared object. */ 661 | #define R_ARM_GLOB_DAT 21 /* Set GOT entry to data address. */ 662 | #define R_ARM_JUMP_SLOT 22 /* Set GOT entry to code address. */ 663 | #define R_ARM_RELATIVE 23 /* Add load address of shared object. */ 664 | #define R_ARM_GOTOFF 24 /* Add GOT-relative symbol address. */ 665 | #define R_ARM_GOTPC 25 /* Add PC-relative GOT table address. */ 666 | #define R_ARM_GOT32 26 /* Add PC-relative GOT offset. */ 667 | #define R_ARM_PLT32 27 /* Add PC-relative PLT offset. */ 668 | #define R_ARM_GNU_VTENTRY 100 669 | #define R_ARM_GNU_VTINHERIT 101 670 | #define R_ARM_RSBREL32 250 671 | #define R_ARM_THM_RPC22 251 672 | #define R_ARM_RREL32 252 673 | #define R_ARM_RABS32 253 674 | #define R_ARM_RPC24 254 675 | #define R_ARM_RBASE 255 676 | 677 | /* Name Value Field Calculation */ 678 | #define R_IA_64_NONE 0 /* None */ 679 | #define R_IA_64_IMM14 0x21 /* immediate14 S + A */ 680 | #define R_IA_64_IMM22 0x22 /* immediate22 S + A */ 681 | #define R_IA_64_IMM64 0x23 /* immediate64 S + A */ 682 | #define R_IA_64_DIR32MSB 0x24 /* word32 MSB S + A */ 683 | #define R_IA_64_DIR32LSB 0x25 /* word32 LSB S + A */ 684 | #define R_IA_64_DIR64MSB 0x26 /* word64 MSB S + A */ 685 | #define R_IA_64_DIR64LSB 0x27 /* word64 LSB S + A */ 686 | #define R_IA_64_GPREL22 0x2a /* immediate22 @gprel(S + A) */ 687 | #define R_IA_64_GPREL64I 0x2b /* immediate64 @gprel(S + A) */ 688 | #define R_IA_64_GPREL32MSB 0x2c /* word32 MSB @gprel(S + A) */ 689 | #define R_IA_64_GPREL32LSB 0x2d /* word32 LSB @gprel(S + A) */ 690 | #define R_IA_64_GPREL64MSB 0x2e /* word64 MSB @gprel(S + A) */ 691 | #define R_IA_64_GPREL64LSB 0x2f /* word64 LSB @gprel(S + A) */ 692 | #define R_IA_64_LTOFF22 0x32 /* immediate22 @ltoff(S + A) */ 693 | #define R_IA_64_LTOFF64I 0x33 /* immediate64 @ltoff(S + A) */ 694 | #define R_IA_64_PLTOFF22 0x3a /* immediate22 @pltoff(S + A) */ 695 | #define R_IA_64_PLTOFF64I 0x3b /* immediate64 @pltoff(S + A) */ 696 | #define R_IA_64_PLTOFF64MSB 0x3e /* word64 MSB @pltoff(S + A) */ 697 | #define R_IA_64_PLTOFF64LSB 0x3f /* word64 LSB @pltoff(S + A) */ 698 | #define R_IA_64_FPTR64I 0x43 /* immediate64 @fptr(S + A) */ 699 | #define R_IA_64_FPTR32MSB 0x44 /* word32 MSB @fptr(S + A) */ 700 | #define R_IA_64_FPTR32LSB 0x45 /* word32 LSB @fptr(S + A) */ 701 | #define R_IA_64_FPTR64MSB 0x46 /* word64 MSB @fptr(S + A) */ 702 | #define R_IA_64_FPTR64LSB 0x47 /* word64 LSB @fptr(S + A) */ 703 | #define R_IA_64_PCREL60B 0x48 /* immediate60 form1 S + A - P */ 704 | #define R_IA_64_PCREL21B 0x49 /* immediate21 form1 S + A - P */ 705 | #define R_IA_64_PCREL21M 0x4a /* immediate21 form2 S + A - P */ 706 | #define R_IA_64_PCREL21F 0x4b /* immediate21 form3 S + A - P */ 707 | #define R_IA_64_PCREL32MSB 0x4c /* word32 MSB S + A - P */ 708 | #define R_IA_64_PCREL32LSB 0x4d /* word32 LSB S + A - P */ 709 | #define R_IA_64_PCREL64MSB 0x4e /* word64 MSB S + A - P */ 710 | #define R_IA_64_PCREL64LSB 0x4f /* word64 LSB S + A - P */ 711 | #define R_IA_64_LTOFF_FPTR22 0x52 /* immediate22 @ltoff(@fptr(S + A)) */ 712 | #define R_IA_64_LTOFF_FPTR64I 0x53 /* immediate64 @ltoff(@fptr(S + A)) */ 713 | #define R_IA_64_LTOFF_FPTR32MSB 0x54 /* word32 MSB @ltoff(@fptr(S + A)) */ 714 | #define R_IA_64_LTOFF_FPTR32LSB 0x55 /* word32 LSB @ltoff(@fptr(S + A)) */ 715 | #define R_IA_64_LTOFF_FPTR64MSB 0x56 /* word64 MSB @ltoff(@fptr(S + A)) */ 716 | #define R_IA_64_LTOFF_FPTR64LSB 0x57 /* word64 LSB @ltoff(@fptr(S + A)) */ 717 | #define R_IA_64_SEGREL32MSB 0x5c /* word32 MSB @segrel(S + A) */ 718 | #define R_IA_64_SEGREL32LSB 0x5d /* word32 LSB @segrel(S + A) */ 719 | #define R_IA_64_SEGREL64MSB 0x5e /* word64 MSB @segrel(S + A) */ 720 | #define R_IA_64_SEGREL64LSB 0x5f /* word64 LSB @segrel(S + A) */ 721 | #define R_IA_64_SECREL32MSB 0x64 /* word32 MSB @secrel(S + A) */ 722 | #define R_IA_64_SECREL32LSB 0x65 /* word32 LSB @secrel(S + A) */ 723 | #define R_IA_64_SECREL64MSB 0x66 /* word64 MSB @secrel(S + A) */ 724 | #define R_IA_64_SECREL64LSB 0x67 /* word64 LSB @secrel(S + A) */ 725 | #define R_IA_64_REL32MSB 0x6c /* word32 MSB BD + A */ 726 | #define R_IA_64_REL32LSB 0x6d /* word32 LSB BD + A */ 727 | #define R_IA_64_REL64MSB 0x6e /* word64 MSB BD + A */ 728 | #define R_IA_64_REL64LSB 0x6f /* word64 LSB BD + A */ 729 | #define R_IA_64_LTV32MSB 0x74 /* word32 MSB S + A */ 730 | #define R_IA_64_LTV32LSB 0x75 /* word32 LSB S + A */ 731 | #define R_IA_64_LTV64MSB 0x76 /* word64 MSB S + A */ 732 | #define R_IA_64_LTV64LSB 0x77 /* word64 LSB S + A */ 733 | #define R_IA_64_PCREL21BI 0x79 /* immediate21 form1 S + A - P */ 734 | #define R_IA_64_PCREL22 0x7a /* immediate22 S + A - P */ 735 | #define R_IA_64_PCREL64I 0x7b /* immediate64 S + A - P */ 736 | #define R_IA_64_IPLTMSB 0x80 /* function descriptor MSB special */ 737 | #define R_IA_64_IPLTLSB 0x81 /* function descriptor LSB speciaal */ 738 | #define R_IA_64_SUB 0x85 /* immediate64 A - S */ 739 | #define R_IA_64_LTOFF22X 0x86 /* immediate22 special */ 740 | #define R_IA_64_LDXMOV 0x87 /* immediate22 special */ 741 | #define R_IA_64_TPREL14 0x91 /* imm14 @tprel(S + A) */ 742 | #define R_IA_64_TPREL22 0x92 /* imm22 @tprel(S + A) */ 743 | #define R_IA_64_TPREL64I 0x93 /* imm64 @tprel(S + A) */ 744 | #define R_IA_64_TPREL64MSB 0x96 /* word64 MSB @tprel(S + A) */ 745 | #define R_IA_64_TPREL64LSB 0x97 /* word64 LSB @tprel(S + A) */ 746 | #define R_IA_64_LTOFF_TPREL22 0x9a /* imm22 @ltoff(@tprel(S+A)) */ 747 | #define R_IA_64_DTPMOD64MSB 0xa6 /* word64 MSB @dtpmod(S + A) */ 748 | #define R_IA_64_DTPMOD64LSB 0xa7 /* word64 LSB @dtpmod(S + A) */ 749 | #define R_IA_64_LTOFF_DTPMOD22 0xaa /* imm22 @ltoff(@dtpmod(S+A)) */ 750 | #define R_IA_64_DTPREL14 0xb1 /* imm14 @dtprel(S + A) */ 751 | #define R_IA_64_DTPREL22 0xb2 /* imm22 @dtprel(S + A) */ 752 | #define R_IA_64_DTPREL64I 0xb3 /* imm64 @dtprel(S + A) */ 753 | #define R_IA_64_DTPREL32MSB 0xb4 /* word32 MSB @dtprel(S + A) */ 754 | #define R_IA_64_DTPREL32LSB 0xb5 /* word32 LSB @dtprel(S + A) */ 755 | #define R_IA_64_DTPREL64MSB 0xb6 /* word64 MSB @dtprel(S + A) */ 756 | #define R_IA_64_DTPREL64LSB 0xb7 /* word64 LSB @dtprel(S + A) */ 757 | #define R_IA_64_LTOFF_DTPREL22 0xba /* imm22 @ltoff(@dtprel(S+A)) */ 758 | 759 | #define R_MIPS_NONE 0 /* No reloc */ 760 | #define R_MIPS_16 1 /* Direct 16 bit */ 761 | #define R_MIPS_32 2 /* Direct 32 bit */ 762 | #define R_MIPS_REL32 3 /* PC relative 32 bit */ 763 | #define R_MIPS_26 4 /* Direct 26 bit shifted */ 764 | #define R_MIPS_HI16 5 /* High 16 bit */ 765 | #define R_MIPS_LO16 6 /* Low 16 bit */ 766 | #define R_MIPS_GPREL16 7 /* GP relative 16 bit */ 767 | #define R_MIPS_LITERAL 8 /* 16 bit literal entry */ 768 | #define R_MIPS_GOT16 9 /* 16 bit GOT entry */ 769 | #define R_MIPS_PC16 10 /* PC relative 16 bit */ 770 | #define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ 771 | #define R_MIPS_GPREL32 12 /* GP relative 32 bit */ 772 | #define R_MIPS_GOTHI16 21 /* GOT HI 16 bit */ 773 | #define R_MIPS_GOTLO16 22 /* GOT LO 16 bit */ 774 | #define R_MIPS_CALLHI16 30 /* upper 16 bit GOT entry for function */ 775 | #define R_MIPS_CALLLO16 31 /* lower 16 bit GOT entry for function */ 776 | 777 | #define R_PPC_NONE 0 /* No relocation. */ 778 | #define R_PPC_ADDR32 1 779 | #define R_PPC_ADDR24 2 780 | #define R_PPC_ADDR16 3 781 | #define R_PPC_ADDR16_LO 4 782 | #define R_PPC_ADDR16_HI 5 783 | #define R_PPC_ADDR16_HA 6 784 | #define R_PPC_ADDR14 7 785 | #define R_PPC_ADDR14_BRTAKEN 8 786 | #define R_PPC_ADDR14_BRNTAKEN 9 787 | #define R_PPC_REL24 10 788 | #define R_PPC_REL14 11 789 | #define R_PPC_REL14_BRTAKEN 12 790 | #define R_PPC_REL14_BRNTAKEN 13 791 | #define R_PPC_GOT16 14 792 | #define R_PPC_GOT16_LO 15 793 | #define R_PPC_GOT16_HI 16 794 | #define R_PPC_GOT16_HA 17 795 | #define R_PPC_PLTREL24 18 796 | #define R_PPC_COPY 19 797 | #define R_PPC_GLOB_DAT 20 798 | #define R_PPC_JMP_SLOT 21 799 | #define R_PPC_RELATIVE 22 800 | #define R_PPC_LOCAL24PC 23 801 | #define R_PPC_UADDR32 24 802 | #define R_PPC_UADDR16 25 803 | #define R_PPC_REL32 26 804 | #define R_PPC_PLT32 27 805 | #define R_PPC_PLTREL32 28 806 | #define R_PPC_PLT16_LO 29 807 | #define R_PPC_PLT16_HI 30 808 | #define R_PPC_PLT16_HA 31 809 | #define R_PPC_SDAREL16 32 810 | #define R_PPC_SECTOFF 33 811 | #define R_PPC_SECTOFF_LO 34 812 | #define R_PPC_SECTOFF_HI 35 813 | #define R_PPC_SECTOFF_HA 36 814 | 815 | /* 816 | * 64-bit relocations 817 | */ 818 | #define R_PPC64_ADDR64 38 819 | #define R_PPC64_ADDR16_HIGHER 39 820 | #define R_PPC64_ADDR16_HIGHERA 40 821 | #define R_PPC64_ADDR16_HIGHEST 41 822 | #define R_PPC64_ADDR16_HIGHESTA 42 823 | #define R_PPC64_UADDR64 43 824 | #define R_PPC64_REL64 44 825 | #define R_PPC64_PLT64 45 826 | #define R_PPC64_PLTREL64 46 827 | #define R_PPC64_TOC16 47 828 | #define R_PPC64_TOC16_LO 48 829 | #define R_PPC64_TOC16_HI 49 830 | #define R_PPC64_TOC16_HA 50 831 | #define R_PPC64_TOC 51 832 | #define R_PPC64_DTPMOD64 68 833 | #define R_PPC64_TPREL64 73 834 | #define R_PPC64_DTPREL64 78 835 | 836 | /* 837 | * TLS relocations 838 | */ 839 | #define R_PPC_TLS 67 840 | #define R_PPC_DTPMOD32 68 841 | #define R_PPC_TPREL16 69 842 | #define R_PPC_TPREL16_LO 70 843 | #define R_PPC_TPREL16_HI 71 844 | #define R_PPC_TPREL16_HA 72 845 | #define R_PPC_TPREL32 73 846 | #define R_PPC_DTPREL16 74 847 | #define R_PPC_DTPREL16_LO 75 848 | #define R_PPC_DTPREL16_HI 76 849 | #define R_PPC_DTPREL16_HA 77 850 | #define R_PPC_DTPREL32 78 851 | #define R_PPC_GOT_TLSGD16 79 852 | #define R_PPC_GOT_TLSGD16_LO 80 853 | #define R_PPC_GOT_TLSGD16_HI 81 854 | #define R_PPC_GOT_TLSGD16_HA 82 855 | #define R_PPC_GOT_TLSLD16 83 856 | #define R_PPC_GOT_TLSLD16_LO 84 857 | #define R_PPC_GOT_TLSLD16_HI 85 858 | #define R_PPC_GOT_TLSLD16_HA 86 859 | #define R_PPC_GOT_TPREL16 87 860 | #define R_PPC_GOT_TPREL16_LO 88 861 | #define R_PPC_GOT_TPREL16_HI 89 862 | #define R_PPC_GOT_TPREL16_HA 90 863 | 864 | /* 865 | * The remaining relocs are from the Embedded ELF ABI, and are not in the 866 | * SVR4 ELF ABI. 867 | */ 868 | 869 | #define R_PPC_EMB_NADDR32 101 870 | #define R_PPC_EMB_NADDR16 102 871 | #define R_PPC_EMB_NADDR16_LO 103 872 | #define R_PPC_EMB_NADDR16_HI 104 873 | #define R_PPC_EMB_NADDR16_HA 105 874 | #define R_PPC_EMB_SDAI16 106 875 | #define R_PPC_EMB_SDA2I16 107 876 | #define R_PPC_EMB_SDA2REL 108 877 | #define R_PPC_EMB_SDA21 109 878 | #define R_PPC_EMB_MRKREF 110 879 | #define R_PPC_EMB_RELSEC16 111 880 | #define R_PPC_EMB_RELST_LO 112 881 | #define R_PPC_EMB_RELST_HI 113 882 | #define R_PPC_EMB_RELST_HA 114 883 | #define R_PPC_EMB_BIT_FLD 115 884 | #define R_PPC_EMB_RELSDA 116 885 | 886 | #define R_SPARC_NONE 0 887 | #define R_SPARC_8 1 888 | #define R_SPARC_16 2 889 | #define R_SPARC_32 3 890 | #define R_SPARC_DISP8 4 891 | #define R_SPARC_DISP16 5 892 | #define R_SPARC_DISP32 6 893 | #define R_SPARC_WDISP30 7 894 | #define R_SPARC_WDISP22 8 895 | #define R_SPARC_HI22 9 896 | #define R_SPARC_22 10 897 | #define R_SPARC_13 11 898 | #define R_SPARC_LO10 12 899 | #define R_SPARC_GOT10 13 900 | #define R_SPARC_GOT13 14 901 | #define R_SPARC_GOT22 15 902 | #define R_SPARC_PC10 16 903 | #define R_SPARC_PC22 17 904 | #define R_SPARC_WPLT30 18 905 | #define R_SPARC_COPY 19 906 | #define R_SPARC_GLOB_DAT 20 907 | #define R_SPARC_JMP_SLOT 21 908 | #define R_SPARC_RELATIVE 22 909 | #define R_SPARC_UA32 23 910 | #define R_SPARC_PLT32 24 911 | #define R_SPARC_HIPLT22 25 912 | #define R_SPARC_LOPLT10 26 913 | #define R_SPARC_PCPLT32 27 914 | #define R_SPARC_PCPLT22 28 915 | #define R_SPARC_PCPLT10 29 916 | #define R_SPARC_10 30 917 | #define R_SPARC_11 31 918 | #define R_SPARC_64 32 919 | #define R_SPARC_OLO10 33 920 | #define R_SPARC_HH22 34 921 | #define R_SPARC_HM10 35 922 | #define R_SPARC_LM22 36 923 | #define R_SPARC_PC_HH22 37 924 | #define R_SPARC_PC_HM10 38 925 | #define R_SPARC_PC_LM22 39 926 | #define R_SPARC_WDISP16 40 927 | #define R_SPARC_WDISP19 41 928 | #define R_SPARC_GLOB_JMP 42 929 | #define R_SPARC_7 43 930 | #define R_SPARC_5 44 931 | #define R_SPARC_6 45 932 | #define R_SPARC_DISP64 46 933 | #define R_SPARC_PLT64 47 934 | #define R_SPARC_HIX22 48 935 | #define R_SPARC_LOX10 49 936 | #define R_SPARC_H44 50 937 | #define R_SPARC_M44 51 938 | #define R_SPARC_L44 52 939 | #define R_SPARC_REGISTER 53 940 | #define R_SPARC_UA64 54 941 | #define R_SPARC_UA16 55 942 | #define R_SPARC_TLS_GD_HI22 56 943 | #define R_SPARC_TLS_GD_LO10 57 944 | #define R_SPARC_TLS_GD_ADD 58 945 | #define R_SPARC_TLS_GD_CALL 59 946 | #define R_SPARC_TLS_LDM_HI22 60 947 | #define R_SPARC_TLS_LDM_LO10 61 948 | #define R_SPARC_TLS_LDM_ADD 62 949 | #define R_SPARC_TLS_LDM_CALL 63 950 | #define R_SPARC_TLS_LDO_HIX22 64 951 | #define R_SPARC_TLS_LDO_LOX10 65 952 | #define R_SPARC_TLS_LDO_ADD 66 953 | #define R_SPARC_TLS_IE_HI22 67 954 | #define R_SPARC_TLS_IE_LO10 68 955 | #define R_SPARC_TLS_IE_LD 69 956 | #define R_SPARC_TLS_IE_LDX 70 957 | #define R_SPARC_TLS_IE_ADD 71 958 | #define R_SPARC_TLS_LE_HIX22 72 959 | #define R_SPARC_TLS_LE_LOX10 73 960 | #define R_SPARC_TLS_DTPMOD32 74 961 | #define R_SPARC_TLS_DTPMOD64 75 962 | #define R_SPARC_TLS_DTPOFF32 76 963 | #define R_SPARC_TLS_DTPOFF64 77 964 | #define R_SPARC_TLS_TPOFF32 78 965 | #define R_SPARC_TLS_TPOFF64 79 966 | 967 | #define R_X86_64_NONE 0 /* No relocation. */ 968 | #define R_X86_64_64 1 /* Add 64 bit symbol value. */ 969 | #define R_X86_64_PC32 2 /* PC-relative 32 bit signed sym value. */ 970 | #define R_X86_64_GOT32 3 /* PC-relative 32 bit GOT offset. */ 971 | #define R_X86_64_PLT32 4 /* PC-relative 32 bit PLT offset. */ 972 | #define R_X86_64_COPY 5 /* Copy data from shared object. */ 973 | #define R_X86_64_GLOB_DAT 6 /* Set GOT entry to data address. */ 974 | #define R_X86_64_JMP_SLOT 7 /* Set GOT entry to code address. */ 975 | #define R_X86_64_RELATIVE 8 /* Add load address of shared object. */ 976 | #define R_X86_64_GOTPCREL 9 /* Add 32 bit signed pcrel offset to GOT. */ 977 | #define R_X86_64_32 10 /* Add 32 bit zero extended symbol value */ 978 | #define R_X86_64_32S 11 /* Add 32 bit sign extended symbol value */ 979 | #define R_X86_64_16 12 /* Add 16 bit zero extended symbol value */ 980 | #define R_X86_64_PC16 13 /* Add 16 bit signed extended pc relative symbol value */ 981 | #define R_X86_64_8 14 /* Add 8 bit zero extended symbol value */ 982 | #define R_X86_64_PC8 15 /* Add 8 bit signed extended pc relative symbol value */ 983 | #define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ 984 | #define R_X86_64_DTPOFF64 17 /* Offset in TLS block */ 985 | #define R_X86_64_TPOFF64 18 /* Offset in static TLS block */ 986 | #define R_X86_64_TLSGD 19 /* PC relative offset to GD GOT entry */ 987 | #define R_X86_64_TLSLD 20 /* PC relative offset to LD GOT entry */ 988 | #define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ 989 | #define R_X86_64_GOTTPOFF 22 /* PC relative offset to IE GOT entry */ 990 | #define R_X86_64_TPOFF32 23 /* Offset in static TLS block */ 991 | #define R_X86_64_IRELATIVE 37 992 | 993 | 994 | #endif /* !_SYS_ELF_COMMON_H_ */ 995 | --------------------------------------------------------------------------------