glibc-liblibos.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. diff --git a/Makeconfig b/Makeconfig
  2. index 1908f27..cf34ba1 100644
  3. --- a/Makeconfig
  4. +++ b/Makeconfig
  5. @@ -1033,7 +1034,7 @@ all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
  6. grp pwd posix io termios resource misc socket sysvipc gmon \
  7. gnulib iconv iconvdata wctype manual shadow gshadow po argp \
  8. crypt localedata timezone rt conform debug \
  9. - $(add-on-subdirs) dlfcn elf
  10. + $(add-on-subdirs) dlfcn elf libos
  11. ifndef avoid-generated
  12. # sysd-sorted itself will contain rules making the sysd-sorted target
  13. diff --git a/Versions.def b/Versions.def
  14. index 759c754..e1a270e 100644
  15. --- a/Versions.def
  16. +++ b/Versions.def
  17. @@ -148,3 +152,6 @@ libanl {
  18. libcidn {
  19. GLIBC_PRIVATE
  20. }
  21. +liblibos {
  22. + GLIBC_2.12
  23. +}
  24. diff --git a/shlib-versions b/shlib-versions
  25. index 78b0ad7..5c3dcf2 100644
  26. --- a/shlib-versions
  27. +++ b/shlib-versions
  28. @@ -108,3 +108,5 @@ sparc64.*-.*-.* libBrokenLocale=1 GLIBC_2.2
  29. # This defines the libgcc soname version this glibc is to load for
  30. # asynchronous cancellation to work correctly.
  31. .*-.*-.* libgcc_s=1
  32. +
  33. +.*-.*-.* liblibos=1
  34. diff --git a/libos/Makefile b/libos/Makefile
  35. new file mode 100644
  36. index 0000000..7e0027d
  37. --- /dev/null
  38. +++ b/libos/Makefile
  39. @@ -0,0 +1,56 @@
  40. +# Copyright (C) 1996-2001,2002,2003,2004,2005,2006
  41. +# Free Software Foundation, Inc.
  42. +# This file is part of the GNU C Library.
  43. +
  44. +# The GNU C Library is free software; you can redistribute it and/or
  45. +# modify it under the terms of the GNU Lesser General Public
  46. +# License as published by the Free Software Foundation; either
  47. +# version 2.1 of the License, or (at your option) any later version.
  48. +
  49. +# The GNU C Library is distributed in the hope that it will be useful,
  50. +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  51. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  52. +# Lesser General Public License for more details.
  53. +
  54. +# You should have received a copy of the GNU Lesser General Public
  55. +# License along with the GNU C Library; if not, write to the Free
  56. +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  57. +# 02111-1307 USA.
  58. +
  59. +# Makefile for the libos library.
  60. +
  61. +subdir := libos
  62. +
  63. +# Installed header files.
  64. +headers :=
  65. +
  66. +# Internal header files.
  67. +distribute := errno.h
  68. +
  69. +liblibos-routines := wrapper
  70. +
  71. +# Build the -llibos library.
  72. +
  73. +extra-libs := liblibos
  74. +extra-libs-others = $(extra-libs)
  75. +
  76. +include ../Makeconfig
  77. +
  78. +ifeq ($(versioning),yes)
  79. +liblibos-routines +=
  80. +liblibos-shared-only-routines :=
  81. +endif
  82. +
  83. +tests =
  84. +
  85. +modules-names =
  86. +
  87. +extra-test-objs += $(modules-names:=.os)
  88. +generated := $(modules-names:=.so)
  89. +
  90. +include ../Rules
  91. +
  92. +# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
  93. +# This ensures they will load libc.so for needed symbols if loaded by
  94. +# a statically-linked program that hasn't already loaded it.
  95. +$(objpfx)liblibos.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
  96. diff --git a/libos/Versions b/libos/Versions
  97. new file mode 100644
  98. index 0000000..3211637
  99. --- /dev/null
  100. +++ b/libos/Versions
  101. @@ -0,0 +1,8 @@
  102. +liblibos {
  103. + GLIBC_2.12 {
  104. + checkpoint;
  105. + sandbox_create; sandbox_attach; sandbox_current;
  106. + msgpersist;
  107. + benchmark_rpc; send_rpc; recv_rpc;
  108. + }
  109. +}
  110. diff --git a/libos/wrapper.c b/libos/wrapper.c
  111. new file mode 100644
  112. index 0000000..8785629
  113. --- /dev/null
  114. +++ b/libos/wrapper.c
  115. @@ -0,0 +1,62 @@
  116. +#include <errno.h>
  117. +#include <kernel-features.h>
  118. +#include <shim_unistd.h>
  119. +#include <sysdep.h>
  120. +#include <sysdep-cancel.h>
  121. +#include <sys/syscall.h>
  122. +
  123. +#ifdef __NR_checkpoint
  124. +int checkpoint (const char *filename)
  125. +{
  126. + return INLINE_SYSCALL (checkpoint, 1, filename);
  127. +}
  128. +#endif
  129. +
  130. +#ifdef __NR_sandbox_create
  131. +long sandbox_create(int flags, const char *fs_sb, struct net_sb *net_sb)
  132. +{
  133. + return INLINE_SYSCALL (sandbox_create, 3, flags, fs_sb, net_sb);
  134. +}
  135. +#endif
  136. +
  137. +#ifdef __NR_sandbox_attach
  138. +int sandbox_attach(unsigned int sbid)
  139. +{
  140. + return INLINE_SYSCALL (sandbox_attach, 1, sbid);
  141. +}
  142. +#endif
  143. +
  144. +#ifdef __NR_sandbox_current
  145. +long sandbox_current(void)
  146. +{
  147. + return INLINE_SYSCALL (sandbox_current, 0);
  148. +}
  149. +#endif
  150. +
  151. +#ifdef __NR_msgpersist
  152. +int msgpersist (int msqid, int cmd)
  153. +{
  154. + return INLINE_SYSCALL (msgpersist, 2, msqid, cmd);
  155. +}
  156. +#endif
  157. +
  158. +#ifdef __NR_benchmark_rpc
  159. +int benchmark_rpc(pid_t pid, int times, const void *buf, size_t size)
  160. +{
  161. + return INLINE_SYSCALL (benchmark_rpc, 4, pid, times, buf, size);
  162. +}
  163. +#endif
  164. +
  165. +#ifdef __NR_send_rpc
  166. +size_t send_rpc (pid_t pid, const void *buf, size_t size)
  167. +{
  168. + return INLINE_SYSCALL (send_rpc, 3, pid, buf, size);
  169. +}
  170. +#endif
  171. +
  172. +#ifdef __NR_recv_rpc
  173. +size_t recv_rpc (pid_t * pid, void *buf, size_t size)
  174. +{
  175. + return INLINE_SYSCALL (recv_rpc, 3, pid, buf, size);
  176. +}
  177. +#endif