summaryrefslogtreecommitdiff
path: root/REORG.TODO/sysdeps/generic
diff options
context:
space:
mode:
Diffstat (limited to 'REORG.TODO/sysdeps/generic')
-rw-r--r--REORG.TODO/sysdeps/generic/Makefile28
-rw-r--r--REORG.TODO/sysdeps/generic/_G_config.h58
-rw-r--r--REORG.TODO/sysdeps/generic/_itoa.h105
-rw-r--r--REORG.TODO/sysdeps/generic/a.out.h339
-rw-r--r--REORG.TODO/sysdeps/generic/abort-instr.h31
-rw-r--r--REORG.TODO/sysdeps/generic/aio_misc.h47
-rw-r--r--REORG.TODO/sysdeps/generic/allocalim.h4
-rw-r--r--REORG.TODO/sysdeps/generic/asm-syntax.h3
-rw-r--r--REORG.TODO/sysdeps/generic/atomic-machine.h42
-rw-r--r--REORG.TODO/sysdeps/generic/c++-types.data2
-rw-r--r--REORG.TODO/sysdeps/generic/confstr.h4
-rw-r--r--REORG.TODO/sysdeps/generic/device-nrs.h27
-rw-r--r--REORG.TODO/sysdeps/generic/dirstream.h29
-rw-r--r--REORG.TODO/sysdeps/generic/dl-cache.h104
-rw-r--r--REORG.TODO/sysdeps/generic/dl-dtprocnum.h21
-rw-r--r--REORG.TODO/sysdeps/generic/dl-dtv.h38
-rw-r--r--REORG.TODO/sysdeps/generic/dl-fcntl.h21
-rw-r--r--REORG.TODO/sysdeps/generic/dl-fileid.h46
-rw-r--r--REORG.TODO/sysdeps/generic/dl-fptr.h45
-rw-r--r--REORG.TODO/sysdeps/generic/dl-hash.h75
-rw-r--r--REORG.TODO/sysdeps/generic/dl-irel.h29
-rw-r--r--REORG.TODO/sysdeps/generic/dl-librecon.h25
-rw-r--r--REORG.TODO/sysdeps/generic/dl-lookupcfg.h28
-rw-r--r--REORG.TODO/sysdeps/generic/dl-machine.h133
-rw-r--r--REORG.TODO/sysdeps/generic/dl-mman.h22
-rw-r--r--REORG.TODO/sysdeps/generic/dl-osinfo.h59
-rw-r--r--REORG.TODO/sysdeps/generic/dl-procinfo.c1
-rw-r--r--REORG.TODO/sysdeps/generic/dl-procinfo.h42
-rw-r--r--REORG.TODO/sysdeps/generic/dl-sysdep.h34
-rw-r--r--REORG.TODO/sysdeps/generic/dl-tls.h2
-rw-r--r--REORG.TODO/sysdeps/generic/dl-unistd.h30
-rw-r--r--REORG.TODO/sysdeps/generic/dwarf2.h590
-rw-r--r--REORG.TODO/sysdeps/generic/elide.h25
-rw-r--r--REORG.TODO/sysdeps/generic/eloop-threshold.h72
-rw-r--r--REORG.TODO/sysdeps/generic/entry.h5
-rw-r--r--REORG.TODO/sysdeps/generic/errqueue.h7
-rw-r--r--REORG.TODO/sysdeps/generic/exit-thread.h28
-rw-r--r--REORG.TODO/sysdeps/generic/fd_to_filename.h25
-rw-r--r--REORG.TODO/sysdeps/generic/fips-private.h36
-rw-r--r--REORG.TODO/sysdeps/generic/fix-fp-int-compare-invalid.h27
-rw-r--r--REORG.TODO/sysdeps/generic/fix-fp-int-convert-overflow.h35
-rw-r--r--REORG.TODO/sysdeps/generic/fix-int-fp-convert-zero.h27
-rw-r--r--REORG.TODO/sysdeps/generic/fork.h8
-rw-r--r--REORG.TODO/sysdeps/generic/fpu_control.h38
-rw-r--r--REORG.TODO/sysdeps/generic/frame.h23
-rw-r--r--REORG.TODO/sysdeps/generic/framestate.c52
-rw-r--r--REORG.TODO/sysdeps/generic/gcc-compat.h42
-rw-r--r--REORG.TODO/sysdeps/generic/gccframe.h49
-rw-r--r--REORG.TODO/sysdeps/generic/get-rounding-mode.h125
-rw-r--r--REORG.TODO/sysdeps/generic/gmp-mparam.h27
-rw-r--r--REORG.TODO/sysdeps/generic/hp-timing-common.h62
-rw-r--r--REORG.TODO/sysdeps/generic/hp-timing.h40
-rw-r--r--REORG.TODO/sysdeps/generic/ifreq.h43
-rw-r--r--REORG.TODO/sysdeps/generic/ifunc-sel.h28
-rw-r--r--REORG.TODO/sysdeps/generic/intr-msg.h15
-rw-r--r--REORG.TODO/sysdeps/generic/inttypes.h434
-rw-r--r--REORG.TODO/sysdeps/generic/ld.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/ldconfig.h94
-rw-r--r--REORG.TODO/sysdeps/generic/ldsodefs.h1092
-rw-r--r--REORG.TODO/sysdeps/generic/libBrokenLocale.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libanl.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libc-lock.h140
-rw-r--r--REORG.TODO/sysdeps/generic/libc-mmap.h26
-rw-r--r--REORG.TODO/sysdeps/generic/libc-tsd.h60
-rw-r--r--REORG.TODO/sysdeps/generic/libc.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libcidn.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libcrypt.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libdl.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libm-test-ulps5
-rw-r--r--REORG.TODO/sysdeps/generic/libm-test-ulps-name1
-rw-r--r--REORG.TODO/sysdeps/generic/libm.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libnsl.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libnss_compat.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libnss_db.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libnss_dns.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libnss_files.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libnss_hesiod.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libnss_nis.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libnss_nisplus.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libpthread.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libresolv.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/librt.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/libutil.abilist0
-rw-r--r--REORG.TODO/sysdeps/generic/linkmap.h4
-rw-r--r--REORG.TODO/sysdeps/generic/local-setxid.h4
-rw-r--r--REORG.TODO/sysdeps/generic/localplt.data18
-rw-r--r--REORG.TODO/sysdeps/generic/machine-gmon.h47
-rw-r--r--REORG.TODO/sysdeps/generic/machine-lock.h63
-rw-r--r--REORG.TODO/sysdeps/generic/machine-sp.h35
-rw-r--r--REORG.TODO/sysdeps/generic/malloc-machine.h41
-rw-r--r--REORG.TODO/sysdeps/generic/malloc-sysdep.h28
-rw-r--r--REORG.TODO/sysdeps/generic/math-tests-arch.h24
-rw-r--r--REORG.TODO/sysdeps/generic/math-tests.h106
-rw-r--r--REORG.TODO/sysdeps/generic/math-type-macros-double.h53
-rw-r--r--REORG.TODO/sysdeps/generic/math-type-macros-float.h39
-rw-r--r--REORG.TODO/sysdeps/generic/math-type-macros-float128.h42
-rw-r--r--REORG.TODO/sysdeps/generic/math-type-macros-ldouble.h36
-rw-r--r--REORG.TODO/sysdeps/generic/math-type-macros.h137
-rw-r--r--REORG.TODO/sysdeps/generic/math_ldbl.h7
-rw-r--r--REORG.TODO/sysdeps/generic/math_ldbl_opt.h14
-rw-r--r--REORG.TODO/sysdeps/generic/math_private.h658
-rw-r--r--REORG.TODO/sysdeps/generic/math_private_calls.h124
-rw-r--r--REORG.TODO/sysdeps/generic/memcopy.h202
-rw-r--r--REORG.TODO/sysdeps/generic/memusage.h51
-rw-r--r--REORG.TODO/sysdeps/generic/nan-high-order-bit.h27
-rw-r--r--REORG.TODO/sysdeps/generic/net/if.h49
-rw-r--r--REORG.TODO/sysdeps/generic/netinet/if_ether.h32
-rw-r--r--REORG.TODO/sysdeps/generic/netinet/in_systm.h40
-rw-r--r--REORG.TODO/sysdeps/generic/netinet/ip.h302
-rw-r--r--REORG.TODO/sysdeps/generic/netinet/tcp.h108
-rw-r--r--REORG.TODO/sysdeps/generic/nfs/nfs.h31
-rw-r--r--REORG.TODO/sysdeps/generic/not-cancel.h54
-rw-r--r--REORG.TODO/sysdeps/generic/nscd-types.h21
-rw-r--r--REORG.TODO/sysdeps/generic/pagecopy.h37
-rw-r--r--REORG.TODO/sysdeps/generic/paths.h75
-rw-r--r--REORG.TODO/sysdeps/generic/profil-counter.h26
-rw-r--r--REORG.TODO/sysdeps/generic/pty-private.h45
-rw-r--r--REORG.TODO/sysdeps/generic/register-dump.h20
-rw-r--r--REORG.TODO/sysdeps/generic/rtld-lowlevel.h1
-rw-r--r--REORG.TODO/sysdeps/generic/safe-fatal.h37
-rw-r--r--REORG.TODO/sysdeps/generic/sigcontextinfo.h26
-rw-r--r--REORG.TODO/sysdeps/generic/siglist.h76
-rw-r--r--REORG.TODO/sysdeps/generic/sigset-cvt-mask.h63
-rw-r--r--REORG.TODO/sysdeps/generic/sigsetops.h77
-rw-r--r--REORG.TODO/sysdeps/generic/stackguard-macros.h12
-rw-r--r--REORG.TODO/sysdeps/generic/stackinfo.h20
-rw-r--r--REORG.TODO/sysdeps/generic/stdint.h329
-rw-r--r--REORG.TODO/sysdeps/generic/stdio-lock.h71
-rw-r--r--REORG.TODO/sysdeps/generic/string_private.h21
-rw-r--r--REORG.TODO/sysdeps/generic/symbol-hacks.h19
-rw-r--r--REORG.TODO/sysdeps/generic/sys/ptrace.h137
-rw-r--r--REORG.TODO/sysdeps/generic/sys/reboot.h9
-rw-r--r--REORG.TODO/sysdeps/generic/sys/socketvar.h3
-rw-r--r--REORG.TODO/sysdeps/generic/sys/swap.h32
-rw-r--r--REORG.TODO/sysdeps/generic/sys/syscall.h2
-rw-r--r--REORG.TODO/sysdeps/generic/sys/sysinfo.h40
-rw-r--r--REORG.TODO/sysdeps/generic/sys/ttydefaults.h100
-rw-r--r--REORG.TODO/sysdeps/generic/sys/ucontext.h44
-rw-r--r--REORG.TODO/sysdeps/generic/sysdep-cancel.h8
-rw-r--r--REORG.TODO/sysdeps/generic/sysdep.h97
-rw-r--r--REORG.TODO/sysdeps/generic/thread_state.h46
-rw-r--r--REORG.TODO/sysdeps/generic/tininess.h33
-rw-r--r--REORG.TODO/sysdeps/generic/tls-macros.h12
-rw-r--r--REORG.TODO/sysdeps/generic/tls.h74
-rw-r--r--REORG.TODO/sysdeps/generic/tst-audit.h11
-rw-r--r--REORG.TODO/sysdeps/generic/tst-stack-align.h34
-rw-r--r--REORG.TODO/sysdeps/generic/unsecvars.h34
-rw-r--r--REORG.TODO/sysdeps/generic/unwind-dw2-fde-glibc.c279
-rw-r--r--REORG.TODO/sysdeps/generic/unwind-dw2-fde.c1079
-rw-r--r--REORG.TODO/sysdeps/generic/unwind-dw2-fde.h169
-rw-r--r--REORG.TODO/sysdeps/generic/unwind-dw2.c1306
-rw-r--r--REORG.TODO/sysdeps/generic/unwind-pe.c5
-rw-r--r--REORG.TODO/sysdeps/generic/unwind-pe.h305
-rw-r--r--REORG.TODO/sysdeps/generic/unwind-resume.h33
-rw-r--r--REORG.TODO/sysdeps/generic/unwind.h219
-rw-r--r--REORG.TODO/sysdeps/generic/utmp-equal.h52
156 files changed, 12270 insertions, 0 deletions
diff --git a/REORG.TODO/sysdeps/generic/Makefile b/REORG.TODO/sysdeps/generic/Makefile
new file mode 100644
index 0000000000..ae37e8d89b
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/Makefile
@@ -0,0 +1,28 @@
+# Copyright (C) 1992-2017 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+ifeq ($(subdir),string)
+CFLAGS-wordcopy.c += -Wno-uninitialized
+endif
+
+ifeq ($(subdir),elf)
+ifeq (yes:yes,$(build-shared):$(unwind-find-fde))
+# This is needed to support g++ v2 and v3.
+sysdep_routines += framestate unwind-pe
+shared-only-routines += framestate unwind-pe
+endif
+endif
diff --git a/REORG.TODO/sysdeps/generic/_G_config.h b/REORG.TODO/sysdeps/generic/_G_config.h
new file mode 100644
index 0000000000..c49eed395b
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/_G_config.h
@@ -0,0 +1,58 @@
+/* This file is needed by libio to define various configuration parameters.
+ These are always the same in the GNU C library. */
+
+#ifndef _G_config_h
+#define _G_config_h 1
+
+/* Define types for libio in terms of the standard internal type names. */
+
+#include <bits/types.h>
+#define __need_size_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wchar_t
+#endif
+#define __need_NULL
+#include <stddef.h>
+
+#include <bits/types/__mbstate_t.h>
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# include <bits/types/wint_t.h>
+#endif
+
+typedef struct
+{
+ __off_t __pos;
+ __mbstate_t __state;
+} _G_fpos_t;
+typedef struct
+{
+ __off64_t __pos;
+ __mbstate_t __state;
+} _G_fpos64_t;
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# include <gconv.h>
+typedef union
+{
+ struct __gconv_info __cd;
+ struct
+ {
+ struct __gconv_info __cd;
+ struct __gconv_step_data __data;
+ } __combined;
+} _G_iconv_t;
+#endif
+
+
+/* These library features are always available in the GNU C library. */
+#define _G_va_list __gnuc_va_list
+
+#define _G_HAVE_MMAP 1
+
+#define _G_IO_IO_FILE_VERSION 0x20001
+
+/* This is defined by <bits/stat.h> if `st_blksize' exists. */
+#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)
+
+#define _G_BUFSIZ 8192
+
+#endif /* _G_config.h */
diff --git a/REORG.TODO/sysdeps/generic/_itoa.h b/REORG.TODO/sysdeps/generic/_itoa.h
new file mode 100644
index 0000000000..a065ecb890
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/_itoa.h
@@ -0,0 +1,105 @@
+/* Internal function for converting integers to ASCII.
+ Copyright (C) 1994-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _ITOA_H
+#define _ITOA_H
+
+#include <limits.h>
+
+/* When long long is different from long, by default, _itoa_word is
+ provided to convert long to ASCII and _itoa is provided to convert
+ long long. A sysdeps _itoa.h can define _ITOA_NEEDED to 0 and define
+ _ITOA_WORD_TYPE to unsigned long long int to override it so that
+ _itoa_word is changed to convert long long to ASCII and _itoa is
+ mapped to _itoa_word. */
+
+#ifndef _ITOA_NEEDED
+# define _ITOA_NEEDED (LONG_MAX != LLONG_MAX)
+#endif
+#ifndef _ITOA_WORD_TYPE
+# define _ITOA_WORD_TYPE unsigned long int
+#endif
+
+
+/* Convert VALUE into ASCII in base BASE (2..36).
+ Write backwards starting the character just before BUFLIM.
+ Return the address of the first (left-to-right) character in the number.
+ Use upper case letters iff UPPER_CASE is nonzero. */
+
+extern char *_itoa (unsigned long long int value, char *buflim,
+ unsigned int base, int upper_case) attribute_hidden;
+
+extern const char _itoa_upper_digits[];
+extern const char _itoa_lower_digits[];
+#if IS_IN (libc) || IS_IN (rtld)
+hidden_proto (_itoa_upper_digits)
+hidden_proto (_itoa_lower_digits)
+#endif
+
+#if IS_IN (libc)
+extern char *_itoa_word (_ITOA_WORD_TYPE value, char *buflim,
+ unsigned int base,
+ int upper_case) attribute_hidden;
+#else
+static inline char * __attribute__ ((unused, always_inline))
+_itoa_word (_ITOA_WORD_TYPE value, char *buflim,
+ unsigned int base, int upper_case)
+{
+ const char *digits = (upper_case
+ ? _itoa_upper_digits
+ : _itoa_lower_digits);
+
+ switch (base)
+ {
+# define SPECIAL(Base) \
+ case Base: \
+ do \
+ *--buflim = digits[value % Base]; \
+ while ((value /= Base) != 0); \
+ break
+
+ SPECIAL (10);
+ SPECIAL (16);
+ SPECIAL (8);
+ default:
+ do
+ *--buflim = digits[value % base];
+ while ((value /= base) != 0);
+ }
+ return buflim;
+}
+# undef SPECIAL
+#endif
+
+/* Similar to the _itoa functions, but output starts at buf and pointer
+ after the last written character is returned. */
+extern char *_fitoa_word (_ITOA_WORD_TYPE value, char *buf,
+ unsigned int base,
+ int upper_case) attribute_hidden;
+extern char *_fitoa (unsigned long long value, char *buf, unsigned int base,
+ int upper_case) attribute_hidden;
+
+#if !_ITOA_NEEDED
+/* No need for special long long versions. */
+# define _itoa(value, buf, base, upper_case) \
+ _itoa_word (value, buf, base, upper_case)
+# define _fitoa(value, buf, base, upper_case) \
+ _fitoa_word (value, buf, base, upper_case)
+#endif
+
+#endif /* itoa.h */
diff --git a/REORG.TODO/sysdeps/generic/a.out.h b/REORG.TODO/sysdeps/generic/a.out.h
new file mode 100644
index 0000000000..2c13762703
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/a.out.h
@@ -0,0 +1,339 @@
+#ifndef __A_OUT_GNU_H__
+#define __A_OUT_GNU_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __GNU_EXEC_MACROS__
+
+#ifndef __STRUCT_EXEC_OVERRIDE__
+
+struct exec
+{
+ unsigned long a_info; /* Use macros N_MAGIC, etc for access */
+ unsigned a_text; /* size of text, in bytes */
+ unsigned a_data; /* size of data, in bytes */
+ unsigned a_bss; /* size of uninitialized data area, in bytes */
+ unsigned a_syms; /* length of symbol table data, in bytes */
+ unsigned a_entry; /* start address */
+ unsigned a_trsize; /* size of reloc info for text, in bytes */
+ unsigned a_drsize; /* size of reloc info for data, in bytes */
+
+#if defined (sequent) && defined (i386)
+ struct gdtbl
+ { /* Global Descriptor Table */
+ unsigned g_code[2];
+ unsigned g_data[2];
+ unsigned g_desc[2];
+ } a_gdtbl;
+ unsigned a_shdata; /* size of initialized shared data */
+ unsigned a_shbss; /* size of uninitialized shared data */
+ unsigned a_shdrsize; /* size of shared data relocation */
+ unsigned a_bootstrap[11]; /* bootstrap for standalone */
+ unsigned a_reserved[3]; /* reserved for future use */
+ unsigned a_version; /* object version */
+#endif /* Sequent Symmetry, Dynix 3.x */
+};
+
+#endif /* __STRUCT_EXEC_OVERRIDE__ */
+
+/* these go in the N_MACHTYPE field */
+enum machine_type {
+#if defined (M_OLDSUN2)
+ M__OLDSUN2 = M_OLDSUN2,
+#else
+ M_OLDSUN2 = 0,
+#endif
+#if defined (M_68010)
+ M__68010 = M_68010,
+#else
+ M_68010 = 1,
+#endif
+#if defined (M_68020)
+ M__68020 = M_68020,
+#else
+ M_68020 = 2,
+#endif
+#if defined (M_SPARC)
+ M__SPARC = M_SPARC,
+#else
+ M_SPARC = 3,
+#endif
+ /* skip a bunch so we don't run into any of sun's numbers */
+ M_386 = 100
+};
+
+#if defined (sequent) && defined (i386)
+
+/* Dynix 3 wants the magic number to be the whole first longword. */
+
+#define N_MAGIC(exec) ((exec).a_info)
+#define N_MACHTYPE(exec) 0
+#define N_FLAGS(exec) 0
+#define N_SET_INFO(exec, magic, type, flags) N_SET_MAGIC ((exec), (magic))
+#define N_SET_MAGIC(exec, magic) ((exec).a_info = (magic))
+#define N_SET_MACHTYPE(exec, machtype) ((void) 0)
+#define N_SET_FLAGS(exec, flags) ((void) 0)
+#define OMAGIC 0x12eb /* impure format - for .o's */
+#define ZMAGIC 0x22eb /* demand load format - zero at zero */
+#define NMAGIC you lose /* syntax error -- no pure format */
+#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != ZMAGIC)
+#define N_ADDRADJ(x) (N_MAGIC(x) == ZMAGIC ? SEGMENT_SIZE : 0)
+#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text - N_ADDRADJ(x))
+#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data + (x).a_shdata)
+#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize + (x).a_shdrsize)
+#define N_TXTADDR(x) SEGMENT_SIZE
+#define N_COMM 0x0a /** conflicts with N_INDR **/
+#define N_FN 0x0c
+/* Note that the Dynix binutils believe that N_SET[TDB] are
+ N_SH{DATA,BSS,COMM} -- be wary when mixing GNU & Dynix objects. */
+#define PAGE_SIZE 4096
+#define SEGMENT_SIZE PAGE_SIZE
+
+#else /* !(sequent && i386) */
+
+#if !defined (N_MAGIC)
+#define N_MAGIC(exec) ((exec).a_info & 0xffff)
+#endif
+#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
+#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
+#define N_SET_INFO(exec, magic, type, flags) \
+ ((exec).a_info = ((magic) & 0xffff) \
+ | (((int)(type) & 0xff) << 16) \
+ | (((flags) & 0xff) << 24))
+#define N_SET_MAGIC(exec, magic) \
+ ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
+
+#define N_SET_MACHTYPE(exec, machtype) \
+ ((exec).a_info = \
+ ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
+
+#define N_SET_FLAGS(exec, flags) \
+ ((exec).a_info = \
+ ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
+
+#endif /* sequent && i386 */
+
+#ifndef OMAGIC
+/* Code indicating object file or impure executable. */
+#define OMAGIC 0407
+/* Code indicating pure executable. */
+#define NMAGIC 0410
+/* Code indicating demand-paged executable. */
+#define ZMAGIC 0413
+#endif /* not OMAGIC */
+
+#if !defined (N_BADMAG)
+#define N_BADMAG(x) \
+ (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
+ && N_MAGIC(x) != ZMAGIC)
+#endif
+
+#define _N_BADMAG(x) \
+ (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
+ && N_MAGIC(x) != ZMAGIC)
+
+#ifndef sparc
+#define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec))
+#else
+#define _N_HDROFF(x) (- sizeof (struct exec))
+#endif
+
+#if !defined (N_TXTOFF)
+#define N_TXTOFF(x) \
+ (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
+#endif
+
+#if !defined (N_DATOFF)
+#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
+#endif
+
+#if !defined (N_TRELOFF)
+#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
+#endif
+
+#if !defined (N_DRELOFF)
+#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
+#endif
+
+#if !defined (N_SYMOFF)
+#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
+#endif
+
+#if !defined (N_STROFF)
+#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
+#endif
+
+/* Address of text segment in memory after it is loaded. */
+#if !defined (N_TXTADDR)
+#define N_TXTADDR(x) 0
+#endif
+
+/* Address of data segment in memory after it is loaded.
+ Note that it is up to you to define SEGMENT_SIZE
+ on machines not listed here. */
+#if defined (hp300) || defined (mips)
+#define PAGE_SIZE 4096
+#endif
+#if defined (sparc) || defined (NeXT)
+#define PAGE_SIZE 0x2000
+#endif
+#if defined (sony) || (defined (sun) && defined (mc68000))
+#define SEGMENT_SIZE 0x2000
+#endif /* Sony or 68k Sun. */
+#ifdef is68k
+#define SEGMENT_SIZE 0x20000
+#endif
+#if defined(m68k) && defined(PORTAR)
+#define PAGE_SIZE 0x400
+#endif
+#if defined(i386) && !defined(sequent)
+/* For COFF encapsulation. */
+#define SEGMENT_SIZE 0x400000
+#endif
+#ifndef SEGMENT_SIZE
+/* This used to be first in this paragraph and under:
+ if (defined(vax) || defined(hp300) || defined(pyr) || defined(sparc) \
+ || (defined(m68k) && defined(PORTAR)) \
+ || defined (NeXT) || defined (mips)) */
+#define SEGMENT_SIZE PAGE_SIZE
+#endif
+#ifndef PAGE_SIZE
+/* This value is for i386-minix, but that has no predefine.
+ Making it default will only cause confusion on machines
+ which have no proper value defined. */
+#define PAGE_SIZE 16
+#endif
+
+#define PAGSIZ PAGE_SIZE
+#define SEGSIZ SEGMENT_SIZE
+
+#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
+
+#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
+
+#ifndef N_DATADDR
+#define N_DATADDR(x) \
+ (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
+ : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
+#endif
+
+/* Address of bss segment in memory after it is loaded. */
+#if !defined (N_BSSADDR)
+#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
+#endif
+
+#if !defined (N_NLIST_DECLARED)
+struct nlist {
+ union {
+ char *n_name;
+ struct nlist *n_next;
+ long n_strx;
+ } n_un;
+ unsigned char n_type;
+ char n_other;
+ short n_desc;
+ unsigned long n_value;
+};
+#endif /* no N_NLIST_DECLARED. */
+
+#if !defined (N_UNDF)
+#define N_UNDF 0
+#endif
+#if !defined (N_ABS)
+#define N_ABS 2
+#endif
+#if !defined (N_TEXT)
+#define N_TEXT 4
+#endif
+#if !defined (N_DATA)
+#define N_DATA 6
+#endif
+#if !defined (N_BSS)
+#define N_BSS 8
+#endif
+#if !defined (N_COMM)
+#define N_COMM 18
+#endif
+#if !defined (N_FN)
+#define N_FN 15
+#endif
+
+#if !defined (N_EXT)
+#define N_EXT 1
+#endif
+#if !defined (N_TYPE)
+#define N_TYPE 036
+#endif
+#if !defined (N_STAB)
+#define N_STAB 0340
+#endif
+
+/* The following type indicates the definition of a symbol as being
+ an indirect reference to another symbol. The other symbol
+ appears as an undefined reference, immediately following this symbol.
+
+ Indirection is asymmetrical. The other symbol's value will be used
+ to satisfy requests for the indirect symbol, but not vice versa.
+ If the other symbol does not have a definition, libraries will
+ be searched to find a definition. */
+#define N_INDR 0xa
+
+/* The following symbols refer to set elements.
+ All the N_SET[ATDB] symbols with the same name form one set.
+ Space is allocated for the set in the text section, and each set
+ element's value is stored into one word of the space.
+ The first word of the space is the length of the set (number of elements).
+
+ The address of the set is made into an N_SETV symbol
+ whose name is the same as the name of the set.
+ This symbol acts like a N_DATA global symbol
+ in that it can satisfy undefined external references. */
+
+/* These appear as input to LD, in a .o file. */
+#define N_SETA 0x14 /* Absolute set element symbol */
+#define N_SETT 0x16 /* Text set element symbol */
+#define N_SETD 0x18 /* Data set element symbol */
+#define N_SETB 0x1A /* Bss set element symbol */
+
+/* This is output from LD. */
+#define N_SETV 0x1C /* Pointer to set vector in data area. */
+
+#if !defined (N_RELOCATION_INFO_DECLARED)
+/* This structure describes a single relocation to be performed.
+ The text-relocation section of the file is a vector of these structures,
+ all of which apply to the text section.
+ Likewise, the data-relocation section applies to the data section. */
+
+struct relocation_info
+{
+ /* Address (within segment) to be relocated. */
+ int r_address;
+ /* The meaning of r_symbolnum depends on r_extern. */
+ unsigned int r_symbolnum:24;
+ /* Nonzero means value is a pc-relative offset
+ and it should be relocated for changes in its own address
+ as well as for changes in the symbol or section specified. */
+ unsigned int r_pcrel:1;
+ /* Length (as exponent of 2) of the field to be relocated.
+ Thus, a value of 2 indicates 1<<2 bytes. */
+ unsigned int r_length:2;
+ /* 1 => relocate with value of symbol.
+ r_symbolnum is the index of the symbol
+ in file's the symbol table.
+ 0 => relocate with the address of a segment.
+ r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
+ (the N_EXT bit may be set also, but signifies nothing). */
+ unsigned int r_extern:1;
+ /* Four bits that aren't used, but when writing an object file
+ it is desirable to clear them. */
+ unsigned int r_pad:4;
+};
+#endif /* no N_RELOCATION_INFO_DECLARED. */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __A_OUT_GNU_H__ */
diff --git a/REORG.TODO/sysdeps/generic/abort-instr.h b/REORG.TODO/sysdeps/generic/abort-instr.h
new file mode 100644
index 0000000000..3c4b8c0da3
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/abort-instr.h
@@ -0,0 +1,31 @@
+/* Magic instruction to crash quickly and reliably. Generic/stub version.
+ Copyright (C) 2014-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _ABORT_INSTR_H
+#define _ABORT_INSTR_H 1
+
+/* If the compiler provides the generic way to generate the right
+ instruction, we can use that without any machine-specific knowledge. */
+#if HAVE_BUILTIN_TRAP
+# define ABORT_INSTRUCTION __builtin_trap ()
+#else
+/* We cannot give any generic instruction to crash the program.
+ abort will have to make sure it never returns. */
+#endif
+
+#endif /* abort-instr.h */
diff --git a/REORG.TODO/sysdeps/generic/aio_misc.h b/REORG.TODO/sysdeps/generic/aio_misc.h
new file mode 100644
index 0000000000..a941a68aaa
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/aio_misc.h
@@ -0,0 +1,47 @@
+/* Internal declarations for <aio.h> functions implementation. Stub version.
+ Copyright (C) 2001-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _AIO_MISC_H
+#define _AIO_MISC_H 1
+
+#include <aio.h>
+
+
+/* Extend the operation enum. */
+enum
+{
+ LIO_DSYNC = LIO_READ + 1,
+ LIO_SYNC,
+ LIO_READ64 = LIO_READ | 128,
+ LIO_WRITE64 = LIO_WRITE | 128
+};
+
+/* Union of the two request types. */
+typedef union
+ {
+ struct aiocb aiocb;
+ struct aiocb64 aiocb64;
+ } aiocb_union;
+
+
+/* Send the signal. */
+extern int __aio_sigqueue (int sig, const union sigval val, pid_t caller_pid)
+ internal_function;
+
+
+#endif /* aio_misc.h */
diff --git a/REORG.TODO/sysdeps/generic/allocalim.h b/REORG.TODO/sysdeps/generic/allocalim.h
new file mode 100644
index 0000000000..2491129a7d
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/allocalim.h
@@ -0,0 +1,4 @@
+extern inline int __libc_use_alloca (size_t size)
+{
+ return size <= __MAX_ALLOCA_CUTOFF;
+}
diff --git a/REORG.TODO/sysdeps/generic/asm-syntax.h b/REORG.TODO/sysdeps/generic/asm-syntax.h
new file mode 100644
index 0000000000..a36150984f
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/asm-syntax.h
@@ -0,0 +1,3 @@
+/* On some machines the mpn function from GNU MP use a file called
+ "asm-syntax.h" to define macros for assembly source code to use. */
+
diff --git a/REORG.TODO/sysdeps/generic/atomic-machine.h b/REORG.TODO/sysdeps/generic/atomic-machine.h
new file mode 100644
index 0000000000..865326eaa4
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/atomic-machine.h
@@ -0,0 +1,42 @@
+/* Copyright (C) 2003-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _ATOMIC_MACHINE_H
+#define _ATOMIC_MACHINE_H 1
+
+/* We have by default no support for atomic operations. So define
+ them non-atomic. If this is a problem somebody will have to come
+ up with real definitions. */
+
+/* The only basic operation needed is compare and exchange. */
+#define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ ({ __typeof (mem) __gmemp = (mem); \
+ __typeof (*mem) __gret = *__gmemp; \
+ __typeof (*mem) __gnewval = (newval); \
+ \
+ if (__gret == (oldval)) \
+ *__gmemp = __gnewval; \
+ __gret; })
+
+#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ ({ __typeof (mem) __gmemp = (mem); \
+ __typeof (*mem) __gnewval = (newval); \
+ \
+ *__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; })
+
+#endif /* atomic-machine.h */
diff --git a/REORG.TODO/sysdeps/generic/c++-types.data b/REORG.TODO/sysdeps/generic/c++-types.data
new file mode 100644
index 0000000000..2ebe1f9abd
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/c++-types.data
@@ -0,0 +1,2 @@
+# This is a placeholder file. This configuration needs its own
+# sysdeps/.../c++-types.data file to make the test pass.
diff --git a/REORG.TODO/sysdeps/generic/confstr.h b/REORG.TODO/sysdeps/generic/confstr.h
new file mode 100644
index 0000000000..988ec88c0c
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/confstr.h
@@ -0,0 +1,4 @@
+/* This file should define values for the strings returned by `confstr'.
+ If _NAME is passed to `confstr', define NAME. */
+
+#define CS_PATH ""
diff --git a/REORG.TODO/sysdeps/generic/device-nrs.h b/REORG.TODO/sysdeps/generic/device-nrs.h
new file mode 100644
index 0000000000..5319e228c7
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/device-nrs.h
@@ -0,0 +1,27 @@
+/* Device numbers of devices used in the implementation. Generic version.
+ Copyright (C) 2000-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DEVICE_NRS_H
+#define _DEVICE_NRS_H 1
+
+/* By default we know no device numbers. */
+
+/* We cannot check whether a given device is a tty. */
+#define DEV_TTY_P(statp) (0)
+
+#endif /* device-nrs.h */
diff --git a/REORG.TODO/sysdeps/generic/dirstream.h b/REORG.TODO/sysdeps/generic/dirstream.h
new file mode 100644
index 0000000000..cadb41b347
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dirstream.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 1993-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DIRSTREAM_H
+
+#define _DIRSTREAM_H 1
+
+
+/* This file should define a type `struct __dirstream', the data type of
+ directory stream objects returned by `opendir'. */
+
+#error "No system-dependent definition of `struct __dirstream'."
+
+
+#endif /* dirstream.h */
diff --git a/REORG.TODO/sysdeps/generic/dl-cache.h b/REORG.TODO/sysdeps/generic/dl-cache.h
new file mode 100644
index 0000000000..1f0b8f629d
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-cache.h
@@ -0,0 +1,104 @@
+/* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
+ Copyright (C) 1999-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdint.h>
+
+#ifndef _DL_CACHE_DEFAULT_ID
+# define _DL_CACHE_DEFAULT_ID 3
+#endif
+
+#ifndef _dl_cache_check_flags
+# define _dl_cache_check_flags(flags) \
+ ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
+#endif
+
+#ifndef LD_SO_CACHE
+# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
+#endif
+
+#ifndef add_system_dir
+# define add_system_dir(dir) add_dir (dir)
+#endif
+
+#define CACHEMAGIC "ld.so-1.7.0"
+
+/* libc5 and glibc 2.0/2.1 use the same format. For glibc 2.2 another
+ format has been added in a compatible way:
+ The beginning of the string table is used for the new table:
+ old_magic
+ nlibs
+ libs[0]
+ ...
+ libs[nlibs-1]
+ pad, new magic needs to be aligned
+ - this is string[0] for the old format
+ new magic - this is string[0] for the new format
+ newnlibs
+ ...
+ newlibs[0]
+ ...
+ newlibs[newnlibs-1]
+ string 1
+ string 2
+ ...
+*/
+struct file_entry
+{
+ int flags; /* This is 1 for an ELF library. */
+ unsigned int key, value; /* String table indices. */
+};
+
+struct cache_file
+{
+ char magic[sizeof CACHEMAGIC - 1];
+ unsigned int nlibs;
+ struct file_entry libs[0];
+};
+
+#define CACHEMAGIC_NEW "glibc-ld.so.cache"
+#define CACHE_VERSION "1.1"
+#define CACHEMAGIC_VERSION_NEW CACHEMAGIC_NEW CACHE_VERSION
+
+
+struct file_entry_new
+{
+ int32_t flags; /* This is 1 for an ELF library. */
+ uint32_t key, value; /* String table indices. */
+ uint32_t osversion; /* Required OS version. */
+ uint64_t hwcap; /* Hwcap entry. */
+};
+
+struct cache_file_new
+{
+ char magic[sizeof CACHEMAGIC_NEW - 1];
+ char version[sizeof CACHE_VERSION - 1];
+ uint32_t nlibs; /* Number of entries. */
+ uint32_t len_strings; /* Size of string table. */
+ uint32_t unused[5]; /* Leave space for future extensions
+ and align to 8 byte boundary. */
+ struct file_entry_new libs[0]; /* Entries describing libraries. */
+ /* After this the string table of size len_strings is found. */
+};
+
+/* Used to align cache_file_new. */
+#define ALIGN_CACHE(addr) \
+(((addr) + __alignof__ (struct cache_file_new) -1) \
+ & (~(__alignof__ (struct cache_file_new) - 1)))
+
+extern int _dl_cache_libcmp (const char *p1, const char *p2)
+ internal_function attribute_hidden;
diff --git a/REORG.TODO/sysdeps/generic/dl-dtprocnum.h b/REORG.TODO/sysdeps/generic/dl-dtprocnum.h
new file mode 100644
index 0000000000..7b6fc86352
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-dtprocnum.h
@@ -0,0 +1,21 @@
+/* Configuration of lookup functions.
+ Copyright (C) 2000-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Number of extra dynamic section entries for this architecture. By
+ default there are none. */
+#define DT_THISPROCNUM 0
diff --git a/REORG.TODO/sysdeps/generic/dl-dtv.h b/REORG.TODO/sysdeps/generic/dl-dtv.h
new file mode 100644
index 0000000000..c9726620d6
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-dtv.h
@@ -0,0 +1,38 @@
+/* Generic declarations for DTV-based TLS handling in the dynamic linker.
+ Copyright (C) 2002-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DL_DTV_H
+#define _DL_DTV_H
+
+struct dtv_pointer
+{
+ void *val; /* Pointer to data, or TLS_DTV_UNALLOCATED. */
+ void *to_free; /* Unaligned pointer, for deallocation. */
+};
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct dtv_pointer pointer;
+} dtv_t;
+
+/* Value used for dtv entries for which the allocation is delayed. */
+#define TLS_DTV_UNALLOCATED ((void *) -1l)
+
+#endif /* _DLT_DTV_H */
diff --git a/REORG.TODO/sysdeps/generic/dl-fcntl.h b/REORG.TODO/sysdeps/generic/dl-fcntl.h
new file mode 100644
index 0000000000..29985439e3
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-fcntl.h
@@ -0,0 +1,21 @@
+/* Functions with hidden attribute internal to ld.so, which are declared
+ in include/fcntl.h. Generic version.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+extern __typeof (__open) __open attribute_hidden;
+extern __typeof (__fcntl) __fcntl attribute_hidden;
diff --git a/REORG.TODO/sysdeps/generic/dl-fileid.h b/REORG.TODO/sysdeps/generic/dl-fileid.h
new file mode 100644
index 0000000000..544ba953df
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-fileid.h
@@ -0,0 +1,46 @@
+/* File identity for the dynamic linker. Stub version.
+ Copyright (C) 2015-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdbool.h>
+
+/* This type stores whatever information is fetched by _dl_get_file_id
+ and compared by _dl_file_id_match_p. */
+struct r_file_id
+ {
+ /* In the stub version, we don't record anything at all. */
+ };
+
+/* Sample FD to fill in *ID. Returns true on success.
+ On error, returns false, with errno set. */
+static inline bool
+_dl_get_file_id (int fd __attribute__ ((unused)),
+ struct r_file_id *id __attribute__ ((unused)))
+{
+ return true;
+}
+
+/* Compare two results from _dl_get_file_id for equality.
+ It's crucial that this never return false-positive matches.
+ It's ideal that it never return false-negative mismatches either,
+ but lack of matches is survivable. */
+static inline bool
+_dl_file_id_match_p (const struct r_file_id *a __attribute__ ((unused)),
+ const struct r_file_id *b __attribute__ ((unused)))
+{
+ return false;
+}
diff --git a/REORG.TODO/sysdeps/generic/dl-fptr.h b/REORG.TODO/sysdeps/generic/dl-fptr.h
new file mode 100644
index 0000000000..b28b72842e
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-fptr.h
@@ -0,0 +1,45 @@
+/* Function descriptors. Generic version.
+ Copyright (C) 1995-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef dl_fptr_h
+#define dl_fptr_h 1
+
+/* An FDESC is a function descriptor. */
+
+struct fdesc
+ {
+ ElfW(Addr) ip; /* code entry point */
+ ElfW(Addr) gp; /* global pointer */
+ };
+
+struct fdesc_table
+ {
+ struct fdesc_table *next;
+ unsigned int len; /* # of entries in fdesc table */
+ volatile unsigned int first_unused; /* index of first available entry */
+ struct fdesc fdesc[0];
+ };
+
+struct link_map;
+
+extern ElfW(Addr) _dl_boot_fptr_table [];
+
+extern ElfW(Addr) _dl_make_fptr (struct link_map *, const ElfW(Sym) *,
+ ElfW(Addr));
+
+#endif /* !dl_fptr_h */
diff --git a/REORG.TODO/sysdeps/generic/dl-hash.h b/REORG.TODO/sysdeps/generic/dl-hash.h
new file mode 100644
index 0000000000..4524381647
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-hash.h
@@ -0,0 +1,75 @@
+/* Compute hash value for given string according to ELF standard.
+ Copyright (C) 1995-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DL_HASH_H
+#define _DL_HASH_H 1
+
+
+/* This is the hashing function specified by the ELF ABI. In the
+ first five operations no overflow is possible so we optimized it a
+ bit. */
+static unsigned int
+__attribute__ ((unused))
+_dl_elf_hash (const char *name_arg)
+{
+ const unsigned char *name = (const unsigned char *) name_arg;
+ unsigned long int hash = *name;
+ if (hash != 0 && name[1] != '\0')
+ {
+ hash = (hash << 4) + name[1];
+ if (name[2] != '\0')
+ {
+ hash = (hash << 4) + name[2];
+ if (name[3] != '\0')
+ {
+ hash = (hash << 4) + name[3];
+ if (name[4] != '\0')
+ {
+ hash = (hash << 4) + name[4];
+ name += 5;
+ while (*name != '\0')
+ {
+ unsigned long int hi;
+ hash = (hash << 4) + *name++;
+ hi = hash & 0xf0000000;
+
+ /* The algorithm specified in the ELF ABI is as
+ follows:
+
+ if (hi != 0)
+ hash ^= hi >> 24;
+
+ hash &= ~hi;
+
+ But the following is equivalent and a lot
+ faster, especially on modern processors. */
+
+ hash ^= hi >> 24;
+ }
+
+ /* Second part of the modified formula. This
+ operation can be lifted outside the loop. */
+ hash &= 0x0fffffff;
+ }
+ }
+ }
+ }
+ return hash;
+}
+
+#endif /* dl-hash.h */
diff --git a/REORG.TODO/sysdeps/generic/dl-irel.h b/REORG.TODO/sysdeps/generic/dl-irel.h
new file mode 100644
index 0000000000..ef98f9df50
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-irel.h
@@ -0,0 +1,29 @@
+/* Machine-dependent ELF indirect relocation inline functions.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DL_IREL_H
+#define _DL_IREL_H
+
+static inline DL_FIXUP_VALUE_TYPE
+__attribute ((always_inline))
+elf_ifunc_invoke (ElfW(Addr) addr)
+{
+ return ((DL_FIXUP_VALUE_TYPE (*) (void)) (addr)) ();
+}
+
+#endif /* dl-irel.h */
diff --git a/REORG.TODO/sysdeps/generic/dl-librecon.h b/REORG.TODO/sysdeps/generic/dl-librecon.h
new file mode 100644
index 0000000000..ecdc8df206
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-librecon.h
@@ -0,0 +1,25 @@
+/* Optional code to distinguish library flavours.
+ Copyright (C) 1998-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DL_LIBRECON_H
+#define _DL_LIBRECON_H 1
+
+/* In the general case we don't do anything. */
+
+#endif /* dl-librecon.h */
diff --git a/REORG.TODO/sysdeps/generic/dl-lookupcfg.h b/REORG.TODO/sysdeps/generic/dl-lookupcfg.h
new file mode 100644
index 0000000000..1f2f2e77d0
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-lookupcfg.h
@@ -0,0 +1,28 @@
+/* Configuration of lookup functions.
+ Copyright (C) 2002-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* The type of the return value of fixup/profile_fixup. */
+#define DL_FIXUP_VALUE_TYPE ElfW(Addr)
+/* Construct a value of type DL_FIXUP_VALUE_TYPE from a code address
+ and a link map. */
+#define DL_FIXUP_MAKE_VALUE(map, addr) (addr)
+/* Extract the code address from a value of type DL_FIXUP_MAKE_VALUE.
+ */
+#define DL_FIXUP_VALUE_CODE_ADDR(value) (value)
+#define DL_FIXUP_VALUE_ADDR(value) (value)
+#define DL_FIXUP_ADDR_VALUE(addr) (addr)
diff --git a/REORG.TODO/sysdeps/generic/dl-machine.h b/REORG.TODO/sysdeps/generic/dl-machine.h
new file mode 100644
index 0000000000..59749bd84f
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-machine.h
@@ -0,0 +1,133 @@
+/* Machine-dependent ELF dynamic relocation inline functions. Stub version.
+ Copyright (C) 1995-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define ELF_MACHINE_NAME "stub"
+
+#include <string.h>
+#include <link.h>
+
+
+/* Return nonzero iff ELF header is compatible with the running host. */
+static inline int
+elf_machine_matches_host (const Elf32_Ehdr *ehdr)
+{
+ switch (ehdr->e_machine)
+ {
+ default:
+ return 0;
+ }
+}
+
+
+/* Return the link-time address of _DYNAMIC. */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
+{
+#error "Damn, no _DYNAMIC"
+}
+
+
+/* Return the run-time load address of the shared object. */
+static inline Elf32_Addr
+elf_machine_load_address (void)
+{
+#error "Where am I?"
+}
+
+/* Fixup a PLT entry to bounce directly to the function at VALUE. */
+
+static inline Elf32_Addr
+elf_machine_fixup_plt (struct link_map *map, lookup_t t,
+ const Elf32_Rel *reloc,
+ Elf32_Addr *reloc_addr, Elf32_Addr value)
+{
+ return *reloc_addr = value;
+}
+
+/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
+ LOADADDR is the load address of the object; INFO is an array indexed
+ by DT_* of the .dynamic section info. */
+
+auto inline void
+__attribute__ ((always_inline))
+elf_machine_rel (Elf32_Addr loadaddr, Elf32_Dyn *info[DT_NUM],
+ const Elf32_Rel *reloc, const Elf32_Sym *sym,
+ Elf32_Addr (*resolve) (const Elf32_Sym **ref,
+ Elf32_Addr reloc_addr,
+ int noplt))
+{
+ Elf32_Addr *const reloc_addr = (Elf32_Addr *) reloc->r_offset;
+ Elf32_Addr loadbase;
+
+ switch (ELF32_R_TYPE (reloc->r_info))
+ {
+ case R_MACHINE_COPY:
+ loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0);
+ memcpy (reloc_addr, (void *) (loadbase + sym->st_value), sym->st_size);
+ break;
+ default:
+ _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 0);
+ break;
+ }
+}
+
+
+auto inline Elf32_Addr
+__attribute__ ((always_inline))
+elf_machine_rela (Elf32_Addr loadaddr, Elf32_Dyn *info[DT_NUM],
+ const Elf32_Rel *reloc, const Elf32_Sym *sym,
+ Elf32_Addr (*resolve) (const Elf32_Sym **ref,
+ Elf32_Addr reloc_addr,
+ int noplt))
+{
+ _dl_signal_error (0, "Elf32_Rela relocation requested -- unused on "
+ NULL, ELF_MACHINE_NAME);
+}
+
+
+/* Set up the loaded object described by L so its unrelocated PLT
+ entries will jump to the on-demand fixup code in dl-runtime.c. */
+
+static inline int
+elf_machine_runtime_setup (struct link_map *l, int lazy)
+{
+ extern void _dl_runtime_resolve (Elf32_Word);
+
+ if (lazy)
+ {
+ /* The GOT entries for functions in the PLT have not yet been filled
+ in. Their initial contents will arrange when called to push an
+ offset into the .rel.plt section, push _GLOBAL_OFFSET_TABLE_[1],
+ and then jump to _GLOBAL_OFFSET_TABLE[2]. */
+ Elf32_Addr *got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
+ got[1] = (Elf32_Addr) l; /* Identify this shared object. */
+
+ /* This function will get called to fix up the GOT entry indicated by
+ the offset on the stack, and then jump to the resolved address. */
+ got[2] = (Elf32_Addr) &_dl_runtime_resolve;
+ }
+
+ return lazy;
+}
+
+
+/* Initial entry point code for the dynamic linker.
+ The C function `_dl_start' is the real entry point;
+ its return value is the user program's entry point. */
+
+#define RTLD_START #error need some startup code
diff --git a/REORG.TODO/sysdeps/generic/dl-mman.h b/REORG.TODO/sysdeps/generic/dl-mman.h
new file mode 100644
index 0000000000..fbabde91e4
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-mman.h
@@ -0,0 +1,22 @@
+/* Functions with hidden attribute internal to ld.so, which are declared
+ in include/sys/mman.h. Generic version.
+ Copyright (C) 2015-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+extern __typeof (__mmap) __mmap attribute_hidden;
+extern __typeof (__mprotect) __mprotect attribute_hidden;
+extern __typeof (__munmap) __munmap attribute_hidden;
diff --git a/REORG.TODO/sysdeps/generic/dl-osinfo.h b/REORG.TODO/sysdeps/generic/dl-osinfo.h
new file mode 100644
index 0000000000..cdee4124d4
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-osinfo.h
@@ -0,0 +1,59 @@
+/* Operating system specific code for generic dynamic loader functions.
+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <endian.h>
+#include <stdint.h>
+
+static inline uintptr_t __attribute__ ((always_inline))
+_dl_setup_stack_chk_guard (void *dl_random)
+{
+ union
+ {
+ uintptr_t num;
+ unsigned char bytes[sizeof (uintptr_t)];
+ } ret = { 0 };
+
+ if (dl_random == NULL)
+ {
+ ret.bytes[sizeof (ret) - 1] = 255;
+ ret.bytes[sizeof (ret) - 2] = '\n';
+ }
+ else
+ {
+ memcpy (ret.bytes, dl_random, sizeof (ret));
+#if BYTE_ORDER == LITTLE_ENDIAN
+ ret.num &= ~(uintptr_t) 0xff;
+#elif BYTE_ORDER == BIG_ENDIAN
+ ret.num &= ~((uintptr_t) 0xff << (8 * (sizeof (ret) - 1)));
+#else
+# error "BYTE_ORDER unknown"
+#endif
+ }
+ return ret.num;
+}
+
+static inline uintptr_t __attribute__ ((always_inline))
+_dl_setup_pointer_guard (void *dl_random, uintptr_t stack_chk_guard)
+{
+ uintptr_t ret;
+ if (dl_random == NULL)
+ ret = stack_chk_guard;
+ else
+ memcpy (&ret, (char *) dl_random + sizeof (ret), sizeof (ret));
+ return ret;
+}
diff --git a/REORG.TODO/sysdeps/generic/dl-procinfo.c b/REORG.TODO/sysdeps/generic/dl-procinfo.c
new file mode 100644
index 0000000000..a056184690
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-procinfo.c
@@ -0,0 +1 @@
+/* No architecture specific definitions. */
diff --git a/REORG.TODO/sysdeps/generic/dl-procinfo.h b/REORG.TODO/sysdeps/generic/dl-procinfo.h
new file mode 100644
index 0000000000..9a0ccacc57
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-procinfo.h
@@ -0,0 +1,42 @@
+/* Stub version of processor capability information handling macros.
+ Copyright (C) 1998-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DL_PROCINFO_H
+#define _DL_PROCINFO_H 1
+
+/* We cannot provide a general printing function. */
+#define _dl_procinfo(type, word) -1
+
+/* There are no hardware capabilities defined. */
+#define _dl_hwcap_string(idx) ""
+
+/* By default there is no important hardware capability. */
+#define HWCAP_IMPORTANT (0)
+
+/* There're no platforms to filter out. */
+#define _DL_HWCAP_PLATFORM 0
+
+/* We don't have any hardware capabilities. */
+#define _DL_HWCAP_COUNT 0
+
+#define _dl_string_hwcap(str) (-1)
+
+#define _dl_string_platform(str) (-1)
+
+#endif /* dl-procinfo.h */
diff --git a/REORG.TODO/sysdeps/generic/dl-sysdep.h b/REORG.TODO/sysdeps/generic/dl-sysdep.h
new file mode 100644
index 0000000000..c69a4e0c02
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-sysdep.h
@@ -0,0 +1,34 @@
+/* System-specific settings for dynamic linker code. Generic version.
+ Copyright (C) 2002-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* No multiple inclusion protection need here because it's just macros.
+ We don't want to use _DL_SYSDEP_H in case we are #include_next'd. */
+
+/* This macro must be defined to either 0 or 1.
+
+ If 1, then an errno global variable hidden in ld.so will work right with
+ all the errno-using libc code compiled for ld.so, and there is never a
+ need to share the errno location with libc. This is appropriate only if
+ all the libc functions that ld.so uses are called without PLT and always
+ get the versions linked into ld.so rather than the libc ones. */
+
+#if IS_IN (rtld)
+# define RTLD_PRIVATE_ERRNO 1
+#else
+# define RTLD_PRIVATE_ERRNO 0
+#endif
diff --git a/REORG.TODO/sysdeps/generic/dl-tls.h b/REORG.TODO/sysdeps/generic/dl-tls.h
new file mode 100644
index 0000000000..7703a97525
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-tls.h
@@ -0,0 +1,2 @@
+/* There has to be an architecture specific version of this file. */
+#error "architecture-specific version of <dl-tls.h> missing"
diff --git a/REORG.TODO/sysdeps/generic/dl-unistd.h b/REORG.TODO/sysdeps/generic/dl-unistd.h
new file mode 100644
index 0000000000..dc738cd8e2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dl-unistd.h
@@ -0,0 +1,30 @@
+/* Functions with hidden attribute internal to ld.so, which are declared
+ in include/unistd.h. Generic version.
+ Copyright (C) 2015-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+extern __typeof (__access) __access attribute_hidden;
+extern __typeof (__brk) __brk attribute_hidden;
+extern __typeof (__close) __close attribute_hidden;
+extern __typeof (__getcwd) __getcwd attribute_hidden;
+extern __typeof (__getpid) __getpid attribute_hidden;
+extern __typeof (__libc_read) __libc_read attribute_hidden;
+extern __typeof (__libc_write) __libc_write attribute_hidden;
+extern __typeof (__lseek) __lseek attribute_hidden;
+extern __typeof (__profil) __profil attribute_hidden;
+extern __typeof (__read) __read attribute_hidden;
+extern __typeof (__sbrk) __sbrk attribute_hidden;
diff --git a/REORG.TODO/sysdeps/generic/dwarf2.h b/REORG.TODO/sysdeps/generic/dwarf2.h
new file mode 100644
index 0000000000..bc68a5901a
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/dwarf2.h
@@ -0,0 +1,590 @@
+/* Declarations and definitions of codes relating to the DWARF2 symbolic
+ debugging information format.
+ Copyright (C) 1992-2017 Free Software Foundation, Inc.
+ Contributed by Gary Funck (gary@intrepid.com). Derived from the
+ DWARF 1 implementation written by Ron Guilmette (rfg@monkeys.com).
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DWARF2_H
+#define _DWARF2_H 1
+
+/* This file is derived from the DWARF specification (a public document)
+ Revision 2.0.0 (July 27, 1993) developed by the UNIX International
+ Programming Languages Special Interest Group (UI/PLSIG) and distributed
+ by UNIX International. Copies of this specification are available from
+ UNIX International, 20 Waterview Boulevard, Parsippany, NJ, 07054. */
+
+/* This file is shared between GCC and GDB, and should not contain
+ prototypes. */
+
+#ifndef __ASSEMBLER__
+/* Tag names and codes. */
+
+enum dwarf_tag
+ {
+ DW_TAG_padding = 0x00,
+ DW_TAG_array_type = 0x01,
+ DW_TAG_class_type = 0x02,
+ DW_TAG_entry_point = 0x03,
+ DW_TAG_enumeration_type = 0x04,
+ DW_TAG_formal_parameter = 0x05,
+ DW_TAG_imported_declaration = 0x08,
+ DW_TAG_label = 0x0a,
+ DW_TAG_lexical_block = 0x0b,
+ DW_TAG_member = 0x0d,
+ DW_TAG_pointer_type = 0x0f,
+ DW_TAG_reference_type = 0x10,
+ DW_TAG_compile_unit = 0x11,
+ DW_TAG_string_type = 0x12,
+ DW_TAG_structure_type = 0x13,
+ DW_TAG_subroutine_type = 0x15,
+ DW_TAG_typedef = 0x16,
+ DW_TAG_union_type = 0x17,
+ DW_TAG_unspecified_parameters = 0x18,
+ DW_TAG_variant = 0x19,
+ DW_TAG_common_block = 0x1a,
+ DW_TAG_common_inclusion = 0x1b,
+ DW_TAG_inheritance = 0x1c,
+ DW_TAG_inlined_subroutine = 0x1d,
+ DW_TAG_module = 0x1e,
+ DW_TAG_ptr_to_member_type = 0x1f,
+ DW_TAG_set_type = 0x20,
+ DW_TAG_subrange_type = 0x21,
+ DW_TAG_with_stmt = 0x22,
+ DW_TAG_access_declaration = 0x23,
+ DW_TAG_base_type = 0x24,
+ DW_TAG_catch_block = 0x25,
+ DW_TAG_const_type = 0x26,
+ DW_TAG_constant = 0x27,
+ DW_TAG_enumerator = 0x28,
+ DW_TAG_file_type = 0x29,
+ DW_TAG_friend = 0x2a,
+ DW_TAG_namelist = 0x2b,
+ DW_TAG_namelist_item = 0x2c,
+ DW_TAG_packed_type = 0x2d,
+ DW_TAG_subprogram = 0x2e,
+ DW_TAG_template_type_param = 0x2f,
+ DW_TAG_template_value_param = 0x30,
+ DW_TAG_thrown_type = 0x31,
+ DW_TAG_try_block = 0x32,
+ DW_TAG_variant_part = 0x33,
+ DW_TAG_variable = 0x34,
+ DW_TAG_volatile_type = 0x35,
+ /* SGI/MIPS Extensions */
+ DW_TAG_MIPS_loop = 0x4081,
+ /* GNU extensions */
+ DW_TAG_format_label = 0x4101, /* for FORTRAN 77 and Fortran 90 */
+ DW_TAG_function_template = 0x4102, /* for C++ */
+ DW_TAG_class_template = 0x4103, /* for C++ */
+ DW_TAG_GNU_BINCL = 0x4104,
+ DW_TAG_GNU_EINCL = 0x4105
+ };
+
+#define DW_TAG_lo_user 0x4080
+#define DW_TAG_hi_user 0xffff
+
+/* flag that tells whether entry has a child or not */
+#define DW_children_no 0
+#define DW_children_yes 1
+
+/* Form names and codes. */
+enum dwarf_form
+ {
+ DW_FORM_addr = 0x01,
+ DW_FORM_block2 = 0x03,
+ DW_FORM_block4 = 0x04,
+ DW_FORM_data2 = 0x05,
+ DW_FORM_data4 = 0x06,
+ DW_FORM_data8 = 0x07,
+ DW_FORM_string = 0x08,
+ DW_FORM_block = 0x09,
+ DW_FORM_block1 = 0x0a,
+ DW_FORM_data1 = 0x0b,
+ DW_FORM_flag = 0x0c,
+ DW_FORM_sdata = 0x0d,
+ DW_FORM_strp = 0x0e,
+ DW_FORM_udata = 0x0f,
+ DW_FORM_ref_addr = 0x10,
+ DW_FORM_ref1 = 0x11,
+ DW_FORM_ref2 = 0x12,
+ DW_FORM_ref4 = 0x13,
+ DW_FORM_ref8 = 0x14,
+ DW_FORM_ref_udata = 0x15,
+ DW_FORM_indirect = 0x16
+ };
+
+/* Attribute names and codes. */
+
+enum dwarf_attribute
+ {
+ DW_AT_sibling = 0x01,
+ DW_AT_location = 0x02,
+ DW_AT_name = 0x03,
+ DW_AT_ordering = 0x09,
+ DW_AT_subscr_data = 0x0a,
+ DW_AT_byte_size = 0x0b,
+ DW_AT_bit_offset = 0x0c,
+ DW_AT_bit_size = 0x0d,
+ DW_AT_element_list = 0x0f,
+ DW_AT_stmt_list = 0x10,
+ DW_AT_low_pc = 0x11,
+ DW_AT_high_pc = 0x12,
+ DW_AT_language = 0x13,
+ DW_AT_member = 0x14,
+ DW_AT_discr = 0x15,
+ DW_AT_discr_value = 0x16,
+ DW_AT_visibility = 0x17,
+ DW_AT_import = 0x18,
+ DW_AT_string_length = 0x19,
+ DW_AT_common_reference = 0x1a,
+ DW_AT_comp_dir = 0x1b,
+ DW_AT_const_value = 0x1c,
+ DW_AT_containing_type = 0x1d,
+ DW_AT_default_value = 0x1e,
+ DW_AT_inline = 0x20,
+ DW_AT_is_optional = 0x21,
+ DW_AT_lower_bound = 0x22,
+ DW_AT_producer = 0x25,
+ DW_AT_prototyped = 0x27,
+ DW_AT_return_addr = 0x2a,
+ DW_AT_start_scope = 0x2c,
+ DW_AT_stride_size = 0x2e,
+ DW_AT_upper_bound = 0x2f,
+ DW_AT_abstract_origin = 0x31,
+ DW_AT_accessibility = 0x32,
+ DW_AT_address_class = 0x33,
+ DW_AT_artificial = 0x34,
+ DW_AT_base_types = 0x35,
+ DW_AT_calling_convention = 0x36,
+ DW_AT_count = 0x37,
+ DW_AT_data_member_location = 0x38,
+ DW_AT_decl_column = 0x39,
+ DW_AT_decl_file = 0x3a,
+ DW_AT_decl_line = 0x3b,
+ DW_AT_declaration = 0x3c,
+ DW_AT_discr_list = 0x3d,
+ DW_AT_encoding = 0x3e,
+ DW_AT_external = 0x3f,
+ DW_AT_frame_base = 0x40,
+ DW_AT_friend = 0x41,
+ DW_AT_identifier_case = 0x42,
+ DW_AT_macro_info = 0x43,
+ DW_AT_namelist_items = 0x44,
+ DW_AT_priority = 0x45,
+ DW_AT_segment = 0x46,
+ DW_AT_specification = 0x47,
+ DW_AT_static_link = 0x48,
+ DW_AT_type = 0x49,
+ DW_AT_use_location = 0x4a,
+ DW_AT_variable_parameter = 0x4b,
+ DW_AT_virtuality = 0x4c,
+ DW_AT_vtable_elem_location = 0x4d,
+ /* SGI/MIPS Extensions */
+ DW_AT_MIPS_fde = 0x2001,
+ DW_AT_MIPS_loop_begin = 0x2002,
+ DW_AT_MIPS_tail_loop_begin = 0x2003,
+ DW_AT_MIPS_epilog_begin = 0x2004,
+ DW_AT_MIPS_loop_unroll_factor = 0x2005,
+ DW_AT_MIPS_software_pipeline_depth = 0x2006,
+ DW_AT_MIPS_linkage_name = 0x2007,
+ DW_AT_MIPS_stride = 0x2008,
+ DW_AT_MIPS_abstract_name = 0x2009,
+ DW_AT_MIPS_clone_origin = 0x200a,
+ DW_AT_MIPS_has_inlines = 0x200b,
+ /* GNU extensions. */
+ DW_AT_sf_names = 0x2101,
+ DW_AT_src_info = 0x2102,
+ DW_AT_mac_info = 0x2103,
+ DW_AT_src_coords = 0x2104,
+ DW_AT_body_begin = 0x2105,
+ DW_AT_body_end = 0x2106
+ };
+
+#define DW_AT_lo_user 0x2000 /* implementation-defined range start */
+#define DW_AT_hi_user 0x3ff0 /* implementation-defined range end */
+
+/* Location atom names and codes. */
+
+enum dwarf_location_atom
+ {
+ DW_OP_addr = 0x03,
+ DW_OP_deref = 0x06,
+ DW_OP_const1u = 0x08,
+ DW_OP_const1s = 0x09,
+ DW_OP_const2u = 0x0a,
+ DW_OP_const2s = 0x0b,
+ DW_OP_const4u = 0x0c,
+ DW_OP_const4s = 0x0d,
+ DW_OP_const8u = 0x0e,
+ DW_OP_const8s = 0x0f,
+ DW_OP_constu = 0x10,
+ DW_OP_consts = 0x11,
+ DW_OP_dup = 0x12,
+ DW_OP_drop = 0x13,
+ DW_OP_over = 0x14,
+ DW_OP_pick = 0x15,
+ DW_OP_swap = 0x16,
+ DW_OP_rot = 0x17,
+ DW_OP_xderef = 0x18,
+ DW_OP_abs = 0x19,
+ DW_OP_and = 0x1a,
+ DW_OP_div = 0x1b,
+ DW_OP_minus = 0x1c,
+ DW_OP_mod = 0x1d,
+ DW_OP_mul = 0x1e,
+ DW_OP_neg = 0x1f,
+ DW_OP_not = 0x20,
+ DW_OP_or = 0x21,
+ DW_OP_plus = 0x22,
+ DW_OP_plus_uconst = 0x23,
+ DW_OP_shl = 0x24,
+ DW_OP_shr = 0x25,
+ DW_OP_shra = 0x26,
+ DW_OP_xor = 0x27,
+ DW_OP_bra = 0x28,
+ DW_OP_eq = 0x29,
+ DW_OP_ge = 0x2a,
+ DW_OP_gt = 0x2b,
+ DW_OP_le = 0x2c,
+ DW_OP_lt = 0x2d,
+ DW_OP_ne = 0x2e,
+ DW_OP_skip = 0x2f,
+ DW_OP_lit0 = 0x30,
+ DW_OP_lit1 = 0x31,
+ DW_OP_lit2 = 0x32,
+ DW_OP_lit3 = 0x33,
+ DW_OP_lit4 = 0x34,
+ DW_OP_lit5 = 0x35,
+ DW_OP_lit6 = 0x36,
+ DW_OP_lit7 = 0x37,
+ DW_OP_lit8 = 0x38,
+ DW_OP_lit9 = 0x39,
+ DW_OP_lit10 = 0x3a,
+ DW_OP_lit11 = 0x3b,
+ DW_OP_lit12 = 0x3c,
+ DW_OP_lit13 = 0x3d,
+ DW_OP_lit14 = 0x3e,
+ DW_OP_lit15 = 0x3f,
+ DW_OP_lit16 = 0x40,
+ DW_OP_lit17 = 0x41,
+ DW_OP_lit18 = 0x42,
+ DW_OP_lit19 = 0x43,
+ DW_OP_lit20 = 0x44,
+ DW_OP_lit21 = 0x45,
+ DW_OP_lit22 = 0x46,
+ DW_OP_lit23 = 0x47,
+ DW_OP_lit24 = 0x48,
+ DW_OP_lit25 = 0x49,
+ DW_OP_lit26 = 0x4a,
+ DW_OP_lit27 = 0x4b,
+ DW_OP_lit28 = 0x4c,
+ DW_OP_lit29 = 0x4d,
+ DW_OP_lit30 = 0x4e,
+ DW_OP_lit31 = 0x4f,
+ DW_OP_reg0 = 0x50,
+ DW_OP_reg1 = 0x51,
+ DW_OP_reg2 = 0x52,
+ DW_OP_reg3 = 0x53,
+ DW_OP_reg4 = 0x54,
+ DW_OP_reg5 = 0x55,
+ DW_OP_reg6 = 0x56,
+ DW_OP_reg7 = 0x57,
+ DW_OP_reg8 = 0x58,
+ DW_OP_reg9 = 0x59,
+ DW_OP_reg10 = 0x5a,
+ DW_OP_reg11 = 0x5b,
+ DW_OP_reg12 = 0x5c,
+ DW_OP_reg13 = 0x5d,
+ DW_OP_reg14 = 0x5e,
+ DW_OP_reg15 = 0x5f,
+ DW_OP_reg16 = 0x60,
+ DW_OP_reg17 = 0x61,
+ DW_OP_reg18 = 0x62,
+ DW_OP_reg19 = 0x63,
+ DW_OP_reg20 = 0x64,
+ DW_OP_reg21 = 0x65,
+ DW_OP_reg22 = 0x66,
+ DW_OP_reg23 = 0x67,
+ DW_OP_reg24 = 0x68,
+ DW_OP_reg25 = 0x69,
+ DW_OP_reg26 = 0x6a,
+ DW_OP_reg27 = 0x6b,
+ DW_OP_reg28 = 0x6c,
+ DW_OP_reg29 = 0x6d,
+ DW_OP_reg30 = 0x6e,
+ DW_OP_reg31 = 0x6f,
+ DW_OP_breg0 = 0x70,
+ DW_OP_breg1 = 0x71,
+ DW_OP_breg2 = 0x72,
+ DW_OP_breg3 = 0x73,
+ DW_OP_breg4 = 0x74,
+ DW_OP_breg5 = 0x75,
+ DW_OP_breg6 = 0x76,
+ DW_OP_breg7 = 0x77,
+ DW_OP_breg8 = 0x78,
+ DW_OP_breg9 = 0x79,
+ DW_OP_breg10 = 0x7a,
+ DW_OP_breg11 = 0x7b,
+ DW_OP_breg12 = 0x7c,
+ DW_OP_breg13 = 0x7d,
+ DW_OP_breg14 = 0x7e,
+ DW_OP_breg15 = 0x7f,
+ DW_OP_breg16 = 0x80,
+ DW_OP_breg17 = 0x81,
+ DW_OP_breg18 = 0x82,
+ DW_OP_breg19 = 0x83,
+ DW_OP_breg20 = 0x84,
+ DW_OP_breg21 = 0x85,
+ DW_OP_breg22 = 0x86,
+ DW_OP_breg23 = 0x87,
+ DW_OP_breg24 = 0x88,
+ DW_OP_breg25 = 0x89,
+ DW_OP_breg26 = 0x8a,
+ DW_OP_breg27 = 0x8b,
+ DW_OP_breg28 = 0x8c,
+ DW_OP_breg29 = 0x8d,
+ DW_OP_breg30 = 0x8e,
+ DW_OP_breg31 = 0x8f,
+ DW_OP_regx = 0x90,
+ DW_OP_fbreg = 0x91,
+ DW_OP_bregx = 0x92,
+ DW_OP_piece = 0x93,
+ DW_OP_deref_size = 0x94,
+ DW_OP_xderef_size = 0x95,
+ DW_OP_nop = 0x96
+ };
+
+#define DW_OP_lo_user 0x80 /* implementation-defined range start */
+#define DW_OP_hi_user 0xff /* implementation-defined range end */
+
+/* Type encodings. */
+
+enum dwarf_type
+ {
+ DW_ATE_void = 0x0,
+ DW_ATE_address = 0x1,
+ DW_ATE_boolean = 0x2,
+ DW_ATE_complex_float = 0x3,
+ DW_ATE_float = 0x4,
+ DW_ATE_signed = 0x5,
+ DW_ATE_signed_char = 0x6,
+ DW_ATE_unsigned = 0x7,
+ DW_ATE_unsigned_char = 0x8
+ };
+
+#define DW_ATE_lo_user 0x80
+#define DW_ATE_hi_user 0xff
+
+/* Array ordering names and codes. */
+enum dwarf_array_dim_ordering
+ {
+ DW_ORD_row_major = 0,
+ DW_ORD_col_major = 1
+ };
+
+/* access attribute */
+enum dwarf_access_attribute
+ {
+ DW_ACCESS_public = 1,
+ DW_ACCESS_protected = 2,
+ DW_ACCESS_private = 3
+ };
+
+/* visibility */
+enum dwarf_visibility_attribute
+ {
+ DW_VIS_local = 1,
+ DW_VIS_exported = 2,
+ DW_VIS_qualified = 3
+ };
+
+/* virtuality */
+enum dwarf_virtuality_attribute
+ {
+ DW_VIRTUALITY_none = 0,
+ DW_VIRTUALITY_virtual = 1,
+ DW_VIRTUALITY_pure_virtual = 2
+ };
+
+/* case sensitivity */
+enum dwarf_id_case
+ {
+ DW_ID_case_sensitive = 0,
+ DW_ID_up_case = 1,
+ DW_ID_down_case = 2,
+ DW_ID_case_insensitive = 3
+ };
+
+/* calling convention */
+enum dwarf_calling_convention
+ {
+ DW_CC_normal = 0x1,
+ DW_CC_program = 0x2,
+ DW_CC_nocall = 0x3
+ };
+
+#define DW_CC_lo_user 0x40
+#define DW_CC_hi_user 0xff
+
+/* inline attribute */
+enum dwarf_inline_attribute
+ {
+ DW_INL_not_inlined = 0,
+ DW_INL_inlined = 1,
+ DW_INL_declared_not_inlined = 2,
+ DW_INL_declared_inlined = 3
+ };
+
+/* discriminant lists */
+enum dwarf_discrim_list
+ {
+ DW_DSC_label = 0,
+ DW_DSC_range = 1
+ };
+
+/* line number opcodes */
+enum dwarf_line_number_ops
+ {
+ DW_LNS_extended_op = 0,
+ DW_LNS_copy = 1,
+ DW_LNS_advance_pc = 2,
+ DW_LNS_advance_line = 3,
+ DW_LNS_set_file = 4,
+ DW_LNS_set_column = 5,
+ DW_LNS_negate_stmt = 6,
+ DW_LNS_set_basic_block = 7,
+ DW_LNS_const_add_pc = 8,
+ DW_LNS_fixed_advance_pc = 9
+ };
+
+/* line number extended opcodes */
+enum dwarf_line_number_x_ops
+ {
+ DW_LNE_end_sequence = 1,
+ DW_LNE_set_address = 2,
+ DW_LNE_define_file = 3
+ };
+
+/* call frame information */
+enum dwarf_call_frame_info
+ {
+ DW_CFA_advance_loc = 0x40,
+ DW_CFA_offset = 0x80,
+ DW_CFA_restore = 0xc0,
+ DW_CFA_nop = 0x00,
+ DW_CFA_set_loc = 0x01,
+ DW_CFA_advance_loc1 = 0x02,
+ DW_CFA_advance_loc2 = 0x03,
+ DW_CFA_advance_loc4 = 0x04,
+ DW_CFA_offset_extended = 0x05,
+ DW_CFA_restore_extended = 0x06,
+ DW_CFA_undefined = 0x07,
+ DW_CFA_same_value = 0x08,
+ DW_CFA_register = 0x09,
+ DW_CFA_remember_state = 0x0a,
+ DW_CFA_restore_state = 0x0b,
+ DW_CFA_def_cfa = 0x0c,
+ DW_CFA_def_cfa_register = 0x0d,
+ DW_CFA_def_cfa_offset = 0x0e,
+ DW_CFA_def_cfa_expression = 0x0f,
+ DW_CFA_expression = 0x10,
+ /* Dwarf 2.1 */
+ DW_CFA_offset_extended_sf = 0x11,
+ DW_CFA_def_cfa_sf = 0x12,
+ DW_CFA_def_cfa_offset_sf = 0x13,
+
+ /* SGI/MIPS specific */
+ DW_CFA_MIPS_advance_loc8 = 0x1d,
+
+ /* GNU extensions */
+ DW_CFA_GNU_window_save = 0x2d,
+ DW_CFA_GNU_args_size = 0x2e,
+ DW_CFA_GNU_negative_offset_extended = 0x2f
+ };
+
+#define DW_CIE_ID 0xffffffff
+#define DW_CIE_VERSION 1
+
+#define DW_CFA_extended 0
+#define DW_CFA_low_user 0x1c
+#define DW_CFA_high_user 0x3f
+
+#define DW_CHILDREN_no 0x00
+#define DW_CHILDREN_yes 0x01
+
+#define DW_ADDR_none 0
+
+/* Source language names and codes. */
+
+enum dwarf_source_language
+ {
+ DW_LANG_C89 = 0x0001,
+ DW_LANG_C = 0x0002,
+ DW_LANG_Ada83 = 0x0003,
+ DW_LANG_C_plus_plus = 0x0004,
+ DW_LANG_Cobol74 = 0x0005,
+ DW_LANG_Cobol85 = 0x0006,
+ DW_LANG_Fortran77 = 0x0007,
+ DW_LANG_Fortran90 = 0x0008,
+ DW_LANG_Pascal83 = 0x0009,
+ DW_LANG_Modula2 = 0x000a,
+ DW_LANG_Java = 0x000b,
+ DW_LANG_Mips_Assembler = 0x8001
+ };
+
+
+#define DW_LANG_lo_user 0x8000 /* implementation-defined range start */
+#define DW_LANG_hi_user 0xffff /* implementation-defined range start */
+
+/* Names and codes for macro information. */
+
+enum dwarf_macinfo_record_type
+ {
+ DW_MACINFO_define = 1,
+ DW_MACINFO_undef = 2,
+ DW_MACINFO_start_file = 3,
+ DW_MACINFO_end_file = 4,
+ DW_MACINFO_vendor_ext = 255
+ };
+
+#endif /* !ASSEMBLER */
+
+/* @@@ For use with GNU frame unwind information. */
+
+#define DW_EH_PE_absptr 0x00
+#define DW_EH_PE_omit 0xff
+
+#define DW_EH_PE_uleb128 0x01
+#define DW_EH_PE_udata2 0x02
+#define DW_EH_PE_udata4 0x03
+#define DW_EH_PE_udata8 0x04
+#define DW_EH_PE_sleb128 0x09
+#define DW_EH_PE_sdata2 0x0A
+#define DW_EH_PE_sdata4 0x0B
+#define DW_EH_PE_sdata8 0x0C
+#define DW_EH_PE_signed 0x08
+
+#define DW_EH_PE_pcrel 0x10
+#define DW_EH_PE_textrel 0x20
+#define DW_EH_PE_datarel 0x30
+#define DW_EH_PE_funcrel 0x40
+#define DW_EH_PE_aligned 0x50
+
+#define DW_EH_PE_indirect 0x80
+
+#endif /* dwarf2.h */
diff --git a/REORG.TODO/sysdeps/generic/elide.h b/REORG.TODO/sysdeps/generic/elide.h
new file mode 100644
index 0000000000..26697be2f1
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/elide.h
@@ -0,0 +1,25 @@
+/* elide.h: Fallback noop lock elision support.
+ Copyright (C) 2014-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+#ifndef ELIDE_H
+#define ELIDE_H 1
+
+#define ELIDE_LOCK(adapt_count, is_lock_free) 0
+#define ELIDE_TRYLOCK(adapt_count, is_lock_free, write) 0
+#define ELIDE_UNLOCK(is_lock_free) 0
+
+#endif
diff --git a/REORG.TODO/sysdeps/generic/eloop-threshold.h b/REORG.TODO/sysdeps/generic/eloop-threshold.h
new file mode 100644
index 0000000000..da6be07a50
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/eloop-threshold.h
@@ -0,0 +1,72 @@
+/* Threshold at which to diagnose ELOOP. Generic version.
+ Copyright (C) 2012-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _ELOOP_THRESHOLD_H
+#define _ELOOP_THRESHOLD_H 1
+
+#include <limits.h>
+#include <sys/param.h>
+
+/* POSIX specifies SYMLOOP_MAX as the "Maximum number of symbolic
+ links that can be reliably traversed in the resolution of a
+ pathname in the absence of a loop." This makes it a minimum that
+ we should certainly accept. But it leaves open the possibility
+ that more might sometimes work--just not "reliably".
+
+ For example, Linux implements a complex policy whereby there is a
+ small limit on the number of direct symlink traversals (a symlink
+ to a symlink to a symlink), but larger limit on the total number of
+ symlink traversals overall. Hence the SYMLOOP_MAX number should be
+ the small one, but the limit library functions enforce on users
+ should be the larger one.
+
+ So, we use the larger of the reported SYMLOOP_MAX (if any) and our
+ own constant MIN_ELOOP_THRESHOLD, below. This constant should be
+ large enough that it never rules out a file name and directory tree
+ that the underlying system (i.e. calls to 'open' et al) would
+ resolve successfully. It should be small enough that actual loops
+ are detected without a huge number of iterations. */
+
+#ifndef MIN_ELOOP_THRESHOLD
+# define MIN_ELOOP_THRESHOLD 40
+#endif
+
+/* Return the maximum number of symlink traversals to permit
+ before diagnosing ELOOP. */
+static inline unsigned int __attribute__ ((const))
+__eloop_threshold (void)
+{
+#ifdef SYMLOOP_MAX
+ const int symloop_max = SYMLOOP_MAX;
+#else
+ /* The function is marked 'const' even though we use memory and
+ call a function, because sysconf is required to return the
+ same value in every call and so it must always be safe to
+ call __eloop_threshold exactly once and reuse the value. */
+ static long int sysconf_symloop_max;
+ if (sysconf_symloop_max == 0)
+ sysconf_symloop_max = __sysconf (_SC_SYMLOOP_MAX);
+ const unsigned int symloop_max = (sysconf_symloop_max <= 0
+ ? _POSIX_SYMLOOP_MAX
+ : sysconf_symloop_max);
+#endif
+
+ return MAX (symloop_max, MIN_ELOOP_THRESHOLD);
+}
+
+#endif /* eloop-threshold.h */
diff --git a/REORG.TODO/sysdeps/generic/entry.h b/REORG.TODO/sysdeps/generic/entry.h
new file mode 100644
index 0000000000..16d3e3045e
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/entry.h
@@ -0,0 +1,5 @@
+#ifndef __ASSEMBLY__
+extern void _start (void) attribute_hidden;
+#endif
+
+#define ENTRY_POINT _start
diff --git a/REORG.TODO/sysdeps/generic/errqueue.h b/REORG.TODO/sysdeps/generic/errqueue.h
new file mode 100644
index 0000000000..dac2bd3863
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/errqueue.h
@@ -0,0 +1,7 @@
+#ifndef _BITS_ERRQUEUE_H
+#define _BITS_ERRQUEUE_H 1
+
+/* This platform does not support socket error reporting
+ via MSG_ERRQUEUE. */
+
+#endif /* bits/errqueue.h */
diff --git a/REORG.TODO/sysdeps/generic/exit-thread.h b/REORG.TODO/sysdeps/generic/exit-thread.h
new file mode 100644
index 0000000000..a90a6b8346
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/exit-thread.h
@@ -0,0 +1,28 @@
+/* Call to terminate the current thread. Stub version.
+ Copyright (C) 2014-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This causes the current thread to exit, without affecting other
+ threads in the process if there are any. If there are no other
+ threads left, then this has the effect of _exit (0). */
+
+static inline void __attribute__ ((noreturn, always_inline, unused))
+__exit_thread (void)
+{
+ while (1)
+ asm ("write me!");
+}
diff --git a/REORG.TODO/sysdeps/generic/fd_to_filename.h b/REORG.TODO/sysdeps/generic/fd_to_filename.h
new file mode 100644
index 0000000000..fe15f5d97e
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/fd_to_filename.h
@@ -0,0 +1,25 @@
+/* Query filename corresponding to an open FD. Generic version.
+ Copyright (C) 2001-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* In general there is no generic way to query filename for an open
+ file descriptor. */
+static inline const char *
+fd_to_filename (int fd)
+{
+ return NULL;
+}
diff --git a/REORG.TODO/sysdeps/generic/fips-private.h b/REORG.TODO/sysdeps/generic/fips-private.h
new file mode 100644
index 0000000000..dde837eb8f
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/fips-private.h
@@ -0,0 +1,36 @@
+/* Dummy implementation of FIPS compliance status test.
+ Copyright (C) 2012-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _FIPS_PRIVATE_H
+#define _FIPS_PRIVATE_H
+
+#include <stdbool.h>
+
+/* Return true if compliance with the FIPS security standards is
+ enabled.
+
+ This is only relevant within crypt, to tell whether MD5 and DES
+ algorithms should be rejected. */
+
+static inline bool
+fips_enabled_p (void)
+{
+ return false;
+}
+
+#endif /* _FIPS_PRIVATE_H */
diff --git a/REORG.TODO/sysdeps/generic/fix-fp-int-compare-invalid.h b/REORG.TODO/sysdeps/generic/fix-fp-int-compare-invalid.h
new file mode 100644
index 0000000000..421452d3a8
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/fix-fp-int-compare-invalid.h
@@ -0,0 +1,27 @@
+/* Fix for missing "invalid" exceptions from floating-point
+ comparisons. Generic version.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef FIX_FP_INT_COMPARE_INVALID_H
+#define FIX_FP_INT_COMPARE_INVALID_H 1
+
+/* Define this macro to 1 to work around ordered comparison operators
+ in C failing to raise the "invalid" exception for NaN operands. */
+#define FIX_COMPARE_INVALID 0
+
+#endif /* fix-fp-int-compare-invalid.h */
diff --git a/REORG.TODO/sysdeps/generic/fix-fp-int-convert-overflow.h b/REORG.TODO/sysdeps/generic/fix-fp-int-convert-overflow.h
new file mode 100644
index 0000000000..4b0cd9159f
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/fix-fp-int-convert-overflow.h
@@ -0,0 +1,35 @@
+/* Fix for conversion of floating point to integer overflow. Generic version.
+ Copyright (C) 2015-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef FIX_FP_INT_CONVERT_OVERFLOW_H
+#define FIX_FP_INT_CONVERT_OVERFLOW_H 1
+
+/* Define these macros to 1 to workaround conversions of out-of-range
+ floating-point numbers to integer types failing to raise the
+ "invalid" exception, or raising spurious "inexact" or other
+ exceptions. */
+#define FIX_FLT_LONG_CONVERT_OVERFLOW 0
+#define FIX_FLT_LLONG_CONVERT_OVERFLOW 0
+#define FIX_DBL_LONG_CONVERT_OVERFLOW 0
+#define FIX_DBL_LLONG_CONVERT_OVERFLOW 0
+#define FIX_LDBL_LONG_CONVERT_OVERFLOW 0
+#define FIX_LDBL_LLONG_CONVERT_OVERFLOW 0
+#define FIX_FLT128_LONG_CONVERT_OVERFLOW 0
+#define FIX_FLT128_LLONG_CONVERT_OVERFLOW 0
+
+#endif /* fix-fp-int-convert-overflow.h */
diff --git a/REORG.TODO/sysdeps/generic/fix-int-fp-convert-zero.h b/REORG.TODO/sysdeps/generic/fix-int-fp-convert-zero.h
new file mode 100644
index 0000000000..1318e3ff93
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/fix-int-fp-convert-zero.h
@@ -0,0 +1,27 @@
+/* Fix for conversion of integer 0 to floating point. Generic version.
+ Copyright (C) 2015-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef FIX_INT_FP_CONVERT_ZERO_H
+#define FIX_INT_FP_CONVERT_ZERO_H 1
+
+/* Define this macro to 1 to work around conversions of integer 0 to
+ floating point returning -0 instead of the correct +0 in some
+ rounding modes. */
+#define FIX_INT_FP_CONVERT_ZERO 0
+
+#endif /* fix-int-fp-convert-zero.h */
diff --git a/REORG.TODO/sysdeps/generic/fork.h b/REORG.TODO/sysdeps/generic/fork.h
new file mode 100644
index 0000000000..623cae28df
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/fork.h
@@ -0,0 +1,8 @@
+/* Stub version of header for fork handling. Mainly to handle pthread_atfork
+ and friends. Outside dependencies:
+
+ UNREGISTER_ATFORK
+ If defined it must expand to a function call which takes one void*
+ parameter which is the DSO handle for the DSO which gets unloaded.
+ The function so called has to remove the atfork handlers registered
+ by this module. */
diff --git a/REORG.TODO/sysdeps/generic/fpu_control.h b/REORG.TODO/sysdeps/generic/fpu_control.h
new file mode 100644
index 0000000000..0ec25c64ab
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/fpu_control.h
@@ -0,0 +1,38 @@
+/* FPU control word definitions. Stub version.
+ Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _FPU_CONTROL_H
+#define _FPU_CONTROL_H
+
+#define _FPU_RESERVED 0xffffffff /* These bits are reserved and not changed. */
+
+/* The fdlibm code requires no interrupts for exceptions. Don't
+ change the rounding mode, it would break long double I/O! */
+#define _FPU_DEFAULT 0x00000000 /* Default value. */
+
+/* Type of the control word. */
+typedef unsigned int fpu_control_t;
+
+/* Macros for accessing the hardware control word. */
+#define _FPU_GETCW(cw) (cw) = 0
+#define _FPU_SETCW(cw) (void) (cw)
+
+/* Default control word set at startup. */
+extern fpu_control_t __fpu_control;
+
+#endif /* _FPU_CONTROL_H */
diff --git a/REORG.TODO/sysdeps/generic/frame.h b/REORG.TODO/sysdeps/generic/frame.h
new file mode 100644
index 0000000000..86a0cf4317
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/frame.h
@@ -0,0 +1,23 @@
+/* Definition of stack frame structure. Generic version.
+ Copyright (C) 2000-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+struct layout
+{
+ void *next;
+ void *return_address;
+};
diff --git a/REORG.TODO/sysdeps/generic/framestate.c b/REORG.TODO/sysdeps/generic/framestate.c
new file mode 100644
index 0000000000..c19d4b1ee4
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/framestate.c
@@ -0,0 +1,52 @@
+/* __frame_state_for unwinder helper function wrapper.
+ Copyright (C) 2001-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2001.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <dlfcn.h>
+#include <stdlib.h>
+#define STATIC static
+#define __frame_state_for fallback_frame_state_for
+#include <unwind-dw2.c>
+#undef __frame_state_for
+#include <gnu/lib-names.h>
+
+typedef struct frame_state * (*framesf)(void *pc, struct frame_state *);
+struct frame_state *__frame_state_for (void *pc,
+ struct frame_state *frame_state);
+
+struct frame_state *
+__frame_state_for (void *pc, struct frame_state *frame_state)
+{
+ static framesf frame_state_for;
+
+ if (frame_state_for == NULL)
+ {
+ void *handle = __libc_dlopen (LIBGCC_S_SO);
+
+ if (handle == NULL
+ || (frame_state_for
+ = (framesf) __libc_dlsym (handle, "__frame_state_for")) == NULL)
+#ifndef __USING_SJLJ_EXCEPTIONS__
+ frame_state_for = fallback_frame_state_for;
+#else
+ frame_state_for = abort;
+#endif
+ }
+
+ return frame_state_for (pc, frame_state);
+}
diff --git a/REORG.TODO/sysdeps/generic/gcc-compat.h b/REORG.TODO/sysdeps/generic/gcc-compat.h
new file mode 100644
index 0000000000..d19f5d069d
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/gcc-compat.h
@@ -0,0 +1,42 @@
+/* Macros for checking required GCC compatibility. Generic version.
+ Copyright (C) 2014-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This is the base file. More-specific sysdeps/.../gcc-compat.h files
+ can define GCC_COMPAT_VERSION and then #include_next this file. */
+
+#ifndef _GENERIC_GCC_COMPAT_H
+#define _GENERIC_GCC_COMPAT_H 1
+
+/* This is the macro that gets used in #if tests in code: true iff
+ the library we build must be compatible with user code built by
+ GCC version MAJOR.MINOR. */
+#define GCC_COMPAT(major, minor) \
+ (GCC_COMPAT_VERSION <= GCC_VERSION (major, minor))
+
+/* This is how we compose an integer from major and minor version
+ numbers, for comparison. */
+#define GCC_VERSION(major, minor) \
+ (((major) << 16) + (minor))
+
+#ifndef GCC_COMPAT_VERSION
+/* GCC 2.7.2 was current at the time of the glibc-2.0 release.
+ We assume nothing before that ever mattered. */
+# define GCC_COMPAT_VERSION GCC_VERSION (2, 7)
+#endif
+
+#endif
diff --git a/REORG.TODO/sysdeps/generic/gccframe.h b/REORG.TODO/sysdeps/generic/gccframe.h
new file mode 100644
index 0000000000..f9406b57ec
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/gccframe.h
@@ -0,0 +1,49 @@
+/* Definition of object in frame unwind info. Generic version.
+ Copyright (C) 2000-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/types.h>
+
+struct dwarf_fde;
+struct fde_vector;
+
+struct object
+{
+ void *pc_begin;
+ void *tbase;
+ void *dbase;
+ union {
+ struct dwarf_fde *single;
+ struct dwarf_fde **array;
+ struct fde_vector *sort;
+ } u;
+
+ union {
+ struct {
+ unsigned long sorted : 1;
+ unsigned long from_array : 1;
+ unsigned long mixed_encoding : 1;
+ unsigned long encoding : 8;
+ /* ??? Wish there was an easy way to detect a 64-bit host here;
+ we've got 32 bits left to play with... */
+ unsigned long count : 21;
+ } b;
+ size_t i;
+ } s;
+
+ struct object *next;
+};
diff --git a/REORG.TODO/sysdeps/generic/get-rounding-mode.h b/REORG.TODO/sysdeps/generic/get-rounding-mode.h
new file mode 100644
index 0000000000..a829bd5d10
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/get-rounding-mode.h
@@ -0,0 +1,125 @@
+/* Determine floating-point rounding mode within libc. Generic version.
+ Copyright (C) 2012-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _GET_ROUNDING_MODE_H
+#define _GET_ROUNDING_MODE_H 1
+
+#include <fpu_control.h>
+#include <stdlib.h>
+
+/* Define values for FE_* modes not defined for this architecture. */
+#ifdef FE_DOWNWARD
+# define ORIG_FE_DOWNWARD FE_DOWNWARD
+#else
+# define ORIG_FE_DOWNWARD 0
+#endif
+#ifdef FE_TONEAREST
+# define ORIG_FE_TONEAREST FE_TONEAREST
+#else
+# define ORIG_FE_TONEAREST 0
+#endif
+#ifdef FE_TOWARDZERO
+# define ORIG_FE_TOWARDZERO FE_TOWARDZERO
+#else
+# define ORIG_FE_TOWARDZERO 0
+#endif
+#ifdef FE_UPWARD
+# define ORIG_FE_UPWARD FE_UPWARD
+#else
+# define ORIG_FE_UPWARD 0
+#endif
+#define FE_CONSTRUCT_DISTINCT_VALUE(X, Y, Z) \
+ ((((X) & 1) | ((Y) & 2) | ((Z) & 4)) ^ 7)
+#ifndef FE_DOWNWARD
+# define FE_DOWNWARD FE_CONSTRUCT_DISTINCT_VALUE (ORIG_FE_TONEAREST, \
+ ORIG_FE_TOWARDZERO, \
+ ORIG_FE_UPWARD)
+#endif
+#ifndef FE_TONEAREST
+# define FE_TONEAREST FE_CONSTRUCT_DISTINCT_VALUE (FE_DOWNWARD, \
+ ORIG_FE_TOWARDZERO, \
+ ORIG_FE_UPWARD)
+#endif
+#ifndef FE_TOWARDZERO
+# define FE_TOWARDZERO FE_CONSTRUCT_DISTINCT_VALUE (FE_DOWNWARD, \
+ FE_TONEAREST, \
+ ORIG_FE_UPWARD)
+#endif
+#ifndef FE_UPWARD
+# define FE_UPWARD FE_CONSTRUCT_DISTINCT_VALUE (FE_DOWNWARD, \
+ FE_TONEAREST, \
+ FE_TOWARDZERO)
+#endif
+
+/* Return the floating-point rounding mode. */
+
+static inline int
+get_rounding_mode (void)
+{
+#if (defined _FPU_RC_DOWN \
+ || defined _FPU_RC_NEAREST \
+ || defined _FPU_RC_ZERO \
+ || defined _FPU_RC_UP)
+ fpu_control_t fc;
+ const fpu_control_t mask = (0
+# ifdef _FPU_RC_DOWN
+ | _FPU_RC_DOWN
+# endif
+# ifdef _FPU_RC_NEAREST
+ | _FPU_RC_NEAREST
+# endif
+# ifdef _FPU_RC_ZERO
+ | _FPU_RC_ZERO
+# endif
+# ifdef _FPU_RC_UP
+ | _FPU_RC_UP
+# endif
+ );
+
+ _FPU_GETCW (fc);
+ switch (fc & mask)
+ {
+# ifdef _FPU_RC_DOWN
+ case _FPU_RC_DOWN:
+ return FE_DOWNWARD;
+# endif
+
+# ifdef _FPU_RC_NEAREST
+ case _FPU_RC_NEAREST:
+ return FE_TONEAREST;
+# endif
+
+# ifdef _FPU_RC_ZERO
+ case _FPU_RC_ZERO:
+ return FE_TOWARDZERO;
+# endif
+
+# ifdef _FPU_RC_UP
+ case _FPU_RC_UP:
+ return FE_UPWARD;
+# endif
+
+ default:
+ abort ();
+ }
+#else
+ return FE_TONEAREST;
+#endif
+}
+
+#endif /* get-rounding-mode.h */
diff --git a/REORG.TODO/sysdeps/generic/gmp-mparam.h b/REORG.TODO/sysdeps/generic/gmp-mparam.h
new file mode 100644
index 0000000000..13b1695d25
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/gmp-mparam.h
@@ -0,0 +1,27 @@
+/* gmp-mparam.h -- Compiler/machine parameter header file.
+Copyright (C) 1991-2017 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or (at your
+option) any later version.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include <bits/wordsize.h>
+
+#define BITS_PER_MP_LIMB __WORDSIZE
+#define BYTES_PER_MP_LIMB (__WORDSIZE / 8)
+#define BITS_PER_LONGINT __WORDSIZE
+#define BITS_PER_INT 32
+#define BITS_PER_SHORTINT 16
+#define BITS_PER_CHAR 8
diff --git a/REORG.TODO/sysdeps/generic/hp-timing-common.h b/REORG.TODO/sysdeps/generic/hp-timing-common.h
new file mode 100644
index 0000000000..929faa2a3c
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/hp-timing-common.h
@@ -0,0 +1,62 @@
+/* High precision, low overhead timing functions. Generic version.
+ Copyright (C) 1998-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* In case a platform supports timers in the hardware the following macros
+ and types must be defined:
+
+ - HP_TIMING_AVAIL: test for availability.
+
+ - HP_TIMING_INLINE: this macro is non-zero if the functionality is not
+ implemented using function calls but instead uses some inlined code
+ which might simply consist of a few assembler instructions. We have to
+ know this since we might want to use the macros here in places where we
+ cannot make function calls.
+
+ - hp_timing_t: This is the type for variables used to store the time
+ values. This type must be integral.
+
+ - HP_TIMING_NOW: place timestamp for current time in variable given as
+ parameter.
+*/
+
+/* The target supports hp-timing. Share the common infrastructure. */
+
+#include <string.h>
+#include <sys/param.h>
+#include <_itoa.h>
+
+/* Compute the difference between START and END, storing into DIFF. */
+#define HP_TIMING_DIFF(Diff, Start, End) ((Diff) = (End) - (Start))
+
+/* Accumulate ADD into SUM. No attempt is made to be thread-safe. */
+#define HP_TIMING_ACCUM_NT(Sum, Diff) ((Sum) += (Diff))
+
+/* Write a decimal representation of the timing value into the given string. */
+#define HP_TIMING_PRINT(Dest, Len, Val) \
+ do { \
+ char __buf[20]; \
+ char *__dest = (Dest); \
+ size_t __len = (Len); \
+ char *__cp = _itoa ((Val), __buf + sizeof (__buf), 10, 0); \
+ size_t __cp_len = MIN (__buf + sizeof (__buf) - __cp, __len); \
+ memcpy (__dest, __cp, __cp_len); \
+ memcpy (__dest + __cp_len, " cycles", \
+ MIN (__len - __cp_len, sizeof (" cycles"))); \
+ __dest[__len - 1] = '\0'; \
+ } while (0)
diff --git a/REORG.TODO/sysdeps/generic/hp-timing.h b/REORG.TODO/sysdeps/generic/hp-timing.h
new file mode 100644
index 0000000000..6c6e39f597
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/hp-timing.h
@@ -0,0 +1,40 @@
+/* High precision, low overhead timing functions. Generic version.
+ Copyright (C) 1998-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _HP_TIMING_H
+#define _HP_TIMING_H 1
+
+/* There are no generic definitions for the times. We could write something
+ using the `gettimeofday' system call where available but the overhead of
+ the system call might be too high. */
+
+/* Provide dummy definitions. */
+#define HP_TIMING_AVAIL (0)
+#define HP_SMALL_TIMING_AVAIL (0)
+#define HP_TIMING_INLINE (0)
+typedef int hp_timing_t;
+#define HP_TIMING_NOW(var)
+#define HP_TIMING_DIFF(Diff, Start, End)
+#define HP_TIMING_ACCUM_NT(Sum, Diff)
+#define HP_TIMING_PRINT(Buf, Len, Val)
+
+/* Since this implementation is not available we tell the user about it. */
+#define HP_TIMING_NONAVAIL 1
+
+#endif /* hp-timing.h */
diff --git a/REORG.TODO/sysdeps/generic/ifreq.h b/REORG.TODO/sysdeps/generic/ifreq.h
new file mode 100644
index 0000000000..6ebd7c83f3
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/ifreq.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 1999-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <net/if.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+
+static inline struct ifreq *
+__if_nextreq (struct ifreq *ifr)
+{
+#ifdef _HAVE_SA_LEN
+ if (ifr->ifr_addr.sa_len > sizeof ifr->ifr_addr)
+ return (struct ifreq *) ((char *) &ifr->ifr_addr + ifr->ifr_addr.sa_len);
+#endif
+ return ifr + 1;
+}
+
+extern void __ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd);
+
+
+static inline void
+__if_freereq (struct ifreq *ifreqs, int num_ifs)
+{
+ free (ifreqs);
+}
diff --git a/REORG.TODO/sysdeps/generic/ifunc-sel.h b/REORG.TODO/sysdeps/generic/ifunc-sel.h
new file mode 100644
index 0000000000..1fff4059cc
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/ifunc-sel.h
@@ -0,0 +1,28 @@
+/* Used by the elf ifunc tests. */
+#ifndef ELF_IFUNC_SEL_H
+#define ELF_IFUNC_SEL_H 1
+
+extern int global;
+
+static inline void *
+inhibit_stack_protector
+ifunc_sel (int (*f1) (void), int (*f2) (void), int (*f3) (void))
+{
+ switch (global)
+ {
+ case 1:
+ return f1;
+ case -1:
+ return f2;
+ default:
+ return f3;
+ }
+}
+
+static inline void *
+inhibit_stack_protector
+ifunc_one (int (*f1) (void))
+{
+ return f1;
+}
+#endif
diff --git a/REORG.TODO/sysdeps/generic/intr-msg.h b/REORG.TODO/sysdeps/generic/intr-msg.h
new file mode 100644
index 0000000000..0186aa3323
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/intr-msg.h
@@ -0,0 +1,15 @@
+/* Stubby version of intr-msg.h. */
+
+/* This file must be written in machine-dependent form for each hurd port.
+ and define the following:
+
+ INTR_MSG_TRAP
+ INTR_MSG_BACK_OUT
+ SYSCALL_EXAMINE
+ struct mach_msg_trap_args
+ MSG_EXAMINE
+
+ See sysdeps/mach/hurd/i386/intr-msg.h for an example. */
+
+
+#error Could not find machine-dependent intr-msg.h file.
diff --git a/REORG.TODO/sysdeps/generic/inttypes.h b/REORG.TODO/sysdeps/generic/inttypes.h
new file mode 100644
index 0000000000..35784ff8db
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/inttypes.h
@@ -0,0 +1,434 @@
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/*
+ * ISO C99: 7.8 Format conversion of integer types <inttypes.h>
+ */
+
+#ifndef _INTTYPES_H
+#define _INTTYPES_H 1
+
+#include <features.h>
+/* Get the type definitions. */
+#include <stdint.h>
+
+/* Get a definition for wchar_t. But we must not define wchar_t itself. */
+#ifndef ____gwchar_t_defined
+# ifdef __cplusplus
+# define __gwchar_t wchar_t
+# elif defined __WCHAR_TYPE__
+typedef __WCHAR_TYPE__ __gwchar_t;
+# else
+# define __need_wchar_t
+# include <stddef.h>
+typedef wchar_t __gwchar_t;
+# endif
+# define ____gwchar_t_defined 1
+#endif
+
+# if __WORDSIZE == 64
+# define __PRI64_PREFIX "l"
+# define __PRIPTR_PREFIX "l"
+# else
+# define __PRI64_PREFIX "ll"
+# define __PRIPTR_PREFIX
+# endif
+
+/* Macros for printing format specifiers. */
+
+/* Decimal notation. */
+# define PRId8 "d"
+# define PRId16 "d"
+# define PRId32 "d"
+# define PRId64 __PRI64_PREFIX "d"
+
+# define PRIdLEAST8 "d"
+# define PRIdLEAST16 "d"
+# define PRIdLEAST32 "d"
+# define PRIdLEAST64 __PRI64_PREFIX "d"
+
+# define PRIdFAST8 "d"
+# define PRIdFAST16 __PRIPTR_PREFIX "d"
+# define PRIdFAST32 __PRIPTR_PREFIX "d"
+# define PRIdFAST64 __PRI64_PREFIX "d"
+
+
+# define PRIi8 "i"
+# define PRIi16 "i"
+# define PRIi32 "i"
+# define PRIi64 __PRI64_PREFIX "i"
+
+# define PRIiLEAST8 "i"
+# define PRIiLEAST16 "i"
+# define PRIiLEAST32 "i"
+# define PRIiLEAST64 __PRI64_PREFIX "i"
+
+# define PRIiFAST8 "i"
+# define PRIiFAST16 __PRIPTR_PREFIX "i"
+# define PRIiFAST32 __PRIPTR_PREFIX "i"
+# define PRIiFAST64 __PRI64_PREFIX "i"
+
+/* Octal notation. */
+# define PRIo8 "o"
+# define PRIo16 "o"
+# define PRIo32 "o"
+# define PRIo64 __PRI64_PREFIX "o"
+
+# define PRIoLEAST8 "o"
+# define PRIoLEAST16 "o"
+# define PRIoLEAST32 "o"
+# define PRIoLEAST64 __PRI64_PREFIX "o"
+
+# define PRIoFAST8 "o"
+# define PRIoFAST16 __PRIPTR_PREFIX "o"
+# define PRIoFAST32 __PRIPTR_PREFIX "o"
+# define PRIoFAST64 __PRI64_PREFIX "o"
+
+/* Unsigned integers. */
+# define PRIu8 "u"
+# define PRIu16 "u"
+# define PRIu32 "u"
+# define PRIu64 __PRI64_PREFIX "u"
+
+# define PRIuLEAST8 "u"
+# define PRIuLEAST16 "u"
+# define PRIuLEAST32 "u"
+# define PRIuLEAST64 __PRI64_PREFIX "u"
+
+# define PRIuFAST8 "u"
+# define PRIuFAST16 __PRIPTR_PREFIX "u"
+# define PRIuFAST32 __PRIPTR_PREFIX "u"
+# define PRIuFAST64 __PRI64_PREFIX "u"
+
+/* lowercase hexadecimal notation. */
+# define PRIx8 "x"
+# define PRIx16 "x"
+# define PRIx32 "x"
+# define PRIx64 __PRI64_PREFIX "x"
+
+# define PRIxLEAST8 "x"
+# define PRIxLEAST16 "x"
+# define PRIxLEAST32 "x"
+# define PRIxLEAST64 __PRI64_PREFIX "x"
+
+# define PRIxFAST8 "x"
+# define PRIxFAST16 __PRIPTR_PREFIX "x"
+# define PRIxFAST32 __PRIPTR_PREFIX "x"
+# define PRIxFAST64 __PRI64_PREFIX "x"
+
+/* UPPERCASE hexadecimal notation. */
+# define PRIX8 "X"
+# define PRIX16 "X"
+# define PRIX32 "X"
+# define PRIX64 __PRI64_PREFIX "X"
+
+# define PRIXLEAST8 "X"
+# define PRIXLEAST16 "X"
+# define PRIXLEAST32 "X"
+# define PRIXLEAST64 __PRI64_PREFIX "X"
+
+# define PRIXFAST8 "X"
+# define PRIXFAST16 __PRIPTR_PREFIX "X"
+# define PRIXFAST32 __PRIPTR_PREFIX "X"
+# define PRIXFAST64 __PRI64_PREFIX "X"
+
+
+/* Macros for printing `intmax_t' and `uintmax_t'. */
+# define PRIdMAX __PRI64_PREFIX "d"
+# define PRIiMAX __PRI64_PREFIX "i"
+# define PRIoMAX __PRI64_PREFIX "o"
+# define PRIuMAX __PRI64_PREFIX "u"
+# define PRIxMAX __PRI64_PREFIX "x"
+# define PRIXMAX __PRI64_PREFIX "X"
+
+
+/* Macros for printing `intptr_t' and `uintptr_t'. */
+# define PRIdPTR __PRIPTR_PREFIX "d"
+# define PRIiPTR __PRIPTR_PREFIX "i"
+# define PRIoPTR __PRIPTR_PREFIX "o"
+# define PRIuPTR __PRIPTR_PREFIX "u"
+# define PRIxPTR __PRIPTR_PREFIX "x"
+# define PRIXPTR __PRIPTR_PREFIX "X"
+
+
+/* Macros for scanning format specifiers. */
+
+/* Signed decimal notation. */
+# define SCNd8 "hhd"
+# define SCNd16 "hd"
+# define SCNd32 "d"
+# define SCNd64 __PRI64_PREFIX "d"
+
+# define SCNdLEAST8 "hhd"
+# define SCNdLEAST16 "hd"
+# define SCNdLEAST32 "d"
+# define SCNdLEAST64 __PRI64_PREFIX "d"
+
+# define SCNdFAST8 "hhd"
+# define SCNdFAST16 __PRIPTR_PREFIX "d"
+# define SCNdFAST32 __PRIPTR_PREFIX "d"
+# define SCNdFAST64 __PRI64_PREFIX "d"
+
+/* Signed decimal notation. */
+# define SCNi8 "hhi"
+# define SCNi16 "hi"
+# define SCNi32 "i"
+# define SCNi64 __PRI64_PREFIX "i"
+
+# define SCNiLEAST8 "hhi"
+# define SCNiLEAST16 "hi"
+# define SCNiLEAST32 "i"
+# define SCNiLEAST64 __PRI64_PREFIX "i"
+
+# define SCNiFAST8 "hhi"
+# define SCNiFAST16 __PRIPTR_PREFIX "i"
+# define SCNiFAST32 __PRIPTR_PREFIX "i"
+# define SCNiFAST64 __PRI64_PREFIX "i"
+
+/* Unsigned decimal notation. */
+# define SCNu8 "hhu"
+# define SCNu16 "hu"
+# define SCNu32 "u"
+# define SCNu64 __PRI64_PREFIX "u"
+
+# define SCNuLEAST8 "hhu"
+# define SCNuLEAST16 "hu"
+# define SCNuLEAST32 "u"
+# define SCNuLEAST64 __PRI64_PREFIX "u"
+
+# define SCNuFAST8 "hhu"
+# define SCNuFAST16 __PRIPTR_PREFIX "u"
+# define SCNuFAST32 __PRIPTR_PREFIX "u"
+# define SCNuFAST64 __PRI64_PREFIX "u"
+
+/* Octal notation. */
+# define SCNo8 "hho"
+# define SCNo16 "ho"
+# define SCNo32 "o"
+# define SCNo64 __PRI64_PREFIX "o"
+
+# define SCNoLEAST8 "hho"
+# define SCNoLEAST16 "ho"
+# define SCNoLEAST32 "o"
+# define SCNoLEAST64 __PRI64_PREFIX "o"
+
+# define SCNoFAST8 "hho"
+# define SCNoFAST16 __PRIPTR_PREFIX "o"
+# define SCNoFAST32 __PRIPTR_PREFIX "o"
+# define SCNoFAST64 __PRI64_PREFIX "o"
+
+/* Hexadecimal notation. */
+# define SCNx8 "hhx"
+# define SCNx16 "hx"
+# define SCNx32 "x"
+# define SCNx64 __PRI64_PREFIX "x"
+
+# define SCNxLEAST8 "hhx"
+# define SCNxLEAST16 "hx"
+# define SCNxLEAST32 "x"
+# define SCNxLEAST64 __PRI64_PREFIX "x"
+
+# define SCNxFAST8 "hhx"
+# define SCNxFAST16 __PRIPTR_PREFIX "x"
+# define SCNxFAST32 __PRIPTR_PREFIX "x"
+# define SCNxFAST64 __PRI64_PREFIX "x"
+
+
+/* Macros for scanning `intmax_t' and `uintmax_t'. */
+# define SCNdMAX __PRI64_PREFIX "d"
+# define SCNiMAX __PRI64_PREFIX "i"
+# define SCNoMAX __PRI64_PREFIX "o"
+# define SCNuMAX __PRI64_PREFIX "u"
+# define SCNxMAX __PRI64_PREFIX "x"
+
+/* Macros for scaning `intptr_t' and `uintptr_t'. */
+# define SCNdPTR __PRIPTR_PREFIX "d"
+# define SCNiPTR __PRIPTR_PREFIX "i"
+# define SCNoPTR __PRIPTR_PREFIX "o"
+# define SCNuPTR __PRIPTR_PREFIX "u"
+# define SCNxPTR __PRIPTR_PREFIX "x"
+
+
+__BEGIN_DECLS
+
+#if __WORDSIZE == 64
+
+/* We have to define the `uintmax_t' type using `ldiv_t'. */
+typedef struct
+ {
+ long int quot; /* Quotient. */
+ long int rem; /* Remainder. */
+ } imaxdiv_t;
+
+#else
+
+/* We have to define the `uintmax_t' type using `lldiv_t'. */
+typedef struct
+ {
+ __extension__ long long int quot; /* Quotient. */
+ __extension__ long long int rem; /* Remainder. */
+ } imaxdiv_t;
+
+#endif
+
+
+/* Compute absolute value of N. */
+extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__));
+
+/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */
+extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom)
+ __THROW __attribute__ ((__const__));
+
+/* Like `strtol' but convert to `intmax_t'. */
+extern intmax_t strtoimax (const char *__restrict __nptr,
+ char **__restrict __endptr, int __base) __THROW;
+
+/* Like `strtoul' but convert to `uintmax_t'. */
+extern uintmax_t strtoumax (const char *__restrict __nptr,
+ char ** __restrict __endptr, int __base) __THROW;
+
+/* Like `wcstol' but convert to `intmax_t'. */
+extern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr,
+ __gwchar_t **__restrict __endptr, int __base)
+ __THROW;
+
+/* Like `wcstoul' but convert to `uintmax_t'. */
+extern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr,
+ __gwchar_t ** __restrict __endptr, int __base)
+ __THROW;
+
+#ifdef __USE_EXTERN_INLINES
+
+# if __WORDSIZE == 64
+
+extern long int __strtol_internal (const char *__restrict __nptr,
+ char **__restrict __endptr,
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `strtol' but convert to `intmax_t'. */
+__extern_inline intmax_t
+__NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr,
+ int base))
+{
+ return __strtol_internal (nptr, endptr, base, 0);
+}
+
+extern unsigned long int __strtoul_internal (const char *__restrict __nptr,
+ char ** __restrict __endptr,
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `strtoul' but convert to `uintmax_t'. */
+__extern_inline uintmax_t
+__NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr,
+ int base))
+{
+ return __strtoul_internal (nptr, endptr, base, 0);
+}
+
+extern long int __wcstol_internal (const __gwchar_t * __restrict __nptr,
+ __gwchar_t **__restrict __endptr,
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `wcstol' but convert to `intmax_t'. */
+__extern_inline intmax_t
+__NTH (wcstoimax (const __gwchar_t *__restrict nptr,
+ __gwchar_t **__restrict endptr, int base))
+{
+ return __wcstol_internal (nptr, endptr, base, 0);
+}
+
+extern unsigned long int __wcstoul_internal (const __gwchar_t *
+ __restrict __nptr,
+ __gwchar_t **
+ __restrict __endptr,
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `wcstoul' but convert to `uintmax_t'. */
+__extern_inline uintmax_t
+__NTH (wcstoumax (const __gwchar_t *__restrict nptr,
+ __gwchar_t **__restrict endptr, int base))
+{
+ return __wcstoul_internal (nptr, endptr, base, 0);
+}
+
+# else /* __WORDSIZE == 32 */
+
+__extension__
+extern long long int __strtoll_internal (const char *__restrict __nptr,
+ char **__restrict __endptr,
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `strtol' but convert to `intmax_t'. */
+__extern_inline intmax_t
+__NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr,
+ int base))
+{
+ return __strtoll_internal (nptr, endptr, base, 0);
+}
+
+__extension__
+extern unsigned long long int __strtoull_internal (const char *
+ __restrict __nptr,
+ char **
+ __restrict __endptr,
+ int __base,
+ int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `strtoul' but convert to `uintmax_t'. */
+__extern_inline uintmax_t
+__NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr,
+ int base))
+{
+ return __strtoull_internal (nptr, endptr, base, 0);
+}
+
+__extension__
+extern long long int __wcstoll_internal (const __gwchar_t *__restrict __nptr,
+ __gwchar_t **__restrict __endptr,
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `wcstol' but convert to `intmax_t'. */
+__extern_inline intmax_t
+__NTH (wcstoimax (const __gwchar_t *__restrict nptr,
+ __gwchar_t **__restrict endptr, int base))
+{
+ return __wcstoll_internal (nptr, endptr, base, 0);
+}
+
+
+__extension__
+extern unsigned long long int __wcstoull_internal (const __gwchar_t *
+ __restrict __nptr,
+ __gwchar_t **
+ __restrict __endptr,
+ int __base,
+ int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `wcstoul' but convert to `uintmax_t'. */
+__extern_inline uintmax_t
+__NTH (wcstoumax (const __gwchar_t *__restrict nptr,
+ __gwchar_t **__restrict endptr, int base))
+{
+ return __wcstoull_internal (nptr, endptr, base, 0);
+}
+
+# endif /* __WORDSIZE == 32 */
+#endif /* Use extern inlines. */
+
+__END_DECLS
+
+#endif /* inttypes.h */
diff --git a/REORG.TODO/sysdeps/generic/ld.abilist b/REORG.TODO/sysdeps/generic/ld.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/ld.abilist
diff --git a/REORG.TODO/sysdeps/generic/ldconfig.h b/REORG.TODO/sysdeps/generic/ldconfig.h
new file mode 100644
index 0000000000..a61ce5ca15
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/ldconfig.h
@@ -0,0 +1,94 @@
+/* Copyright (C) 1999-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 1999.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LDCONFIG_H
+#define _LDCONFIG_H
+
+#include <stdint.h>
+
+#define FLAG_ANY -1
+#define FLAG_TYPE_MASK 0x00ff
+#define FLAG_LIBC4 0x0000
+#define FLAG_ELF 0x0001
+#define FLAG_ELF_LIBC5 0x0002
+#define FLAG_ELF_LIBC6 0x0003
+#define FLAG_REQUIRED_MASK 0xff00
+#define FLAG_SPARC_LIB64 0x0100
+#define FLAG_IA64_LIB64 0x0200
+#define FLAG_X8664_LIB64 0x0300
+#define FLAG_S390_LIB64 0x0400
+#define FLAG_POWERPC_LIB64 0x0500
+#define FLAG_MIPS64_LIBN32 0x0600
+#define FLAG_MIPS64_LIBN64 0x0700
+#define FLAG_X8664_LIBX32 0x0800
+#define FLAG_ARM_LIBHF 0x0900
+#define FLAG_AARCH64_LIB64 0x0a00
+#define FLAG_ARM_LIBSF 0x0b00
+#define FLAG_MIPS_LIB32_NAN2008 0x0c00
+#define FLAG_MIPS64_LIBN32_NAN2008 0x0d00
+#define FLAG_MIPS64_LIBN64_NAN2008 0x0e00
+
+/* Name of auxiliary cache. */
+#define _PATH_LDCONFIG_AUX_CACHE "/var/cache/ldconfig/aux-cache"
+
+/* Declared in cache.c. */
+extern void print_cache (const char *cache_name);
+
+extern void init_cache (void);
+
+extern void save_cache (const char *cache_name);
+
+extern void add_to_cache (const char *path, const char *lib, int flags,
+ unsigned int osversion, uint64_t hwcap);
+
+extern void init_aux_cache (void);
+
+extern void load_aux_cache (const char *aux_cache_name);
+
+extern int search_aux_cache (struct stat64 *stat_buf, int *flags,
+ unsigned int *osversion, char **soname);
+
+extern void add_to_aux_cache (struct stat64 *stat_buf, int flags,
+ unsigned int osversion, const char *soname);
+
+extern void save_aux_cache (const char *aux_cache_name);
+
+/* Declared in readlib.c. */
+extern int process_file (const char *real_file_name, const char *file_name,
+ const char *lib, int *flag, unsigned int *osversion,
+ char **soname, int is_link, struct stat64 *stat_buf);
+
+extern char *implicit_soname (const char *lib, int flag);
+
+/* Declared in readelflib.c. */
+extern int process_elf_file (const char *file_name, const char *lib, int *flag,
+ unsigned int *osversion, char **soname,
+ void *file_contents, size_t file_length);
+
+/* Declared in chroot_canon.c. */
+extern char *chroot_canon (const char *chroot, const char *name);
+
+/* Declared in ldconfig.c. */
+extern int opt_verbose;
+
+extern int opt_format;
+
+/* Prototypes for a few program-wide used functions. */
+#include <programs/xmalloc.h>
+
+#endif /* ! _LDCONFIG_H */
diff --git a/REORG.TODO/sysdeps/generic/ldsodefs.h b/REORG.TODO/sysdeps/generic/ldsodefs.h
new file mode 100644
index 0000000000..695ac24c77
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/ldsodefs.h
@@ -0,0 +1,1092 @@
+/* Run-time dynamic linker data structures for loaded ELF shared objects.
+ Copyright (C) 1995-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LDSODEFS_H
+#define _LDSODEFS_H 1
+
+#include <features.h>
+
+#include <stdbool.h>
+#define __need_size_t
+#define __need_NULL
+#include <stddef.h>
+#include <string.h>
+#include <stdint.h>
+
+#include <elf.h>
+#include <dlfcn.h>
+#include <fpu_control.h>
+#include <sys/mman.h>
+#include <link.h>
+#include <dl-lookupcfg.h>
+#include <dl-sysdep.h>
+#include <libc-lock.h>
+#include <hp-timing.h>
+#include <tls.h>
+
+__BEGIN_DECLS
+
+#define VERSYMIDX(sym) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (sym))
+#define VALIDX(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
+ + DT_EXTRANUM + DT_VALTAGIDX (tag))
+#define ADDRIDX(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
+ + DT_EXTRANUM + DT_VALNUM + DT_ADDRTAGIDX (tag))
+
+/* We use this macro to refer to ELF types independent of the native wordsize.
+ `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
+#define ELFW(type) _ElfW (ELF, __ELF_NATIVE_CLASS, type)
+
+/* All references to the value of l_info[DT_PLTGOT],
+ l_info[DT_STRTAB], l_info[DT_SYMTAB], l_info[DT_RELA],
+ l_info[DT_REL], l_info[DT_JMPREL], and l_info[VERSYMIDX (DT_VERSYM)]
+ have to be accessed via the D_PTR macro. The macro is needed since for
+ most architectures the entry is already relocated - but for some not
+ and we need to relocate at access time. */
+#ifdef DL_RO_DYN_SECTION
+# define D_PTR(map, i) ((map)->i->d_un.d_ptr + (map)->l_addr)
+#else
+# define D_PTR(map, i) (map)->i->d_un.d_ptr
+#endif
+
+/* Result of the lookup functions and how to retrieve the base address. */
+typedef struct link_map *lookup_t;
+#define LOOKUP_VALUE(map) map
+#define LOOKUP_VALUE_ADDRESS(map) ((map) ? (map)->l_addr : 0)
+
+/* On some architectures a pointer to a function is not just a pointer
+ to the actual code of the function but rather an architecture
+ specific descriptor. */
+#ifndef ELF_FUNCTION_PTR_IS_SPECIAL
+# define DL_SYMBOL_ADDRESS(map, ref) \
+ (void *) (LOOKUP_VALUE_ADDRESS (map) + ref->st_value)
+# define DL_LOOKUP_ADDRESS(addr) ((ElfW(Addr)) (addr))
+# define DL_CALL_DT_INIT(map, start, argc, argv, env) \
+ ((init_t) (start)) (argc, argv, env)
+# define DL_CALL_DT_FINI(map, start) ((fini_t) (start)) ()
+#endif
+
+/* On some architectures dladdr can't use st_size of all symbols this way. */
+#define DL_ADDR_SYM_MATCH(L, SYM, MATCHSYM, ADDR) \
+ ((ADDR) >= (L)->l_addr + (SYM)->st_value \
+ && ((((SYM)->st_shndx == SHN_UNDEF || (SYM)->st_size == 0) \
+ && (ADDR) == (L)->l_addr + (SYM)->st_value) \
+ || (ADDR) < (L)->l_addr + (SYM)->st_value + (SYM)->st_size) \
+ && ((MATCHSYM) == NULL || (MATCHSYM)->st_value < (SYM)->st_value))
+
+/* According to the ELF gABI no STV_HIDDEN or STV_INTERNAL symbols are
+ expected to be present in dynamic symbol tables as they should have
+ been either removed or converted to STB_LOCAL binding by the static
+ linker. However some GNU binutils versions produce such symbols in
+ some cases. To prevent such symbols present in a buggy binary from
+ preempting global symbols we filter them out with this predicate. */
+static __always_inline bool
+dl_symbol_visibility_binds_local_p (const ElfW(Sym) *sym)
+{
+ return (ELFW(ST_VISIBILITY) (sym->st_other) == STV_HIDDEN
+ || ELFW(ST_VISIBILITY) (sym->st_other) == STV_INTERNAL);
+}
+
+/* Unmap a loaded object, called by _dl_close (). */
+#ifndef DL_UNMAP_IS_SPECIAL
+# define DL_UNMAP(map) _dl_unmap_segments (map)
+#endif
+
+/* By default we do not need special support to initialize DSOs loaded
+ by statically linked binaries. */
+#ifndef DL_STATIC_INIT
+# define DL_STATIC_INIT(map)
+#endif
+
+/* Reloc type classes as returned by elf_machine_type_class().
+ ELF_RTYPE_CLASS_PLT means this reloc should not be satisfied by
+ some PLT symbol, ELF_RTYPE_CLASS_COPY means this reloc should not be
+ satisfied by any symbol in the executable. Some architectures do
+ not support copy relocations. In this case we define the macro to
+ zero so that the code for handling them gets automatically optimized
+ out. ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA means address of protected
+ data defined in the shared library may be external, i.e., due to copy
+ relocation. */
+#define ELF_RTYPE_CLASS_PLT 1
+#ifndef DL_NO_COPY_RELOCS
+# define ELF_RTYPE_CLASS_COPY 2
+#else
+# define ELF_RTYPE_CLASS_COPY 0
+#endif
+/* If DL_EXTERN_PROTECTED_DATA is defined, address of protected data
+ defined in the shared library may be external, i.e., due to copy
+ relocation. */
+#ifdef DL_EXTERN_PROTECTED_DATA
+# define ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA 4
+#else
+# define ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA 0
+#endif
+
+/* ELF uses the PF_x macros to specify the segment permissions, mmap
+ uses PROT_xxx. In most cases the three macros have the values 1, 2,
+ and 3 but not in a matching order. The following macros allows
+ converting from the PF_x values to PROT_xxx values. */
+#define PF_TO_PROT \
+ ((PROT_READ << (PF_R * 4)) \
+ | (PROT_WRITE << (PF_W * 4)) \
+ | (PROT_EXEC << (PF_X * 4)) \
+ | ((PROT_READ | PROT_WRITE) << ((PF_R | PF_W) * 4)) \
+ | ((PROT_READ | PROT_EXEC) << ((PF_R | PF_X) * 4)) \
+ | ((PROT_WRITE | PROT_EXEC) << (PF_W | PF_X) * 4) \
+ | ((PROT_READ | PROT_WRITE | PROT_EXEC) << ((PF_R | PF_W | PF_X) * 4)))
+
+/* The filename itself, or the main program name, if available. */
+#define DSO_FILENAME(name) ((name)[0] ? (name) \
+ : (rtld_progname ?: "<main program>"))
+
+#define RTLD_PROGNAME (rtld_progname ?: "<program name unknown>")
+
+/* For the version handling we need an array with only names and their
+ hash values. */
+struct r_found_version
+ {
+ const char *name;
+ ElfW(Word) hash;
+
+ int hidden;
+ const char *filename;
+ };
+
+/* We want to cache information about the searches for shared objects. */
+
+enum r_dir_status { unknown, nonexisting, existing };
+
+struct r_search_path_elem
+ {
+ /* This link is only used in the `all_dirs' member of `r_search_path'. */
+ struct r_search_path_elem *next;
+
+ /* Strings saying where the definition came from. */
+ const char *what;
+ const char *where;
+
+ /* Basename for this search path element. The string must end with
+ a slash character. */
+ const char *dirname;
+ size_t dirnamelen;
+
+ enum r_dir_status status[0];
+ };
+
+struct r_strlenpair
+ {
+ const char *str;
+ size_t len;
+ };
+
+
+/* A data structure for a simple single linked list of strings. */
+struct libname_list
+ {
+ const char *name; /* Name requested (before search). */
+ struct libname_list *next; /* Link to next name for this object. */
+ int dont_free; /* Flag whether this element should be freed
+ if the object is not entirely unloaded. */
+ };
+
+
+/* Bit masks for the objects which valid callers can come from to
+ functions with restricted interface. */
+enum allowmask
+ {
+ allow_libc = 1,
+ allow_libdl = 2,
+ allow_libpthread = 4,
+ allow_ldso = 8
+ };
+
+
+struct audit_ifaces
+{
+ void (*activity) (uintptr_t *, unsigned int);
+ char *(*objsearch) (const char *, uintptr_t *, unsigned int);
+ unsigned int (*objopen) (struct link_map *, Lmid_t, uintptr_t *);
+ void (*preinit) (uintptr_t *);
+ union
+ {
+ uintptr_t (*symbind32) (Elf32_Sym *, unsigned int, uintptr_t *,
+ uintptr_t *, unsigned int *, const char *);
+ uintptr_t (*symbind64) (Elf64_Sym *, unsigned int, uintptr_t *,
+ uintptr_t *, unsigned int *, const char *);
+ };
+ union
+ {
+#ifdef ARCH_PLTENTER_MEMBERS
+ ARCH_PLTENTER_MEMBERS;
+#endif
+ };
+ union
+ {
+#ifdef ARCH_PLTEXIT_MEMBERS
+ ARCH_PLTEXIT_MEMBERS;
+#endif
+ };
+ unsigned int (*objclose) (uintptr_t *);
+
+ struct audit_ifaces *next;
+};
+
+
+/* Test whether given NAME matches any of the names of the given object. */
+extern int _dl_name_match_p (const char *__name, const struct link_map *__map)
+ internal_function attribute_hidden;
+
+/* Compute next higher prime number. */
+extern unsigned long int _dl_higher_prime_number (unsigned long int n)
+ internal_function attribute_hidden;
+
+/* Function used as argument for `_dl_receive_error' function. The
+ arguments are the error code, error string, and the objname the
+ error occurred in. */
+typedef void (*receiver_fct) (int, const char *, const char *);
+
+/* Internal functions of the run-time dynamic linker.
+ These can be accessed if you link again the dynamic linker
+ as a shared library, as in `-lld' or `/lib/ld.so' explicitly;
+ but are not normally of interest to user programs.
+
+ The `-ldl' library functions in <dlfcn.h> provide a simple
+ user interface to run-time dynamic linking. */
+
+
+#ifndef SHARED
+# define EXTERN extern
+# define GL(name) _##name
+#else
+# define EXTERN
+# if IS_IN (rtld)
+# define GL(name) _rtld_local._##name
+# else
+# define GL(name) _rtld_global._##name
+# endif
+struct rtld_global
+{
+#endif
+ /* Don't change the order of the following elements. 'dl_loaded'
+ must remain the first element. Forever. */
+
+/* Non-shared code has no support for multiple namespaces. */
+#ifdef SHARED
+# define DL_NNS 16
+#else
+# define DL_NNS 1
+#endif
+ EXTERN struct link_namespaces
+ {
+ /* A pointer to the map for the main map. */
+ struct link_map *_ns_loaded;
+ /* Number of object in the _dl_loaded list. */
+ unsigned int _ns_nloaded;
+ /* Direct pointer to the searchlist of the main object. */
+ struct r_scope_elem *_ns_main_searchlist;
+ /* This is zero at program start to signal that the global scope map is
+ allocated by rtld. Later it keeps the size of the map. It might be
+ reset if in _dl_close if the last global object is removed. */
+ size_t _ns_global_scope_alloc;
+ /* Search table for unique objects. */
+ struct unique_sym_table
+ {
+ __rtld_lock_define_recursive (, lock)
+ struct unique_sym
+ {
+ uint32_t hashval;
+ const char *name;
+ const ElfW(Sym) *sym;
+ const struct link_map *map;
+ } *entries;
+ size_t size;
+ size_t n_elements;
+ void (*free) (void *);
+ } _ns_unique_sym_table;
+ /* Keep track of changes to each namespace' list. */
+ struct r_debug _ns_debug;
+ } _dl_ns[DL_NNS];
+ /* One higher than index of last used namespace. */
+ EXTERN size_t _dl_nns;
+
+ /* During the program run we must not modify the global data of
+ loaded shared object simultanously in two threads. Therefore we
+ protect `_dl_open' and `_dl_close' in dl-close.c.
+
+ This must be a recursive lock since the initializer function of
+ the loaded object might as well require a call to this function.
+ At this time it is not anymore a problem to modify the tables. */
+ __rtld_lock_define_recursive (EXTERN, _dl_load_lock)
+ /* This lock is used to keep __dl_iterate_phdr from inspecting the
+ list of loaded objects while an object is added to or removed
+ from that list. */
+ __rtld_lock_define_recursive (EXTERN, _dl_load_write_lock)
+
+ /* Incremented whenever something may have been added to dl_loaded. */
+ EXTERN unsigned long long _dl_load_adds;
+
+ /* The object to be initialized first. */
+ EXTERN struct link_map *_dl_initfirst;
+
+#if HP_SMALL_TIMING_AVAIL
+ /* Start time on CPU clock. */
+ EXTERN hp_timing_t _dl_cpuclock_offset;
+#endif
+
+ /* Map of shared object to be profiled. */
+ EXTERN struct link_map *_dl_profile_map;
+
+ /* Counters for the number of relocations performed. */
+ EXTERN unsigned long int _dl_num_relocations;
+ EXTERN unsigned long int _dl_num_cache_relocations;
+
+ /* List of search directories. */
+ EXTERN struct r_search_path_elem *_dl_all_dirs;
+
+ /* Structure describing the dynamic linker itself. We need to
+ reserve memory for the data the audit libraries need. */
+ EXTERN struct link_map _dl_rtld_map;
+#ifdef SHARED
+ struct auditstate audit_data[DL_NNS];
+#endif
+
+#if defined SHARED && defined _LIBC_REENTRANT \
+ && defined __rtld_lock_default_lock_recursive
+ EXTERN void (*_dl_rtld_lock_recursive) (void *);
+ EXTERN void (*_dl_rtld_unlock_recursive) (void *);
+#endif
+
+ /* If loading a shared object requires that we make the stack executable
+ when it was not, we do it by calling this function.
+ It returns an errno code or zero on success. */
+ EXTERN int (*_dl_make_stack_executable_hook) (void **) internal_function;
+
+ /* Prevailing state of the stack, PF_X indicating it's executable. */
+ EXTERN ElfW(Word) _dl_stack_flags;
+
+ /* Flag signalling whether there are gaps in the module ID allocation. */
+ EXTERN bool _dl_tls_dtv_gaps;
+ /* Highest dtv index currently needed. */
+ EXTERN size_t _dl_tls_max_dtv_idx;
+ /* Information about the dtv slots. */
+ EXTERN struct dtv_slotinfo_list
+ {
+ size_t len;
+ struct dtv_slotinfo_list *next;
+ struct dtv_slotinfo
+ {
+ size_t gen;
+ struct link_map *map;
+ } slotinfo[0];
+ } *_dl_tls_dtv_slotinfo_list;
+ /* Number of modules in the static TLS block. */
+ EXTERN size_t _dl_tls_static_nelem;
+ /* Size of the static TLS block. */
+ EXTERN size_t _dl_tls_static_size;
+ /* Size actually allocated in the static TLS block. */
+ EXTERN size_t _dl_tls_static_used;
+ /* Alignment requirement of the static TLS block. */
+ EXTERN size_t _dl_tls_static_align;
+
+/* Number of additional entries in the slotinfo array of each slotinfo
+ list element. A large number makes it almost certain take we never
+ have to iterate beyond the first element in the slotinfo list. */
+#define TLS_SLOTINFO_SURPLUS (62)
+
+/* Number of additional slots in the dtv allocated. */
+#define DTV_SURPLUS (14)
+
+ /* Initial dtv of the main thread, not allocated with normal malloc. */
+ EXTERN void *_dl_initial_dtv;
+ /* Generation counter for the dtv. */
+ EXTERN size_t _dl_tls_generation;
+
+ EXTERN void (*_dl_init_static_tls) (struct link_map *);
+
+ EXTERN void (*_dl_wait_lookup_done) (void);
+
+ /* Scopes to free after next THREAD_GSCOPE_WAIT (). */
+ EXTERN struct dl_scope_free_list
+ {
+ size_t count;
+ void *list[50];
+ } *_dl_scope_free_list;
+#ifdef SHARED
+};
+# define __rtld_global_attribute__
+# if IS_IN (rtld)
+# ifdef HAVE_SDATA_SECTION
+# define __rtld_local_attribute__ \
+ __attribute__ ((visibility ("hidden"), section (".sdata")))
+# undef __rtld_global_attribute__
+# define __rtld_global_attribute__ __attribute__ ((section (".sdata")))
+# else
+# define __rtld_local_attribute__ __attribute__ ((visibility ("hidden")))
+# endif
+extern struct rtld_global _rtld_local __rtld_local_attribute__;
+# undef __rtld_local_attribute__
+# endif
+extern struct rtld_global _rtld_global __rtld_global_attribute__;
+# undef __rtld_global_attribute__
+#endif
+
+#ifndef SHARED
+# define GLRO(name) _##name
+#else
+# if IS_IN (rtld)
+# define GLRO(name) _rtld_local_ro._##name
+# else
+# define GLRO(name) _rtld_global_ro._##name
+# endif
+struct rtld_global_ro
+{
+#endif
+
+ /* If nonzero the appropriate debug information is printed. */
+ EXTERN int _dl_debug_mask;
+#define DL_DEBUG_LIBS (1 << 0)
+#define DL_DEBUG_IMPCALLS (1 << 1)
+#define DL_DEBUG_BINDINGS (1 << 2)
+#define DL_DEBUG_SYMBOLS (1 << 3)
+#define DL_DEBUG_VERSIONS (1 << 4)
+#define DL_DEBUG_RELOC (1 << 5)
+#define DL_DEBUG_FILES (1 << 6)
+#define DL_DEBUG_STATISTICS (1 << 7)
+#define DL_DEBUG_UNUSED (1 << 8)
+#define DL_DEBUG_SCOPES (1 << 9)
+/* These two are used only internally. */
+#define DL_DEBUG_HELP (1 << 10)
+#define DL_DEBUG_PRELINK (1 << 11)
+
+ /* OS version. */
+ EXTERN unsigned int _dl_osversion;
+ /* Platform name. */
+ EXTERN const char *_dl_platform;
+ EXTERN size_t _dl_platformlen;
+
+ /* Cached value of `getpagesize ()'. */
+ EXTERN size_t _dl_pagesize;
+
+ /* Do we read from ld.so.cache? */
+ EXTERN int _dl_inhibit_cache;
+
+ /* Copy of the content of `_dl_main_searchlist' at startup time. */
+ EXTERN struct r_scope_elem _dl_initial_searchlist;
+
+ /* CLK_TCK as reported by the kernel. */
+ EXTERN int _dl_clktck;
+
+ /* If nonzero print warnings messages. */
+ EXTERN int _dl_verbose;
+
+ /* File descriptor to write debug messages to. */
+ EXTERN int _dl_debug_fd;
+
+ /* Do we do lazy relocations? */
+ EXTERN int _dl_lazy;
+
+ /* Nonzero if runtime lookups should not update the .got/.plt. */
+ EXTERN int _dl_bind_not;
+
+ /* Nonzero if references should be treated as weak during runtime
+ linking. */
+ EXTERN int _dl_dynamic_weak;
+
+ /* Default floating-point control word. */
+ EXTERN fpu_control_t _dl_fpu_control;
+
+ /* Expected cache ID. */
+ EXTERN int _dl_correct_cache_id;
+
+ /* Mask for hardware capabilities that are available. */
+ EXTERN uint64_t _dl_hwcap;
+
+#if !HAVE_TUNABLES
+ /* Mask for important hardware capabilities we honour. */
+ EXTERN uint64_t _dl_hwcap_mask;
+#endif
+
+#ifdef HAVE_AUX_VECTOR
+ /* Pointer to the auxv list supplied to the program at startup. */
+ EXTERN ElfW(auxv_t) *_dl_auxv;
+#endif
+
+ /* Get architecture specific definitions. */
+#define PROCINFO_DECL
+#ifndef PROCINFO_CLASS
+# define PROCINFO_CLASS EXTERN
+#endif
+#include <dl-procinfo.c>
+
+ /* Names of shared object for which the RPATH should be ignored. */
+ EXTERN const char *_dl_inhibit_rpath;
+
+ /* Location of the binary. */
+ EXTERN const char *_dl_origin_path;
+
+ /* -1 if the dynamic linker should honor library load bias,
+ 0 if not, -2 use the default (honor biases for normal
+ binaries, don't honor for PIEs). */
+ EXTERN ElfW(Addr) _dl_use_load_bias;
+
+ /* Name of the shared object to be profiled (if any). */
+ EXTERN const char *_dl_profile;
+ /* Filename of the output file. */
+ EXTERN const char *_dl_profile_output;
+ /* Name of the object we want to trace the prelinking. */
+ EXTERN const char *_dl_trace_prelink;
+ /* Map of shared object to be prelink traced. */
+ EXTERN struct link_map *_dl_trace_prelink_map;
+
+ /* All search directories defined at startup. */
+ EXTERN struct r_search_path_elem *_dl_init_all_dirs;
+
+#ifdef NEED_DL_SYSINFO
+ /* Syscall handling improvements. This is very specific to x86. */
+ EXTERN uintptr_t _dl_sysinfo;
+#endif
+
+#ifdef NEED_DL_SYSINFO_DSO
+ /* The vsyscall page is a virtual DSO pre-mapped by the kernel.
+ This points to its ELF header. */
+ EXTERN const ElfW(Ehdr) *_dl_sysinfo_dso;
+
+ /* At startup time we set up the normal DSO data structure for it,
+ and this points to it. */
+ EXTERN struct link_map *_dl_sysinfo_map;
+#endif
+
+ /* Mask for more hardware capabilities that are available on some
+ platforms. */
+ EXTERN uint64_t _dl_hwcap2;
+
+#ifdef SHARED
+ /* We add a function table to _rtld_global which is then used to
+ call the function instead of going through the PLT. The result
+ is that we can avoid exporting the functions and we do not jump
+ PLT relocations in libc.so. */
+ void (*_dl_debug_printf) (const char *, ...)
+ __attribute__ ((__format__ (__printf__, 1, 2)));
+ void (*_dl_mcount) (ElfW(Addr) frompc, ElfW(Addr) selfpc);
+ lookup_t (internal_function *_dl_lookup_symbol_x) (const char *,
+ struct link_map *,
+ const ElfW(Sym) **,
+ struct r_scope_elem *[],
+ const struct r_found_version *,
+ int, int,
+ struct link_map *);
+ int (*_dl_check_caller) (const void *, enum allowmask);
+ void *(*_dl_open) (const char *file, int mode, const void *caller_dlopen,
+ Lmid_t nsid, int argc, char *argv[], char *env[]);
+ void (*_dl_close) (void *map);
+ void *(*_dl_tls_get_addr_soft) (struct link_map *);
+#ifdef HAVE_DL_DISCOVER_OSVERSION
+ int (*_dl_discover_osversion) (void);
+#endif
+
+ /* List of auditing interfaces. */
+ struct audit_ifaces *_dl_audit;
+ unsigned int _dl_naudit;
+};
+# define __rtld_global_attribute__
+# if IS_IN (rtld)
+# define __rtld_local_attribute__ __attribute__ ((visibility ("hidden")))
+extern struct rtld_global_ro _rtld_local_ro
+ attribute_relro __rtld_local_attribute__;
+extern struct rtld_global_ro _rtld_global_ro
+ attribute_relro __rtld_global_attribute__;
+# undef __rtld_local_attribute__
+# else
+/* We cheat a bit here. We declare the variable as as const even
+ though it is at startup. */
+extern const struct rtld_global_ro _rtld_global_ro
+ attribute_relro __rtld_global_attribute__;
+# endif
+# undef __rtld_global_attribute__
+#endif
+#undef EXTERN
+
+#ifndef SHARED
+/* dl-support.c defines these and initializes them early on. */
+extern const ElfW(Phdr) *_dl_phdr;
+extern size_t _dl_phnum;
+#endif
+
+/* This is the initial value of GL(dl_make_stack_executable_hook).
+ A threads library can change it. */
+extern int _dl_make_stack_executable (void **stack_endp) internal_function;
+rtld_hidden_proto (_dl_make_stack_executable)
+
+/* Variable pointing to the end of the stack (or close to it). This value
+ must be constant over the runtime of the application. Some programs
+ might use the variable which results in copy relocations on some
+ platforms. But this does not matter, ld.so can always use the local
+ copy. */
+extern void *__libc_stack_end
+#ifndef LIBC_STACK_END_NOT_RELRO
+ attribute_relro
+#endif
+ ;
+rtld_hidden_proto (__libc_stack_end)
+
+/* Parameters passed to the dynamic linker. */
+extern int _dl_argc attribute_hidden attribute_relro;
+extern char **_dl_argv
+#ifndef DL_ARGV_NOT_RELRO
+ attribute_relro
+#endif
+ ;
+rtld_hidden_proto (_dl_argv)
+#if IS_IN (rtld)
+extern unsigned int _dl_skip_args attribute_hidden
+# ifndef DL_ARGV_NOT_RELRO
+ attribute_relro
+# endif
+ ;
+extern unsigned int _dl_skip_args_internal attribute_hidden
+# ifndef DL_ARGV_NOT_RELRO
+ attribute_relro
+# endif
+ ;
+#endif
+#define rtld_progname _dl_argv[0]
+
+/* Flag set at startup and cleared when the last initializer has run. */
+extern int _dl_starting_up;
+weak_extern (_dl_starting_up)
+rtld_hidden_proto (_dl_starting_up)
+
+/* Random data provided by the kernel. */
+extern void *_dl_random attribute_hidden attribute_relro;
+
+/* OS-dependent function to open the zero-fill device. */
+extern int _dl_sysdep_open_zero_fill (void); /* dl-sysdep.c */
+
+
+/* Write message on the debug file descriptor. The parameters are
+ interpreted as for a `printf' call. All the lines start with a
+ tag showing the PID. */
+extern void _dl_debug_printf (const char *fmt, ...)
+ __attribute__ ((__format__ (__printf__, 1, 2))) attribute_hidden;
+
+/* Write message on the debug file descriptor. The parameters are
+ interpreted as for a `printf' call. All the lines buf the first
+ start with a tag showing the PID. */
+extern void _dl_debug_printf_c (const char *fmt, ...)
+ __attribute__ ((__format__ (__printf__, 1, 2))) attribute_hidden;
+
+
+/* Write a message on the specified descriptor FD. The parameters are
+ interpreted as for a `printf' call. */
+#if IS_IN (rtld) || !defined (SHARED)
+extern void _dl_dprintf (int fd, const char *fmt, ...)
+ __attribute__ ((__format__ (__printf__, 2, 3)))
+ attribute_hidden;
+#else
+__attribute__ ((always_inline, __format__ (__printf__, 2, 3)))
+static inline void
+_dl_dprintf (int fd, const char *fmt, ...)
+{
+ /* Use local declaration to avoid includign <stdio.h>. */
+ extern int __dprintf(int fd, const char *format, ...) attribute_hidden;
+ __dprintf (fd, fmt, __builtin_va_arg_pack ());
+}
+#endif
+
+/* Write a message on the specified descriptor standard output. The
+ parameters are interpreted as for a `printf' call. */
+#define _dl_printf(fmt, args...) \
+ _dl_dprintf (STDOUT_FILENO, fmt, ##args)
+
+/* Write a message on the specified descriptor standard error. The
+ parameters are interpreted as for a `printf' call. */
+#define _dl_error_printf(fmt, args...) \
+ _dl_dprintf (STDERR_FILENO, fmt, ##args)
+
+/* Write a message on the specified descriptor standard error and exit
+ the program. The parameters are interpreted as for a `printf' call. */
+#define _dl_fatal_printf(fmt, args...) \
+ do \
+ { \
+ _dl_dprintf (STDERR_FILENO, fmt, ##args); \
+ _exit (127); \
+ } \
+ while (1)
+
+
+/* This function is called by all the internal dynamic linker functions
+ when they encounter an error. ERRCODE is either an `errno' code or
+ zero; OBJECT is the name of the problematical shared object, or null if
+ it is a general problem; ERRSTRING is a string describing the specific
+ problem. */
+extern void _dl_signal_error (int errcode, const char *object,
+ const char *occurred, const char *errstring)
+ internal_function __attribute__ ((__noreturn__));
+libc_hidden_proto (_dl_signal_error)
+
+/* Like _dl_signal_error, but may return when called in the context of
+ _dl_receive_error. This is only used during ld.so bootstrap. In
+ static and profiled builds, this is equivalent to
+ _dl_signal_error. */
+#if IS_IN (rtld)
+extern void _dl_signal_cerror (int errcode, const char *object,
+ const char *occation, const char *errstring)
+ internal_function attribute_hidden;
+#else
+__attribute__ ((always_inline))
+static inline void
+_dl_signal_cerror (int errcode, const char *object,
+ const char *occation, const char *errstring)
+{
+ _dl_signal_error (errcode, object, occation, errstring);
+}
+#endif
+
+/* Call OPERATE, receiving errors from `dl_signal_cerror'. Unlike
+ `_dl_catch_error' the operation is resumed after the OPERATE
+ function returns.
+ ARGS is passed as argument to OPERATE. */
+extern void _dl_receive_error (receiver_fct fct, void (*operate) (void *),
+ void *args)
+ internal_function attribute_hidden;
+
+/* Call OPERATE, catching errors from `dl_signal_error'. If there is no
+ error, *ERRSTRING is set to null. If there is an error, *ERRSTRING is
+ set to a string constructed from the strings passed to _dl_signal_error,
+ and the error code passed is the return value and *OBJNAME is set to
+ the object name which experienced the problems. ERRSTRING if nonzero
+ points to a malloc'ed string which the caller has to free after use.
+ ARGS is passed as argument to OPERATE. MALLOCEDP is set to true only
+ if the returned string is allocated using the libc's malloc. */
+extern int _dl_catch_error (const char **objname, const char **errstring,
+ bool *mallocedp, void (*operate) (void *),
+ void *args)
+ internal_function;
+libc_hidden_proto (_dl_catch_error)
+
+/* Open the shared object NAME and map in its segments.
+ LOADER's DT_RPATH is used in searching for NAME.
+ If the object is already opened, returns its existing map. */
+extern struct link_map *_dl_map_object (struct link_map *loader,
+ const char *name,
+ int type, int trace_mode, int mode,
+ Lmid_t nsid)
+ internal_function attribute_hidden;
+
+/* Call _dl_map_object on the dependencies of MAP, and set up
+ MAP->l_searchlist. PRELOADS points to a vector of NPRELOADS previously
+ loaded objects that will be inserted into MAP->l_searchlist after MAP
+ but before its dependencies. */
+extern void _dl_map_object_deps (struct link_map *map,
+ struct link_map **preloads,
+ unsigned int npreloads, int trace_mode,
+ int open_mode)
+ internal_function attribute_hidden;
+
+/* Cache the locations of MAP's hash table. */
+extern void _dl_setup_hash (struct link_map *map)
+ internal_function attribute_hidden;
+
+
+/* Collect the directories in the search path for LOADER's dependencies.
+ The data structure is defined in <dlfcn.h>. If COUNTING is true,
+ SI->dls_cnt and SI->dls_size are set; if false, those must be as set
+ by a previous call with COUNTING set, and SI must point to SI->dls_size
+ bytes to be used in filling in the result. */
+extern void _dl_rtld_di_serinfo (struct link_map *loader,
+ Dl_serinfo *si, bool counting)
+ internal_function;
+
+
+/* Search loaded objects' symbol tables for a definition of the symbol
+ referred to by UNDEF. *SYM is the symbol table entry containing the
+ reference; it is replaced with the defining symbol, and the base load
+ address of the defining object is returned. SYMBOL_SCOPE is a
+ null-terminated list of object scopes to search; each object's
+ l_searchlist (i.e. the segment of the dependency tree starting at that
+ object) is searched in turn. REFERENCE_NAME should name the object
+ containing the reference; it is used in error messages.
+ TYPE_CLASS describes the type of symbol we are looking for. */
+enum
+ {
+ /* If necessary add dependency between user and provider object. */
+ DL_LOOKUP_ADD_DEPENDENCY = 1,
+ /* Return most recent version instead of default version for
+ unversioned lookup. */
+ DL_LOOKUP_RETURN_NEWEST = 2,
+ /* Set if dl_lookup* called with GSCOPE lock held. */
+ DL_LOOKUP_GSCOPE_LOCK = 4,
+ };
+
+/* Lookup versioned symbol. */
+extern lookup_t _dl_lookup_symbol_x (const char *undef,
+ struct link_map *undef_map,
+ const ElfW(Sym) **sym,
+ struct r_scope_elem *symbol_scope[],
+ const struct r_found_version *version,
+ int type_class, int flags,
+ struct link_map *skip_map)
+ internal_function attribute_hidden;
+
+
+/* Look up symbol NAME in MAP's scope and return its run-time address. */
+extern ElfW(Addr) _dl_symbol_value (struct link_map *map, const char *name)
+ internal_function;
+
+/* Add the new link_map NEW to the end of the namespace list. */
+extern void _dl_add_to_namespace_list (struct link_map *new, Lmid_t nsid)
+ internal_function attribute_hidden;
+
+/* Allocate a `struct link_map' for a new object being loaded. */
+extern struct link_map *_dl_new_object (char *realname, const char *libname,
+ int type, struct link_map *loader,
+ int mode, Lmid_t nsid)
+ internal_function attribute_hidden;
+
+/* Relocate the given object (if it hasn't already been).
+ SCOPE is passed to _dl_lookup_symbol in symbol lookups.
+ If RTLD_LAZY is set in RELOC-MODE, don't relocate its PLT. */
+extern void _dl_relocate_object (struct link_map *map,
+ struct r_scope_elem *scope[],
+ int reloc_mode, int consider_profiling)
+ attribute_hidden;
+
+/* Protect PT_GNU_RELRO area. */
+extern void _dl_protect_relro (struct link_map *map)
+ internal_function attribute_hidden;
+
+/* Call _dl_signal_error with a message about an unhandled reloc type.
+ TYPE is the result of ELFW(R_TYPE) (r_info), i.e. an R_<CPU>_* value.
+ PLT is nonzero if this was a PLT reloc; it just affects the message. */
+extern void _dl_reloc_bad_type (struct link_map *map,
+ unsigned int type, int plt)
+ internal_function attribute_hidden __attribute__ ((__noreturn__));
+
+/* Resolve conflicts if prelinking. */
+extern void _dl_resolve_conflicts (struct link_map *l,
+ ElfW(Rela) *conflict,
+ ElfW(Rela) *conflictend)
+ attribute_hidden;
+
+/* Check the version dependencies of all objects available through
+ MAP. If VERBOSE print some more diagnostics. */
+extern int _dl_check_all_versions (struct link_map *map, int verbose,
+ int trace_mode)
+ internal_function attribute_hidden;
+
+/* Check the version dependencies for MAP. If VERBOSE print some more
+ diagnostics. */
+extern int _dl_check_map_versions (struct link_map *map, int verbose,
+ int trace_mode)
+ internal_function attribute_hidden;
+
+/* Initialize the object in SCOPE by calling the constructors with
+ ARGC, ARGV, and ENV as the parameters. */
+extern void _dl_init (struct link_map *main_map, int argc, char **argv,
+ char **env) internal_function attribute_hidden;
+
+/* Call the finalizer functions of all shared objects whose
+ initializer functions have completed. */
+extern void _dl_fini (void) internal_function;
+
+/* Sort array MAPS according to dependencies of the contained objects. */
+extern void _dl_sort_fini (struct link_map **maps, size_t nmaps, char *used,
+ Lmid_t ns)
+ internal_function attribute_hidden;
+
+/* The dynamic linker calls this function before and having changing
+ any shared object mappings. The `r_state' member of `struct r_debug'
+ says what change is taking place. This function's address is
+ the value of the `r_brk' member. */
+extern void _dl_debug_state (void);
+rtld_hidden_proto (_dl_debug_state)
+
+/* Initialize `struct r_debug' if it has not already been done. The
+ argument is the run-time load address of the dynamic linker, to be put
+ in the `r_ldbase' member. Returns the address of the structure. */
+extern struct r_debug *_dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
+ internal_function attribute_hidden;
+
+/* Initialize the basic data structure for the search paths. */
+extern void _dl_init_paths (const char *library_path)
+ internal_function attribute_hidden;
+
+/* Gather the information needed to install the profiling tables and start
+ the timers. */
+extern void _dl_start_profile (void) internal_function attribute_hidden;
+
+/* The actual functions used to keep book on the calls. */
+extern void _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc);
+rtld_hidden_proto (_dl_mcount)
+
+/* This function is simply a wrapper around the _dl_mcount function
+ which does not require a FROMPC parameter since this is the
+ calling function. */
+extern void _dl_mcount_wrapper (void *selfpc);
+
+/* Show the members of the auxiliary array passed up from the kernel. */
+extern void _dl_show_auxv (void)
+ internal_function attribute_hidden;
+
+/* Return all environment variables starting with `LD_', one after the
+ other. */
+extern char *_dl_next_ld_env_entry (char ***position)
+ internal_function attribute_hidden;
+
+/* Return an array with the names of the important hardware capabilities. */
+extern const struct r_strlenpair *_dl_important_hwcaps (const char *platform,
+ size_t paltform_len,
+ size_t *sz,
+ size_t *max_capstrlen)
+ internal_function attribute_hidden;
+
+/* Look up NAME in ld.so.cache and return the file name stored there,
+ or null if none is found. Caller must free returned string. */
+extern char *_dl_load_cache_lookup (const char *name)
+ internal_function attribute_hidden;
+
+/* If the system does not support MAP_COPY we cannot leave the file open
+ all the time since this would create problems when the file is replaced.
+ Therefore we provide this function to close the file and open it again
+ once needed. */
+extern void _dl_unload_cache (void) attribute_hidden;
+
+/* System-dependent function to read a file's whole contents in the
+ most convenient manner available. *SIZEP gets the size of the
+ file. On error MAP_FAILED is returned. */
+extern void *_dl_sysdep_read_whole_file (const char *file, size_t *sizep,
+ int prot)
+ internal_function attribute_hidden;
+
+/* System-specific function to do initial startup for the dynamic linker.
+ After this, file access calls and getenv must work. This is responsible
+ for setting __libc_enable_secure if we need to be secure (e.g. setuid),
+ and for setting _dl_argc and _dl_argv, and then calling _dl_main. */
+extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
+ void (*dl_main) (const ElfW(Phdr) *phdr,
+ ElfW(Word) phnum,
+ ElfW(Addr) *user_entry,
+ ElfW(auxv_t) *auxv))
+ attribute_hidden;
+
+extern void _dl_sysdep_start_cleanup (void)
+ internal_function attribute_hidden;
+
+
+/* Determine next available module ID. */
+extern size_t _dl_next_tls_modid (void) internal_function attribute_hidden;
+
+/* Count the modules with TLS segments. */
+extern size_t _dl_count_modids (void) internal_function attribute_hidden;
+
+/* Calculate offset of the TLS blocks in the static TLS block. */
+extern void _dl_determine_tlsoffset (void) internal_function attribute_hidden;
+
+#ifndef SHARED
+/* Set up the TCB for statically linked applications. This is called
+ early during startup because we always use TLS (for errno and the
+ stack protector, among other things). */
+void __libc_setup_tls (void);
+
+/* Initialization of libpthread for statically linked applications.
+ If libpthread is not linked in, this is an empty function. */
+void __pthread_initialize_minimal (void) weak_function;
+#endif
+
+/* Allocate memory for static TLS block (unless MEM is nonzero) and dtv. */
+extern void *_dl_allocate_tls (void *mem) internal_function;
+rtld_hidden_proto (_dl_allocate_tls)
+
+/* Get size and alignment requirements of the static TLS block. */
+extern void _dl_get_tls_static_info (size_t *sizep, size_t *alignp)
+ internal_function;
+
+extern void _dl_allocate_static_tls (struct link_map *map)
+ internal_function attribute_hidden;
+
+/* These are internal entry points to the two halves of _dl_allocate_tls,
+ only used within rtld.c itself at startup time. */
+extern void *_dl_allocate_tls_storage (void)
+ internal_function attribute_hidden;
+extern void *_dl_allocate_tls_init (void *) internal_function;
+rtld_hidden_proto (_dl_allocate_tls_init)
+
+/* Deallocate memory allocated with _dl_allocate_tls. */
+extern void _dl_deallocate_tls (void *tcb, bool dealloc_tcb) internal_function;
+rtld_hidden_proto (_dl_deallocate_tls)
+
+extern void _dl_nothread_init_static_tls (struct link_map *) attribute_hidden;
+
+/* Find origin of the executable. */
+extern const char *_dl_get_origin (void) attribute_hidden;
+
+/* Count DSTs. */
+extern size_t _dl_dst_count (const char *name, int is_path) attribute_hidden;
+
+/* Substitute DST values. */
+extern char *_dl_dst_substitute (struct link_map *l, const char *name,
+ char *result, int is_path) attribute_hidden;
+
+/* Check validity of the caller. */
+extern int _dl_check_caller (const void *caller, enum allowmask mask)
+ attribute_hidden;
+
+/* Open the shared object NAME, relocate it, and run its initializer if it
+ hasn't already been run. MODE is as for `dlopen' (see <dlfcn.h>). If
+ the object is already opened, returns its existing map. */
+extern void *_dl_open (const char *name, int mode, const void *caller,
+ Lmid_t nsid, int argc, char *argv[], char *env[])
+ attribute_hidden;
+
+/* Free or queue for freeing scope OLD. If other threads might be
+ in the middle of _dl_fixup, _dl_profile_fixup or dl*sym using the
+ old scope, OLD can't be freed until no thread is using it. */
+extern int _dl_scope_free (void *) attribute_hidden;
+
+/* Add module to slot information data. */
+extern void _dl_add_to_slotinfo (struct link_map *l) attribute_hidden;
+
+/* Update slot information data for at least the generation of the
+ module with the given index. */
+extern struct link_map *_dl_update_slotinfo (unsigned long int req_modid)
+ attribute_hidden;
+
+/* Look up the module's TLS block as for __tls_get_addr,
+ but never touch anything. Return null if it's not allocated yet. */
+extern void *_dl_tls_get_addr_soft (struct link_map *l) attribute_hidden;
+
+extern int _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr)
+ internal_function attribute_hidden;
+
+/* Show show of an object. */
+extern void _dl_show_scope (struct link_map *new, int from)
+ attribute_hidden;
+
+extern struct link_map *_dl_find_dso_for_object (const ElfW(Addr) addr)
+ internal_function;
+rtld_hidden_proto (_dl_find_dso_for_object)
+
+/* Initialization which is normally done by the dynamic linker. */
+extern void _dl_non_dynamic_init (void) internal_function;
+
+/* Used by static binaries to check the auxiliary vector. */
+extern void _dl_aux_init (ElfW(auxv_t) *av) internal_function;
+
+
+__END_DECLS
+
+#endif /* ldsodefs.h */
diff --git a/REORG.TODO/sysdeps/generic/libBrokenLocale.abilist b/REORG.TODO/sysdeps/generic/libBrokenLocale.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libBrokenLocale.abilist
diff --git a/REORG.TODO/sysdeps/generic/libanl.abilist b/REORG.TODO/sysdeps/generic/libanl.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libanl.abilist
diff --git a/REORG.TODO/sysdeps/generic/libc-lock.h b/REORG.TODO/sysdeps/generic/libc-lock.h
new file mode 100644
index 0000000000..ed7bdc0393
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libc-lock.h
@@ -0,0 +1,140 @@
+/* libc-internal interface for mutex locks. Stub version.
+ Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LIBC_LOCK_H
+#define _LIBC_LOCK_H 1
+
+
+/* Define a lock variable NAME with storage class CLASS. The lock must be
+ initialized with __libc_lock_init before it can be used (or define it
+ with __libc_lock_define_initialized, below). Use `extern' for CLASS to
+ declare a lock defined in another module. In public structure
+ definitions you must use a pointer to the lock structure (i.e., NAME
+ begins with a `*'), because its storage size will not be known outside
+ of libc. */
+#define __libc_lock_define(CLASS,NAME)
+#define __libc_lock_define_recursive(CLASS,NAME)
+#define __rtld_lock_define_recursive(CLASS,NAME)
+#define __libc_rwlock_define(CLASS,NAME)
+
+/* Define an initialized lock variable NAME with storage class CLASS. */
+#define __libc_lock_define_initialized(CLASS,NAME)
+#define __libc_rwlock_define_initialized(CLASS,NAME)
+
+/* Define an initialized recursive lock variable NAME with storage
+ class CLASS. */
+#define __libc_lock_define_initialized_recursive(CLASS,NAME)
+#define __rtld_lock_define_initialized_recursive(CLASS,NAME)
+
+/* Initialize the named lock variable, leaving it in a consistent, unlocked
+ state. */
+#define __libc_lock_init(NAME)
+#define __rtld_lock_initialize(NAME)
+#define __libc_rwlock_init(NAME)
+
+/* Same as last but this time we initialize a recursive mutex. */
+#define __libc_lock_init_recursive(NAME)
+
+/* Finalize the named lock variable, which must be locked. It cannot be
+ used again until __libc_lock_init is called again on it. This must be
+ called on a lock variable before the containing storage is reused. */
+#define __libc_lock_fini(NAME)
+#define __libc_rwlock_fini(NAME)
+
+/* Finalize recursive named lock. */
+#define __libc_lock_fini_recursive(NAME)
+
+/* Lock the named lock variable. */
+#define __libc_lock_lock(NAME)
+#define __libc_rwlock_rdlock(NAME)
+#define __libc_rwlock_wrlock(NAME)
+
+/* Lock the recursive named lock variable. */
+#define __libc_lock_lock_recursive(NAME)
+#define __rtld_lock_lock_recursive(NAME)
+
+/* Try to lock the named lock variable. */
+#define __libc_lock_trylock(NAME) 0
+#define __libc_rwlock_tryrdlock(NAME) 0
+#define __libc_rwlock_trywrlock(NAME) 0
+
+/* Try to lock the recursive named lock variable. */
+#define __libc_lock_trylock_recursive(NAME) 0
+
+/* Unlock the named lock variable. */
+#define __libc_lock_unlock(NAME)
+#define __libc_rwlock_unlock(NAME)
+
+/* Unlock the recursive named lock variable. */
+#define __libc_lock_unlock_recursive(NAME)
+#define __rtld_lock_unlock_recursive(NAME)
+
+
+/* Define once control variable. */
+#define __libc_once_define(CLASS, NAME) CLASS int NAME = 0
+
+/* Call handler iff the first call. */
+#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
+ do { \
+ if ((ONCE_CONTROL) == 0) { \
+ INIT_FUNCTION (); \
+ (ONCE_CONTROL) = 1; \
+ } \
+ } while (0)
+
+/* Get once control variable. */
+#define __libc_once_get(ONCE_CONTROL) \
+ ((ONCE_CONTROL) == 1)
+
+/* Start a critical region with a cleanup function */
+#define __libc_cleanup_region_start(DOIT, FCT, ARG) \
+{ \
+ typeof (***(FCT)) *__save_FCT = (DOIT) ? (FCT) : 0; \
+ typeof (ARG) __save_ARG = ARG; \
+ /* close brace is in __libc_cleanup_region_end below. */
+
+/* End a critical region started with __libc_cleanup_region_start. */
+#define __libc_cleanup_region_end(DOIT) \
+ if ((DOIT) && __save_FCT != 0) \
+ (*__save_FCT)(__save_ARG); \
+}
+
+/* Sometimes we have to exit the block in the middle. */
+#define __libc_cleanup_end(DOIT) \
+ if ((DOIT) && __save_FCT != 0) \
+ (*__save_FCT)(__save_ARG); \
+
+#define __libc_cleanup_push(fct, arg) __libc_cleanup_region_start (1, fct, arg)
+#define __libc_cleanup_pop(execute) __libc_cleanup_region_end (execute)
+
+/* We need portable names for some of the functions. */
+#define __libc_mutex_unlock
+
+/* Type for key of thread specific data. */
+typedef int __libc_key_t;
+
+/* Create key for thread specific data. */
+#define __libc_key_create(KEY,DEST) ((void) (KEY), (void) (DEST), -1)
+
+/* Set thread-specific data associated with KEY to VAL. */
+#define __libc_setspecific(KEY,VAL) ((void) (KEY), (void) (VAL))
+
+/* Get thread-specific data associated with KEY. */
+#define __libc_getspecific(KEY) ((void) (KEY), (void *) 0)
+
+#endif /* libc-lock.h */
diff --git a/REORG.TODO/sysdeps/generic/libc-mmap.h b/REORG.TODO/sysdeps/generic/libc-mmap.h
new file mode 100644
index 0000000000..9b64fb4780
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libc-mmap.h
@@ -0,0 +1,26 @@
+/* Internal logic for dealing with mmap quirks.
+ Copyright (C) 2013-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LIBC_MMAP_H
+#define _LIBC_MMAP_H 1
+
+/* Using MAP_FIXED with mmap sometimes requires larger alignment. */
+#include <sys/shm.h>
+#define MAP_FIXED_ALIGNMENT SHMLBA
+
+#endif
diff --git a/REORG.TODO/sysdeps/generic/libc-tsd.h b/REORG.TODO/sysdeps/generic/libc-tsd.h
new file mode 100644
index 0000000000..cd04e02050
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libc-tsd.h
@@ -0,0 +1,60 @@
+/* libc-internal interface for thread-specific data. Stub or TLS version.
+ Copyright (C) 1998-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _GENERIC_LIBC_TSD_H
+#define _GENERIC_LIBC_TSD_H 1
+
+/* This file defines the following macros for accessing a small fixed
+ set of thread-specific `void *' data used only internally by libc.
+
+ __libc_tsd_define(CLASS, TYPE, KEY) -- Define or declare a datum with TYPE
+ for KEY. CLASS can be `static' for
+ keys used in only one source file,
+ empty for global definitions, or
+ `extern' for global declarations.
+ __libc_tsd_address(TYPE, KEY) -- Return the `TYPE *' pointing to
+ the current thread's datum for KEY.
+ __libc_tsd_get(TYPE, KEY) -- Return the `TYPE' datum for KEY.
+ __libc_tsd_set(TYPE, KEY, VALUE) -- Set the datum for KEY to VALUE.
+
+ The set of available KEY's will usually be provided as an enum,
+ and contains (at least):
+ _LIBC_TSD_KEY_MALLOC
+ _LIBC_TSD_KEY_DL_ERROR
+ _LIBC_TSD_KEY_RPC_VARS
+ All uses must be the literal _LIBC_TSD_* name in the __libc_tsd_* macros.
+ Some implementations may not provide any enum at all and instead
+ using string pasting in the macros. */
+
+#include <tls.h>
+
+/* When full support for __thread variables is available, this interface is
+ just a trivial wrapper for it. Without TLS, this is the generic/stub
+ implementation for wholly single-threaded systems.
+
+ We don't define an enum for the possible key values, because the KEYs
+ translate directly into variables by macro magic. */
+
+#define __libc_tsd_define(CLASS, TYPE, KEY) \
+ CLASS __thread TYPE __libc_tsd_##KEY attribute_tls_model_ie;
+
+#define __libc_tsd_address(TYPE, KEY) (&__libc_tsd_##KEY)
+#define __libc_tsd_get(TYPE, KEY) (__libc_tsd_##KEY)
+#define __libc_tsd_set(TYPE, KEY, VALUE) (__libc_tsd_##KEY = (VALUE))
+
+#endif /* libc-tsd.h */
diff --git a/REORG.TODO/sysdeps/generic/libc.abilist b/REORG.TODO/sysdeps/generic/libc.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libc.abilist
diff --git a/REORG.TODO/sysdeps/generic/libcidn.abilist b/REORG.TODO/sysdeps/generic/libcidn.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libcidn.abilist
diff --git a/REORG.TODO/sysdeps/generic/libcrypt.abilist b/REORG.TODO/sysdeps/generic/libcrypt.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libcrypt.abilist
diff --git a/REORG.TODO/sysdeps/generic/libdl.abilist b/REORG.TODO/sysdeps/generic/libdl.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libdl.abilist
diff --git a/REORG.TODO/sysdeps/generic/libm-test-ulps b/REORG.TODO/sysdeps/generic/libm-test-ulps
new file mode 100644
index 0000000000..7cfa1f8285
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libm-test-ulps
@@ -0,0 +1,5 @@
+# File with deltas for math/libm-test
+# This file is the fallback and contains
+# no data
+# You can create a new file with e.g. `test-double -u'
+# followed by `gen-libm-test.pl -u ULPs -n'.
diff --git a/REORG.TODO/sysdeps/generic/libm-test-ulps-name b/REORG.TODO/sysdeps/generic/libm-test-ulps-name
new file mode 100644
index 0000000000..8470d61195
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libm-test-ulps-name
@@ -0,0 +1 @@
+Generic
diff --git a/REORG.TODO/sysdeps/generic/libm.abilist b/REORG.TODO/sysdeps/generic/libm.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libm.abilist
diff --git a/REORG.TODO/sysdeps/generic/libnsl.abilist b/REORG.TODO/sysdeps/generic/libnsl.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libnsl.abilist
diff --git a/REORG.TODO/sysdeps/generic/libnss_compat.abilist b/REORG.TODO/sysdeps/generic/libnss_compat.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libnss_compat.abilist
diff --git a/REORG.TODO/sysdeps/generic/libnss_db.abilist b/REORG.TODO/sysdeps/generic/libnss_db.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libnss_db.abilist
diff --git a/REORG.TODO/sysdeps/generic/libnss_dns.abilist b/REORG.TODO/sysdeps/generic/libnss_dns.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libnss_dns.abilist
diff --git a/REORG.TODO/sysdeps/generic/libnss_files.abilist b/REORG.TODO/sysdeps/generic/libnss_files.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libnss_files.abilist
diff --git a/REORG.TODO/sysdeps/generic/libnss_hesiod.abilist b/REORG.TODO/sysdeps/generic/libnss_hesiod.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libnss_hesiod.abilist
diff --git a/REORG.TODO/sysdeps/generic/libnss_nis.abilist b/REORG.TODO/sysdeps/generic/libnss_nis.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libnss_nis.abilist
diff --git a/REORG.TODO/sysdeps/generic/libnss_nisplus.abilist b/REORG.TODO/sysdeps/generic/libnss_nisplus.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libnss_nisplus.abilist
diff --git a/REORG.TODO/sysdeps/generic/libpthread.abilist b/REORG.TODO/sysdeps/generic/libpthread.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libpthread.abilist
diff --git a/REORG.TODO/sysdeps/generic/libresolv.abilist b/REORG.TODO/sysdeps/generic/libresolv.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libresolv.abilist
diff --git a/REORG.TODO/sysdeps/generic/librt.abilist b/REORG.TODO/sysdeps/generic/librt.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/librt.abilist
diff --git a/REORG.TODO/sysdeps/generic/libutil.abilist b/REORG.TODO/sysdeps/generic/libutil.abilist
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/libutil.abilist
diff --git a/REORG.TODO/sysdeps/generic/linkmap.h b/REORG.TODO/sysdeps/generic/linkmap.h
new file mode 100644
index 0000000000..470b4d3e5f
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/linkmap.h
@@ -0,0 +1,4 @@
+struct link_map_machine
+ {
+ /* empty by default */
+ };
diff --git a/REORG.TODO/sysdeps/generic/local-setxid.h b/REORG.TODO/sysdeps/generic/local-setxid.h
new file mode 100644
index 0000000000..b70d9ffb32
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/local-setxid.h
@@ -0,0 +1,4 @@
+/* No special support. Fall back to the regular functions. */
+
+#define local_seteuid(id) seteuid (id)
+#define local_setegid(id) setegid (id)
diff --git a/REORG.TODO/sysdeps/generic/localplt.data b/REORG.TODO/sysdeps/generic/localplt.data
new file mode 100644
index 0000000000..81c741b038
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/localplt.data
@@ -0,0 +1,18 @@
+# See scripts/check-localplt.awk for how this file is processed.
+# PLT use is required for the malloc family and for matherr because
+# users can define their own functions and have library internals call them.
+libc.so: calloc
+libc.so: free
+libc.so: malloc
+libc.so: memalign
+libc.so: realloc
+libm.so: matherr
+# The main malloc is interposed into the dynamic linker, for
+# allocations after the initial link (when dlopen is used).
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
+# The TLS-enabled version of these functions is interposed from libc.so.
+ld.so: _dl_signal_error
+ld.so: _dl_catch_error
diff --git a/REORG.TODO/sysdeps/generic/machine-gmon.h b/REORG.TODO/sysdeps/generic/machine-gmon.h
new file mode 100644
index 0000000000..b100d4d49f
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/machine-gmon.h
@@ -0,0 +1,47 @@
+/* Machine-dependent definitions for profiling support. Generic GCC 2 version.
+ Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* GCC version 2 gives us a perfect magical function to get
+ just the information we need:
+ void *__builtin_return_address (unsigned int N)
+ returns the return address of the frame N frames up. */
+
+/* Be warned that GCC cannot usefully compile __builtin_return_address(N)
+ for N != 0 on all machines. In this case, you may have to write
+ your own version of _mcount(). */
+
+#if __GNUC__ < 2
+ #error "This file uses __builtin_return_address, a GCC 2 extension."
+#endif
+
+#include <sysdep.h>
+/* The canonical name for the function is `_mcount' in both C and asm,
+ but some old asm code might assume it's `mcount'. */
+void _mcount (void);
+weak_alias (_mcount, mcount)
+
+static void mcount_internal (u_long frompc, u_long selfpc);
+
+#define _MCOUNT_DECL(frompc, selfpc) \
+static inline void mcount_internal (u_long frompc, u_long selfpc)
+
+#define MCOUNT \
+void _mcount (void) \
+{ \
+ mcount_internal ((u_long) RETURN_ADDRESS (1), (u_long) RETURN_ADDRESS (0)); \
+}
diff --git a/REORG.TODO/sysdeps/generic/machine-lock.h b/REORG.TODO/sysdeps/generic/machine-lock.h
new file mode 100644
index 0000000000..b4b2f18b3c
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/machine-lock.h
@@ -0,0 +1,63 @@
+/* Machine-specific definition for spin locks. Stub version.
+ Copyright (C) 1994-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MACHINE_LOCK_H
+#define _MACHINE_LOCK_H
+
+/* The type of a spin lock variable. */
+
+typedef volatile int __spin_lock_t;
+
+/* Value to initialize `__spin_lock_t' variables to. */
+
+#define __SPIN_LOCK_INITIALIZER 0
+
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE __extern_inline
+#endif
+
+/* Unlock LOCK. */
+
+_EXTERN_INLINE void
+__spin_unlock (__spin_lock_t *__lock)
+{
+ *__lock = 0;
+}
+
+/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
+
+_EXTERN_INLINE int
+__spin_try_lock (__spin_lock_t *__lock)
+{
+ if (*__lock)
+ return 0;
+ *__lock = 1;
+ return 1;
+}
+
+/* Return nonzero if LOCK is locked. */
+
+_EXTERN_INLINE int
+__spin_lock_locked (__spin_lock_t *__lock)
+{
+ return *__lock != 0;
+}
+
+
+#endif /* machine-lock.h */
diff --git a/REORG.TODO/sysdeps/generic/machine-sp.h b/REORG.TODO/sysdeps/generic/machine-sp.h
new file mode 100644
index 0000000000..aaa45fd390
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/machine-sp.h
@@ -0,0 +1,35 @@
+/* Machine-specific function to return the stack pointer. Stub version.
+ Copyright (C) 1994-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MACHINE_SP_H
+#define _MACHINE_SP_H
+
+/* Return the current stack pointer. */
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE __extern_inline
+#endif
+
+_EXTERN_INLINE void *
+__thread_stack_pointer (void)
+{
+ register void *__sp__ ("{STACK-POINTER}");
+ return __sp__;
+}
+
+#endif /* machine-sp.h */
diff --git a/REORG.TODO/sysdeps/generic/malloc-machine.h b/REORG.TODO/sysdeps/generic/malloc-machine.h
new file mode 100644
index 0000000000..21aa9fcdce
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/malloc-machine.h
@@ -0,0 +1,41 @@
+/* Basic platform-independent macro definitions for mutexes,
+ thread-specific data and parameters for malloc.
+ Copyright (C) 2003-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _GENERIC_MALLOC_MACHINE_H
+#define _GENERIC_MALLOC_MACHINE_H
+
+#include <atomic.h>
+
+#ifndef atomic_full_barrier
+# define atomic_full_barrier() __asm ("" ::: "memory")
+#endif
+
+#ifndef atomic_read_barrier
+# define atomic_read_barrier() atomic_full_barrier ()
+#endif
+
+#ifndef atomic_write_barrier
+# define atomic_write_barrier() atomic_full_barrier ()
+#endif
+
+#ifndef DEFAULT_TOP_PAD
+# define DEFAULT_TOP_PAD 131072
+#endif
+
+#endif /* !defined(_GENERIC_MALLOC_MACHINE_H) */
diff --git a/REORG.TODO/sysdeps/generic/malloc-sysdep.h b/REORG.TODO/sysdeps/generic/malloc-sysdep.h
new file mode 100644
index 0000000000..ece389d27e
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/malloc-sysdep.h
@@ -0,0 +1,28 @@
+/* System-specific malloc support functions. Generic version.
+ Copyright (C) 2012-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdbool.h>
+#include <unistd.h>
+
+/* Force an unmap when the heap shrinks in a secure exec. This ensures that
+ the old data pages immediately cease to be accessible. */
+static inline bool
+check_may_shrink_heap (void)
+{
+ return __libc_enable_secure;
+}
diff --git a/REORG.TODO/sysdeps/generic/math-tests-arch.h b/REORG.TODO/sysdeps/generic/math-tests-arch.h
new file mode 100644
index 0000000000..88d7aea2f1
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/math-tests-arch.h
@@ -0,0 +1,24 @@
+/* Runtime architecture check for math tests.
+ Copyright (C) 2014-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* These macros used for architecture check in math tests runtime.
+ INIT_ARCH_EXT should set up for example some global variable which is
+ checked by CHECK_ARCH_EXT which produces return from individual test to
+ prevent run on hardware not supported by tested function implementation. */
+#define INIT_ARCH_EXT
+#define CHECK_ARCH_EXT
diff --git a/REORG.TODO/sysdeps/generic/math-tests.h b/REORG.TODO/sysdeps/generic/math-tests.h
new file mode 100644
index 0000000000..a4054eae91
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/math-tests.h
@@ -0,0 +1,106 @@
+/* Configuration for math tests. Generic version.
+ Copyright (C) 2013-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Indicate whether to run tests involving sNaN values for the float, double,
+ and long double C data types, respectively. All are run unless
+ overridden. */
+#ifndef SNAN_TESTS_float
+# define SNAN_TESTS_float 1
+#endif
+#ifndef SNAN_TESTS_double
+# define SNAN_TESTS_double 1
+#endif
+#ifndef SNAN_TESTS_long_double
+# define SNAN_TESTS_long_double 1
+#endif
+
+/* Return nonzero value if to run tests involving sNaN values for X. */
+#define SNAN_TESTS(x) \
+ (sizeof (x) == sizeof (float) ? SNAN_TESTS_float \
+ : sizeof (x) == sizeof (double) ? SNAN_TESTS_double \
+ : SNAN_TESTS_long_double)
+
+/* Indicate whether to run tests involving type casts of sNaN values. These
+ are run unless overridden. */
+#ifndef SNAN_TESTS_TYPE_CAST
+# define SNAN_TESTS_TYPE_CAST 1
+#endif
+
+/* Indicate whether operations on signaling NaNs preserve the payload
+ (if possible; it is not possible with a zero payload if the high
+ bit is set for signaling NaNs) when generating a quiet NaN, and
+ this should be tested. */
+#ifndef SNAN_TESTS_PRESERVE_PAYLOAD
+# define SNAN_TESTS_PRESERVE_PAYLOAD 1
+#endif
+
+/* Indicate whether to run tests involving a given rounding mode for a
+ given floating-point type, given that fesetround succeeds for that
+ mode. All are run if fesetround succeeds unless overridden. */
+#ifndef ROUNDING_TESTS_float
+# define ROUNDING_TESTS_float(MODE) 1
+#endif
+#ifndef ROUNDING_TESTS_double
+# define ROUNDING_TESTS_double(MODE) 1
+#endif
+#ifndef ROUNDING_TESTS_long_double
+# define ROUNDING_TESTS_long_double(MODE) 1
+#endif
+
+#define ROUNDING_TESTS(TYPE, MODE) \
+ (sizeof (TYPE) == sizeof (float) ? ROUNDING_TESTS_float (MODE) \
+ : sizeof (TYPE) == sizeof (double) ? ROUNDING_TESTS_double (MODE) \
+ : ROUNDING_TESTS_long_double (MODE))
+
+/* Indicate whether to run tests of floating-point exceptions for a
+ given floating-point type, given that the exception macros are
+ defined. All are run unless overridden. */
+#ifndef EXCEPTION_TESTS_float
+# define EXCEPTION_TESTS_float 1
+#endif
+#ifndef EXCEPTION_TESTS_double
+# define EXCEPTION_TESTS_double 1
+#endif
+#ifndef EXCEPTION_TESTS_long_double
+# define EXCEPTION_TESTS_long_double 1
+#endif
+
+#define EXCEPTION_TESTS(TYPE) \
+ (sizeof (TYPE) == sizeof (float) ? EXCEPTION_TESTS_float \
+ : sizeof (TYPE) == sizeof (double) ? EXCEPTION_TESTS_double \
+ : EXCEPTION_TESTS_long_double)
+
+/* Indicate whether the given exception trap(s) can be enabled
+ in feenableexcept. If non-zero, the traps are always supported.
+ If zero, traps may or may not be supported depending on the
+ target (this can be determined by checking the return value
+ of feenableexcept). This enables skipping of tests which use
+ traps. By default traps are supported unless overridden. */
+#ifndef EXCEPTION_ENABLE_SUPPORTED
+# define EXCEPTION_ENABLE_SUPPORTED(EXCEPT) \
+ (EXCEPTION_TESTS_float || EXCEPTION_TESTS_double)
+#endif
+
+/* Indicate whether exception traps, if enabled, occur whenever an
+ exception flag is set explicitly, so it is not possible to set flag
+ bits with traps enabled without causing traps to be taken. If
+ traps cannot be enabled, the value of this macro does not
+ matter. */
+#ifndef EXCEPTION_SET_FORCES_TRAP
+# define EXCEPTION_SET_FORCES_TRAP 0
+#endif
diff --git a/REORG.TODO/sysdeps/generic/math-type-macros-double.h b/REORG.TODO/sysdeps/generic/math-type-macros-double.h
new file mode 100644
index 0000000000..6116f7f32f
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/math-type-macros-double.h
@@ -0,0 +1,53 @@
+/* Helper macros for double variants of type generic functions of libm.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MATH_TYPE_MACROS_DOUBLE
+#define _MATH_TYPE_MACROS_DOUBLE
+
+#define M_LIT(c) c
+#define M_MLIT(c) c
+#define M_PFX DBL
+#define M_SUF(c) c
+#define FLOAT double
+#define CFLOAT _Complex double
+#define M_STRTO_NAN __strtod_nan
+
+/* Machines without a distinct long double type
+ alias long double functions to their double
+ equivalent. */
+#if defined NO_LONG_DOUBLE && !defined declare_mgen_alias
+# define declare_mgen_alias(from, to) \
+ weak_alias (from, to) \
+ strong_alias (from, from ## l) \
+ weak_alias (from, to ## l)
+#endif
+
+#if defined NO_LONG_DOUBLE && !defined declare_mgen_alias_2
+# define declare_mgen_alias_2(from, to, to2) \
+ declare_mgen_alias (from, to) \
+ weak_alias (from, to2) \
+ weak_alias (from, to2 ## l)
+#endif
+
+/* Supply the generic macros. */
+#include <math-type-macros.h>
+
+/* Do not use the type-generic wrapper templates. */
+#define __USE_WRAPPER_TEMPLATE 0
+
+#endif
diff --git a/REORG.TODO/sysdeps/generic/math-type-macros-float.h b/REORG.TODO/sysdeps/generic/math-type-macros-float.h
new file mode 100644
index 0000000000..712e517a81
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/math-type-macros-float.h
@@ -0,0 +1,39 @@
+/* Helper macros for float variants of type generic functions of libm.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MATH_TYPE_MACROS_FLOAT
+#define _MATH_TYPE_MACROS_FLOAT
+
+#define M_LIT(c) c ## f
+#define M_PFX FLT
+#define M_SUF(c) c ## f
+#define FLOAT float
+#define CFLOAT _Complex float
+#define M_STRTO_NAN __strtof_nan
+
+/* Standard/GNU macro literals do not exist for the float type. Use
+ the double macro constants. */
+#define M_MLIT(c) c
+
+/* Supply the generic macros. */
+#include <math-type-macros.h>
+
+/* Do not use the type-generic wrapper templates. */
+#define __USE_WRAPPER_TEMPLATE 0
+
+#endif
diff --git a/REORG.TODO/sysdeps/generic/math-type-macros-float128.h b/REORG.TODO/sysdeps/generic/math-type-macros-float128.h
new file mode 100644
index 0000000000..5d734db29f
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/math-type-macros-float128.h
@@ -0,0 +1,42 @@
+/* Helper macros for _Float128 variants of type generic functions of libm.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MATH_TYPE_MACROS_FLOAT128
+#define _MATH_TYPE_MACROS_FLOAT128
+
+#include <math.h>
+#include <complex.h>
+
+#define M_LIT(c) __f128 (c)
+#define M_PFX FLT128
+#define M_SUF(c) c ## f128
+#define FLOAT _Float128
+#define M_STRTO_NAN __strtof128_nan
+
+#define CFLOAT __CFLOAT128
+
+#define M_MLIT(c) c ## f128
+
+
+/* Supply the generic macros. */
+#include <math-type-macros.h>
+
+/* Use the type-generic wrapper templates. */
+#define __USE_WRAPPER_TEMPLATE 1
+
+#endif
diff --git a/REORG.TODO/sysdeps/generic/math-type-macros-ldouble.h b/REORG.TODO/sysdeps/generic/math-type-macros-ldouble.h
new file mode 100644
index 0000000000..4e02e53f70
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/math-type-macros-ldouble.h
@@ -0,0 +1,36 @@
+/* Helper macros for long double variants of type generic functions of libm.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MATH_TYPE_MACROS_LDOUBLE
+#define _MATH_TYPE_MACROS_LDOUBLE
+
+#define M_LIT(c) c ## L
+#define M_MLIT(c) c ## l
+#define M_PFX LDBL
+#define M_SUF(c) c ## l
+#define FLOAT long double
+#define CFLOAT _Complex long double
+#define M_STRTO_NAN __strtold_nan
+
+/* Supply the generic macros. */
+#include <math-type-macros.h>
+
+/* Do not use the type-generic wrapper templates. */
+#define __USE_WRAPPER_TEMPLATE 0
+
+#endif
diff --git a/REORG.TODO/sysdeps/generic/math-type-macros.h b/REORG.TODO/sysdeps/generic/math-type-macros.h
new file mode 100644
index 0000000000..b4c2aee6aa
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/math-type-macros.h
@@ -0,0 +1,137 @@
+/* Helper macros for type generic function implementations within libm.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MATH_TYPE_MACROS
+#define _MATH_TYPE_MACROS
+
+/* Each type imports a header which is expected to
+ define:
+
+ M_LIT(x) - Paste the type specific suffix onto the constant x.
+ M_MLIT(x) - Paste the type specific suffix used by the macro
+ constants in math.h, i.e M_PI or M_PIl.
+ M_PFX - The prefixed used by float.h macros like FLT_MANT_DIG.
+ M_SUF(x) - Paste the the type specific suffix used by functions
+ i.e expf expl exp.
+ FLOAT - Resolves to the C typename of M_TYPE.
+ CFLOAT - Resolves to the complex typename of M_TYPE.
+ M_STRTO_NAN - Resolves to the internal libc function which
+ converts a string into the appropriate FLOAT nan
+ value.
+
+ Optionally, these headers may inject a non-standard
+ definition for the following:
+
+ declare_mgen_alias(from,to)
+ This exposes the appropriate symbol(s) for a
+ function f of type FLOAT.
+
+ declare_mgen_alias_2(from,to,to2)
+ This exposes the appropriate symbol(s) for a
+ function f of type FLOAT when it is aliased
+ to two symbols.
+
+ M_LIBM_NEED_COMPAT(func)
+ This is utilized in macro context to indicate
+ whether func should declare compat symbols.
+
+ declare_mgen_libm_compat(from,to)
+ This is used in conjunction with the above macro
+ outside of macro context to paste whatever is
+ required to generate a compat symbol. */
+
+#ifndef M_PFX
+# error "M_PFX must be defined."
+#endif
+#ifndef M_LIT
+# error "M_LIT must be defined."
+#endif
+#ifndef M_MLIT
+# error "M_MLIT must be defined."
+#endif
+#ifndef M_SUF
+# error "M_SUF must be defined."
+#endif
+#ifndef FLOAT
+# error "FLOAT must be defined."
+#endif
+#ifndef CFLOAT
+# error "CFLOAT must be defined."
+#endif
+
+#define __M_CONCAT(a,b) a ## b
+#define __M_CONCATX(a,b) __M_CONCAT(a,b)
+
+#define M_NAN M_SUF (__builtin_nan) ("")
+#define M_MIN_EXP __M_CONCATX (M_PFX, _MIN_EXP)
+#define M_MAX_EXP __M_CONCATX (M_PFX, _MAX_EXP)
+#define M_MIN __M_CONCATX (M_PFX, _MIN)
+#define M_MAX __M_CONCATX (M_PFX, _MAX)
+#define M_MANT_DIG __M_CONCATX (M_PFX, _MANT_DIG)
+#define M_HUGE_VAL (M_SUF (__builtin_huge_val) ())
+
+/* Helper macros for commonly used functions. */
+#define M_COPYSIGN M_SUF (__copysign)
+#define M_FABS M_SUF (fabs)
+#define M_SINCOS M_SUF (__sincos)
+#define M_SCALBN M_SUF (__scalbn)
+#define M_LOG1P M_SUF (__log1p)
+
+#define M_ATAN2 M_SUF (__ieee754_atan2)
+#define M_COSH M_SUF (__ieee754_cosh)
+#define M_EXP M_SUF (__ieee754_exp)
+#define M_HYPOT M_SUF (__ieee754_hypot)
+#define M_LOG M_SUF (__ieee754_log)
+#define M_SINH M_SUF (__ieee754_sinh)
+#define M_SQRT M_SUF (__ieee754_sqrt)
+
+/* Needed to evaluate M_MANT_DIG below. */
+#include <float.h>
+
+/* Use a special epsilon value for IBM long double
+ to avoid spurious overflows/underflows. */
+#if M_MANT_DIG != 106
+# define M_EPSILON __M_CONCATX (M_PFX, _EPSILON)
+#else
+# define M_EPSILON M_LIT (0x1p-106)
+#endif
+
+/* Enable overloading of function name to assist reuse. */
+#ifndef M_DECL_FUNC
+# define M_DECL_FUNC(f) M_SUF (f)
+#endif
+
+/* If the type does not declare special aliasing, use the default. */
+#ifndef declare_mgen_alias
+# define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Likewise, if two aliases are derived from the same symbol. */
+#ifndef declare_mgen_alias_2
+# define declare_mgen_alias_2(from, to, to2) \
+ declare_mgen_alias (from, to) \
+ declare_mgen_alias (from, to2)
+#endif
+
+/* Do not generate anything for compat symbols by default. */
+#ifndef M_LIBM_NEED_COMPAT
+# define M_LIBM_NEED_COMPAT(func) 0
+# define declare_mgen_libm_compat(from, to)
+#endif
+
+#endif /* _MATH_TYPE_MACROS */
diff --git a/REORG.TODO/sysdeps/generic/math_ldbl.h b/REORG.TODO/sysdeps/generic/math_ldbl.h
new file mode 100644
index 0000000000..4e7ee7912e
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/math_ldbl.h
@@ -0,0 +1,7 @@
+#ifndef _MATH_LDBL_H_
+#define _MATH_LDBL_H_ 1
+
+/* Any machine with a 'long double' distinct from 'double' must
+ override this header. */
+
+#endif
diff --git a/REORG.TODO/sysdeps/generic/math_ldbl_opt.h b/REORG.TODO/sysdeps/generic/math_ldbl_opt.h
new file mode 100644
index 0000000000..8a5d8ba107
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/math_ldbl_opt.h
@@ -0,0 +1,14 @@
+/* -mlong-double-64 compatibility mode macros. Stub version.
+
+ These macros are used by some math/ and sysdeps/ieee754/ code.
+ These are the generic definitions for when no funny business is going on.
+ sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h defines them differently
+ for platforms where compatibility symbols are required for a previous
+ ABI that defined long double functions as aliases for the double code. */
+
+#define LONG_DOUBLE_COMPAT(lib, introduced) 0
+#define long_double_symbol(lib, local, symbol)
+#define ldbl_hidden_def(local, name) libc_hidden_def (name)
+#define ldbl_strong_alias(name, aliasname) strong_alias (name, aliasname)
+#define ldbl_weak_alias(name, aliasname) weak_alias (name, aliasname)
+#define __ldbl_is_dbl 0
diff --git a/REORG.TODO/sysdeps/generic/math_private.h b/REORG.TODO/sysdeps/generic/math_private.h
new file mode 100644
index 0000000000..6ea5e25e5a
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/math_private.h
@@ -0,0 +1,658 @@
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * from: @(#)fdlibm.h 5.1 93/09/24
+ */
+
+#ifndef _MATH_PRIVATE_H_
+#define _MATH_PRIVATE_H_
+
+#include <endian.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <fenv.h>
+#include <float.h>
+#include <get-rounding-mode.h>
+
+/* Gather machine dependent _Floatn support. */
+#include <bits/floatn.h>
+
+/* The original fdlibm code used statements like:
+ n0 = ((*(int*)&one)>>29)^1; * index of high word *
+ ix0 = *(n0+(int*)&x); * high word of x *
+ ix1 = *((1-n0)+(int*)&x); * low word of x *
+ to dig two 32 bit words out of the 64 bit IEEE floating point
+ value. That is non-ANSI, and, moreover, the gcc instruction
+ scheduler gets it wrong. We instead use the following macros.
+ Unlike the original code, we determine the endianness at compile
+ time, not at run time; I don't see much benefit to selecting
+ endianness at run time. */
+
+/* A union which permits us to convert between a double and two 32 bit
+ ints. */
+
+#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
+
+typedef union
+{
+ double value;
+ struct
+ {
+ u_int32_t msw;
+ u_int32_t lsw;
+ } parts;
+ uint64_t word;
+} ieee_double_shape_type;
+
+#endif
+
+#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
+
+typedef union
+{
+ double value;
+ struct
+ {
+ u_int32_t lsw;
+ u_int32_t msw;
+ } parts;
+ uint64_t word;
+} ieee_double_shape_type;
+
+#endif
+
+/* Get two 32 bit ints from a double. */
+
+#define EXTRACT_WORDS(ix0,ix1,d) \
+do { \
+ ieee_double_shape_type ew_u; \
+ ew_u.value = (d); \
+ (ix0) = ew_u.parts.msw; \
+ (ix1) = ew_u.parts.lsw; \
+} while (0)
+
+/* Get the more significant 32 bit int from a double. */
+
+#ifndef GET_HIGH_WORD
+# define GET_HIGH_WORD(i,d) \
+do { \
+ ieee_double_shape_type gh_u; \
+ gh_u.value = (d); \
+ (i) = gh_u.parts.msw; \
+} while (0)
+#endif
+
+/* Get the less significant 32 bit int from a double. */
+
+#ifndef GET_LOW_WORD
+# define GET_LOW_WORD(i,d) \
+do { \
+ ieee_double_shape_type gl_u; \
+ gl_u.value = (d); \
+ (i) = gl_u.parts.lsw; \
+} while (0)
+#endif
+
+/* Get all in one, efficient on 64-bit machines. */
+#ifndef EXTRACT_WORDS64
+# define EXTRACT_WORDS64(i,d) \
+do { \
+ ieee_double_shape_type gh_u; \
+ gh_u.value = (d); \
+ (i) = gh_u.word; \
+} while (0)
+#endif
+
+/* Set a double from two 32 bit ints. */
+#ifndef INSERT_WORDS
+# define INSERT_WORDS(d,ix0,ix1) \
+do { \
+ ieee_double_shape_type iw_u; \
+ iw_u.parts.msw = (ix0); \
+ iw_u.parts.lsw = (ix1); \
+ (d) = iw_u.value; \
+} while (0)
+#endif
+
+/* Get all in one, efficient on 64-bit machines. */
+#ifndef INSERT_WORDS64
+# define INSERT_WORDS64(d,i) \
+do { \
+ ieee_double_shape_type iw_u; \
+ iw_u.word = (i); \
+ (d) = iw_u.value; \
+} while (0)
+#endif
+
+/* Set the more significant 32 bits of a double from an int. */
+#ifndef SET_HIGH_WORD
+#define SET_HIGH_WORD(d,v) \
+do { \
+ ieee_double_shape_type sh_u; \
+ sh_u.value = (d); \
+ sh_u.parts.msw = (v); \
+ (d) = sh_u.value; \
+} while (0)
+#endif
+
+/* Set the less significant 32 bits of a double from an int. */
+#ifndef SET_LOW_WORD
+# define SET_LOW_WORD(d,v) \
+do { \
+ ieee_double_shape_type sl_u; \
+ sl_u.value = (d); \
+ sl_u.parts.lsw = (v); \
+ (d) = sl_u.value; \
+} while (0)
+#endif
+
+/* A union which permits us to convert between a float and a 32 bit
+ int. */
+
+typedef union
+{
+ float value;
+ u_int32_t word;
+} ieee_float_shape_type;
+
+/* Get a 32 bit int from a float. */
+#ifndef GET_FLOAT_WORD
+# define GET_FLOAT_WORD(i,d) \
+do { \
+ ieee_float_shape_type gf_u; \
+ gf_u.value = (d); \
+ (i) = gf_u.word; \
+} while (0)
+#endif
+
+/* Set a float from a 32 bit int. */
+#ifndef SET_FLOAT_WORD
+# define SET_FLOAT_WORD(d,i) \
+do { \
+ ieee_float_shape_type sf_u; \
+ sf_u.word = (i); \
+ (d) = sf_u.value; \
+} while (0)
+#endif
+
+/* We need to guarantee an expansion of name when building
+ ldbl-128 files as another type (e.g _Float128). */
+#define mathx_hidden_def(name) hidden_def(name)
+
+/* Get long double macros from a separate header. */
+#include <math_ldbl.h>
+
+/* Include function declarations for each floating-point. */
+#define _Mdouble_ double
+#define _MSUF_
+#include <math_private_calls.h>
+#undef _MSUF_
+#undef _Mdouble_
+
+#define _Mdouble_ float
+#define _MSUF_ f
+#define __MATH_DECLARING_FLOAT
+#include <math_private_calls.h>
+#undef __MATH_DECLARING_FLOAT
+#undef _MSUF_
+#undef _Mdouble_
+
+#define _Mdouble_ long double
+#define _MSUF_ l
+#define __MATH_DECLARING_LONG_DOUBLE
+#include <math_private_calls.h>
+#undef __MATH_DECLARING_LONG_DOUBLE
+#undef _MSUF_
+#undef _Mdouble_
+
+#if __HAVE_DISTINCT_FLOAT128
+# define _Mdouble_ _Float128
+# define _MSUF_ f128
+# define __MATH_DECLARING_FLOATN
+# include <math_private_calls.h>
+# undef __MATH_DECLARING_FLOATN
+# undef _MSUF_
+# undef _Mdouble_
+#endif
+
+#if __HAVE_DISTINCT_FLOAT128
+
+/* __builtin_isinf_sign is broken in GCC < 7 for float128. */
+# if ! __GNUC_PREREQ (7, 0)
+# include <ieee754_float128.h>
+extern inline int
+__isinff128 (_Float128 x)
+{
+ int64_t hx, lx;
+ GET_FLOAT128_WORDS64 (hx, lx, x);
+ lx |= (hx & 0x7fffffffffffffffLL) ^ 0x7fff000000000000LL;
+ lx |= -lx;
+ return ~(lx >> 63) & (hx >> 62);
+}
+# endif
+
+extern inline _Float128
+fabsf128 (_Float128 x)
+{
+ return __builtin_fabsf128 (x);
+}
+#endif
+
+
+
+/* fdlibm kernel function */
+extern double __kernel_standard (double,double,int);
+extern float __kernel_standard_f (float,float,int);
+extern long double __kernel_standard_l (long double,long double,int);
+
+/* Prototypes for functions of the IBM Accurate Mathematical Library. */
+extern double __exp1 (double __x, double __xx, double __error);
+extern double __sin (double __x);
+extern double __cos (double __x);
+extern int __branred (double __x, double *__a, double *__aa);
+extern void __doasin (double __x, double __dx, double __v[]);
+extern void __dubsin (double __x, double __dx, double __v[]);
+extern void __dubcos (double __x, double __dx, double __v[]);
+extern double __halfulp (double __x, double __y);
+extern double __sin32 (double __x, double __res, double __res1);
+extern double __cos32 (double __x, double __res, double __res1);
+extern double __mpsin (double __x, double __dx, bool __range_reduce);
+extern double __mpcos (double __x, double __dx, bool __range_reduce);
+extern double __slowexp (double __x);
+extern double __slowpow (double __x, double __y, double __z);
+extern void __docos (double __x, double __dx, double __v[]);
+
+#ifndef math_opt_barrier
+# define math_opt_barrier(x) \
+({ __typeof (x) __x = (x); __asm ("" : "+m" (__x)); __x; })
+# define math_force_eval(x) \
+({ __typeof (x) __x = (x); __asm __volatile__ ("" : : "m" (__x)); })
+#endif
+
+/* math_narrow_eval reduces its floating-point argument to the range
+ and precision of its semantic type. (The original evaluation may
+ still occur with excess range and precision, so the result may be
+ affected by double rounding.) */
+#if FLT_EVAL_METHOD == 0
+# define math_narrow_eval(x) (x)
+#else
+# if FLT_EVAL_METHOD == 1
+# define excess_precision(type) __builtin_types_compatible_p (type, float)
+# else
+# define excess_precision(type) (__builtin_types_compatible_p (type, float) \
+ || __builtin_types_compatible_p (type, \
+ double))
+# endif
+# define math_narrow_eval(x) \
+ ({ \
+ __typeof (x) math_narrow_eval_tmp = (x); \
+ if (excess_precision (__typeof (math_narrow_eval_tmp))) \
+ __asm__ ("" : "+m" (math_narrow_eval_tmp)); \
+ math_narrow_eval_tmp; \
+ })
+#endif
+
+#if __HAVE_DISTINCT_FLOAT128
+# define __EXPR_FLT128(x, yes, no) \
+ __builtin_choose_expr (__builtin_types_compatible_p \
+ (__typeof (x), long double), no, yes)
+#else
+# define __EXPR_FLT128(x, yes, no) no
+#endif
+
+
+#define fabs_tg(x) __MATH_TG ((x), (__typeof (x)) __builtin_fabs, (x))
+
+#define min_of_type(type) __builtin_choose_expr \
+ (__builtin_types_compatible_p (type, float), \
+ FLT_MIN, \
+ __builtin_choose_expr \
+ (__builtin_types_compatible_p (type, double), \
+ DBL_MIN, \
+ __EXPR_FLT128 (x, FLT128_MIN, LDBL_MIN)))
+
+/* If X (which is not a NaN) is subnormal, force an underflow
+ exception. */
+#define math_check_force_underflow(x) \
+ do \
+ { \
+ __typeof (x) force_underflow_tmp = (x); \
+ if (fabs_tg (force_underflow_tmp) \
+ < min_of_type (__typeof (force_underflow_tmp))) \
+ { \
+ __typeof (force_underflow_tmp) force_underflow_tmp2 \
+ = force_underflow_tmp * force_underflow_tmp; \
+ math_force_eval (force_underflow_tmp2); \
+ } \
+ } \
+ while (0)
+/* Likewise, but X is also known to be nonnegative. */
+#define math_check_force_underflow_nonneg(x) \
+ do \
+ { \
+ __typeof (x) force_underflow_tmp = (x); \
+ if (force_underflow_tmp \
+ < min_of_type (__typeof (force_underflow_tmp))) \
+ { \
+ __typeof (force_underflow_tmp) force_underflow_tmp2 \
+ = force_underflow_tmp * force_underflow_tmp; \
+ math_force_eval (force_underflow_tmp2); \
+ } \
+ } \
+ while (0)
+/* Likewise, for both real and imaginary parts of a complex
+ result. */
+#define math_check_force_underflow_complex(x) \
+ do \
+ { \
+ __typeof (x) force_underflow_complex_tmp = (x); \
+ math_check_force_underflow (__real__ force_underflow_complex_tmp); \
+ math_check_force_underflow (__imag__ force_underflow_complex_tmp); \
+ } \
+ while (0)
+
+/* The standards only specify one variant of the fenv.h interfaces.
+ But at least for some architectures we can be more efficient if we
+ know what operations are going to be performed. Therefore we
+ define additional interfaces. By default they refer to the normal
+ interfaces. */
+
+static __always_inline void
+default_libc_feholdexcept (fenv_t *e)
+{
+ (void) __feholdexcept (e);
+}
+
+#ifndef libc_feholdexcept
+# define libc_feholdexcept default_libc_feholdexcept
+#endif
+#ifndef libc_feholdexceptf
+# define libc_feholdexceptf default_libc_feholdexcept
+#endif
+#ifndef libc_feholdexceptl
+# define libc_feholdexceptl default_libc_feholdexcept
+#endif
+
+static __always_inline void
+default_libc_fesetround (int r)
+{
+ (void) __fesetround (r);
+}
+
+#ifndef libc_fesetround
+# define libc_fesetround default_libc_fesetround
+#endif
+#ifndef libc_fesetroundf
+# define libc_fesetroundf default_libc_fesetround
+#endif
+#ifndef libc_fesetroundl
+# define libc_fesetroundl default_libc_fesetround
+#endif
+
+static __always_inline void
+default_libc_feholdexcept_setround (fenv_t *e, int r)
+{
+ __feholdexcept (e);
+ __fesetround (r);
+}
+
+#ifndef libc_feholdexcept_setround
+# define libc_feholdexcept_setround default_libc_feholdexcept_setround
+#endif
+#ifndef libc_feholdexcept_setroundf
+# define libc_feholdexcept_setroundf default_libc_feholdexcept_setround
+#endif
+#ifndef libc_feholdexcept_setroundl
+# define libc_feholdexcept_setroundl default_libc_feholdexcept_setround
+#endif
+
+#ifndef libc_feholdsetround_53bit
+# define libc_feholdsetround_53bit libc_feholdsetround
+#endif
+
+#ifndef libc_fetestexcept
+# define libc_fetestexcept fetestexcept
+#endif
+#ifndef libc_fetestexceptf
+# define libc_fetestexceptf fetestexcept
+#endif
+#ifndef libc_fetestexceptl
+# define libc_fetestexceptl fetestexcept
+#endif
+
+static __always_inline void
+default_libc_fesetenv (fenv_t *e)
+{
+ (void) __fesetenv (e);
+}
+
+#ifndef libc_fesetenv
+# define libc_fesetenv default_libc_fesetenv
+#endif
+#ifndef libc_fesetenvf
+# define libc_fesetenvf default_libc_fesetenv
+#endif
+#ifndef libc_fesetenvl
+# define libc_fesetenvl default_libc_fesetenv
+#endif
+
+static __always_inline void
+default_libc_feupdateenv (fenv_t *e)
+{
+ (void) __feupdateenv (e);
+}
+
+#ifndef libc_feupdateenv
+# define libc_feupdateenv default_libc_feupdateenv
+#endif
+#ifndef libc_feupdateenvf
+# define libc_feupdateenvf default_libc_feupdateenv
+#endif
+#ifndef libc_feupdateenvl
+# define libc_feupdateenvl default_libc_feupdateenv
+#endif
+
+#ifndef libc_feresetround_53bit
+# define libc_feresetround_53bit libc_feresetround
+#endif
+
+static __always_inline int
+default_libc_feupdateenv_test (fenv_t *e, int ex)
+{
+ int ret = fetestexcept (ex);
+ __feupdateenv (e);
+ return ret;
+}
+
+#ifndef libc_feupdateenv_test
+# define libc_feupdateenv_test default_libc_feupdateenv_test
+#endif
+#ifndef libc_feupdateenv_testf
+# define libc_feupdateenv_testf default_libc_feupdateenv_test
+#endif
+#ifndef libc_feupdateenv_testl
+# define libc_feupdateenv_testl default_libc_feupdateenv_test
+#endif
+
+/* Save and set the rounding mode. The use of fenv_t to store the old mode
+ allows a target-specific version of this function to avoid converting the
+ rounding mode from the fpu format. By default we have no choice but to
+ manipulate the entire env. */
+
+#ifndef libc_feholdsetround
+# define libc_feholdsetround libc_feholdexcept_setround
+#endif
+#ifndef libc_feholdsetroundf
+# define libc_feholdsetroundf libc_feholdexcept_setroundf
+#endif
+#ifndef libc_feholdsetroundl
+# define libc_feholdsetroundl libc_feholdexcept_setroundl
+#endif
+
+/* ... and the reverse. */
+
+#ifndef libc_feresetround
+# define libc_feresetround libc_feupdateenv
+#endif
+#ifndef libc_feresetroundf
+# define libc_feresetroundf libc_feupdateenvf
+#endif
+#ifndef libc_feresetroundl
+# define libc_feresetroundl libc_feupdateenvl
+#endif
+
+/* ... and a version that may also discard exceptions. */
+
+#ifndef libc_feresetround_noex
+# define libc_feresetround_noex libc_fesetenv
+#endif
+#ifndef libc_feresetround_noexf
+# define libc_feresetround_noexf libc_fesetenvf
+#endif
+#ifndef libc_feresetround_noexl
+# define libc_feresetround_noexl libc_fesetenvl
+#endif
+
+#ifndef HAVE_RM_CTX
+# define HAVE_RM_CTX 0
+#endif
+
+#if HAVE_RM_CTX
+/* Set/Restore Rounding Modes only when necessary. If defined, these functions
+ set/restore floating point state only if the state needed within the lexical
+ block is different from the current state. This saves a lot of time when
+ the floating point unit is much slower than the fixed point units. */
+
+# ifndef libc_feholdsetround_noex_ctx
+# define libc_feholdsetround_noex_ctx libc_feholdsetround_ctx
+# endif
+# ifndef libc_feholdsetround_noexf_ctx
+# define libc_feholdsetround_noexf_ctx libc_feholdsetroundf_ctx
+# endif
+# ifndef libc_feholdsetround_noexl_ctx
+# define libc_feholdsetround_noexl_ctx libc_feholdsetroundl_ctx
+# endif
+
+# ifndef libc_feresetround_noex_ctx
+# define libc_feresetround_noex_ctx libc_fesetenv_ctx
+# endif
+# ifndef libc_feresetround_noexf_ctx
+# define libc_feresetround_noexf_ctx libc_fesetenvf_ctx
+# endif
+# ifndef libc_feresetround_noexl_ctx
+# define libc_feresetround_noexl_ctx libc_fesetenvl_ctx
+# endif
+
+#else
+
+/* Default implementation using standard fenv functions.
+ Avoid unnecessary rounding mode changes by first checking the
+ current rounding mode. Note the use of __glibc_unlikely is
+ important for performance. */
+
+static __always_inline void
+libc_feholdsetround_ctx (struct rm_ctx *ctx, int round)
+{
+ ctx->updated_status = false;
+
+ /* Update rounding mode only if different. */
+ if (__glibc_unlikely (round != get_rounding_mode ()))
+ {
+ ctx->updated_status = true;
+ __fegetenv (&ctx->env);
+ __fesetround (round);
+ }
+}
+
+static __always_inline void
+libc_feresetround_ctx (struct rm_ctx *ctx)
+{
+ /* Restore the rounding mode if updated. */
+ if (__glibc_unlikely (ctx->updated_status))
+ __feupdateenv (&ctx->env);
+}
+
+static __always_inline void
+libc_feholdsetround_noex_ctx (struct rm_ctx *ctx, int round)
+{
+ /* Save exception flags and rounding mode. */
+ __fegetenv (&ctx->env);
+
+ /* Update rounding mode only if different. */
+ if (__glibc_unlikely (round != get_rounding_mode ()))
+ __fesetround (round);
+}
+
+static __always_inline void
+libc_feresetround_noex_ctx (struct rm_ctx *ctx)
+{
+ /* Restore exception flags and rounding mode. */
+ __fesetenv (&ctx->env);
+}
+
+# define libc_feholdsetroundf_ctx libc_feholdsetround_ctx
+# define libc_feholdsetroundl_ctx libc_feholdsetround_ctx
+# define libc_feresetroundf_ctx libc_feresetround_ctx
+# define libc_feresetroundl_ctx libc_feresetround_ctx
+
+# define libc_feholdsetround_noexf_ctx libc_feholdsetround_noex_ctx
+# define libc_feholdsetround_noexl_ctx libc_feholdsetround_noex_ctx
+# define libc_feresetround_noexf_ctx libc_feresetround_noex_ctx
+# define libc_feresetround_noexl_ctx libc_feresetround_noex_ctx
+
+#endif
+
+#ifndef libc_feholdsetround_53bit_ctx
+# define libc_feholdsetround_53bit_ctx libc_feholdsetround_ctx
+#endif
+#ifndef libc_feresetround_53bit_ctx
+# define libc_feresetround_53bit_ctx libc_feresetround_ctx
+#endif
+
+#define SET_RESTORE_ROUND_GENERIC(RM,ROUNDFUNC,CLEANUPFUNC) \
+ struct rm_ctx ctx __attribute__((cleanup (CLEANUPFUNC ## _ctx))); \
+ ROUNDFUNC ## _ctx (&ctx, (RM))
+
+/* Set the rounding mode within a lexical block. Restore the rounding mode to
+ the value at the start of the block. The exception mode must be preserved.
+ Exceptions raised within the block must be set in the exception flags.
+ Non-stop mode may be enabled inside the block. */
+
+#define SET_RESTORE_ROUND(RM) \
+ SET_RESTORE_ROUND_GENERIC (RM, libc_feholdsetround, libc_feresetround)
+#define SET_RESTORE_ROUNDF(RM) \
+ SET_RESTORE_ROUND_GENERIC (RM, libc_feholdsetroundf, libc_feresetroundf)
+#define SET_RESTORE_ROUNDL(RM) \
+ SET_RESTORE_ROUND_GENERIC (RM, libc_feholdsetroundl, libc_feresetroundl)
+
+/* Set the rounding mode within a lexical block. Restore the rounding mode to
+ the value at the start of the block. The exception mode must be preserved.
+ Exceptions raised within the block must be discarded, and exception flags
+ are restored to the value at the start of the block.
+ Non-stop mode may be enabled inside the block. */
+
+#define SET_RESTORE_ROUND_NOEX(RM) \
+ SET_RESTORE_ROUND_GENERIC (RM, libc_feholdsetround_noex, \
+ libc_feresetround_noex)
+#define SET_RESTORE_ROUND_NOEXF(RM) \
+ SET_RESTORE_ROUND_GENERIC (RM, libc_feholdsetround_noexf, \
+ libc_feresetround_noexf)
+#define SET_RESTORE_ROUND_NOEXL(RM) \
+ SET_RESTORE_ROUND_GENERIC (RM, libc_feholdsetround_noexl, \
+ libc_feresetround_noexl)
+
+/* Like SET_RESTORE_ROUND, but also set rounding precision to 53 bits. */
+#define SET_RESTORE_ROUND_53BIT(RM) \
+ SET_RESTORE_ROUND_GENERIC (RM, libc_feholdsetround_53bit, \
+ libc_feresetround_53bit)
+
+#endif /* _MATH_PRIVATE_H_ */
diff --git a/REORG.TODO/sysdeps/generic/math_private_calls.h b/REORG.TODO/sysdeps/generic/math_private_calls.h
new file mode 100644
index 0000000000..34bbd5e684
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/math_private_calls.h
@@ -0,0 +1,124 @@
+/* Private function declarations for libm.
+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define __MSUF_X(x, suffix) x ## suffix
+#define __MSUF_S(...) __MSUF_X (__VA_ARGS__)
+#define __MSUF(x) __MSUF_S (x, _MSUF_)
+
+#define __MSUF_R_X(x, suffix) x ## suffix ## _r
+#define __MSUF_R_S(...) __MSUF_R_X (__VA_ARGS__)
+#define __MSUF_R(x) __MSUF_R_S (x, _MSUF_)
+
+/* IEEE style elementary functions. */
+extern _Mdouble_ __MSUF (__ieee754_acos) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_acosh) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_asin) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_atan2) (_Mdouble_, _Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_atanh) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_cosh) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_exp) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_exp10) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_exp2) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_fmod) (_Mdouble_, _Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_gamma) (_Mdouble_);
+extern _Mdouble_ __MSUF_R (__ieee754_gamma) (_Mdouble_, int *);
+extern _Mdouble_ __MSUF (__ieee754_hypot) (_Mdouble_, _Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_j0) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_j1) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_jn) (int, _Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_lgamma) (_Mdouble_);
+extern _Mdouble_ __MSUF_R (__ieee754_lgamma) (_Mdouble_, int *);
+extern _Mdouble_ __MSUF (__ieee754_log) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_log10) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_log2) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_pow) (_Mdouble_, _Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_remainder) (_Mdouble_, _Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_sinh) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_sqrt) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_y0) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_y1) (_Mdouble_);
+extern _Mdouble_ __MSUF (__ieee754_yn) (int, _Mdouble_);
+
+extern _Mdouble_ __MSUF (__ieee754_scalb) (_Mdouble_, _Mdouble_);
+extern int __MSUF (__ieee754_ilogb) (_Mdouble_);
+
+extern int32_t __MSUF (__ieee754_rem_pio2) (_Mdouble_, _Mdouble_ *);
+
+/* fdlibm kernel functions. */
+extern _Mdouble_ __MSUF (__kernel_sin) (_Mdouble_, _Mdouble_, int);
+extern _Mdouble_ __MSUF (__kernel_cos) (_Mdouble_, _Mdouble_);
+extern _Mdouble_ __MSUF (__kernel_tan) (_Mdouble_, _Mdouble_, int);
+
+#if defined __MATH_DECLARING_LONG_DOUBLE || defined __MATH_DECLARING_FLOATN
+extern void __MSUF (__kernel_sincos) (_Mdouble_, _Mdouble_,
+ _Mdouble_ *, _Mdouble_ *, int);
+#endif
+
+#if !defined __MATH_DECLARING_LONG_DOUBLE || defined __MATH_DECLARING_FLOATN
+extern int __MSUF (__kernel_rem_pio2) (_Mdouble_ *, _Mdouble_ *, int,
+ int, int, const int32_t *);
+#endif
+
+/* Internal functions. */
+#if !defined __MATH_DECLARING_LONG_DOUBLE || !defined NO_LONG_DOUBLE
+extern _Mdouble_ __MSUF (__copysign) (_Mdouble_ x, _Mdouble_ __y);
+
+extern inline _Mdouble_
+__MSUF (__copysign) (_Mdouble_ x, _Mdouble_ __y)
+{
+ return __MSUF (__builtin_copysign) (x, __y);
+}
+#endif
+
+/* Return X^2 + Y^2 - 1, computed without large cancellation error.
+ It is given that 1 > X >= Y >= epsilon / 2, and that X^2 + Y^2 >=
+ 0.5. */
+extern _Mdouble_ __MSUF (__x2y2m1) (_Mdouble_ x, _Mdouble_ y);
+
+/* Compute the product of X + X_EPS, X + X_EPS + 1, ..., X + X_EPS + N
+ - 1, in the form R * (1 + *EPS) where the return value R is an
+ approximation to the product and *EPS is set to indicate the
+ approximate error in the return value. X is such that all the
+ values X + 1, ..., X + N - 1 are exactly representable, and X_EPS /
+ X is small enough that factors quadratic in it can be
+ neglected. */
+extern _Mdouble_ __MSUF (__gamma_product) (_Mdouble_ x, _Mdouble_ x_eps,
+ int n, _Mdouble_ *eps);
+
+/* Compute lgamma of a negative argument X, if it is in a range
+ (depending on the floating-point format) for which expansion around
+ zeros is used, setting *SIGNGAMP accordingly. */
+extern _Mdouble_ __MSUF (__lgamma_neg) (_Mdouble_ x, int *signgamp);
+
+/* Compute the product of 1 + (T / (X + X_EPS)), 1 + (T / (X + X_EPS +
+ 1)), ..., 1 + (T / (X + X_EPS + N - 1)), minus 1. X is such that
+ all the values X + 1, ..., X + N - 1 are exactly representable, and
+ X_EPS / X is small enough that factors quadratic in it can be
+ neglected. */
+#if !defined __MATH_DECLARING_FLOAT
+extern _Mdouble_ __MSUF (__lgamma_product) (_Mdouble_ t, _Mdouble_ x,
+ _Mdouble_ x_eps, int n);
+#endif
+
+#undef __MSUF_X
+#undef __MSUF_S
+#undef __MSUF
+
+#undef __MSUF_R_X
+#undef __MSUF_R_S
+#undef __MSUF_R
diff --git a/REORG.TODO/sysdeps/generic/memcopy.h b/REORG.TODO/sysdeps/generic/memcopy.h
new file mode 100644
index 0000000000..83b8fd6de8
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/memcopy.h
@@ -0,0 +1,202 @@
+/* memcopy.h -- definitions for memory copy functions. Generic C version.
+ Copyright (C) 1991-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MEMCOPY_H
+#define _MEMCOPY_H 1
+
+/* The strategy of the memory functions is:
+
+ 1. Copy bytes until the destination pointer is aligned.
+
+ 2. Copy words in unrolled loops. If the source and destination
+ are not aligned in the same way, use word memory operations,
+ but shift and merge two read words before writing.
+
+ 3. Copy the few remaining bytes.
+
+ This is fast on processors that have at least 10 registers for
+ allocation by GCC, and that can access memory at reg+const in one
+ instruction.
+
+ I made an "exhaustive" test of this memmove when I wrote it,
+ exhaustive in the sense that I tried all alignment and length
+ combinations, with and without overlap. */
+
+#include <sys/cdefs.h>
+#include <endian.h>
+#include <pagecopy.h>
+
+/* The macros defined in this file are:
+
+ BYTE_COPY_FWD(dst_beg_ptr, src_beg_ptr, nbytes_to_copy)
+
+ BYTE_COPY_BWD(dst_end_ptr, src_end_ptr, nbytes_to_copy)
+
+ WORD_COPY_FWD(dst_beg_ptr, src_beg_ptr, nbytes_remaining, nbytes_to_copy)
+
+ WORD_COPY_BWD(dst_end_ptr, src_end_ptr, nbytes_remaining, nbytes_to_copy)
+
+ MERGE(old_word, sh_1, new_word, sh_2)
+ [I fail to understand. I feel stupid. --roland]
+*/
+
+/* Type to use for aligned memory operations.
+ This should normally be the biggest type supported by a single load
+ and store. */
+#define op_t unsigned long int
+#define OPSIZ (sizeof(op_t))
+
+/* Type to use for unaligned operations. */
+typedef unsigned char byte;
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2)))
+#endif
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2)))
+#endif
+
+/* Copy exactly NBYTES bytes from SRC_BP to DST_BP,
+ without any assumptions about alignment of the pointers. */
+#define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \
+ do \
+ { \
+ size_t __nbytes = (nbytes); \
+ while (__nbytes > 0) \
+ { \
+ byte __x = ((byte *) src_bp)[0]; \
+ src_bp += 1; \
+ __nbytes -= 1; \
+ ((byte *) dst_bp)[0] = __x; \
+ dst_bp += 1; \
+ } \
+ } while (0)
+
+/* Copy exactly NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR,
+ beginning at the bytes right before the pointers and continuing towards
+ smaller addresses. Don't assume anything about alignment of the
+ pointers. */
+#define BYTE_COPY_BWD(dst_ep, src_ep, nbytes) \
+ do \
+ { \
+ size_t __nbytes = (nbytes); \
+ while (__nbytes > 0) \
+ { \
+ byte __x; \
+ src_ep -= 1; \
+ __x = ((byte *) src_ep)[0]; \
+ dst_ep -= 1; \
+ __nbytes -= 1; \
+ ((byte *) dst_ep)[0] = __x; \
+ } \
+ } while (0)
+
+/* Copy *up to* NBYTES bytes from SRC_BP to DST_BP, with
+ the assumption that DST_BP is aligned on an OPSIZ multiple. If
+ not all bytes could be easily copied, store remaining number of bytes
+ in NBYTES_LEFT, otherwise store 0. */
+extern void _wordcopy_fwd_aligned (long int, long int, size_t)
+ attribute_hidden __THROW;
+extern void _wordcopy_fwd_dest_aligned (long int, long int, size_t)
+ attribute_hidden __THROW;
+#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
+ do \
+ { \
+ if (src_bp % OPSIZ == 0) \
+ _wordcopy_fwd_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \
+ else \
+ _wordcopy_fwd_dest_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \
+ src_bp += (nbytes) & -OPSIZ; \
+ dst_bp += (nbytes) & -OPSIZ; \
+ (nbytes_left) = (nbytes) % OPSIZ; \
+ } while (0)
+
+/* Copy *up to* NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR,
+ beginning at the words (of type op_t) right before the pointers and
+ continuing towards smaller addresses. May take advantage of that
+ DST_END_PTR is aligned on an OPSIZ multiple. If not all bytes could be
+ easily copied, store remaining number of bytes in NBYTES_REMAINING,
+ otherwise store 0. */
+extern void _wordcopy_bwd_aligned (long int, long int, size_t)
+ attribute_hidden __THROW;
+extern void _wordcopy_bwd_dest_aligned (long int, long int, size_t)
+ attribute_hidden __THROW;
+#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
+ do \
+ { \
+ if (src_ep % OPSIZ == 0) \
+ _wordcopy_bwd_aligned (dst_ep, src_ep, (nbytes) / OPSIZ); \
+ else \
+ _wordcopy_bwd_dest_aligned (dst_ep, src_ep, (nbytes) / OPSIZ); \
+ src_ep -= (nbytes) & -OPSIZ; \
+ dst_ep -= (nbytes) & -OPSIZ; \
+ (nbytes_left) = (nbytes) % OPSIZ; \
+ } while (0)
+
+/* The macro PAGE_COPY_FWD_MAYBE (dstp, srcp, nbytes_left, nbytes) is invoked
+ like WORD_COPY_FWD et al. The pointers should be at least word aligned.
+ This will check if virtual copying by pages can and should be done and do it
+ if so. The pointers will be aligned to PAGE_SIZE bytes. The macro requires
+ that pagecopy.h defines at least PAGE_COPY_THRESHOLD to 0. If
+ PAGE_COPY_THRESHOLD is non-zero, the header must also define PAGE_COPY_FWD
+ and PAGE_SIZE.
+*/
+#if PAGE_COPY_THRESHOLD
+
+# include <assert.h>
+
+# define PAGE_COPY_FWD_MAYBE(dstp, srcp, nbytes_left, nbytes) \
+ do \
+ { \
+ if ((nbytes) >= PAGE_COPY_THRESHOLD && \
+ PAGE_OFFSET ((dstp) - (srcp)) == 0) \
+ { \
+ /* The amount to copy is past the threshold for copying \
+ pages virtually with kernel VM operations, and the \
+ source and destination addresses have the same alignment. */ \
+ size_t nbytes_before = PAGE_OFFSET (-(dstp)); \
+ if (nbytes_before != 0) \
+ { \
+ /* First copy the words before the first page boundary. */ \
+ WORD_COPY_FWD (dstp, srcp, nbytes_left, nbytes_before); \
+ assert (nbytes_left == 0); \
+ nbytes -= nbytes_before; \
+ } \
+ PAGE_COPY_FWD (dstp, srcp, nbytes_left, nbytes); \
+ } \
+ } while (0)
+
+/* The page size is always a power of two, so we can avoid modulo division. */
+# define PAGE_OFFSET(n) ((n) & (PAGE_SIZE - 1))
+
+#else
+
+# define PAGE_COPY_FWD_MAYBE(dstp, srcp, nbytes_left, nbytes) /* nada */
+
+#endif
+
+/* Threshold value for when to enter the unrolled loops. */
+#define OP_T_THRES 16
+
+/* Set to 1 if memcpy is safe to use for forward-copying memmove with
+ overlapping addresses. This is 0 by default because memcpy implementations
+ are generally not safe for overlapping addresses. */
+#define MEMCPY_OK_FOR_FWD_MEMMOVE 0
+
+#endif /* memcopy.h */
diff --git a/REORG.TODO/sysdeps/generic/memusage.h b/REORG.TODO/sysdeps/generic/memusage.h
new file mode 100644
index 0000000000..c640d6db1d
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/memusage.h
@@ -0,0 +1,51 @@
+/* Copyright (C) 2000-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+
+#include <limits.h>
+#include <atomic.h>
+#include <stdint.h>
+
+#ifndef GETSP
+# warning "GETSP is not defined for this architecture."
+# define GETSP 0
+#endif
+
+#ifndef GETTIME
+# define GETTIME(low,high) \
+ { \
+ struct timeval tval; \
+ uint64_t usecs; \
+ gettimeofday (&tval, NULL); \
+ usecs = (uint64_t) tval.tv_usec + (uint64_t) tval.tv_usec * 1000000; \
+ low = usecs & 0xffffffff; \
+ high = usecs >> 32; \
+ }
+#endif
+
+#if LONG_BIT == 32
+# define memusage_cntr_t uatomic32_t
+#else
+# define memusage_cntr_t uatomic64_t
+#endif
+#ifndef memusage_size_t
+# if LONG_BIT == 32
+# define memusage_size_t uatomic32_t
+# else
+# define memusage_size_t uatomic64_t
+# endif
+#endif
diff --git a/REORG.TODO/sysdeps/generic/nan-high-order-bit.h b/REORG.TODO/sysdeps/generic/nan-high-order-bit.h
new file mode 100644
index 0000000000..4ae711d9c4
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/nan-high-order-bit.h
@@ -0,0 +1,27 @@
+/* Specify NaN high-order bit conventions. Generic version.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef NAN_HIGH_ORDER_BIT_H
+#define NAN_HIGH_ORDER_BIT_H 1
+
+/* Define this macro to 1 if the high-order bit of a NaN's mantissa is
+ set for signaling NaNs and clear for quiet NaNs, 0 otherwise (the
+ preferred IEEE convention). */
+#define HIGH_ORDER_BIT_IS_SET_FOR_SNAN 0
+
+#endif /* nan-high-order-bit.h */
diff --git a/REORG.TODO/sysdeps/generic/net/if.h b/REORG.TODO/sysdeps/generic/net/if.h
new file mode 100644
index 0000000000..31150e2a31
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/net/if.h
@@ -0,0 +1,49 @@
+/* net/if.h -- declarations for inquiring about network interfaces
+ Copyright (C) 2000-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _NET_IF_H
+
+#define _NET_IF_H 1
+#include <features.h>
+
+
+__BEGIN_DECLS
+
+/* Convert an interface name to an index, and vice versa. */
+
+extern unsigned int if_nametoindex (const char *__ifname) __THROW;
+extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW;
+
+/* Return a list of all interfaces and their indices. */
+
+struct if_nameindex
+ {
+ unsigned int if_index; /* 1, 2, ... */
+ char *if_name; /* null terminated name: "eth0", ... */
+ };
+
+extern struct if_nameindex *if_nameindex (void) __THROW;
+
+/* Free the data returned from if_nameindex. */
+
+extern void if_freenameindex (struct if_nameindex *__ptr) __THROW;
+
+__END_DECLS
+
+
+#endif /* net/if.h */
diff --git a/REORG.TODO/sysdeps/generic/netinet/if_ether.h b/REORG.TODO/sysdeps/generic/netinet/if_ether.h
new file mode 100644
index 0000000000..123f9ef173
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/netinet/if_ether.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef __NETINET_IF_ETHER_H
+#define __NETINET_IF_ETHER_H 1
+
+#include <sys/types.h>
+
+#define ETH_ALEN 6 /* Octets in one ethernet address. */
+
+/* This is a name for the 48 bit ethernet address available on many
+ systems. */
+struct ether_addr
+{
+ uint8_t ether_addr_octet[ETH_ALEN];
+} __attribute__ ((__packed__));
+
+#endif /* netinet/if_ether.h */
diff --git a/REORG.TODO/sysdeps/generic/netinet/in_systm.h b/REORG.TODO/sysdeps/generic/netinet/in_systm.h
new file mode 100644
index 0000000000..6697207a6c
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/netinet/in_systm.h
@@ -0,0 +1,40 @@
+/* System specific type definitions for networking code.
+ Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _NETINET_IN_SYSTM_H
+#define _NETINET_IN_SYSTM_H 1
+
+#include <sys/types.h>
+#include <stdint.h>
+
+__BEGIN_DECLS
+
+/*
+ * Network order versions of various data types. Unfortunately, BSD
+ * assumes specific sizes for shorts (16 bit) and longs (32 bit) which
+ * don't hold in general. As a consequence, the network order versions
+ * may not reflect the actual size of the native data types.
+ */
+
+typedef uint16_t n_short; /* short as received from the net */
+typedef uint32_t n_long; /* long as received from the net */
+typedef uint32_t n_time; /* ms since 00:00 GMT, byte rev */
+
+__END_DECLS
+
+#endif /* netinet/in_systm.h */
diff --git a/REORG.TODO/sysdeps/generic/netinet/ip.h b/REORG.TODO/sysdeps/generic/netinet/ip.h
new file mode 100644
index 0000000000..d57a0d9a1a
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/netinet/ip.h
@@ -0,0 +1,302 @@
+/* Copyright (C) 1991-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef __NETINET_IP_H
+#define __NETINET_IP_H 1
+
+#include <features.h>
+#include <sys/types.h>
+
+#include <netinet/in.h>
+
+__BEGIN_DECLS
+
+struct timestamp
+ {
+ uint8_t len;
+ uint8_t ptr;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int flags:4;
+ unsigned int overflow:4;
+#elif __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int overflow:4;
+ unsigned int flags:4;
+#else
+# error "Please fix <bits/endian.h>"
+#endif
+ uint32_t data[9];
+ };
+
+struct iphdr
+ {
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int ihl:4;
+ unsigned int version:4;
+#elif __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int version:4;
+ unsigned int ihl:4;
+#else
+# error "Please fix <bits/endian.h>"
+#endif
+ uint8_t tos;
+ uint16_t tot_len;
+ uint16_t id;
+ uint16_t frag_off;
+ uint8_t ttl;
+ uint8_t protocol;
+ uint16_t check;
+ uint32_t saddr;
+ uint32_t daddr;
+ /*The options start here. */
+ };
+
+#ifdef __USE_MISC
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ip.h 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * Definitions for internet protocol version 4.
+ * Per RFC 791, September 1981.
+ */
+
+/*
+ * Structure of an internet header, naked of options.
+ */
+struct ip
+ {
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int ip_hl:4; /* header length */
+ unsigned int ip_v:4; /* version */
+#endif
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int ip_v:4; /* version */
+ unsigned int ip_hl:4; /* header length */
+#endif
+ uint8_t ip_tos; /* type of service */
+ unsigned short ip_len; /* total length */
+ unsigned short ip_id; /* identification */
+ unsigned short ip_off; /* fragment offset field */
+#define IP_RF 0x8000 /* reserved fragment flag */
+#define IP_DF 0x4000 /* dont fragment flag */
+#define IP_MF 0x2000 /* more fragments flag */
+#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
+ uint8_t ip_ttl; /* time to live */
+ uint8_t ip_p; /* protocol */
+ unsigned short ip_sum; /* checksum */
+ struct in_addr ip_src, ip_dst; /* source and dest address */
+ };
+
+/*
+ * Time stamp option structure.
+ */
+struct ip_timestamp
+ {
+ uint8_t ipt_code; /* IPOPT_TS */
+ uint8_t ipt_len; /* size of structure (variable) */
+ uint8_t ipt_ptr; /* index of current entry */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int ipt_flg:4; /* flags, see below */
+ unsigned int ipt_oflw:4; /* overflow counter */
+#endif
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int ipt_oflw:4; /* overflow counter */
+ unsigned int ipt_flg:4; /* flags, see below */
+#endif
+ uint32_t data[9];
+ };
+#endif /* __USE_MISC */
+
+#define IPVERSION 4 /* IP version number */
+#define IP_MAXPACKET 65535 /* maximum packet size */
+
+/*
+ * Definitions for Explicit Congestion Notification (ECN)
+ *
+ * Taken from RFC-3168, Section 5.
+ */
+
+#define IPTOS_ECN_MASK 0x03
+#define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK)
+#define IPTOS_ECN_NOT_ECT 0x00
+#define IPTOS_ECN_ECT1 0x01
+#define IPTOS_ECN_ECT0 0x02
+#define IPTOS_ECN_CE 0x03
+
+/*
+ * Definitions for IP differentiated services code points (DSCP)
+ *
+ * Taken from RFC-2597, Section 6 and RFC-2598, Section 2.3.
+ */
+
+#define IPTOS_DSCP_MASK 0xfc
+#define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK)
+#define IPTOS_DSCP_AF11 0x28
+#define IPTOS_DSCP_AF12 0x30
+#define IPTOS_DSCP_AF13 0x38
+#define IPTOS_DSCP_AF21 0x48
+#define IPTOS_DSCP_AF22 0x50
+#define IPTOS_DSCP_AF23 0x58
+#define IPTOS_DSCP_AF31 0x68
+#define IPTOS_DSCP_AF32 0x70
+#define IPTOS_DSCP_AF33 0x78
+#define IPTOS_DSCP_AF41 0x88
+#define IPTOS_DSCP_AF42 0x90
+#define IPTOS_DSCP_AF43 0x98
+#define IPTOS_DSCP_EF 0xb8
+
+/*
+ * In RFC 2474, Section 4.2.2.1, the Class Selector Codepoints subsume
+ * the old ToS Precedence values.
+ */
+
+#define IPTOS_CLASS_MASK 0xe0
+#define IPTOS_CLASS(class) ((class) & IPTOS_CLASS_MASK)
+#define IPTOS_CLASS_CS0 0x00
+#define IPTOS_CLASS_CS1 0x20
+#define IPTOS_CLASS_CS2 0x40
+#define IPTOS_CLASS_CS3 0x60
+#define IPTOS_CLASS_CS4 0x80
+#define IPTOS_CLASS_CS5 0xa0
+#define IPTOS_CLASS_CS6 0xc0
+#define IPTOS_CLASS_CS7 0xe0
+
+#define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0
+
+/*
+ * Definitions for IP type of service (ip_tos) [deprecated; use DSCP
+ * and CS definitions above instead.]
+ */
+#define IPTOS_TOS_MASK 0x1E
+#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
+#define IPTOS_LOWDELAY 0x10
+#define IPTOS_THROUGHPUT 0x08
+#define IPTOS_RELIABILITY 0x04
+#define IPTOS_LOWCOST 0x02
+#define IPTOS_MINCOST IPTOS_LOWCOST
+
+/*
+ * Definitions for IP precedence (also in ip_tos) [also deprecated.]
+ */
+#define IPTOS_PREC_MASK IPTOS_CLASS_MASK
+#define IPTOS_PREC(tos) IPTOS_CLASS(tos)
+#define IPTOS_PREC_NETCONTROL IPTOS_CLASS_CS7
+#define IPTOS_PREC_INTERNETCONTROL IPTOS_CLASS_CS6
+#define IPTOS_PREC_CRITIC_ECP IPTOS_CLASS_CS5
+#define IPTOS_PREC_FLASHOVERRIDE IPTOS_CLASS_CS4
+#define IPTOS_PREC_FLASH IPTOS_CLASS_CS3
+#define IPTOS_PREC_IMMEDIATE IPTOS_CLASS_CS2
+#define IPTOS_PREC_PRIORITY IPTOS_CLASS_CS1
+#define IPTOS_PREC_ROUTINE IPTOS_CLASS_CS0
+
+/*
+ * Definitions for options.
+ */
+#define IPOPT_COPY 0x80
+#define IPOPT_CLASS_MASK 0x60
+#define IPOPT_NUMBER_MASK 0x1f
+
+#define IPOPT_COPIED(o) ((o) & IPOPT_COPY)
+#define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK)
+#define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK)
+
+#define IPOPT_CONTROL 0x00
+#define IPOPT_RESERVED1 0x20
+#define IPOPT_DEBMEAS 0x40
+#define IPOPT_MEASUREMENT IPOPT_DEBMEAS
+#define IPOPT_RESERVED2 0x60
+
+#define IPOPT_EOL 0 /* end of option list */
+#define IPOPT_END IPOPT_EOL
+#define IPOPT_NOP 1 /* no operation */
+#define IPOPT_NOOP IPOPT_NOP
+
+#define IPOPT_RR 7 /* record packet route */
+#define IPOPT_TS 68 /* timestamp */
+#define IPOPT_TIMESTAMP IPOPT_TS
+#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
+#define IPOPT_SEC IPOPT_SECURITY
+#define IPOPT_LSRR 131 /* loose source route */
+#define IPOPT_SATID 136 /* satnet id */
+#define IPOPT_SID IPOPT_SATID
+#define IPOPT_SSRR 137 /* strict source route */
+#define IPOPT_RA 148 /* router alert */
+
+/*
+ * Offsets to fields in options other than EOL and NOP.
+ */
+#define IPOPT_OPTVAL 0 /* option ID */
+#define IPOPT_OLEN 1 /* option length */
+#define IPOPT_OFFSET 2 /* offset within option */
+#define IPOPT_MINOFF 4 /* min value of above */
+
+#define MAX_IPOPTLEN 40
+
+/* flag bits for ipt_flg */
+#define IPOPT_TS_TSONLY 0 /* timestamps only */
+#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
+#define IPOPT_TS_PRESPEC 3 /* specified modules only */
+
+/* bits for security (not byte swapped) */
+#define IPOPT_SECUR_UNCLASS 0x0000
+#define IPOPT_SECUR_CONFID 0xf135
+#define IPOPT_SECUR_EFTO 0x789a
+#define IPOPT_SECUR_MMMM 0xbc4d
+#define IPOPT_SECUR_RESTR 0xaf13
+#define IPOPT_SECUR_SECRET 0xd788
+#define IPOPT_SECUR_TOPSECRET 0x6bc5
+
+/*
+ * Internet implementation parameters.
+ */
+#define MAXTTL 255 /* maximum time to live (seconds) */
+#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
+#define IPFRAGTTL 60 /* time to live for frags, slowhz */
+#define IPTTLDEC 1 /* subtracted when forwarding */
+
+#define IP_MSS 576 /* default maximum segment size */
+
+__END_DECLS
+
+#endif /* netinet/ip.h */
diff --git a/REORG.TODO/sysdeps/generic/netinet/tcp.h b/REORG.TODO/sysdeps/generic/netinet/tcp.h
new file mode 100644
index 0000000000..49f1bfbc26
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/netinet/tcp.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)tcp.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_TCP_H
+
+#define _NETINET_TCP_H 1
+#include <sys/cdefs.h>
+
+
+__BEGIN_DECLS
+
+typedef unsigned int tcp_seq;
+/*
+ * TCP header.
+ * Per RFC 793, September, 1981.
+ */
+struct tcphdr {
+ unsigned short th_sport; /* source port */
+ unsigned short th_dport; /* destination port */
+ tcp_seq th_seq; /* sequence number */
+ tcp_seq th_ack; /* acknowledgement number */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned char th_x2:4, /* (unused) */
+ th_off:4; /* data offset */
+#endif
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned char th_off:4, /* data offset */
+ th_x2:4; /* (unused) */
+#endif
+ unsigned char th_flags;
+#define TH_FIN 0x01
+#define TH_SYN 0x02
+#define TH_RST 0x04
+#define TH_PUSH 0x08
+#define TH_ACK 0x10
+#define TH_URG 0x20
+ unsigned short th_win; /* window */
+ unsigned short th_sum; /* checksum */
+ unsigned short th_urp; /* urgent pointer */
+};
+
+#define TCPOPT_EOL 0
+#define TCPOPT_NOP 1
+#define TCPOPT_MAXSEG 2
+#define TCPOLEN_MAXSEG 4
+#define TCPOPT_WINDOW 3
+#define TCPOLEN_WINDOW 3
+#define TCPOPT_SACK_PERMITTED 4 /* Experimental */
+#define TCPOLEN_SACK_PERMITTED 2
+#define TCPOPT_SACK 5 /* Experimental */
+#define TCPOPT_TIMESTAMP 8
+#define TCPOLEN_TIMESTAMP 10
+#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */
+
+#define TCPOPT_TSTAMP_HDR \
+ (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
+
+/*
+ * Default maximum segment size for TCP.
+ * With an IP MSS of 576, this is 536,
+ * but 512 is probably more convenient.
+ * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
+ */
+#define TCP_MSS 512
+
+#define TCP_MAXWIN 65535 /* largest value for (unscaled) window */
+
+#define TCP_MAX_WINSHIFT 14 /* maximum window shift */
+
+/*
+ * User-settable options (used with setsockopt).
+ */
+#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
+#define TCP_MAXSEG 0x02 /* set maximum segment size */
+
+#define SOL_TCP 6 /* TCP level */
+
+__END_DECLS
+
+#endif /* netinet/tcp.h */
diff --git a/REORG.TODO/sysdeps/generic/nfs/nfs.h b/REORG.TODO/sysdeps/generic/nfs/nfs.h
new file mode 100644
index 0000000000..89a878cea4
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/nfs/nfs.h
@@ -0,0 +1,31 @@
+/* <nfs/nfs.h> -- ill-specified NFS-related definitions
+ Copyright (C) 1999-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _NFS_NFS_H
+#define _NFS_NFS_H 1
+
+/* This file is empty for now. Its contents do not seem to be
+ standardized in any way. It exists solely for the sake of
+ <rpcsvc/bootparam_prot.h> which insists on including <nfs/nfs.h>.
+
+ For the time being, we just provide this file here to smooth building
+ the libc distribution (i.e. librpcsvc). We do not install this file for
+ users, since we haven't really figured out what the right thing to go
+ here is. */
+
+#endif /* nfs/nfs.h */
diff --git a/REORG.TODO/sysdeps/generic/not-cancel.h b/REORG.TODO/sysdeps/generic/not-cancel.h
new file mode 100644
index 0000000000..5eabd2b31a
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/not-cancel.h
@@ -0,0 +1,54 @@
+/* Uncancelable versions of cancelable interfaces. Generic version.
+ Copyright (C) 2003-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* By default we have none. Map the name to the normal functions. */
+#define open_not_cancel(name, flags, mode) \
+ __libc_open (name, flags, mode)
+#define open_not_cancel_2(name, flags) \
+ __libc_open (name, flags)
+#define openat_not_cancel(fd, name, flags, mode) \
+ __openat (fd, name, flags, mode)
+#define openat_not_cancel_3(fd, name, flags) \
+ __openat (fd, name, flags, 0)
+#define openat64_not_cancel(fd, name, flags, mode) \
+ __openat64 (fd, name, flags, mode)
+#define openat64_not_cancel_3(fd, name, flags) \
+ __openat64 (fd, name, flags, 0)
+#define close_not_cancel(fd) \
+ __close (fd)
+#define close_not_cancel_no_status(fd) \
+ (void) __close (fd)
+#define read_not_cancel(fd, buf, n) \
+ __read (fd, buf, n)
+#define write_not_cancel(fd, buf, n) \
+ __write (fd, buf, n)
+#define writev_not_cancel_no_status(fd, iov, n) \
+ (void) __writev (fd, iov, n)
+#define fcntl_not_cancel(fd, cmd, val) \
+ __fcntl (fd, cmd, val)
+# define waitpid_not_cancel(pid, stat_loc, options) \
+ __waitpid (pid, stat_loc, options)
+#define pause_not_cancel() \
+ __pause ()
+#define nanosleep_not_cancel(requested_time, remaining) \
+ __nanosleep (requested_time, remaining)
+#define sigsuspend_not_cancel(set) \
+ __sigsuspend (set)
+
+#define NO_CANCELLATION 1
diff --git a/REORG.TODO/sysdeps/generic/nscd-types.h b/REORG.TODO/sysdeps/generic/nscd-types.h
new file mode 100644
index 0000000000..1bcfdf4bca
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/nscd-types.h
@@ -0,0 +1,21 @@
+/* Types for the NSCD implementation. Generic version.
+ Copyright (c) 2000-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdint.h>
+
+typedef int32_t nscd_ssize_t;
diff --git a/REORG.TODO/sysdeps/generic/pagecopy.h b/REORG.TODO/sysdeps/generic/pagecopy.h
new file mode 100644
index 0000000000..3ef17070c9
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/pagecopy.h
@@ -0,0 +1,37 @@
+/* Macros for copying by pages; used in memcpy, memmove.
+ Copyright (C) 1995-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* The macro PAGE_COPY_FWD_MAYBE defined in memcopy.h is used in memmove if the
+ PAGE_COPY_THRESHOLD macro is set to a non-zero value. The default is 0,
+ that is copying by pages is not implemented.
+
+ System-specific pagecopy.h files that want to support page copying should
+ define these macros:
+
+ PAGE_COPY_THRESHOLD
+ -- A non-zero minimum size for which virtual copying by pages is worthwhile.
+
+ PAGE_SIZE
+ -- Size of a page.
+
+ PAGE_COPY_FWD (dstp, srcp, nbytes_left, nbytes)
+ -- Macro to perform the virtual copy operation.
+ The pointers will be aligned to PAGE_SIZE bytes.
+*/
+
+#define PAGE_COPY_THRESHOLD 0
diff --git a/REORG.TODO/sysdeps/generic/paths.h b/REORG.TODO/sysdeps/generic/paths.h
new file mode 100644
index 0000000000..893b4c2286
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/paths.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)paths.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _PATHS_H_
+#define _PATHS_H_
+
+/* Default search path. */
+#define _PATH_DEFPATH "/usr/bin:/bin"
+/* All standard utilities path. */
+#define _PATH_STDPATH \
+ "/usr/bin:/bin:/usr/sbin:/sbin"
+
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_CONSOLE "/dev/console"
+#define _PATH_CSHELL "/bin/csh"
+#define _PATH_DEVDB "/var/run/dev.db"
+#define _PATH_DEVNULL "/dev/null"
+#define _PATH_DRUM "/dev/drum"
+#define _PATH_GSHADOW "/etc/gshadow"
+#define _PATH_KMEM "/dev/kmem"
+#define _PATH_LASTLOG "/var/log/lastlog"
+#define _PATH_MAILDIR "/var/mail"
+#define _PATH_MAN "/usr/share/man"
+#define _PATH_MEM "/dev/mem"
+#define _PATH_MNTTAB "/etc/fstab"
+#define _PATH_MOUNTED "/var/run/mtab"
+#define _PATH_NOLOGIN "/etc/nologin"
+#define _PATH_PRESERVE "/var/lib"
+#define _PATH_RWHODIR "/var/spool/rwho"
+#define _PATH_SENDMAIL "/usr/sbin/sendmail"
+#define _PATH_SHADOW "/etc/shadow"
+#define _PATH_SHELLS "/etc/shells"
+#define _PATH_TTY "/dev/tty"
+#define _PATH_UNIX "/vmunix"
+#define _PATH_UTMP "/var/run/utmp"
+#define _PATH_UTMP_DB "/var/run/utmp.db"
+#define _PATH_VI "/usr/bin/vi"
+#define _PATH_WTMP "/var/log/wtmp"
+
+/* Provide trailing slash, since mostly used for building pathnames. */
+#define _PATH_DEV "/dev/"
+#define _PATH_TMP "/tmp/"
+#define _PATH_VARDB "/var/db/"
+#define _PATH_VARRUN "/var/run/"
+#define _PATH_VARTMP "/var/tmp/"
+
+#endif /* !_PATHS_H_ */
diff --git a/REORG.TODO/sysdeps/generic/profil-counter.h b/REORG.TODO/sysdeps/generic/profil-counter.h
new file mode 100644
index 0000000000..e2fc9ffdce
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/profil-counter.h
@@ -0,0 +1,26 @@
+/* Machine-dependent SIGPROF signal handler. "Generic" version w/ sigcontext
+ Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* In many Unix systems signal handlers are called like this
+ and the interrupted PC is easily findable in the `struct sigcontext'. */
+
+static void
+__profil_counter (int signr, int code, struct sigcontext *scp)
+{
+ profil_count ((void *) scp->sc_pc);
+}
diff --git a/REORG.TODO/sysdeps/generic/pty-private.h b/REORG.TODO/sysdeps/generic/pty-private.h
new file mode 100644
index 0000000000..e667ae89b3
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/pty-private.h
@@ -0,0 +1,45 @@
+/* Internal defenitions and declarations for pseudo terminal functions.
+ Copyright (C) 1998-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _PTY_PRIVATE_H
+#define _PTY_PRIVATE_H 1
+
+/* The group slave pseudo terminals belong to. */
+#define TTY_GROUP "tty"
+
+/* The file descriptor connected to the master pseudo terminal. */
+#define PTY_FILENO 3
+
+/* Path to the helper program that implements `grantpt' in user space. */
+#define _PATH_PT_CHOWN LIBEXECDIR "/pt_chown"
+
+/* Test whether given TTY is really a Unix98 pseudo terminal. */
+/* #define unix98_pseudo_p(Dev) ... */
+
+/* Exit codes for the helper program. */
+enum /* failure modes */
+{
+ FAIL_EBADF = 1,
+ FAIL_EINVAL,
+ FAIL_EACCES,
+ FAIL_EXEC,
+ FAIL_ENOMEM
+};
+
+#endif /* pty-private.h */
diff --git a/REORG.TODO/sysdeps/generic/register-dump.h b/REORG.TODO/sysdeps/generic/register-dump.h
new file mode 100644
index 0000000000..2af34a9295
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/register-dump.h
@@ -0,0 +1,20 @@
+/* Dump registers.
+ Copyright (C) 1998-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* In general we cannot do anything. */
diff --git a/REORG.TODO/sysdeps/generic/rtld-lowlevel.h b/REORG.TODO/sysdeps/generic/rtld-lowlevel.h
new file mode 100644
index 0000000000..353fad28d4
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/rtld-lowlevel.h
@@ -0,0 +1 @@
+#error "Lowlevel primitives for ld.so not implemented"
diff --git a/REORG.TODO/sysdeps/generic/safe-fatal.h b/REORG.TODO/sysdeps/generic/safe-fatal.h
new file mode 100644
index 0000000000..05129250c4
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/safe-fatal.h
@@ -0,0 +1,37 @@
+/* Crash the process immediately, without possibility of deadlock. Generic.
+ Copyright (C) 2014-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SAFE_FATAL_H
+#define _SAFE_FATAL_H 1
+
+#include <abort-instr.h>
+
+static inline void
+__safe_fatal (void)
+{
+#ifdef ABORT_INSTRUCTION
+ /* This is not guaranteed to be free from the possibility of deadlock,
+ since it might generate a signal that can be caught. But it's better
+ than nothing. */
+ ABORT_INSTRUCTION;
+#else
+# error Need an OS-specific or machine-specific safe-fatal.h
+#endif
+}
+
+#endif /* safe-fatal.h */
diff --git a/REORG.TODO/sysdeps/generic/sigcontextinfo.h b/REORG.TODO/sysdeps/generic/sigcontextinfo.h
new file mode 100644
index 0000000000..d25a787d05
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sigcontextinfo.h
@@ -0,0 +1,26 @@
+/* Copyright (C) 1998-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* In general we cannot provide any information. */
+#define SIGCONTEXT struct sigcontext *
+#define SIGCONTEXT_EXTRA_ARGS
+#define GET_PC(ctx) ((void *) 0)
+#define GET_FRAME(ctx) ((void *) 0)
+#define GET_STACK(ctx) ((void *) 0)
+#define CALL_SIGHANDLER(handler, signo, ctx) \
+ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
diff --git a/REORG.TODO/sysdeps/generic/siglist.h b/REORG.TODO/sysdeps/generic/siglist.h
new file mode 100644
index 0000000000..dd72929ed5
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/siglist.h
@@ -0,0 +1,76 @@
+/* Canonical list of all signal names.
+ Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This file should be usable for any platform, since it just associates
+ the SIG* macros with text names and descriptions. The actual values
+ come from <bits/signum.h> (via <signal.h>). For any signal macros do not
+ exist on every platform, we can use #ifdef tests here and still use
+ this single common file for all platforms. */
+
+/* This file is included multiple times. */
+
+/* Standard signals */
+ init_sig (SIGHUP, "HUP", N_("Hangup"))
+ init_sig (SIGINT, "INT", N_("Interrupt"))
+ init_sig (SIGQUIT, "QUIT", N_("Quit"))
+ init_sig (SIGILL, "ILL", N_("Illegal instruction"))
+ init_sig (SIGTRAP, "TRAP", N_("Trace/breakpoint trap"))
+ init_sig (SIGABRT, "ABRT", N_("Aborted"))
+ init_sig (SIGFPE, "FPE", N_("Floating point exception"))
+ init_sig (SIGKILL, "KILL", N_("Killed"))
+ init_sig (SIGBUS, "BUS", N_("Bus error"))
+ init_sig (SIGSEGV, "SEGV", N_("Segmentation fault"))
+ init_sig (SIGPIPE, "PIPE", N_("Broken pipe"))
+ init_sig (SIGALRM, "ALRM", N_("Alarm clock"))
+ init_sig (SIGTERM, "TERM", N_("Terminated"))
+ init_sig (SIGURG, "URG", N_("Urgent I/O condition"))
+ init_sig (SIGSTOP, "STOP", N_("Stopped (signal)"))
+ init_sig (SIGTSTP, "TSTP", N_("Stopped"))
+ init_sig (SIGCONT, "CONT", N_("Continued"))
+ init_sig (SIGCHLD, "CHLD", N_("Child exited"))
+ init_sig (SIGTTIN, "TTIN", N_("Stopped (tty input)"))
+ init_sig (SIGTTOU, "TTOU", N_("Stopped (tty output)"))
+ init_sig (SIGIO, "IO", N_("I/O possible"))
+ init_sig (SIGXCPU, "XCPU", N_("CPU time limit exceeded"))
+ init_sig (SIGXFSZ, "XFSZ", N_("File size limit exceeded"))
+ init_sig (SIGVTALRM, "VTALRM", N_("Virtual timer expired"))
+ init_sig (SIGPROF, "PROF", N_("Profiling timer expired"))
+ init_sig (SIGUSR1, "USR1", N_("User defined signal 1"))
+ init_sig (SIGUSR2, "USR2", N_("User defined signal 2"))
+
+/* Variations */
+#ifdef SIGEMT
+ init_sig (SIGEMT, "EMT", N_("EMT trap"))
+#endif
+#ifdef SIGSYS
+ init_sig (SIGSYS, "SYS", N_("Bad system call"))
+#endif
+#ifdef SIGSTKFLT
+ init_sig (SIGSTKFLT, "STKFLT", N_("Stack fault"))
+#endif
+#ifdef SIGINFO
+ init_sig (SIGINFO, "INFO", N_("Information request"))
+#elif defined(SIGPWR) && (!defined(SIGLOST) || (SIGPWR != SIGLOST))
+ init_sig (SIGPWR, "PWR", N_("Power failure"))
+#endif
+#ifdef SIGLOST
+ init_sig (SIGLOST, "LOST", N_("Resource lost"))
+#endif
+#ifdef SIGWINCH
+ init_sig (SIGWINCH, "WINCH", N_("Window changed"))
+#endif
diff --git a/REORG.TODO/sysdeps/generic/sigset-cvt-mask.h b/REORG.TODO/sysdeps/generic/sigset-cvt-mask.h
new file mode 100644
index 0000000000..b73bc64028
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sigset-cvt-mask.h
@@ -0,0 +1,63 @@
+/* Convert between lowlevel sigmask and libc representation of sigset_t.
+ Generic version.
+ Copyright (C) 1998-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Joe Keane <jgk@jgk.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Convert between an old-style 32-bit signal mask and a POSIX sigset_t. */
+
+/* Perform *SET = MASK. Unused bits of *SET are set to 0.
+ Returns zero for success or -1 for errors (from sigaddset/sigemptyset). */
+static inline int __attribute__ ((unused))
+sigset_set_old_mask (sigset_t *set, int mask)
+{
+ if (sizeof (__sigset_t) == sizeof (unsigned int))
+ *set = (unsigned int) mask;
+ else
+ {
+ unsigned int __sig;
+
+ if (__sigemptyset (set) < 0)
+ return -1;
+
+ for (__sig = 1; __sig < NSIG && __sig <= sizeof (mask) * 8; __sig++)
+ if (mask & sigmask (__sig))
+ if (__sigaddset (set, __sig) < 0)
+ return -1;
+ }
+ return 0;
+}
+
+/* Return the sigmask corresponding to *SET.
+ Unused bits of *SET are thrown away. */
+static inline int __attribute__ ((unused))
+sigset_get_old_mask (const sigset_t *set)
+{
+ if (sizeof (sigset_t) == sizeof (unsigned int))
+ return (unsigned int) *set;
+ else
+ {
+ unsigned int mask = 0;
+ unsigned int sig;
+
+ for (sig = 1; sig < NSIG && sig <= sizeof (mask) * 8; sig++)
+ if (__sigismember (set, sig))
+ mask |= sigmask (sig);
+
+ return mask;
+ }
+}
diff --git a/REORG.TODO/sysdeps/generic/sigsetops.h b/REORG.TODO/sysdeps/generic/sigsetops.h
new file mode 100644
index 0000000000..e8e5553981
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sigsetops.h
@@ -0,0 +1,77 @@
+/* __sigset_t manipulators. Generic/BSD version.
+ Copyright (C) 1991-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SIGSETOPS_H
+#define _SIGSETOPS_H 1
+
+#include <signal.h>
+
+/* Return a mask that includes SIG only. The cast to `sigset_t' avoids
+ overflow if `sigset_t' is wider than `int'. */
+# define __sigmask(sig) (((__sigset_t) 1) << ((sig) - 1))
+
+#define __sigemptyset(set) \
+ (__extension__ ({ \
+ *(set) = (__sigset_t) 0; \
+ (void)0; \
+ }))
+#define __sigfillset(set) \
+ (__extension__ ({ \
+ *(set) = ~(__sigset_t) 0; \
+ (void)0; \
+ }))
+
+# define __sigisemptyset(set) \
+ (*(set) == (__sigset_t) 0)
+
+# define __sigandset(dest, left, right) \
+ (__extension__ ({ \
+ *(dest) = *(left) & *(right); \
+ (void)0; \
+ }))
+
+# define __sigorset(dest, left, right) \
+ (__extension__ ({ \
+ *(dest) = *(left) | *(right); \
+ (void)0; \
+ }))
+#endif
+
+/* These macros needn't check for a bogus signal number;
+ checking is done in the non-__ versions. */
+# define __sigismember(set, sig) \
+ (__extension__ ({ \
+ __sigset_t __mask = __sigmask (sig); \
+ (set) & __mask ? 1 : 0; \
+ }))
+
+# define __sigaddset(set, sig) \
+ (__extension__ ({ \
+ __sigset_t __mask = __sigmask (sig); \
+ (set) |= __mask; \
+ (void)0; \
+ }))
+
+# define __sigdelset(set, sig) \
+ (__extension__ ({ \
+ __sigset_t __mask = __sigmask (sig); \
+ (set) &= ~__mask; \
+ (void)0; \
+ }))
+
+#endif
diff --git a/REORG.TODO/sysdeps/generic/stackguard-macros.h b/REORG.TODO/sysdeps/generic/stackguard-macros.h
new file mode 100644
index 0000000000..b4a6b23ff8
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/stackguard-macros.h
@@ -0,0 +1,12 @@
+#include <stdint.h>
+
+extern uintptr_t __stack_chk_guard;
+#define STACK_CHK_GUARD __stack_chk_guard
+
+#ifdef PTRGUARD_LOCAL
+extern uintptr_t __pointer_chk_guard_local;
+# define POINTER_CHK_GUARD __pointer_chk_guard_local
+#else
+extern uintptr_t __pointer_chk_guard;
+# define POINTER_CHK_GUARD __pointer_chk_guard
+#endif
diff --git a/REORG.TODO/sysdeps/generic/stackinfo.h b/REORG.TODO/sysdeps/generic/stackinfo.h
new file mode 100644
index 0000000000..718c74582a
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/stackinfo.h
@@ -0,0 +1,20 @@
+/* Copyright (C) 1999-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. Since there is no general truth we can't say
+ anything here. */
diff --git a/REORG.TODO/sysdeps/generic/stdint.h b/REORG.TODO/sysdeps/generic/stdint.h
new file mode 100644
index 0000000000..b553c52665
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/stdint.h
@@ -0,0 +1,329 @@
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/*
+ * ISO C99: 7.18 Integer types <stdint.h>
+ */
+
+#ifndef _STDINT_H
+#define _STDINT_H 1
+
+#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
+#include <bits/libc-header-start.h>
+#include <bits/types.h>
+#include <bits/wchar.h>
+#include <bits/wordsize.h>
+
+/* Exact integral types. */
+
+/* Signed. */
+#include <bits/stdint-intn.h>
+
+/* Unsigned. */
+#include <bits/stdint-uintn.h>
+
+
+/* Small types. */
+
+/* Signed. */
+typedef signed char int_least8_t;
+typedef short int int_least16_t;
+typedef int int_least32_t;
+#if __WORDSIZE == 64
+typedef long int int_least64_t;
+#else
+__extension__
+typedef long long int int_least64_t;
+#endif
+
+/* Unsigned. */
+typedef unsigned char uint_least8_t;
+typedef unsigned short int uint_least16_t;
+typedef unsigned int uint_least32_t;
+#if __WORDSIZE == 64
+typedef unsigned long int uint_least64_t;
+#else
+__extension__
+typedef unsigned long long int uint_least64_t;
+#endif
+
+
+/* Fast types. */
+
+/* Signed. */
+typedef signed char int_fast8_t;
+#if __WORDSIZE == 64
+typedef long int int_fast16_t;
+typedef long int int_fast32_t;
+typedef long int int_fast64_t;
+#else
+typedef int int_fast16_t;
+typedef int int_fast32_t;
+__extension__
+typedef long long int int_fast64_t;
+#endif
+
+/* Unsigned. */
+typedef unsigned char uint_fast8_t;
+#if __WORDSIZE == 64
+typedef unsigned long int uint_fast16_t;
+typedef unsigned long int uint_fast32_t;
+typedef unsigned long int uint_fast64_t;
+#else
+typedef unsigned int uint_fast16_t;
+typedef unsigned int uint_fast32_t;
+__extension__
+typedef unsigned long long int uint_fast64_t;
+#endif
+
+
+/* Types for `void *' pointers. */
+#if __WORDSIZE == 64
+# ifndef __intptr_t_defined
+typedef long int intptr_t;
+# define __intptr_t_defined
+# endif
+typedef unsigned long int uintptr_t;
+#else
+# ifndef __intptr_t_defined
+typedef int intptr_t;
+# define __intptr_t_defined
+# endif
+typedef unsigned int uintptr_t;
+#endif
+
+
+/* Largest integral types. */
+typedef __intmax_t intmax_t;
+typedef __uintmax_t uintmax_t;
+
+
+# if __WORDSIZE == 64
+# define __INT64_C(c) c ## L
+# define __UINT64_C(c) c ## UL
+# else
+# define __INT64_C(c) c ## LL
+# define __UINT64_C(c) c ## ULL
+# endif
+
+/* Limits of integral types. */
+
+/* Minimum of signed integral types. */
+# define INT8_MIN (-128)
+# define INT16_MIN (-32767-1)
+# define INT32_MIN (-2147483647-1)
+# define INT64_MIN (-__INT64_C(9223372036854775807)-1)
+/* Maximum of signed integral types. */
+# define INT8_MAX (127)
+# define INT16_MAX (32767)
+# define INT32_MAX (2147483647)
+# define INT64_MAX (__INT64_C(9223372036854775807))
+
+/* Maximum of unsigned integral types. */
+# define UINT8_MAX (255)
+# define UINT16_MAX (65535)
+# define UINT32_MAX (4294967295U)
+# define UINT64_MAX (__UINT64_C(18446744073709551615))
+
+
+/* Minimum of signed integral types having a minimum size. */
+# define INT_LEAST8_MIN (-128)
+# define INT_LEAST16_MIN (-32767-1)
+# define INT_LEAST32_MIN (-2147483647-1)
+# define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1)
+/* Maximum of signed integral types having a minimum size. */
+# define INT_LEAST8_MAX (127)
+# define INT_LEAST16_MAX (32767)
+# define INT_LEAST32_MAX (2147483647)
+# define INT_LEAST64_MAX (__INT64_C(9223372036854775807))
+
+/* Maximum of unsigned integral types having a minimum size. */
+# define UINT_LEAST8_MAX (255)
+# define UINT_LEAST16_MAX (65535)
+# define UINT_LEAST32_MAX (4294967295U)
+# define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615))
+
+
+/* Minimum of fast signed integral types having a minimum size. */
+# define INT_FAST8_MIN (-128)
+# if __WORDSIZE == 64
+# define INT_FAST16_MIN (-9223372036854775807L-1)
+# define INT_FAST32_MIN (-9223372036854775807L-1)
+# else
+# define INT_FAST16_MIN (-2147483647-1)
+# define INT_FAST32_MIN (-2147483647-1)
+# endif
+# define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1)
+/* Maximum of fast signed integral types having a minimum size. */
+# define INT_FAST8_MAX (127)
+# if __WORDSIZE == 64
+# define INT_FAST16_MAX (9223372036854775807L)
+# define INT_FAST32_MAX (9223372036854775807L)
+# else
+# define INT_FAST16_MAX (2147483647)
+# define INT_FAST32_MAX (2147483647)
+# endif
+# define INT_FAST64_MAX (__INT64_C(9223372036854775807))
+
+/* Maximum of fast unsigned integral types having a minimum size. */
+# define UINT_FAST8_MAX (255)
+# if __WORDSIZE == 64
+# define UINT_FAST16_MAX (18446744073709551615UL)
+# define UINT_FAST32_MAX (18446744073709551615UL)
+# else
+# define UINT_FAST16_MAX (4294967295U)
+# define UINT_FAST32_MAX (4294967295U)
+# endif
+# define UINT_FAST64_MAX (__UINT64_C(18446744073709551615))
+
+
+/* Values to test for integral types holding `void *' pointer. */
+# if __WORDSIZE == 64
+# define INTPTR_MIN (-9223372036854775807L-1)
+# define INTPTR_MAX (9223372036854775807L)
+# define UINTPTR_MAX (18446744073709551615UL)
+# else
+# define INTPTR_MIN (-2147483647-1)
+# define INTPTR_MAX (2147483647)
+# define UINTPTR_MAX (4294967295U)
+# endif
+
+
+/* Minimum for largest signed integral type. */
+# define INTMAX_MIN (-__INT64_C(9223372036854775807)-1)
+/* Maximum for largest signed integral type. */
+# define INTMAX_MAX (__INT64_C(9223372036854775807))
+
+/* Maximum for largest unsigned integral type. */
+# define UINTMAX_MAX (__UINT64_C(18446744073709551615))
+
+
+/* Limits of other integer types. */
+
+/* Limits of `ptrdiff_t' type. */
+# if __WORDSIZE == 64
+# define PTRDIFF_MIN (-9223372036854775807L-1)
+# define PTRDIFF_MAX (9223372036854775807L)
+# else
+# if __WORDSIZE32_PTRDIFF_LONG
+# define PTRDIFF_MIN (-2147483647L-1)
+# define PTRDIFF_MAX (2147483647L)
+# else
+# define PTRDIFF_MIN (-2147483647-1)
+# define PTRDIFF_MAX (2147483647)
+# endif
+# endif
+
+/* Limits of `sig_atomic_t'. */
+# define SIG_ATOMIC_MIN (-2147483647-1)
+# define SIG_ATOMIC_MAX (2147483647)
+
+/* Limit of `size_t' type. */
+# if __WORDSIZE == 64
+# define SIZE_MAX (18446744073709551615UL)
+# else
+# if __WORDSIZE32_SIZE_ULONG
+# define SIZE_MAX (4294967295UL)
+# else
+# define SIZE_MAX (4294967295U)
+# endif
+# endif
+
+/* Limits of `wchar_t'. */
+# ifndef WCHAR_MIN
+/* These constants might also be defined in <wchar.h>. */
+# define WCHAR_MIN __WCHAR_MIN
+# define WCHAR_MAX __WCHAR_MAX
+# endif
+
+/* Limits of `wint_t'. */
+# define WINT_MIN (0u)
+# define WINT_MAX (4294967295u)
+
+/* Signed. */
+# define INT8_C(c) c
+# define INT16_C(c) c
+# define INT32_C(c) c
+# if __WORDSIZE == 64
+# define INT64_C(c) c ## L
+# else
+# define INT64_C(c) c ## LL
+# endif
+
+/* Unsigned. */
+# define UINT8_C(c) c
+# define UINT16_C(c) c
+# define UINT32_C(c) c ## U
+# if __WORDSIZE == 64
+# define UINT64_C(c) c ## UL
+# else
+# define UINT64_C(c) c ## ULL
+# endif
+
+/* Maximal type. */
+# if __WORDSIZE == 64
+# define INTMAX_C(c) c ## L
+# define UINTMAX_C(c) c ## UL
+# else
+# define INTMAX_C(c) c ## LL
+# define UINTMAX_C(c) c ## ULL
+# endif
+
+#if __GLIBC_USE (IEC_60559_BFP_EXT)
+
+# define INT8_WIDTH 8
+# define UINT8_WIDTH 8
+# define INT16_WIDTH 16
+# define UINT16_WIDTH 16
+# define INT32_WIDTH 32
+# define UINT32_WIDTH 32
+# define INT64_WIDTH 64
+# define UINT64_WIDTH 64
+
+# define INT_LEAST8_WIDTH 8
+# define UINT_LEAST8_WIDTH 8
+# define INT_LEAST16_WIDTH 16
+# define UINT_LEAST16_WIDTH 16
+# define INT_LEAST32_WIDTH 32
+# define UINT_LEAST32_WIDTH 32
+# define INT_LEAST64_WIDTH 64
+# define UINT_LEAST64_WIDTH 64
+
+# define INT_FAST8_WIDTH 8
+# define UINT_FAST8_WIDTH 8
+# define INT_FAST16_WIDTH __WORDSIZE
+# define UINT_FAST16_WIDTH __WORDSIZE
+# define INT_FAST32_WIDTH __WORDSIZE
+# define UINT_FAST32_WIDTH __WORDSIZE
+# define INT_FAST64_WIDTH 64
+# define UINT_FAST64_WIDTH 64
+
+# define INTPTR_WIDTH __WORDSIZE
+# define UINTPTR_WIDTH __WORDSIZE
+
+# define INTMAX_WIDTH 64
+# define UINTMAX_WIDTH 64
+
+# define PTRDIFF_WIDTH __WORDSIZE
+# define SIG_ATOMIC_WIDTH 32
+# define SIZE_WIDTH __WORDSIZE
+# define WCHAR_WIDTH 32
+# define WINT_WIDTH 32
+
+#endif
+
+#endif /* stdint.h */
diff --git a/REORG.TODO/sysdeps/generic/stdio-lock.h b/REORG.TODO/sysdeps/generic/stdio-lock.h
new file mode 100644
index 0000000000..763c7d465a
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/stdio-lock.h
@@ -0,0 +1,71 @@
+/* Thread package specific definitions of stream lock type. Generic version.
+ Copyright (C) 2000-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _STDIO_LOCK_H
+#define _STDIO_LOCK_H 1
+
+#include <libc-lock.h>
+
+__libc_lock_define_recursive (typedef, _IO_lock_t)
+#define _IO_lock_t_defined 1
+
+/* We need recursive (counting) mutexes. */
+#ifdef _LIBC_LOCK_RECURSIVE_INITIALIZER
+# define _IO_lock_initializer _LIBC_LOCK_RECURSIVE_INITIALIZER
+#elif _IO_MTSAFE_IO
+ #error libio needs recursive mutexes for _IO_MTSAFE_IO
+#endif
+
+#define _IO_lock_init(_name) __libc_lock_init_recursive (_name)
+#define _IO_lock_fini(_name) __libc_lock_fini_recursive (_name)
+#define _IO_lock_lock(_name) __libc_lock_lock_recursive (_name)
+#define _IO_lock_trylock(_name) __libc_lock_trylock_recursive (_name)
+#define _IO_lock_unlock(_name) __libc_lock_unlock_recursive (_name)
+
+
+#define _IO_cleanup_region_start(_fct, _fp) \
+ __libc_cleanup_region_start (((_fp)->_flags & _IO_USER_LOCK) == 0, _fct, _fp)
+#define _IO_cleanup_region_start_noarg(_fct) \
+ __libc_cleanup_region_start (1, _fct, NULL)
+#define _IO_cleanup_region_end(_doit) \
+ __libc_cleanup_region_end (_doit)
+
+#if defined _LIBC && IS_IN (libc)
+
+# ifdef __EXCEPTIONS
+# define _IO_acquire_lock(_fp) \
+ do { \
+ _IO_FILE *_IO_acquire_lock_file \
+ __attribute__((cleanup (_IO_acquire_lock_fct))) \
+ = (_fp); \
+ _IO_flockfile (_IO_acquire_lock_file);
+# define _IO_acquire_lock_clear_flags2(_fp) \
+ do { \
+ _IO_FILE *_IO_acquire_lock_file \
+ __attribute__((cleanup (_IO_acquire_lock_clear_flags2_fct))) \
+ = (_fp); \
+ _IO_flockfile (_IO_acquire_lock_file);
+# else
+# define _IO_acquire_lock(_fp) _IO_acquire_lock_needs_exceptions_enabled
+# define _IO_acquire_lock_clear_flags2(_fp) _IO_acquire_lock (_fp)
+# endif
+# define _IO_release_lock(_fp) ; } while (0)
+
+#endif
+
+#endif /* stdio-lock.h */
diff --git a/REORG.TODO/sysdeps/generic/string_private.h b/REORG.TODO/sysdeps/generic/string_private.h
new file mode 100644
index 0000000000..e117a590f1
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/string_private.h
@@ -0,0 +1,21 @@
+/* Define _STRING_ARCH_unaligned. Generic version.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Define to 1 if architecture can access unaligned multi-byte
+ variables. */
+#define _STRING_ARCH_unaligned 0
diff --git a/REORG.TODO/sysdeps/generic/symbol-hacks.h b/REORG.TODO/sysdeps/generic/symbol-hacks.h
new file mode 100644
index 0000000000..d614c099c9
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/symbol-hacks.h
@@ -0,0 +1,19 @@
+/* Some compiler optimizations may transform loops into memset/memmove
+ calls and without proper declaration it may generate PLT calls. */
+#if !defined __ASSEMBLER__ && IS_IN (libc) && defined SHARED
+asm ("memmove = __GI_memmove");
+asm ("memset = __GI_memset");
+asm ("memcpy = __GI_memcpy");
+
+/* Some targets do not use __stack_chk_fail_local. In libc.so,
+ redirect __stack_chk_fail to a hidden reference
+ __stack_chk_fail_local, to avoid the PLT reference.
+ __stack_chk_fail itself is a global symbol, exported from libc.so,
+ and cannot be made hidden. */
+
+# if IS_IN (libc) && defined SHARED && \
+ defined STACK_PROTECTOR_LEVEL && STACK_PROTECTOR_LEVEL > 0
+asm (".hidden __stack_chk_fail_local\n"
+ "__stack_chk_fail = __stack_chk_fail_local");
+# endif
+#endif
diff --git a/REORG.TODO/sysdeps/generic/sys/ptrace.h b/REORG.TODO/sysdeps/generic/sys/ptrace.h
new file mode 100644
index 0000000000..2b5ce4d74d
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sys/ptrace.h
@@ -0,0 +1,137 @@
+/* `ptrace' debugger support interface. Generic version; constants are common.
+ Copyright (C) 1991-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _PTRACE_H
+
+#define _PTRACE_H 1
+#include <features.h>
+
+__BEGIN_DECLS
+
+
+/* Type of the REQUEST argument to `ptrace.' */
+enum __ptrace_request
+{
+ /* Indicate that the process making this request should be traced.
+ All signals received by this process can be intercepted by its
+ parent, and its parent can use the other `ptrace' requests. */
+ PTRACE_TRACEME = 0,
+#define PT_TRACE_ME PTRACE_TRACEME
+
+ /* Return the word in the process's text space at address ADDR. */
+ PTRACE_PEEKTEXT,
+#define PT_READ_I PTRACE_PEEKTEXT
+
+ /* Return the word in the process's data space at address ADDR. */
+ PTRACE_PEEKDATA,
+#define PT_READ_D PTRACE_PEEKDATA
+
+ /* Return the word in the process's user area at offset ADDR. */
+ PTRACE_PEEKUSER,
+#define PT_READ_U PTRACE_PEEKUSER
+
+ /* Write the word DATA into the process's text space at address ADDR. */
+ PTRACE_POKETEXT,
+#define PT_WRITE_I PTRACE_POKETEXT
+
+ /* Write the word DATA into the process's data space at address ADDR. */
+ PTRACE_POKEDATA,
+#define PT_WRITE_D PTRACE_POKEDATA
+
+ /* Write the word DATA into the process's user space at offset ADDR. */
+ PTRACE_POKEUSER,
+#define PT_WRITE_U PTRACE_POKEUSER
+
+ /* Continue the process. */
+ PTRACE_CONT,
+#define PT_CONTINUE PTRACE_CONT
+
+ /* Kill the process. */
+ PTRACE_KILL,
+#define PT_KILL PTRACE_KILL
+
+ /* Single step the process.
+ This is not supported on all machines. */
+ PTRACE_SINGLESTEP,
+#define PT_STEP PTRACE_SINGLESTEP
+
+ /* Attach to a process that is already running. */
+ PTRACE_ATTACH,
+#define PT_ATTACH PTRACE_ATTACH
+
+ /* Detach from a process attached to with PTRACE_ATTACH. */
+ PTRACE_DETACH,
+#define PT_DETACH PTRACE_DETACH
+
+ /* Get the process's registers (not including floating-point registers)
+ and put them in the `struct regs' (see <machine/regs.h>) at ADDR. */
+ PTRACE_GETREGS = 12,
+
+ /* Set the process's registers (not including floating-point registers)
+ to the contents of the `struct regs' (see <machine/regs.h>) at ADDR. */
+ PTRACE_SETREGS,
+
+ /* Get the process's floating point registers and put them
+ in the `struct fp_status' (see <machine/regs.h>) at ADDR. */
+ PTRACE_GETFPREGS = 14,
+
+ /* Set the process's floating point registers to the contents
+ of the `struct fp_status' (see <machine/regs.h>) at ADDR. */
+ PTRACE_SETFPREGS,
+
+ /* Read DATA bytes from the process's data space at address ADDR.
+ Put the result starting at address ADDR2 in the caller's
+ address space. */
+ PTRACE_READDATA = 16,
+
+ /* Write DATA bytes from ADDR2 in the caller's address space into
+ the process's data space at address ADDR. */
+ PTRACE_WRITEDATA,
+
+ /* Read DATA bytes from the process's text space at address ADDR.
+ Put the result starting at address ADDR2 in the caller's
+ address space. */
+ PTRACE_READTEXT = 18,
+
+ /* Write DATA bytes from ADDR2 in the caller's address space into
+ the process's text space at address ADDR. */
+ PTRACE_WRITETEXT,
+
+ /* Read the floating-point accelerator unit registers and
+ put them into the `struct fpa_regs' (see <machine/regs.h>) at ADDR. */
+ PTRACE_GETFPAREGS = 20,
+
+ /* Write the floating-point accelerator unit registers from
+ the contents of the `struct fpa_regs' at ADDR. */
+ PTRACE_SETFPAREGS
+};
+
+/* Perform process tracing functions. REQUEST is one of the values
+ above, and determines the action to be taken.
+ For all requests except PTRACE_TRACEME, PID specifies the process to be
+ traced.
+
+ PID and the other arguments described above for the various requests should
+ appear (those that are used for the particular request) as:
+ pid_t PID, void *ADDR, int DATA, void *ADDR2
+ after REQUEST. */
+extern int ptrace (enum __ptrace_request __request, ...);
+
+__END_DECLS
+
+#endif /* ptrace.h */
diff --git a/REORG.TODO/sysdeps/generic/sys/reboot.h b/REORG.TODO/sysdeps/generic/sys/reboot.h
new file mode 100644
index 0000000000..bada28dd6c
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sys/reboot.h
@@ -0,0 +1,9 @@
+/* This file should define RB_* macros to be used as flag
+ bits in the argument to the `reboot' system call. */
+
+#ifndef _SYS_REBOOT_H
+#define _SYS_REBOOT_H
+
+#define RB_AUTOBOOT 0
+
+#endif /* <sys/reboot.h> */
diff --git a/REORG.TODO/sysdeps/generic/sys/socketvar.h b/REORG.TODO/sysdeps/generic/sys/socketvar.h
new file mode 100644
index 0000000000..b177158d0b
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sys/socketvar.h
@@ -0,0 +1,3 @@
+/* This header is used on many systems but for GNU we have everything
+ already defined in the standard header. */
+#include <sys/socket.h>
diff --git a/REORG.TODO/sysdeps/generic/sys/swap.h b/REORG.TODO/sysdeps/generic/sys/swap.h
new file mode 100644
index 0000000000..f86df4a607
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sys/swap.h
@@ -0,0 +1,32 @@
+/* Calls to enable and disable swapping on specified locations. Unix version.
+ Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef __SYS_SWAP_H
+
+#define __SYS_SWAP_H 1
+#include <features.h>
+
+
+/* Make the block special device PATH available to the system for swapping.
+ This call is restricted to the super-user. */
+extern int swapon (const char *__path, int __flags) __THROW;
+
+/* Stop using block special device PATH for swapping. */
+extern int swapoff (const char *__path) __THROW;
+
+#endif /* sys/swap.h */
diff --git a/REORG.TODO/sysdeps/generic/sys/syscall.h b/REORG.TODO/sysdeps/generic/sys/syscall.h
new file mode 100644
index 0000000000..719bd08904
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sys/syscall.h
@@ -0,0 +1,2 @@
+/* For Unix-like systems, this file should contain definitions
+ of macros SYS_call for each system call, giving the call numbers. */
diff --git a/REORG.TODO/sysdeps/generic/sys/sysinfo.h b/REORG.TODO/sysdeps/generic/sys/sysinfo.h
new file mode 100644
index 0000000000..279493de7e
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sys/sysinfo.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_SYSINFO_H
+#define _SYS_SYSINFO_H 1
+
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* Return number of configured processors. */
+extern int get_nprocs_conf (void) __THROW;
+
+/* Return number of available processors. */
+extern int get_nprocs (void) __THROW;
+
+
+/* Return number of physical pages of memory in the system. */
+extern long int get_phys_pages (void) __THROW;
+
+/* Return number of available physical pages of memory in the system. */
+extern long int get_avphys_pages (void) __THROW;
+
+__END_DECLS
+
+#endif /* sys/sysinfo.h */
diff --git a/REORG.TODO/sysdeps/generic/sys/ttydefaults.h b/REORG.TODO/sysdeps/generic/sys/ttydefaults.h
new file mode 100644
index 0000000000..683dc8d805
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sys/ttydefaults.h
@@ -0,0 +1,100 @@
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94
+ */
+
+/*
+ * System wide defaults for terminal state. 4.4 BSD/generic GNU version.
+ */
+#ifndef _SYS_TTYDEFAULTS_H_
+#define _SYS_TTYDEFAULTS_H_
+
+/*
+ * Defaults on "first" open.
+ */
+#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
+#define TTYDEF_OFLAG (OPOST | ONLCR | OXTABS)
+#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
+#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL)
+#define TTYDEF_SPEED (B9600)
+
+/*
+ * Control Character Defaults
+ */
+#define CTRL(x) (x&037)
+#define CEOF CTRL('d')
+#ifdef _POSIX_VDISABLE
+# define CEOL _POSIX_VDISABLE
+#else
+# define CEOL ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */
+#endif
+#define CERASE 0177
+#define CINTR CTRL('c')
+#ifdef _POSIX_VDISABLE
+# define CSTATUS _POSIX_VDISABLE
+#else
+# define CSTATUS ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */
+#endif
+#define CKILL CTRL('u')
+#define CMIN 1
+#define CQUIT 034 /* FS, ^\ */
+#define CSUSP CTRL('z')
+#define CTIME 0
+#define CDSUSP CTRL('y')
+#define CSTART CTRL('q')
+#define CSTOP CTRL('s')
+#define CLNEXT CTRL('v')
+#define CDISCARD CTRL('o')
+#define CWERASE CTRL('w')
+#define CREPRINT CTRL('r')
+#define CEOT CEOF
+/* compat */
+#define CBRK CEOL
+#define CRPRNT CREPRINT
+#define CFLUSH CDISCARD
+
+/* PROTECTED INCLUSION ENDS HERE */
+#endif /* !_SYS_TTYDEFAULTS_H_ */
+
+/*
+ * #define TTYDEFCHARS to include an array of default control characters.
+ */
+#ifdef TTYDEFCHARS
+cc_t ttydefchars[NCCS] = {
+ CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT,
+ _POSIX_VDISABLE, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT,
+ CDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE
+};
+#undef TTYDEFCHARS
+#endif
diff --git a/REORG.TODO/sysdeps/generic/sys/ucontext.h b/REORG.TODO/sysdeps/generic/sys/ucontext.h
new file mode 100644
index 0000000000..a64460c9ae
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sys/ucontext.h
@@ -0,0 +1,44 @@
+/* Data structures for user-level context switching. Generic version.
+ Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This file's definitions suffice for any platform where all
+ the machine-specific state is described in `struct sigcontext'. */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+
+#include <bits/types/sigset_t.h>
+#include <bits/sigcontext.h>
+#include <bits/types/stack_t.h>
+
+
+typedef struct sigcontext mcontext_t;
+
+/* Userlevel context. */
+typedef struct ucontext
+ {
+ unsigned long int uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ sigset_t uc_sigmask;
+ } ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/REORG.TODO/sysdeps/generic/sysdep-cancel.h b/REORG.TODO/sysdeps/generic/sysdep-cancel.h
new file mode 100644
index 0000000000..ba6a1e04ba
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sysdep-cancel.h
@@ -0,0 +1,8 @@
+#include <sysdep.h>
+
+/* No multi-thread handling enabled. */
+#define SINGLE_THREAD_P (1)
+#define RTLD_SINGLE_THREAD_P (1)
+#define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */
+#define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */
+#define LIBC_CANCEL_HANDLED() /* Nothing. */
diff --git a/REORG.TODO/sysdeps/generic/sysdep.h b/REORG.TODO/sysdeps/generic/sysdep.h
new file mode 100644
index 0000000000..dfb34e3a3f
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/sysdep.h
@@ -0,0 +1,97 @@
+/* Generic asm macros used on many machines.
+ Copyright (C) 1991-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef C_LABEL
+
+/* Define a macro we can use to construct the asm name for a C symbol. */
+# define C_LABEL(name) name##:
+
+#endif
+
+#ifdef __ASSEMBLER__
+/* Mark the end of function named SYM. This is used on some platforms
+ to generate correct debugging information. */
+# ifndef END
+# define END(sym)
+# endif
+
+# ifndef JUMPTARGET
+# define JUMPTARGET(sym) sym
+# endif
+#endif
+
+/* Makros to generate eh_frame unwind information. */
+#ifdef __ASSEMBLER__
+# define cfi_startproc .cfi_startproc
+# define cfi_endproc .cfi_endproc
+# define cfi_def_cfa(reg, off) .cfi_def_cfa reg, off
+# define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg
+# define cfi_def_cfa_offset(off) .cfi_def_cfa_offset off
+# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
+# define cfi_offset(reg, off) .cfi_offset reg, off
+# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
+# define cfi_register(r1, r2) .cfi_register r1, r2
+# define cfi_return_column(reg) .cfi_return_column reg
+# define cfi_restore(reg) .cfi_restore reg
+# define cfi_same_value(reg) .cfi_same_value reg
+# define cfi_undefined(reg) .cfi_undefined reg
+# define cfi_remember_state .cfi_remember_state
+# define cfi_restore_state .cfi_restore_state
+# define cfi_window_save .cfi_window_save
+# define cfi_personality(enc, exp) .cfi_personality enc, exp
+# define cfi_lsda(enc, exp) .cfi_lsda enc, exp
+
+#else /* ! ASSEMBLER */
+
+# define CFI_STRINGIFY(Name) CFI_STRINGIFY2 (Name)
+# define CFI_STRINGIFY2(Name) #Name
+# define CFI_STARTPROC ".cfi_startproc"
+# define CFI_ENDPROC ".cfi_endproc"
+# define CFI_DEF_CFA(reg, off) \
+ ".cfi_def_cfa " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
+# define CFI_DEF_CFA_REGISTER(reg) \
+ ".cfi_def_cfa_register " CFI_STRINGIFY(reg)
+# define CFI_DEF_CFA_OFFSET(off) \
+ ".cfi_def_cfa_offset " CFI_STRINGIFY(off)
+# define CFI_ADJUST_CFA_OFFSET(off) \
+ ".cfi_adjust_cfa_offset " CFI_STRINGIFY(off)
+# define CFI_OFFSET(reg, off) \
+ ".cfi_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
+# define CFI_REL_OFFSET(reg, off) \
+ ".cfi_rel_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
+# define CFI_REGISTER(r1, r2) \
+ ".cfi_register " CFI_STRINGIFY(r1) "," CFI_STRINGIFY(r2)
+# define CFI_RETURN_COLUMN(reg) \
+ ".cfi_return_column " CFI_STRINGIFY(reg)
+# define CFI_RESTORE(reg) \
+ ".cfi_restore " CFI_STRINGIFY(reg)
+# define CFI_UNDEFINED(reg) \
+ ".cfi_undefined " CFI_STRINGIFY(reg)
+# define CFI_REMEMBER_STATE \
+ ".cfi_remember_state"
+# define CFI_RESTORE_STATE \
+ ".cfi_restore_state"
+# define CFI_WINDOW_SAVE \
+ ".cfi_window_save"
+# define CFI_PERSONALITY(enc, exp) \
+ ".cfi_personality " CFI_STRINGIFY(enc) "," CFI_STRINGIFY(exp)
+# define CFI_LSDA(enc, exp) \
+ ".cfi_lsda " CFI_STRINGIFY(enc) "," CFI_STRINGIFY(exp)
+#endif
+
+#include "dwarf2.h"
diff --git a/REORG.TODO/sysdeps/generic/thread_state.h b/REORG.TODO/sysdeps/generic/thread_state.h
new file mode 100644
index 0000000000..ca579ee493
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/thread_state.h
@@ -0,0 +1,46 @@
+/* Mach thread state definitions for machine-independent code. Stub version.
+ Copyright (C) 1994-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Everything else is called `thread_state', but CMU's header file is
+ called `thread_status'. Oh boy. */
+#include <mach/thread_state.h>
+
+/* Replace <machine> with "i386" or "mips" or whatever. */
+
+#define MACHINE_THREAD_STATE_FLAVOR <machine>_THREAD_STATE
+#define MACHINE_THREAD_STATE_COUNT <machine>_THREAD_STATE_COUNT
+
+#define machine_thread_state <machine>_thread_state
+
+/* Define these to the member names in `struct <machine>_thread_state'
+ for the PC and stack pointer. */
+#define PC ?
+#define SP ?
+
+/* This structure should contain all of the different flavors of thread
+ state structures which are meaningful for this machine. Every machine's
+ definition of this structure should have a member `int set' which is a
+ bit mask (1 << FLAVOR) of the flavors of thread state in the structure
+ which are filled in; and a member `struct machine_thread_state basic'.
+ On some machines those are the only members (e.g. i386); on others,
+ there are several relevant flavors of thread state (e.g. mips). */
+struct machine_thread_all_state
+ {
+ int set; /* Mask of bits (1 << FLAVOR). */
+ struct <machine>_thread_state basic;
+ };
diff --git a/REORG.TODO/sysdeps/generic/tininess.h b/REORG.TODO/sysdeps/generic/tininess.h
new file mode 100644
index 0000000000..bafdaacd15
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/tininess.h
@@ -0,0 +1,33 @@
+/* Specify architecture-specific rules for determining tininess of
+ floating-point results. Generic version.
+ Copyright (C) 2012-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _TININESS_H
+#define _TININESS_H 1
+
+/* Under IEEE 754, an architecture may determine tininess of
+ floating-point results either "before rounding" or "after
+ rounding", but must do so in the same way for all operations
+ returning binary results. Define TININESS_AFTER_ROUNDING to 1 for
+ "after rounding" architectures, 0 for "before rounding"
+ architectures. The test stdlib/tst-tininess will fail if the
+ definition is incorrect. */
+
+#define TININESS_AFTER_ROUNDING 0
+
+#endif /* tininess.h */
diff --git a/REORG.TODO/sysdeps/generic/tls-macros.h b/REORG.TODO/sysdeps/generic/tls-macros.h
new file mode 100644
index 0000000000..0a08f7c145
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/tls-macros.h
@@ -0,0 +1,12 @@
+/* Macros to support TLS testing in times of missing compiler support.
+ Stub version.
+
+ These macros should yield int * expressions for the TLS symbol X
+ accessed using the various TLS access models. Macros for some machines
+ are defined in elf/tls-macros.h, but ports can instead provide this file.
+
+#define TLS_LE(x)
+#define TLS_IE(x)
+#define TLS_LD(x)
+#define TLS_GD(x)
+*/
diff --git a/REORG.TODO/sysdeps/generic/tls.h b/REORG.TODO/sysdeps/generic/tls.h
new file mode 100644
index 0000000000..90c5c792ff
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/tls.h
@@ -0,0 +1,74 @@
+/* Definition for thread-local data handling. Generic version.
+ Copyright (C) 2002-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* An architecture-specific version of this file has to defined a
+ number of symbols:
+
+ TLS_TCB_AT_TP or TLS_DTV_AT_TP
+
+ The presence of one of these symbols signals which variant of
+ the TLS ABI is used. There are in the moment two variants
+ available:
+
+ * the thread pointer points to a thread control block
+
+ * the thread pointer points to the dynamic thread vector
+
+
+ TLS_TCB_SIZE
+
+ This is the size of the thread control block structure. How
+ this is actually defined depends on the ABI. The thread control
+ block could be internal descriptor of the thread library or
+ just a data structure which allows finding the DTV.
+
+ TLS_INIT_TCB_SIZE
+
+ Similarly, but this value is only used at startup and in the
+ dynamic linker itself. There are no threads in use at that time.
+
+
+ TLS_TCB_ALIGN
+
+ Alignment requirements for the TCB structure.
+
+ TLS_INIT_TCB_ALIGN
+
+ Similarly, but for the structure used at startup time.
+
+
+ INSTALL_DTV(tcb, init_dtv)
+
+ This macro must install the given initial DTV into the thread control
+ block TCB. The normal runtime functionality must then be able to
+ use the value.
+
+
+ TLS_INIT_TP(tcb)
+
+ This macro must initialize the thread pointer to enable normal TLS
+ operation. The parameter is a pointer to the thread control block.
+ ld.so calls this macro once.
+
+
+ THREAD_DTV()
+
+ This macro returns the address of the DTV of the current thread.
+ This normally is done using the thread register which points
+ to the dtv or the TCB (from which the DTV can found).
+ */
diff --git a/REORG.TODO/sysdeps/generic/tst-audit.h b/REORG.TODO/sysdeps/generic/tst-audit.h
new file mode 100644
index 0000000000..45bc6039b2
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/tst-audit.h
@@ -0,0 +1,11 @@
+/* Machines can supply a tst-audit.h to define these macros used in
+ elf/tst-auditmod1.c.
+
+
+# define pltenter la_CPU_gnu_pltenter
+# define pltexit la_CPU_gnu_pltexit
+# define La_regs La_CPU_regs
+# define La_retval La_CPU_retval
+# define int_retval lrv_RETVALREG
+
+*/
diff --git a/REORG.TODO/sysdeps/generic/tst-stack-align.h b/REORG.TODO/sysdeps/generic/tst-stack-align.h
new file mode 100644
index 0000000000..2433b8beaf
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/tst-stack-align.h
@@ -0,0 +1,34 @@
+/* Copyright (C) 2003-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdint.h>
+
+#define TEST_STACK_ALIGN() \
+ ({ \
+ double _d = 12.0; \
+ long double _ld = 15.0; \
+ int _ret = 0; \
+ printf ("double: %g %p %zu\n", _d, &_d, __alignof (double)); \
+ if ((((uintptr_t) &_d) & (__alignof (double) - 1)) != 0) \
+ _ret = 1; \
+ \
+ printf ("ldouble: %Lg %p %zu\n", _ld, &_ld, __alignof (long double)); \
+ if ((((uintptr_t) &_ld) & (__alignof (long double) - 1)) != 0) \
+ _ret = 1; \
+ _ret; \
+ })
diff --git a/REORG.TODO/sysdeps/generic/unsecvars.h b/REORG.TODO/sysdeps/generic/unsecvars.h
new file mode 100644
index 0000000000..5ea8a4a259
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/unsecvars.h
@@ -0,0 +1,34 @@
+#if !HAVE_TUNABLES
+# define GLIBC_TUNABLES_ENVVAR "GLIBC_TUNABLES\0"
+#else
+# define GLIBC_TUNABLES_ENVVAR
+#endif
+
+/* Environment variable to be removed for SUID programs. The names are
+ all stuffed in a single string which means they have to be terminated
+ with a '\0' explicitly. */
+#define UNSECURE_ENVVARS \
+ "GCONV_PATH\0" \
+ "GETCONF_DIR\0" \
+ GLIBC_TUNABLES_ENVVAR \
+ "HOSTALIASES\0" \
+ "LD_AUDIT\0" \
+ "LD_DEBUG\0" \
+ "LD_DEBUG_OUTPUT\0" \
+ "LD_DYNAMIC_WEAK\0" \
+ "LD_HWCAP_MASK\0" \
+ "LD_LIBRARY_PATH\0" \
+ "LD_ORIGIN_PATH\0" \
+ "LD_PRELOAD\0" \
+ "LD_PROFILE\0" \
+ "LD_SHOW_AUXV\0" \
+ "LD_USE_LOAD_BIAS\0" \
+ "LOCALDOMAIN\0" \
+ "LOCPATH\0" \
+ "MALLOC_TRACE\0" \
+ "NIS_PATH\0" \
+ "NLSPATH\0" \
+ "RESOLV_HOST_CONF\0" \
+ "RES_OPTIONS\0" \
+ "TMPDIR\0" \
+ "TZDIR\0"
diff --git a/REORG.TODO/sysdeps/generic/unwind-dw2-fde-glibc.c b/REORG.TODO/sysdeps/generic/unwind-dw2-fde-glibc.c
new file mode 100644
index 0000000000..9d698d575b
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/unwind-dw2-fde-glibc.c
@@ -0,0 +1,279 @@
+/* Copyright (C) 2001-2017 Free Software Foundation, Inc.
+ Contributed by Jakub Jelinek <jakub@redhat.com>.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Locate the FDE entry for a given address, using PT_GNU_EH_FRAME ELF
+ segment and dl_iterate_phdr to avoid register/deregister calls at
+ DSO load/unload. */
+
+#ifdef _LIBC
+# include <shlib-compat.h>
+#endif
+
+#if !defined _LIBC || SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2_5)
+
+#include <link.h>
+#include <stddef.h>
+
+#define _Unwind_Find_FDE _Unwind_Find_registered_FDE
+
+#include <unwind-dw2-fde.c>
+
+#undef _Unwind_Find_FDE
+
+extern fde * _Unwind_Find_registered_FDE (void *pc,
+ struct dwarf_eh_bases *bases);
+extern fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);
+
+struct unw_eh_callback_data
+{
+ _Unwind_Ptr pc;
+ void *tbase;
+ void *dbase;
+ void *func;
+ fde *ret;
+};
+
+struct unw_eh_frame_hdr
+{
+ unsigned char version;
+ unsigned char eh_frame_ptr_enc;
+ unsigned char fde_count_enc;
+ unsigned char table_enc;
+};
+
+/* Like base_of_encoded_value, but take the base from a struct object
+ instead of an _Unwind_Context. */
+
+static _Unwind_Ptr
+base_from_cb_data (unsigned char encoding, struct unw_eh_callback_data *data)
+{
+ if (encoding == DW_EH_PE_omit)
+ return 0;
+
+ switch (encoding & 0x70)
+ {
+ case DW_EH_PE_absptr:
+ case DW_EH_PE_pcrel:
+ case DW_EH_PE_aligned:
+ return 0;
+
+ case DW_EH_PE_textrel:
+ return (_Unwind_Ptr) data->tbase;
+ case DW_EH_PE_datarel:
+ return (_Unwind_Ptr) data->dbase;
+ }
+ abort ();
+}
+
+static int
+_Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr)
+{
+ struct unw_eh_callback_data *data = (struct unw_eh_callback_data *) ptr;
+ const ElfW(Phdr) *phdr, *p_eh_frame_hdr;
+ const ElfW(Phdr) *p_dynamic __attribute__ ((unused));
+ long n, match;
+ _Unwind_Ptr load_base;
+ const unsigned char *p;
+ const struct unw_eh_frame_hdr *hdr;
+ _Unwind_Ptr eh_frame;
+ struct object ob;
+
+ /* Make sure struct dl_phdr_info is at least as big as we need. */
+ if (size < offsetof (struct dl_phdr_info, dlpi_phnum)
+ + sizeof (info->dlpi_phnum))
+ return -1;
+
+ match = 0;
+ phdr = info->dlpi_phdr;
+ load_base = info->dlpi_addr;
+ p_eh_frame_hdr = NULL;
+ p_dynamic = NULL;
+
+ /* See if PC falls into one of the loaded segments. Find the eh_frame
+ segment at the same time. */
+ for (n = info->dlpi_phnum; --n >= 0; phdr++)
+ {
+ if (phdr->p_type == PT_LOAD)
+ {
+ _Unwind_Ptr vaddr = phdr->p_vaddr + load_base;
+ if (data->pc >= vaddr && data->pc < vaddr + phdr->p_memsz)
+ match = 1;
+ }
+ else if (phdr->p_type == PT_GNU_EH_FRAME)
+ p_eh_frame_hdr = phdr;
+ else if (phdr->p_type == PT_DYNAMIC)
+ p_dynamic = phdr;
+ }
+ if (!match || !p_eh_frame_hdr)
+ return 0;
+
+ /* Read .eh_frame_hdr header. */
+ hdr = (const struct unw_eh_frame_hdr *)
+ (p_eh_frame_hdr->p_vaddr + load_base);
+ if (hdr->version != 1)
+ return 1;
+
+#ifdef CRT_GET_RFIB_DATA
+# ifdef __i386__
+ data->dbase = NULL;
+ if (p_dynamic)
+ {
+ /* For dynamicly linked executables and shared libraries,
+ DT_PLTGOT is the gp value for that object. */
+ ElfW(Dyn) *dyn = (ElfW(Dyn) *)(p_dynamic->p_vaddr + load_base);
+ for (; dyn->d_tag != DT_NULL ; dyn++)
+ if (dyn->d_tag == DT_PLTGOT)
+ {
+ /* On IA-32, _DYNAMIC is writable and GLIBC has relocated it. */
+ data->dbase = (void *) dyn->d_un.d_ptr;
+ break;
+ }
+ }
+# else
+# error What is DW_EH_PE_datarel base on this platform?
+# endif
+#endif
+#ifdef CRT_GET_RFIB_TEXT
+# error What is DW_EH_PE_textrel base on this platform?
+#endif
+
+ p = read_encoded_value_with_base (hdr->eh_frame_ptr_enc,
+ base_from_cb_data (hdr->eh_frame_ptr_enc,
+ data),
+ (const unsigned char *) (hdr + 1),
+ &eh_frame);
+
+ /* We require here specific table encoding to speed things up.
+ Also, DW_EH_PE_datarel here means using PT_GNU_EH_FRAME start
+ as base, not the processor specific DW_EH_PE_datarel. */
+ if (hdr->fde_count_enc != DW_EH_PE_omit
+ && hdr->table_enc == (DW_EH_PE_datarel | DW_EH_PE_sdata4))
+ {
+ _Unwind_Ptr fde_count;
+
+ p = read_encoded_value_with_base (hdr->fde_count_enc,
+ base_from_cb_data (hdr->fde_count_enc,
+ data),
+ p, &fde_count);
+ /* Shouldn't happen. */
+ if (fde_count == 0)
+ return 1;
+ if ((((_Unwind_Ptr) p) & 3) == 0)
+ {
+ struct fde_table {
+ signed initial_loc __attribute__ ((mode (SI)));
+ signed fde __attribute__ ((mode (SI)));
+ };
+ const struct fde_table *table = (const struct fde_table *) p;
+ size_t lo, hi, mid;
+ _Unwind_Ptr data_base = (_Unwind_Ptr) hdr;
+ fde *f;
+ unsigned int f_enc, f_enc_size;
+ _Unwind_Ptr range;
+
+ mid = fde_count - 1;
+ if (data->pc < table[0].initial_loc + data_base)
+ return 1;
+ else if (data->pc < table[mid].initial_loc + data_base)
+ {
+ lo = 0;
+ hi = mid;
+
+ while (lo < hi)
+ {
+ mid = (lo + hi) / 2;
+ if (data->pc < table[mid].initial_loc + data_base)
+ hi = mid;
+ else if (data->pc >= table[mid + 1].initial_loc + data_base)
+ lo = mid + 1;
+ else
+ break;
+ }
+
+ if (lo >= hi)
+ __gxx_abort ();
+ }
+
+ f = (fde *) (table[mid].fde + data_base);
+ f_enc = get_fde_encoding (f);
+ f_enc_size = size_of_encoded_value (f_enc);
+ read_encoded_value_with_base (f_enc & 0x0f, 0,
+ &f->pc_begin[f_enc_size], &range);
+ if (data->pc < table[mid].initial_loc + data_base + range)
+ data->ret = f;
+ data->func = (void *) (table[mid].initial_loc + data_base);
+ return 1;
+ }
+ }
+
+ /* We have no sorted search table, so need to go the slow way.
+ As soon as GLIBC will provide API so to notify that a library has been
+ removed, we could cache this (and thus use search_object). */
+ ob.pc_begin = NULL;
+ ob.tbase = data->tbase;
+ ob.dbase = data->dbase;
+ ob.u.single = (fde *) eh_frame;
+ ob.s.i = 0;
+ ob.s.b.mixed_encoding = 1; /* Need to assume worst case. */
+ data->ret = linear_search_fdes (&ob, (fde *) eh_frame, (void *) data->pc);
+ if (data->ret != NULL)
+ {
+ unsigned int encoding = get_fde_encoding (data->ret);
+ _Unwind_Ptr func;
+ read_encoded_value_with_base (encoding,
+ base_from_cb_data (encoding, data),
+ data->ret->pc_begin, &func);
+ data->func = (void *) func;
+ }
+ return 1;
+}
+
+# ifdef _LIBC
+# define dl_iterate_phdr __dl_iterate_phdr
+# endif
+
+fde *
+_Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
+{
+ struct unw_eh_callback_data data;
+ fde *ret;
+
+ ret = _Unwind_Find_registered_FDE (pc, bases);
+ if (ret != NULL)
+ return ret;
+
+ data.pc = (_Unwind_Ptr) pc;
+ data.tbase = NULL;
+ data.dbase = NULL;
+ data.func = NULL;
+ data.ret = NULL;
+
+ if (dl_iterate_phdr (_Unwind_IteratePhdrCallback, &data) < 0)
+ return NULL;
+
+ if (data.ret)
+ {
+ bases->tbase = data.tbase;
+ bases->dbase = data.dbase;
+ bases->func = data.func;
+ }
+ return data.ret;
+}
+
+#endif
diff --git a/REORG.TODO/sysdeps/generic/unwind-dw2-fde.c b/REORG.TODO/sysdeps/generic/unwind-dw2-fde.c
new file mode 100644
index 0000000000..104a2552b4
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/unwind-dw2-fde.c
@@ -0,0 +1,1079 @@
+/* Subroutines needed for unwinding stack frames for exception handling. */
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ Contributed by Jason Merrill <jason@cygnus.com>.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef _LIBC
+# include <shlib-compat.h>
+#endif
+
+#if !defined _LIBC || SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2_5)
+
+#ifdef _LIBC
+#include <stdlib.h>
+#include <string.h>
+#include <libc-lock.h>
+#include <dwarf2.h>
+#include <unwind.h>
+#define NO_BASE_OF_ENCODED_VALUE
+#include <unwind-pe.h>
+#include <unwind-dw2-fde.h>
+#else
+#ifndef _Unwind_Find_FDE
+#include "tconfig.h"
+#include "tsystem.h"
+#include "dwarf2.h"
+#include "unwind.h"
+#define NO_BASE_OF_ENCODED_VALUE
+#include "unwind-pe.h"
+#include "unwind-dw2-fde.h"
+#include "gthr.h"
+#endif
+#endif
+
+/* The unseen_objects list contains objects that have been registered
+ but not yet categorized in any way. The seen_objects list has had
+ it's pc_begin and count fields initialized at minimum, and is sorted
+ by decreasing value of pc_begin. */
+static struct object *unseen_objects;
+static struct object *seen_objects;
+
+#ifdef _LIBC
+
+__libc_lock_define_initialized (static, object_mutex)
+#define init_object_mutex_once()
+#define __gthread_mutex_lock(m) __libc_lock_lock (*(m))
+#define __gthread_mutex_unlock(m) __libc_lock_unlock (*(m))
+
+void __register_frame_info_bases (void *begin, struct object *ob,
+ void *tbase, void *dbase);
+hidden_proto (__register_frame_info_bases)
+void __register_frame_info_table_bases (void *begin,
+ struct object *ob,
+ void *tbase, void *dbase);
+hidden_proto (__register_frame_info_table_bases)
+void *__deregister_frame_info_bases (void *begin);
+hidden_proto (__deregister_frame_info_bases)
+
+#else
+
+#ifdef __GTHREAD_MUTEX_INIT
+static __gthread_mutex_t object_mutex = __GTHREAD_MUTEX_INIT;
+#else
+static __gthread_mutex_t object_mutex;
+#endif
+
+#ifdef __GTHREAD_MUTEX_INIT_FUNCTION
+static void
+init_object_mutex (void)
+{
+ __GTHREAD_MUTEX_INIT_FUNCTION (&object_mutex);
+}
+
+static void
+init_object_mutex_once (void)
+{
+ static __gthread_once_t once = __GTHREAD_ONCE_INIT;
+ __gthread_once (&once, init_object_mutex);
+}
+#else
+#define init_object_mutex_once()
+#endif
+
+#endif /* _LIBC */
+
+/* Called from crtbegin.o to register the unwind info for an object. */
+
+void
+__register_frame_info_bases (void *begin, struct object *ob,
+ void *tbase, void *dbase)
+{
+ /* If .eh_frame is empty, don't register at all. */
+ if (*(uword *) begin == 0)
+ return;
+
+ ob->pc_begin = (void *)-1;
+ ob->tbase = tbase;
+ ob->dbase = dbase;
+ ob->u.single = begin;
+ ob->s.i = 0;
+ ob->s.b.encoding = DW_EH_PE_omit;
+#ifdef DWARF2_OBJECT_END_PTR_EXTENSION
+ ob->fde_end = NULL;
+#endif
+
+ init_object_mutex_once ();
+ __gthread_mutex_lock (&object_mutex);
+
+ ob->next = unseen_objects;
+ unseen_objects = ob;
+
+ __gthread_mutex_unlock (&object_mutex);
+}
+hidden_def (__register_frame_info_bases)
+
+void
+__register_frame_info (void *begin, struct object *ob)
+{
+ __register_frame_info_bases (begin, ob, 0, 0);
+}
+
+void
+__register_frame (void *begin)
+{
+ struct object *ob;
+
+ /* If .eh_frame is empty, don't register at all. */
+ if (*(uword *) begin == 0)
+ return;
+
+ ob = (struct object *) malloc (sizeof (struct object));
+ __register_frame_info_bases (begin, ob, 0, 0);
+}
+
+/* Similar, but BEGIN is actually a pointer to a table of unwind entries
+ for different translation units. Called from the file generated by
+ collect2. */
+
+void
+__register_frame_info_table_bases (void *begin, struct object *ob,
+ void *tbase, void *dbase)
+{
+ ob->pc_begin = (void *)-1;
+ ob->tbase = tbase;
+ ob->dbase = dbase;
+ ob->u.array = begin;
+ ob->s.i = 0;
+ ob->s.b.from_array = 1;
+ ob->s.b.encoding = DW_EH_PE_omit;
+
+ init_object_mutex_once ();
+ __gthread_mutex_lock (&object_mutex);
+
+ ob->next = unseen_objects;
+ unseen_objects = ob;
+
+ __gthread_mutex_unlock (&object_mutex);
+}
+hidden_def (__register_frame_info_table_bases)
+
+void
+__register_frame_info_table (void *begin, struct object *ob)
+{
+ __register_frame_info_table_bases (begin, ob, 0, 0);
+}
+
+void
+__register_frame_table (void *begin)
+{
+ struct object *ob = (struct object *) malloc (sizeof (struct object));
+ __register_frame_info_table_bases (begin, ob, 0, 0);
+}
+
+/* Called from crtbegin.o to deregister the unwind info for an object. */
+/* ??? Glibc has for a while now exported __register_frame_info and
+ __deregister_frame_info. If we call __register_frame_info_bases
+ from crtbegin (wherein it is declared weak), and this object does
+ not get pulled from libgcc.a for other reasons, then the
+ invocation of __deregister_frame_info will be resolved from glibc.
+ Since the registration did not happen there, we'll abort.
+
+ Therefore, declare a new deregistration entry point that does the
+ exact same thing, but will resolve to the same library as
+ implements __register_frame_info_bases. */
+
+void *
+__deregister_frame_info_bases (void *begin)
+{
+ struct object **p;
+ struct object *ob = 0;
+ struct fde_vector *tofree = NULL;
+
+ /* If .eh_frame is empty, we haven't registered. */
+ if (*(uword *) begin == 0)
+ return ob;
+
+ init_object_mutex_once ();
+ __gthread_mutex_lock (&object_mutex);
+
+ for (p = &unseen_objects; *p ; p = &(*p)->next)
+ if ((*p)->u.single == begin)
+ {
+ ob = *p;
+ *p = ob->next;
+ goto out;
+ }
+
+ for (p = &seen_objects; *p ; p = &(*p)->next)
+ if ((*p)->s.b.sorted)
+ {
+ if ((*p)->u.sort->orig_data == begin)
+ {
+ ob = *p;
+ *p = ob->next;
+ tofree = ob->u.sort;
+ goto out;
+ }
+ }
+ else
+ {
+ if ((*p)->u.single == begin)
+ {
+ ob = *p;
+ *p = ob->next;
+ goto out;
+ }
+ }
+
+ __gthread_mutex_unlock (&object_mutex);
+ abort ();
+
+ out:
+ __gthread_mutex_unlock (&object_mutex);
+ free (tofree);
+ return (void *) ob;
+}
+hidden_def (__deregister_frame_info_bases)
+
+void *
+__deregister_frame_info (void *begin)
+{
+ return __deregister_frame_info_bases (begin);
+}
+
+void
+__deregister_frame (void *begin)
+{
+ /* If .eh_frame is empty, we haven't registered. */
+ if (*(uword *) begin != 0)
+ free (__deregister_frame_info_bases (begin));
+}
+
+
+/* Like base_of_encoded_value, but take the base from a struct object
+ instead of an _Unwind_Context. */
+
+static _Unwind_Ptr
+base_from_object (unsigned char encoding, struct object *ob)
+{
+ if (encoding == DW_EH_PE_omit)
+ return 0;
+
+ switch (encoding & 0x70)
+ {
+ case DW_EH_PE_absptr:
+ case DW_EH_PE_pcrel:
+ case DW_EH_PE_aligned:
+ return 0;
+
+ case DW_EH_PE_textrel:
+ return (_Unwind_Ptr) ob->tbase;
+ case DW_EH_PE_datarel:
+ return (_Unwind_Ptr) ob->dbase;
+ }
+ abort ();
+}
+
+/* Return the FDE pointer encoding from the CIE. */
+/* ??? This is a subset of extract_cie_info from unwind-dw2.c. */
+
+static int
+get_cie_encoding (struct dwarf_cie *cie)
+{
+ const unsigned char *aug, *p;
+ _Unwind_Ptr dummy;
+ _Unwind_Word utmp;
+ _Unwind_Sword stmp;
+
+ aug = cie->augmentation;
+ if (aug[0] != 'z')
+ return DW_EH_PE_absptr;
+
+ /* Skip the augmentation string. */
+ p = aug + strlen ((const char *) aug) + 1;
+ p = read_uleb128 (p, &utmp); /* Skip code alignment. */
+ p = read_sleb128 (p, &stmp); /* Skip data alignment. */
+ p++; /* Skip return address column. */
+
+ aug++; /* Skip 'z' */
+ p = read_uleb128 (p, &utmp); /* Skip augmentation length. */
+ while (1)
+ {
+ /* This is what we're looking for. */
+ if (*aug == 'R')
+ return *p;
+ /* Personality encoding and pointer. */
+ else if (*aug == 'P')
+ {
+ /* ??? Avoid dereferencing indirect pointers, since we're
+ faking the base address. Gotta keep DW_EH_PE_aligned
+ intact, however. */
+ p = read_encoded_value_with_base (*p & 0x7F, 0, p + 1, &dummy);
+ }
+ /* LSDA encoding. */
+ else if (*aug == 'L')
+ p++;
+ /* Otherwise end of string, or unknown augmentation. */
+ else
+ return DW_EH_PE_absptr;
+ aug++;
+ }
+}
+
+static inline int
+get_fde_encoding (struct dwarf_fde *f)
+{
+ return get_cie_encoding (get_cie (f));
+}
+
+
+/* Sorting an array of FDEs by address.
+ (Ideally we would have the linker sort the FDEs so we don't have to do
+ it at run time. But the linkers are not yet prepared for this.) */
+
+/* Return the Nth pc_begin value from FDE x. */
+
+static inline _Unwind_Ptr
+get_pc_begin (fde *x, size_t n)
+{
+ _Unwind_Ptr p;
+ memcpy (&p, x->pc_begin + n * sizeof (_Unwind_Ptr), sizeof (_Unwind_Ptr));
+ return p;
+}
+
+/* Comparison routines. Three variants of increasing complexity. */
+
+static int
+fde_unencoded_compare (struct object *ob __attribute__((unused)),
+ fde *x, fde *y)
+{
+ _Unwind_Ptr x_ptr = get_pc_begin (x, 0);
+ _Unwind_Ptr y_ptr = get_pc_begin (y, 0);
+
+ if (x_ptr > y_ptr)
+ return 1;
+ if (x_ptr < y_ptr)
+ return -1;
+ return 0;
+}
+
+static int
+fde_single_encoding_compare (struct object *ob, fde *x, fde *y)
+{
+ _Unwind_Ptr base, x_ptr, y_ptr;
+
+ base = base_from_object (ob->s.b.encoding, ob);
+ read_encoded_value_with_base (ob->s.b.encoding, base, x->pc_begin, &x_ptr);
+ read_encoded_value_with_base (ob->s.b.encoding, base, y->pc_begin, &y_ptr);
+
+ if (x_ptr > y_ptr)
+ return 1;
+ if (x_ptr < y_ptr)
+ return -1;
+ return 0;
+}
+
+static int
+fde_mixed_encoding_compare (struct object *ob, fde *x, fde *y)
+{
+ int x_encoding, y_encoding;
+ _Unwind_Ptr x_ptr, y_ptr;
+
+ x_encoding = get_fde_encoding (x);
+ read_encoded_value_with_base (x_encoding, base_from_object (x_encoding, ob),
+ x->pc_begin, &x_ptr);
+
+ y_encoding = get_fde_encoding (y);
+ read_encoded_value_with_base (y_encoding, base_from_object (y_encoding, ob),
+ y->pc_begin, &y_ptr);
+
+ if (x_ptr > y_ptr)
+ return 1;
+ if (x_ptr < y_ptr)
+ return -1;
+ return 0;
+}
+
+typedef int (*fde_compare_t) (struct object *, fde *, fde *);
+
+
+/* This is a special mix of insertion sort and heap sort, optimized for
+ the data sets that actually occur. They look like
+ 101 102 103 127 128 105 108 110 190 111 115 119 125 160 126 129 130.
+ I.e. a linearly increasing sequence (coming from functions in the text
+ section), with additionally a few unordered elements (coming from functions
+ in gnu_linkonce sections) whose values are higher than the values in the
+ surrounding linear sequence (but not necessarily higher than the values
+ at the end of the linear sequence!).
+ The worst-case total run time is O(N) + O(n log (n)), where N is the
+ total number of FDEs and n is the number of erratic ones. */
+
+struct fde_accumulator
+{
+ struct fde_vector *linear;
+ struct fde_vector *erratic;
+};
+
+static int
+start_fde_sort (struct fde_accumulator *accu, size_t count)
+{
+ size_t size;
+ if (! count)
+ return 0;
+
+ size = sizeof (struct fde_vector) + sizeof (fde *) * count;
+ if ((accu->linear = (struct fde_vector *) malloc (size)))
+ {
+ accu->linear->count = 0;
+ if ((accu->erratic = (struct fde_vector *) malloc (size)))
+ accu->erratic->count = 0;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+static inline void
+fde_insert (struct fde_accumulator *accu, fde *this_fde)
+{
+ if (accu->linear)
+ accu->linear->array[accu->linear->count++] = this_fde;
+}
+
+/* Split LINEAR into a linear sequence with low values and an erratic
+ sequence with high values, put the linear one (of longest possible
+ length) into LINEAR and the erratic one into ERRATIC. This is O(N).
+
+ Because the longest linear sequence we are trying to locate within the
+ incoming LINEAR array can be interspersed with (high valued) erratic
+ entries. We construct a chain indicating the sequenced entries.
+ To avoid having to allocate this chain, we overlay it onto the space of
+ the ERRATIC array during construction. A final pass iterates over the
+ chain to determine what should be placed in the ERRATIC array, and
+ what is the linear sequence. This overlay is safe from aliasing. */
+
+static void
+fde_split (struct object *ob, fde_compare_t fde_compare,
+ struct fde_vector *linear, struct fde_vector *erratic)
+{
+ static fde *marker;
+ size_t count = linear->count;
+ fde **chain_end = &marker;
+ size_t i, j, k;
+
+ /* This should optimize out, but it is wise to make sure this assumption
+ is correct. Should these have different sizes, we cannot cast between
+ them and the overlaying onto ERRATIC will not work. */
+ if (sizeof (fde *) != sizeof (fde **))
+ abort ();
+
+ for (i = 0; i < count; i++)
+ {
+ fde **probe;
+
+ for (probe = chain_end;
+ probe != &marker && fde_compare (ob, linear->array[i], *probe) < 0;
+ probe = chain_end)
+ {
+ chain_end = (fde **) erratic->array[probe - linear->array];
+ erratic->array[probe - linear->array] = NULL;
+ }
+ erratic->array[i] = (fde *) chain_end;
+ chain_end = &linear->array[i];
+ }
+
+ /* Each entry in LINEAR which is part of the linear sequence we have
+ discovered will correspond to a non-NULL entry in the chain we built in
+ the ERRATIC array. */
+ for (i = j = k = 0; i < count; i++)
+ if (erratic->array[i])
+ linear->array[j++] = linear->array[i];
+ else
+ erratic->array[k++] = linear->array[i];
+ linear->count = j;
+ erratic->count = k;
+}
+
+/* This is O(n log(n)). BSD/OS defines heapsort in stdlib.h, so we must
+ use a name that does not conflict. */
+
+static void
+frame_heapsort (struct object *ob, fde_compare_t fde_compare,
+ struct fde_vector *erratic)
+{
+ /* For a description of this algorithm, see:
+ Samuel P. Harbison, Guy L. Steele Jr.: C, a reference manual, 2nd ed.,
+ p. 60-61. */
+ fde ** a = erratic->array;
+ /* A portion of the array is called a "heap" if for all i>=0:
+ If i and 2i+1 are valid indices, then a[i] >= a[2i+1].
+ If i and 2i+2 are valid indices, then a[i] >= a[2i+2]. */
+#define SWAP(x,y) do { fde * tmp = x; x = y; y = tmp; } while (0)
+ size_t n = erratic->count;
+ size_t m = n;
+ size_t i;
+
+ while (m > 0)
+ {
+ /* Invariant: a[m..n-1] is a heap. */
+ m--;
+ for (i = m; 2*i+1 < n; )
+ {
+ if (2*i+2 < n
+ && fde_compare (ob, a[2*i+2], a[2*i+1]) > 0
+ && fde_compare (ob, a[2*i+2], a[i]) > 0)
+ {
+ SWAP (a[i], a[2*i+2]);
+ i = 2*i+2;
+ }
+ else if (fde_compare (ob, a[2*i+1], a[i]) > 0)
+ {
+ SWAP (a[i], a[2*i+1]);
+ i = 2*i+1;
+ }
+ else
+ break;
+ }
+ }
+ while (n > 1)
+ {
+ /* Invariant: a[0..n-1] is a heap. */
+ n--;
+ SWAP (a[0], a[n]);
+ for (i = 0; 2*i+1 < n; )
+ {
+ if (2*i+2 < n
+ && fde_compare (ob, a[2*i+2], a[2*i+1]) > 0
+ && fde_compare (ob, a[2*i+2], a[i]) > 0)
+ {
+ SWAP (a[i], a[2*i+2]);
+ i = 2*i+2;
+ }
+ else if (fde_compare (ob, a[2*i+1], a[i]) > 0)
+ {
+ SWAP (a[i], a[2*i+1]);
+ i = 2*i+1;
+ }
+ else
+ break;
+ }
+ }
+#undef SWAP
+}
+
+/* Merge V1 and V2, both sorted, and put the result into V1. */
+static void
+fde_merge (struct object *ob, fde_compare_t fde_compare,
+ struct fde_vector *v1, struct fde_vector *v2)
+{
+ size_t i1, i2;
+ fde * fde2;
+
+ i2 = v2->count;
+ if (i2 > 0)
+ {
+ i1 = v1->count;
+ do
+ {
+ i2--;
+ fde2 = v2->array[i2];
+ while (i1 > 0 && fde_compare (ob, v1->array[i1-1], fde2) > 0)
+ {
+ v1->array[i1+i2] = v1->array[i1-1];
+ i1--;
+ }
+ v1->array[i1+i2] = fde2;
+ }
+ while (i2 > 0);
+ v1->count += v2->count;
+ }
+}
+
+static void
+end_fde_sort (struct object *ob, struct fde_accumulator *accu, size_t count)
+{
+ fde_compare_t fde_compare;
+
+ if (accu->linear->count != count)
+ abort ();
+
+ if (ob->s.b.mixed_encoding)
+ fde_compare = fde_mixed_encoding_compare;
+ else if (ob->s.b.encoding == DW_EH_PE_absptr)
+ fde_compare = fde_unencoded_compare;
+ else
+ fde_compare = fde_single_encoding_compare;
+
+ if (accu->erratic)
+ {
+ fde_split (ob, fde_compare, accu->linear, accu->erratic);
+ if (accu->linear->count + accu->erratic->count != count)
+ abort ();
+ frame_heapsort (ob, fde_compare, accu->erratic);
+ fde_merge (ob, fde_compare, accu->linear, accu->erratic);
+ free (accu->erratic);
+ }
+ else
+ {
+ /* We've not managed to malloc an erratic array,
+ so heap sort in the linear one. */
+ frame_heapsort (ob, fde_compare, accu->linear);
+ }
+}
+
+
+/* Update encoding, mixed_encoding, and pc_begin for OB for the
+ fde array beginning at THIS_FDE. Return the number of fdes
+ encountered along the way. */
+
+static size_t
+classify_object_over_fdes (struct object *ob, fde *this_fde)
+{
+ struct dwarf_cie *last_cie = 0;
+ size_t count = 0;
+ int encoding = DW_EH_PE_absptr;
+ _Unwind_Ptr base = 0;
+
+ for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde))
+ {
+ struct dwarf_cie *this_cie;
+ _Unwind_Ptr mask, pc_begin;
+
+ /* Skip CIEs. */
+ if (this_fde->CIE_delta == 0)
+ continue;
+
+ /* Determine the encoding for this FDE. Note mixed encoded
+ objects for later. */
+ this_cie = get_cie (this_fde);
+ if (this_cie != last_cie)
+ {
+ last_cie = this_cie;
+ encoding = get_cie_encoding (this_cie);
+ base = base_from_object (encoding, ob);
+ if (ob->s.b.encoding == DW_EH_PE_omit)
+ ob->s.b.encoding = encoding;
+ else if (ob->s.b.encoding != encoding)
+ ob->s.b.mixed_encoding = 1;
+ }
+
+ read_encoded_value_with_base (encoding, base, this_fde->pc_begin,
+ &pc_begin);
+
+ /* Take care to ignore link-once functions that were removed.
+ In these cases, the function address will be NULL, but if
+ the encoding is smaller than a pointer a true NULL may not
+ be representable. Assume 0 in the representable bits is NULL. */
+ mask = size_of_encoded_value (encoding);
+ if (mask < sizeof (void *))
+ mask = (1L << (mask << 3)) - 1;
+ else
+ mask = -1;
+
+ if ((pc_begin & mask) == 0)
+ continue;
+
+ count += 1;
+ if ((void *) pc_begin < ob->pc_begin)
+ ob->pc_begin = (void *) pc_begin;
+ }
+
+ return count;
+}
+
+static void
+add_fdes (struct object *ob, struct fde_accumulator *accu, fde *this_fde)
+{
+ struct dwarf_cie *last_cie = 0;
+ int encoding = ob->s.b.encoding;
+ _Unwind_Ptr base = base_from_object (ob->s.b.encoding, ob);
+
+ for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde))
+ {
+ struct dwarf_cie *this_cie;
+
+ /* Skip CIEs. */
+ if (this_fde->CIE_delta == 0)
+ continue;
+
+ if (ob->s.b.mixed_encoding)
+ {
+ /* Determine the encoding for this FDE. Note mixed encoded
+ objects for later. */
+ this_cie = get_cie (this_fde);
+ if (this_cie != last_cie)
+ {
+ last_cie = this_cie;
+ encoding = get_cie_encoding (this_cie);
+ base = base_from_object (encoding, ob);
+ }
+ }
+
+ if (encoding == DW_EH_PE_absptr)
+ {
+ if (get_pc_begin (this_fde, 0) == 0)
+ continue;
+ }
+ else
+ {
+ _Unwind_Ptr pc_begin, mask;
+
+ read_encoded_value_with_base (encoding, base, this_fde->pc_begin,
+ &pc_begin);
+
+ /* Take care to ignore link-once functions that were removed.
+ In these cases, the function address will be NULL, but if
+ the encoding is smaller than a pointer a true NULL may not
+ be representable. Assume 0 in the representable bits is NULL. */
+ mask = size_of_encoded_value (encoding);
+ if (mask < sizeof (void *))
+ mask = (1L << (mask << 3)) - 1;
+ else
+ mask = -1;
+
+ if ((pc_begin & mask) == 0)
+ continue;
+ }
+
+ fde_insert (accu, this_fde);
+ }
+}
+
+/* Set up a sorted array of pointers to FDEs for a loaded object. We
+ count up the entries before allocating the array because it's likely to
+ be faster. We can be called multiple times, should we have failed to
+ allocate a sorted fde array on a previous occasion. */
+
+static void
+init_object (struct object* ob)
+{
+ struct fde_accumulator accu;
+ size_t count;
+
+ count = ob->s.b.count;
+ if (count == 0)
+ {
+ if (ob->s.b.from_array)
+ {
+ fde **p = ob->u.array;
+ for (count = 0; *p; ++p)
+ count += classify_object_over_fdes (ob, *p);
+ }
+ else
+ count = classify_object_over_fdes (ob, ob->u.single);
+
+ /* The count field we have in the main struct object is somewhat
+ limited, but should suffice for virtually all cases. If the
+ counted value doesn't fit, re-write a zero. The worst that
+ happens is that we re-count next time -- admittedly non-trivial
+ in that this implies some 2M fdes, but at least we function. */
+ ob->s.b.count = count;
+ if (ob->s.b.count != count)
+ ob->s.b.count = 0;
+ }
+
+ if (!start_fde_sort (&accu, count))
+ return;
+
+ if (ob->s.b.from_array)
+ {
+ fde **p;
+ for (p = ob->u.array; *p; ++p)
+ add_fdes (ob, &accu, *p);
+ }
+ else
+ add_fdes (ob, &accu, ob->u.single);
+
+ end_fde_sort (ob, &accu, count);
+
+ /* Save the original fde pointer, since this is the key by which the
+ DSO will deregister the object. */
+ accu.linear->orig_data = ob->u.single;
+ ob->u.sort = accu.linear;
+
+ ob->s.b.sorted = 1;
+}
+
+/* A linear search through a set of FDEs for the given PC. This is
+ used when there was insufficient memory to allocate and sort an
+ array. */
+
+static fde *
+linear_search_fdes (struct object *ob, fde *this_fde, void *pc)
+{
+ struct dwarf_cie *last_cie = 0;
+ int encoding = ob->s.b.encoding;
+ _Unwind_Ptr base = base_from_object (ob->s.b.encoding, ob);
+
+ for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde))
+ {
+ struct dwarf_cie *this_cie;
+ _Unwind_Ptr pc_begin, pc_range;
+
+ /* Skip CIEs. */
+ if (this_fde->CIE_delta == 0)
+ continue;
+
+ if (ob->s.b.mixed_encoding)
+ {
+ /* Determine the encoding for this FDE. Note mixed encoded
+ objects for later. */
+ this_cie = get_cie (this_fde);
+ if (this_cie != last_cie)
+ {
+ last_cie = this_cie;
+ encoding = get_cie_encoding (this_cie);
+ base = base_from_object (encoding, ob);
+ }
+ }
+
+ if (encoding == DW_EH_PE_absptr)
+ {
+ pc_begin = get_pc_begin (this_fde, 0);
+ pc_range = get_pc_begin (this_fde, 1);
+ if (pc_begin == 0)
+ continue;
+ }
+ else
+ {
+ _Unwind_Ptr mask;
+ const unsigned char *p;
+
+ p = read_encoded_value_with_base (encoding, base,
+ this_fde->pc_begin, &pc_begin);
+ read_encoded_value_with_base (encoding & 0x0F, 0, p, &pc_range);
+
+ /* Take care to ignore link-once functions that were removed.
+ In these cases, the function address will be NULL, but if
+ the encoding is smaller than a pointer a true NULL may not
+ be representable. Assume 0 in the representable bits is NULL. */
+ mask = size_of_encoded_value (encoding);
+ if (mask < sizeof (void *))
+ mask = (1L << (mask << 3)) - 1;
+ else
+ mask = -1;
+
+ if ((pc_begin & mask) == 0)
+ continue;
+ }
+
+ if ((_Unwind_Ptr) pc - pc_begin < pc_range)
+ return this_fde;
+ }
+
+ return NULL;
+}
+
+/* Binary search for an FDE containing the given PC. Here are three
+ implementations of increasing complexity. */
+
+static fde *
+binary_search_unencoded_fdes (struct object *ob, void *pc)
+{
+ struct fde_vector *vec = ob->u.sort;
+ size_t lo, hi;
+
+ for (lo = 0, hi = vec->count; lo < hi; )
+ {
+ size_t i = (lo + hi) / 2;
+ fde *f = vec->array[i];
+ void *pc_begin;
+ uaddr pc_range;
+
+ pc_begin = (void *) get_pc_begin (f, 0);
+ pc_range = (uaddr) get_pc_begin (f, 1);
+
+ if (pc < pc_begin)
+ hi = i;
+ else if (pc >= pc_begin + pc_range)
+ lo = i + 1;
+ else
+ return f;
+ }
+
+ return NULL;
+}
+
+static fde *
+binary_search_single_encoding_fdes (struct object *ob, void *pc)
+{
+ struct fde_vector *vec = ob->u.sort;
+ int encoding = ob->s.b.encoding;
+ _Unwind_Ptr base = base_from_object (encoding, ob);
+ size_t lo, hi;
+
+ for (lo = 0, hi = vec->count; lo < hi; )
+ {
+ size_t i = (lo + hi) / 2;
+ fde *f = vec->array[i];
+ _Unwind_Ptr pc_begin, pc_range;
+ const unsigned char *p;
+
+ p = read_encoded_value_with_base (encoding, base, f->pc_begin,
+ &pc_begin);
+ read_encoded_value_with_base (encoding & 0x0F, 0, p, &pc_range);
+
+ if ((_Unwind_Ptr) pc < pc_begin)
+ hi = i;
+ else if ((_Unwind_Ptr) pc >= pc_begin + pc_range)
+ lo = i + 1;
+ else
+ return f;
+ }
+
+ return NULL;
+}
+
+static fde *
+binary_search_mixed_encoding_fdes (struct object *ob, void *pc)
+{
+ struct fde_vector *vec = ob->u.sort;
+ size_t lo, hi;
+
+ for (lo = 0, hi = vec->count; lo < hi; )
+ {
+ size_t i = (lo + hi) / 2;
+ fde *f = vec->array[i];
+ _Unwind_Ptr pc_begin, pc_range;
+ const unsigned char *p;
+ int encoding;
+
+ encoding = get_fde_encoding (f);
+ p = read_encoded_value_with_base (encoding,
+ base_from_object (encoding, ob),
+ f->pc_begin, &pc_begin);
+ read_encoded_value_with_base (encoding & 0x0F, 0, p, &pc_range);
+
+ if ((_Unwind_Ptr) pc < pc_begin)
+ hi = i;
+ else if ((_Unwind_Ptr) pc >= pc_begin + pc_range)
+ lo = i + 1;
+ else
+ return f;
+ }
+
+ return NULL;
+}
+
+static fde *
+search_object (struct object* ob, void *pc)
+{
+ /* If the data hasn't been sorted, try to do this now. We may have
+ more memory available than last time we tried. */
+ if (! ob->s.b.sorted)
+ {
+ init_object (ob);
+
+ /* Despite the above comment, the normal reason to get here is
+ that we've not processed this object before. A quick range
+ check is in order. */
+ if (pc < ob->pc_begin)
+ return NULL;
+ }
+
+ if (ob->s.b.sorted)
+ {
+ if (ob->s.b.mixed_encoding)
+ return binary_search_mixed_encoding_fdes (ob, pc);
+ else if (ob->s.b.encoding == DW_EH_PE_absptr)
+ return binary_search_unencoded_fdes (ob, pc);
+ else
+ return binary_search_single_encoding_fdes (ob, pc);
+ }
+ else
+ {
+ /* Long slow labourious linear search, cos we've no memory. */
+ if (ob->s.b.from_array)
+ {
+ fde **p;
+ for (p = ob->u.array; *p ; p++)
+ {
+ fde *f = linear_search_fdes (ob, *p, pc);
+ if (f)
+ return f;
+ }
+ return NULL;
+ }
+ else
+ return linear_search_fdes (ob, ob->u.single, pc);
+ }
+}
+
+fde *
+_Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
+{
+ struct object *ob;
+ fde *f = NULL;
+
+ init_object_mutex_once ();
+ __gthread_mutex_lock (&object_mutex);
+
+ /* Linear search through the classified objects, to find the one
+ containing the pc. Note that pc_begin is sorted descending, and
+ we expect objects to be non-overlapping. */
+ for (ob = seen_objects; ob; ob = ob->next)
+ if (pc >= ob->pc_begin)
+ {
+ f = search_object (ob, pc);
+ if (f)
+ goto fini;
+ break;
+ }
+
+ /* Classify and search the objects we've not yet processed. */
+ while ((ob = unseen_objects))
+ {
+ struct object **p;
+
+ unseen_objects = ob->next;
+ f = search_object (ob, pc);
+
+ /* Insert the object into the classified list. */
+ for (p = &seen_objects; *p ; p = &(*p)->next)
+ if ((*p)->pc_begin < ob->pc_begin)
+ break;
+ ob->next = *p;
+ *p = ob;
+
+ if (f)
+ goto fini;
+ }
+
+ fini:
+ __gthread_mutex_unlock (&object_mutex);
+
+ if (f)
+ {
+ int encoding;
+ _Unwind_Ptr func;
+
+ bases->tbase = ob->tbase;
+ bases->dbase = ob->dbase;
+
+ encoding = ob->s.b.encoding;
+ if (ob->s.b.mixed_encoding)
+ encoding = get_fde_encoding (f);
+ read_encoded_value_with_base (encoding, base_from_object (encoding, ob),
+ f->pc_begin, &func);
+ bases->func = (void *) func;
+ }
+
+ return f;
+}
+
+#endif
diff --git a/REORG.TODO/sysdeps/generic/unwind-dw2-fde.h b/REORG.TODO/sysdeps/generic/unwind-dw2-fde.h
new file mode 100644
index 0000000000..941ab80d7b
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/unwind-dw2-fde.h
@@ -0,0 +1,169 @@
+/* Subroutines needed for unwinding stack frames for exception handling. */
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ Contributed by Jason Merrill <jason@cygnus.com>.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+
+struct fde_vector
+{
+ void *orig_data;
+ size_t count;
+ struct dwarf_fde *array __flexarr;
+};
+
+#ifdef _LIBC
+#include <gccframe.h>
+#else
+struct object
+{
+ void *pc_begin;
+ void *tbase;
+ void *dbase;
+ union {
+ struct dwarf_fde *single;
+ struct dwarf_fde **array;
+ struct fde_vector *sort;
+ } u;
+
+ union {
+ struct {
+ unsigned long sorted : 1;
+ unsigned long from_array : 1;
+ unsigned long mixed_encoding : 1;
+ unsigned long encoding : 8;
+ /* ??? Wish there was an easy way to detect a 64-bit host here;
+ we've got 32 bits left to play with... */
+ unsigned long count : 21;
+ } b;
+ size_t i;
+ } s;
+
+#ifdef DWARF2_OBJECT_END_PTR_EXTENSION
+ char *fde_end;
+#endif
+
+ struct object *next;
+};
+#endif
+
+/* This is the original definition of struct object. While the struct
+ itself was opaque to users, they did know how large it was, and
+ allocate one statically in crtbegin for each DSO. Keep this around
+ so that we're aware of the static size limitations for the new struct. */
+struct old_object
+{
+ void *pc_begin;
+ void *pc_end;
+ struct dwarf_fde *fde_begin;
+ struct dwarf_fde **fde_array;
+ size_t count;
+ struct old_object *next;
+};
+
+struct dwarf_eh_bases
+{
+ void *tbase;
+ void *dbase;
+ void *func;
+};
+
+
+extern void __register_frame_info_bases (void *, struct object *,
+ void *, void *);
+extern void __register_frame_info (void *, struct object *);
+extern void __register_frame (void *);
+extern void __register_frame_info_table_bases (void *, struct object *,
+ void *, void *);
+extern void __register_frame_info_table (void *, struct object *);
+extern void __register_frame_table (void *);
+extern void *__deregister_frame_info (void *);
+extern void *__deregister_frame_info_bases (void *);
+extern void __deregister_frame (void *);
+
+
+typedef int sword __attribute__ ((mode (SI)));
+typedef unsigned int uword __attribute__ ((mode (SI)));
+typedef unsigned int uaddr __attribute__ ((mode (pointer)));
+typedef int saddr __attribute__ ((mode (pointer)));
+typedef unsigned char ubyte;
+
+/* Terminology:
+ CIE - Common Information Element
+ FDE - Frame Descriptor Element
+
+ There is one per function, and it describes where the function code
+ is located, and what the register lifetimes and stack layout are
+ within the function.
+
+ The data structures are defined in the DWARF specification, although
+ not in a very readable way (see LITERATURE).
+
+ Every time an exception is thrown, the code needs to locate the FDE
+ for the current function, and starts to look for exception regions
+ from that FDE. This works in a two-level search:
+ a) in a linear search, find the shared image (i.e. DLL) containing
+ the PC
+ b) using the FDE table for that shared object, locate the FDE using
+ binary search (which requires the sorting). */
+
+/* The first few fields of a CIE. The CIE_id field is 0 for a CIE,
+ to distinguish it from a valid FDE. FDEs are aligned to an addressing
+ unit boundary, but the fields within are unaligned. */
+struct dwarf_cie
+{
+ uword length;
+ sword CIE_id;
+ ubyte version;
+ unsigned char augmentation __flexarr;
+} __attribute__ ((packed, aligned (__alignof__ (void *))));
+
+/* The first few fields of an FDE. */
+struct dwarf_fde
+{
+ uword length;
+ sword CIE_delta;
+ unsigned char pc_begin __flexarr;
+} __attribute__ ((packed, aligned (__alignof__ (void *))));
+
+typedef struct dwarf_fde fde;
+
+/* Locate the CIE for a given FDE. */
+
+static inline struct dwarf_cie *
+get_cie (struct dwarf_fde *f)
+{
+ return (void *)&f->CIE_delta - f->CIE_delta;
+}
+
+static inline fde *
+next_fde (fde *f)
+{
+ return (fde *) ((char *) f + f->length + sizeof (f->length));
+}
+
+extern fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);
+
+static inline int
+last_fde (struct object *obj __attribute__ ((__unused__)), fde *f)
+{
+#ifdef DWARF2_OBJECT_END_PTR_EXTENSION
+ return (char *)f == obj->fde_end || f->length == 0;
+#else
+ return f->length == 0;
+#endif
+}
diff --git a/REORG.TODO/sysdeps/generic/unwind-dw2.c b/REORG.TODO/sysdeps/generic/unwind-dw2.c
new file mode 100644
index 0000000000..42b23517d5
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/unwind-dw2.c
@@ -0,0 +1,1306 @@
+/* DWARF2 exception handling and frame unwind runtime interface routines.
+ Copyright (C) 1997-2017 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef _LIBC
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+#include <libintl.h>
+#include <dwarf2.h>
+#include <stdio.h>
+#include <unwind.h>
+#include <unwind-pe.h>
+#include <unwind-dw2-fde.h>
+#else
+#include "tconfig.h"
+#include "tsystem.h"
+#include "dwarf2.h"
+#include "unwind.h"
+#include "unwind-pe.h"
+#include "unwind-dw2-fde.h"
+#include "gthr.h"
+#endif
+
+
+
+#ifndef STACK_GROWS_DOWNWARD
+#define STACK_GROWS_DOWNWARD 0
+#else
+#undef STACK_GROWS_DOWNWARD
+#define STACK_GROWS_DOWNWARD 1
+#endif
+
+/* A target can override (perhaps for backward compatibility) how
+ many dwarf2 columns are unwound. */
+#ifndef DWARF_FRAME_REGISTERS
+#define DWARF_FRAME_REGISTERS FIRST_PSEUDO_REGISTER
+#endif
+
+/* Dwarf frame registers used for pre gcc 3.0 compiled glibc. */
+#ifndef PRE_GCC3_DWARF_FRAME_REGISTERS
+#define PRE_GCC3_DWARF_FRAME_REGISTERS DWARF_FRAME_REGISTERS
+#endif
+
+/* This is the register and unwind state for a particular frame. This
+ provides the information necessary to unwind up past a frame and return
+ to its caller. */
+struct _Unwind_Context
+{
+ void *reg[DWARF_FRAME_REGISTERS+1];
+ void *cfa;
+ void *ra;
+ void *lsda;
+ struct dwarf_eh_bases bases;
+ _Unwind_Word args_size;
+};
+
+#ifndef _LIBC
+/* Byte size of every register managed by these routines. */
+static unsigned char dwarf_reg_size_table[DWARF_FRAME_REGISTERS];
+#endif
+
+
+/* The result of interpreting the frame unwind info for a frame.
+ This is all symbolic at this point, as none of the values can
+ be resolved until the target pc is located. */
+typedef struct
+{
+ /* Each register save state can be described in terms of a CFA slot,
+ another register, or a location expression. */
+ struct frame_state_reg_info
+ {
+ struct {
+ union {
+ _Unwind_Word reg;
+ _Unwind_Sword offset;
+ const unsigned char *exp;
+ } loc;
+ enum {
+ REG_UNSAVED,
+ REG_SAVED_OFFSET,
+ REG_SAVED_REG,
+ REG_SAVED_EXP,
+ } how;
+ } reg[DWARF_FRAME_REGISTERS+1];
+
+ /* Used to implement DW_CFA_remember_state. */
+ struct frame_state_reg_info *prev;
+ } regs;
+
+ /* The CFA can be described in terms of a reg+offset or a
+ location expression. */
+ _Unwind_Sword cfa_offset;
+ _Unwind_Word cfa_reg;
+ const unsigned char *cfa_exp;
+ enum {
+ CFA_UNSET,
+ CFA_REG_OFFSET,
+ CFA_EXP,
+ } cfa_how;
+
+ /* The PC described by the current frame state. */
+ void *pc;
+
+ /* The information we care about from the CIE/FDE. */
+ _Unwind_Personality_Fn personality;
+ _Unwind_Sword data_align;
+ _Unwind_Word code_align;
+ unsigned char retaddr_column;
+ unsigned char fde_encoding;
+ unsigned char lsda_encoding;
+ unsigned char saw_z;
+ void *eh_ptr;
+} _Unwind_FrameState;
+
+/* Read unaligned data from the instruction buffer. */
+
+union unaligned
+{
+ void *p;
+ unsigned u2 __attribute__ ((mode (HI)));
+ unsigned u4 __attribute__ ((mode (SI)));
+ unsigned u8 __attribute__ ((mode (DI)));
+ signed s2 __attribute__ ((mode (HI)));
+ signed s4 __attribute__ ((mode (SI)));
+ signed s8 __attribute__ ((mode (DI)));
+} __attribute__ ((packed));
+
+static inline void *
+read_pointer (const void *p) { const union unaligned *up = p; return up->p; }
+
+static inline int
+read_1u (const void *p) { return *(const unsigned char *) p; }
+
+static inline int
+read_1s (const void *p) { return *(const signed char *) p; }
+
+static inline int
+read_2u (const void *p) { const union unaligned *up = p; return up->u2; }
+
+static inline int
+read_2s (const void *p) { const union unaligned *up = p; return up->s2; }
+
+static inline unsigned int
+read_4u (const void *p) { const union unaligned *up = p; return up->u4; }
+
+static inline int
+read_4s (const void *p) { const union unaligned *up = p; return up->s4; }
+
+static inline unsigned long
+read_8u (const void *p) { const union unaligned *up = p; return up->u8; }
+
+static inline unsigned long
+read_8s (const void *p) { const union unaligned *up = p; return up->s8; }
+
+/* Get the value of register REG as saved in CONTEXT. */
+
+inline _Unwind_Word
+_Unwind_GetGR (struct _Unwind_Context *context, int index)
+{
+ /* This will segfault if the register hasn't been saved. */
+ return * (_Unwind_Word *) context->reg[index];
+}
+
+/* Get the value of the CFA as saved in CONTEXT. */
+
+_Unwind_Word
+_Unwind_GetCFA (struct _Unwind_Context *context)
+{
+ return (_Unwind_Ptr) context->cfa;
+}
+
+/* Overwrite the saved value for register REG in CONTEXT with VAL. */
+
+inline void
+_Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word val)
+{
+ * (_Unwind_Word *) context->reg[index] = val;
+}
+
+/* Retrieve the return address for CONTEXT. */
+
+inline _Unwind_Ptr
+_Unwind_GetIP (struct _Unwind_Context *context)
+{
+ return (_Unwind_Ptr) context->ra;
+}
+
+/* Overwrite the return address for CONTEXT with VAL. */
+
+inline void
+_Unwind_SetIP (struct _Unwind_Context *context, _Unwind_Ptr val)
+{
+ context->ra = (void *) val;
+}
+
+void *
+_Unwind_GetLanguageSpecificData (struct _Unwind_Context *context)
+{
+ return context->lsda;
+}
+
+_Unwind_Ptr
+_Unwind_GetRegionStart (struct _Unwind_Context *context)
+{
+ return (_Unwind_Ptr) context->bases.func;
+}
+
+void *
+_Unwind_FindEnclosingFunction (void *pc)
+{
+ struct dwarf_eh_bases bases;
+ struct dwarf_fde *fde = _Unwind_Find_FDE (pc-1, &bases);
+ if (fde)
+ return bases.func;
+ else
+ return NULL;
+}
+
+#ifndef __ia64__
+_Unwind_Ptr
+_Unwind_GetDataRelBase (struct _Unwind_Context *context)
+{
+ return (_Unwind_Ptr) context->bases.dbase;
+}
+
+_Unwind_Ptr
+_Unwind_GetTextRelBase (struct _Unwind_Context *context)
+{
+ return (_Unwind_Ptr) context->bases.tbase;
+}
+#endif
+
+/* Extract any interesting information from the CIE for the translation
+ unit F belongs to. Return a pointer to the byte after the augmentation,
+ or NULL if we encountered an undecipherable augmentation. */
+
+static const unsigned char *
+extract_cie_info (struct dwarf_cie *cie, struct _Unwind_Context *context,
+ _Unwind_FrameState *fs)
+{
+ const unsigned char *aug = cie->augmentation;
+ const unsigned char *p = aug + strlen ((const char *) aug) + 1;
+ const unsigned char *ret = NULL;
+ _Unwind_Word utmp;
+
+ /* g++ v2 "eh" has pointer immediately following augmentation string,
+ so it must be handled first. */
+ if (aug[0] == 'e' && aug[1] == 'h')
+ {
+ fs->eh_ptr = read_pointer (p);
+ p += sizeof (void *);
+ aug += 2;
+ }
+
+ /* Immediately following the augmentation are the code and
+ data alignment and return address column. */
+ p = read_uleb128 (p, &fs->code_align);
+ p = read_sleb128 (p, &fs->data_align);
+ fs->retaddr_column = *p++;
+ fs->lsda_encoding = DW_EH_PE_omit;
+
+ /* If the augmentation starts with 'z', then a uleb128 immediately
+ follows containing the length of the augmentation field following
+ the size. */
+ if (*aug == 'z')
+ {
+ p = read_uleb128 (p, &utmp);
+ ret = p + utmp;
+
+ fs->saw_z = 1;
+ ++aug;
+ }
+
+ /* Iterate over recognized augmentation subsequences. */
+ while (*aug != '\0')
+ {
+ /* "L" indicates a byte showing how the LSDA pointer is encoded. */
+ if (aug[0] == 'L')
+ {
+ fs->lsda_encoding = *p++;
+ aug += 1;
+ }
+
+ /* "R" indicates a byte indicating how FDE addresses are encoded. */
+ else if (aug[0] == 'R')
+ {
+ fs->fde_encoding = *p++;
+ aug += 1;
+ }
+
+ /* "P" indicates a personality routine in the CIE augmentation. */
+ else if (aug[0] == 'P')
+ {
+ _Unwind_Ptr personality;
+ p = read_encoded_value (context, *p, p + 1, &personality);
+ fs->personality = (_Unwind_Personality_Fn) personality;
+ aug += 1;
+ }
+
+ /* Otherwise we have an unknown augmentation string.
+ Bail unless we saw a 'z' prefix. */
+ else
+ return ret;
+ }
+
+ return ret ? ret : p;
+}
+
+#ifndef _LIBC
+/* Decode a DW_OP stack program. Return the top of stack. Push INITIAL
+ onto the stack to start. */
+
+static _Unwind_Word
+execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
+ struct _Unwind_Context *context, _Unwind_Word initial)
+{
+ _Unwind_Word stack[64]; /* ??? Assume this is enough. */
+ int stack_elt;
+
+ stack[0] = initial;
+ stack_elt = 1;
+
+ while (op_ptr < op_end)
+ {
+ enum dwarf_location_atom op = *op_ptr++;
+ _Unwind_Word result, reg, utmp;
+ _Unwind_Sword offset, stmp;
+
+ switch (op)
+ {
+ case DW_OP_lit0:
+ case DW_OP_lit1:
+ case DW_OP_lit2:
+ case DW_OP_lit3:
+ case DW_OP_lit4:
+ case DW_OP_lit5:
+ case DW_OP_lit6:
+ case DW_OP_lit7:
+ case DW_OP_lit8:
+ case DW_OP_lit9:
+ case DW_OP_lit10:
+ case DW_OP_lit11:
+ case DW_OP_lit12:
+ case DW_OP_lit13:
+ case DW_OP_lit14:
+ case DW_OP_lit15:
+ case DW_OP_lit16:
+ case DW_OP_lit17:
+ case DW_OP_lit18:
+ case DW_OP_lit19:
+ case DW_OP_lit20:
+ case DW_OP_lit21:
+ case DW_OP_lit22:
+ case DW_OP_lit23:
+ case DW_OP_lit24:
+ case DW_OP_lit25:
+ case DW_OP_lit26:
+ case DW_OP_lit27:
+ case DW_OP_lit28:
+ case DW_OP_lit29:
+ case DW_OP_lit30:
+ case DW_OP_lit31:
+ result = op - DW_OP_lit0;
+ break;
+
+ case DW_OP_addr:
+ result = (_Unwind_Word) (_Unwind_Ptr) read_pointer (op_ptr);
+ op_ptr += sizeof (void *);
+ break;
+
+ case DW_OP_const1u:
+ result = read_1u (op_ptr);
+ op_ptr += 1;
+ break;
+ case DW_OP_const1s:
+ result = read_1s (op_ptr);
+ op_ptr += 1;
+ break;
+ case DW_OP_const2u:
+ result = read_2u (op_ptr);
+ op_ptr += 2;
+ break;
+ case DW_OP_const2s:
+ result = read_2s (op_ptr);
+ op_ptr += 2;
+ break;
+ case DW_OP_const4u:
+ result = read_4u (op_ptr);
+ op_ptr += 4;
+ break;
+ case DW_OP_const4s:
+ result = read_4s (op_ptr);
+ op_ptr += 4;
+ break;
+ case DW_OP_const8u:
+ result = read_8u (op_ptr);
+ op_ptr += 8;
+ break;
+ case DW_OP_const8s:
+ result = read_8s (op_ptr);
+ op_ptr += 8;
+ break;
+ case DW_OP_constu:
+ op_ptr = read_uleb128 (op_ptr, &result);
+ break;
+ case DW_OP_consts:
+ op_ptr = read_sleb128 (op_ptr, &stmp);
+ result = stmp;
+ break;
+
+ case DW_OP_reg0:
+ case DW_OP_reg1:
+ case DW_OP_reg2:
+ case DW_OP_reg3:
+ case DW_OP_reg4:
+ case DW_OP_reg5:
+ case DW_OP_reg6:
+ case DW_OP_reg7:
+ case DW_OP_reg8:
+ case DW_OP_reg9:
+ case DW_OP_reg10:
+ case DW_OP_reg11:
+ case DW_OP_reg12:
+ case DW_OP_reg13:
+ case DW_OP_reg14:
+ case DW_OP_reg15:
+ case DW_OP_reg16:
+ case DW_OP_reg17:
+ case DW_OP_reg18:
+ case DW_OP_reg19:
+ case DW_OP_reg20:
+ case DW_OP_reg21:
+ case DW_OP_reg22:
+ case DW_OP_reg23:
+ case DW_OP_reg24:
+ case DW_OP_reg25:
+ case DW_OP_reg26:
+ case DW_OP_reg27:
+ case DW_OP_reg28:
+ case DW_OP_reg29:
+ case DW_OP_reg30:
+ case DW_OP_reg31:
+ result = _Unwind_GetGR (context, op - DW_OP_reg0);
+ break;
+ case DW_OP_regx:
+ op_ptr = read_uleb128 (op_ptr, &reg);
+ result = _Unwind_GetGR (context, reg);
+ break;
+
+ case DW_OP_breg0:
+ case DW_OP_breg1:
+ case DW_OP_breg2:
+ case DW_OP_breg3:
+ case DW_OP_breg4:
+ case DW_OP_breg5:
+ case DW_OP_breg6:
+ case DW_OP_breg7:
+ case DW_OP_breg8:
+ case DW_OP_breg9:
+ case DW_OP_breg10:
+ case DW_OP_breg11:
+ case DW_OP_breg12:
+ case DW_OP_breg13:
+ case DW_OP_breg14:
+ case DW_OP_breg15:
+ case DW_OP_breg16:
+ case DW_OP_breg17:
+ case DW_OP_breg18:
+ case DW_OP_breg19:
+ case DW_OP_breg20:
+ case DW_OP_breg21:
+ case DW_OP_breg22:
+ case DW_OP_breg23:
+ case DW_OP_breg24:
+ case DW_OP_breg25:
+ case DW_OP_breg26:
+ case DW_OP_breg27:
+ case DW_OP_breg28:
+ case DW_OP_breg29:
+ case DW_OP_breg30:
+ case DW_OP_breg31:
+ op_ptr = read_sleb128 (op_ptr, &offset);
+ result = _Unwind_GetGR (context, op - DW_OP_breg0) + offset;
+ break;
+ case DW_OP_bregx:
+ op_ptr = read_uleb128 (op_ptr, &reg);
+ op_ptr = read_sleb128 (op_ptr, &offset);
+ result = _Unwind_GetGR (context, reg) + offset;
+ break;
+
+ case DW_OP_dup:
+ if (stack_elt < 1)
+ abort ();
+ result = stack[stack_elt - 1];
+ break;
+
+ case DW_OP_drop:
+ if (--stack_elt < 0)
+ abort ();
+ goto no_push;
+
+ case DW_OP_pick:
+ offset = *op_ptr++;
+ if (offset >= stack_elt - 1)
+ abort ();
+ result = stack[stack_elt - 1 - offset];
+ break;
+
+ case DW_OP_over:
+ if (stack_elt < 2)
+ abort ();
+ result = stack[stack_elt - 2];
+ break;
+
+ case DW_OP_rot:
+ {
+ _Unwind_Word t1, t2, t3;
+
+ if (stack_elt < 3)
+ abort ();
+ t1 = stack[stack_elt - 1];
+ t2 = stack[stack_elt - 2];
+ t3 = stack[stack_elt - 3];
+ stack[stack_elt - 1] = t2;
+ stack[stack_elt - 2] = t3;
+ stack[stack_elt - 3] = t1;
+ goto no_push;
+ }
+
+ case DW_OP_deref:
+ case DW_OP_deref_size:
+ case DW_OP_abs:
+ case DW_OP_neg:
+ case DW_OP_not:
+ case DW_OP_plus_uconst:
+ /* Unary operations. */
+ if (--stack_elt < 0)
+ abort ();
+ result = stack[stack_elt];
+
+ switch (op)
+ {
+ case DW_OP_deref:
+ {
+ void *ptr = (void *) (_Unwind_Ptr) result;
+ result = (_Unwind_Ptr) read_pointer (ptr);
+ }
+ break;
+
+ case DW_OP_deref_size:
+ {
+ void *ptr = (void *) (_Unwind_Ptr) result;
+ switch (*op_ptr++)
+ {
+ case 1:
+ result = read_1u (ptr);
+ break;
+ case 2:
+ result = read_2u (ptr);
+ break;
+ case 4:
+ result = read_4u (ptr);
+ break;
+ case 8:
+ result = read_8u (ptr);
+ break;
+ default:
+ abort ();
+ }
+ }
+ break;
+
+ case DW_OP_abs:
+ if ((_Unwind_Sword) result < 0)
+ result = -result;
+ break;
+ case DW_OP_neg:
+ result = -result;
+ break;
+ case DW_OP_not:
+ result = ~result;
+ break;
+ case DW_OP_plus_uconst:
+ op_ptr = read_uleb128 (op_ptr, &utmp);
+ result += utmp;
+ break;
+
+ default:
+ abort ();
+ }
+ break;
+
+ case DW_OP_and:
+ case DW_OP_div:
+ case DW_OP_minus:
+ case DW_OP_mod:
+ case DW_OP_mul:
+ case DW_OP_or:
+ case DW_OP_plus:
+ case DW_OP_le:
+ case DW_OP_ge:
+ case DW_OP_eq:
+ case DW_OP_lt:
+ case DW_OP_gt:
+ case DW_OP_ne:
+ {
+ /* Binary operations. */
+ _Unwind_Word first, second;
+ if ((stack_elt -= 2) < 0)
+ abort ();
+ second = stack[stack_elt];
+ first = stack[stack_elt + 1];
+
+ switch (op)
+ {
+ case DW_OP_and:
+ result = second & first;
+ break;
+ case DW_OP_div:
+ result = (_Unwind_Sword) second / (_Unwind_Sword) first;
+ break;
+ case DW_OP_minus:
+ result = second - first;
+ break;
+ case DW_OP_mod:
+ result = (_Unwind_Sword) second % (_Unwind_Sword) first;
+ break;
+ case DW_OP_mul:
+ result = second * first;
+ break;
+ case DW_OP_or:
+ result = second | first;
+ break;
+ case DW_OP_plus:
+ result = second + first;
+ break;
+ case DW_OP_shl:
+ result = second << first;
+ break;
+ case DW_OP_shr:
+ result = second >> first;
+ break;
+ case DW_OP_shra:
+ result = (_Unwind_Sword) second >> first;
+ break;
+ case DW_OP_xor:
+ result = second ^ first;
+ break;
+ case DW_OP_le:
+ result = (_Unwind_Sword) first <= (_Unwind_Sword) second;
+ break;
+ case DW_OP_ge:
+ result = (_Unwind_Sword) first >= (_Unwind_Sword) second;
+ break;
+ case DW_OP_eq:
+ result = (_Unwind_Sword) first == (_Unwind_Sword) second;
+ break;
+ case DW_OP_lt:
+ result = (_Unwind_Sword) first < (_Unwind_Sword) second;
+ break;
+ case DW_OP_gt:
+ result = (_Unwind_Sword) first > (_Unwind_Sword) second;
+ break;
+ case DW_OP_ne:
+ result = (_Unwind_Sword) first != (_Unwind_Sword) second;
+ break;
+
+ default:
+ abort ();
+ }
+ }
+ break;
+
+ case DW_OP_skip:
+ offset = read_2s (op_ptr);
+ op_ptr += 2;
+ op_ptr += offset;
+ goto no_push;
+
+ case DW_OP_bra:
+ if (--stack_elt < 0)
+ abort ();
+ offset = read_2s (op_ptr);
+ op_ptr += 2;
+ if (stack[stack_elt] != 0)
+ op_ptr += offset;
+ goto no_push;
+
+ case DW_OP_nop:
+ goto no_push;
+
+ default:
+ abort ();
+ }
+
+ /* Most things push a result value. */
+ if ((size_t) stack_elt >= sizeof(stack)/sizeof(*stack))
+ abort ();
+ stack[stack_elt++] = result;
+ no_push:;
+ }
+
+ /* We were executing this program to get a value. It should be
+ at top of stack. */
+ if (--stack_elt < 0)
+ abort ();
+ return stack[stack_elt];
+}
+#endif
+
+/* Decode DWARF 2 call frame information. Takes pointers the
+ instruction sequence to decode, current register information and
+ CIE info, and the PC range to evaluate. */
+
+static void
+execute_cfa_program (const unsigned char *insn_ptr,
+ const unsigned char *insn_end,
+ struct _Unwind_Context *context,
+ _Unwind_FrameState *fs)
+{
+ struct frame_state_reg_info *unused_rs = NULL;
+
+ /* Don't allow remember/restore between CIE and FDE programs. */
+ fs->regs.prev = NULL;
+
+ /* The comparison with the return address uses < rather than <= because
+ we are only interested in the effects of code before the call; for a
+ noreturn function, the return address may point to unrelated code with
+ a different stack configuration that we are not interested in. We
+ assume that the call itself is unwind info-neutral; if not, or if
+ there are delay instructions that adjust the stack, these must be
+ reflected at the point immediately before the call insn. */
+ while (insn_ptr < insn_end && fs->pc < context->ra)
+ {
+ unsigned char insn = *insn_ptr++;
+ _Unwind_Word reg, utmp;
+ _Unwind_Sword offset, stmp;
+
+ if ((insn & 0xc0) == DW_CFA_advance_loc)
+ fs->pc += (insn & 0x3f) * fs->code_align;
+ else if ((insn & 0xc0) == DW_CFA_offset)
+ {
+ reg = insn & 0x3f;
+ insn_ptr = read_uleb128 (insn_ptr, &utmp);
+ offset = (_Unwind_Sword) utmp * fs->data_align;
+ fs->regs.reg[reg].how = REG_SAVED_OFFSET;
+ fs->regs.reg[reg].loc.offset = offset;
+ }
+ else if ((insn & 0xc0) == DW_CFA_restore)
+ {
+ reg = insn & 0x3f;
+ fs->regs.reg[reg].how = REG_UNSAVED;
+ }
+ else switch (insn)
+ {
+ case DW_CFA_set_loc:
+ {
+ _Unwind_Ptr pc;
+ insn_ptr = read_encoded_value (context, fs->fde_encoding,
+ insn_ptr, &pc);
+ fs->pc = (void *) pc;
+ }
+ break;
+
+ case DW_CFA_advance_loc1:
+ fs->pc += read_1u (insn_ptr) * fs->code_align;
+ insn_ptr += 1;
+ break;
+ case DW_CFA_advance_loc2:
+ fs->pc += read_2u (insn_ptr) * fs->code_align;
+ insn_ptr += 2;
+ break;
+ case DW_CFA_advance_loc4:
+ fs->pc += read_4u (insn_ptr) * fs->code_align;
+ insn_ptr += 4;
+ break;
+
+ case DW_CFA_offset_extended:
+ insn_ptr = read_uleb128 (insn_ptr, &reg);
+ insn_ptr = read_uleb128 (insn_ptr, &utmp);
+ offset = (_Unwind_Sword) utmp * fs->data_align;
+ fs->regs.reg[reg].how = REG_SAVED_OFFSET;
+ fs->regs.reg[reg].loc.offset = offset;
+ break;
+
+ case DW_CFA_restore_extended:
+ insn_ptr = read_uleb128 (insn_ptr, &reg);
+ fs->regs.reg[reg].how = REG_UNSAVED;
+ break;
+
+ case DW_CFA_undefined:
+ case DW_CFA_same_value:
+ insn_ptr = read_uleb128 (insn_ptr, &reg);
+ break;
+
+ case DW_CFA_nop:
+ break;
+
+ case DW_CFA_register:
+ {
+ _Unwind_Word reg2;
+ insn_ptr = read_uleb128 (insn_ptr, &reg);
+ insn_ptr = read_uleb128 (insn_ptr, &reg2);
+ fs->regs.reg[reg].how = REG_SAVED_REG;
+ fs->regs.reg[reg].loc.reg = reg2;
+ }
+ break;
+
+ case DW_CFA_remember_state:
+ {
+ struct frame_state_reg_info *new_rs;
+ if (unused_rs)
+ {
+ new_rs = unused_rs;
+ unused_rs = unused_rs->prev;
+ }
+ else
+ new_rs = __builtin_alloca (sizeof (struct frame_state_reg_info));
+
+ *new_rs = fs->regs;
+ fs->regs.prev = new_rs;
+ }
+ break;
+
+ case DW_CFA_restore_state:
+ {
+ struct frame_state_reg_info *old_rs = fs->regs.prev;
+#ifdef _LIBC
+ if (old_rs == NULL)
+ __libc_fatal ("invalid DWARF unwind data");
+ else
+#endif
+ {
+ fs->regs = *old_rs;
+ old_rs->prev = unused_rs;
+ unused_rs = old_rs;
+ }
+ }
+ break;
+
+ case DW_CFA_def_cfa:
+ insn_ptr = read_uleb128 (insn_ptr, &fs->cfa_reg);
+ insn_ptr = read_uleb128 (insn_ptr, &utmp);
+ fs->cfa_offset = utmp;
+ fs->cfa_how = CFA_REG_OFFSET;
+ break;
+
+ case DW_CFA_def_cfa_register:
+ insn_ptr = read_uleb128 (insn_ptr, &fs->cfa_reg);
+ fs->cfa_how = CFA_REG_OFFSET;
+ break;
+
+ case DW_CFA_def_cfa_offset:
+ insn_ptr = read_uleb128 (insn_ptr, &utmp);
+ fs->cfa_offset = utmp;
+ /* cfa_how deliberately not set. */
+ break;
+
+ case DW_CFA_def_cfa_expression:
+ fs->cfa_exp = insn_ptr;
+ fs->cfa_how = CFA_EXP;
+ insn_ptr = read_uleb128 (insn_ptr, &utmp);
+ insn_ptr += utmp;
+ break;
+
+ case DW_CFA_expression:
+ insn_ptr = read_uleb128 (insn_ptr, &reg);
+ fs->regs.reg[reg].how = REG_SAVED_EXP;
+ fs->regs.reg[reg].loc.exp = insn_ptr;
+ insn_ptr = read_uleb128 (insn_ptr, &utmp);
+ insn_ptr += utmp;
+ break;
+
+ /* From the 2.1 draft. */
+ case DW_CFA_offset_extended_sf:
+ insn_ptr = read_uleb128 (insn_ptr, &reg);
+ insn_ptr = read_sleb128 (insn_ptr, &stmp);
+ offset = stmp * fs->data_align;
+ fs->regs.reg[reg].how = REG_SAVED_OFFSET;
+ fs->regs.reg[reg].loc.offset = offset;
+ break;
+
+ case DW_CFA_def_cfa_sf:
+ insn_ptr = read_uleb128 (insn_ptr, &fs->cfa_reg);
+ insn_ptr = read_sleb128 (insn_ptr, &fs->cfa_offset);
+ fs->cfa_how = CFA_REG_OFFSET;
+ break;
+
+ case DW_CFA_def_cfa_offset_sf:
+ insn_ptr = read_sleb128 (insn_ptr, &fs->cfa_offset);
+ /* cfa_how deliberately not set. */
+ break;
+
+ case DW_CFA_GNU_window_save:
+ /* ??? Hardcoded for SPARC register window configuration.
+ At least do not do anything for archs which explicitly
+ define a lower register number. */
+#if DWARF_FRAME_REGISTERS >= 32
+ for (reg = 16; reg < 32; ++reg)
+ {
+ fs->regs.reg[reg].how = REG_SAVED_OFFSET;
+ fs->regs.reg[reg].loc.offset = (reg - 16) * sizeof (void *);
+ }
+#endif
+ break;
+
+ case DW_CFA_GNU_args_size:
+ insn_ptr = read_uleb128 (insn_ptr, &context->args_size);
+ break;
+
+ case DW_CFA_GNU_negative_offset_extended:
+ /* Obsoleted by DW_CFA_offset_extended_sf, but used by
+ older PowerPC code. */
+ insn_ptr = read_uleb128 (insn_ptr, &reg);
+ insn_ptr = read_uleb128 (insn_ptr, &utmp);
+ offset = (_Unwind_Word) utmp * fs->data_align;
+ fs->regs.reg[reg].how = REG_SAVED_OFFSET;
+ fs->regs.reg[reg].loc.offset = -offset;
+ break;
+
+ default:
+ abort ();
+ }
+ }
+}
+
+/* Given the _Unwind_Context CONTEXT for a stack frame, look up the FDE for
+ its caller and decode it into FS. This function also sets the
+ args_size and lsda members of CONTEXT, as they are really information
+ about the caller's frame. */
+
+static _Unwind_Reason_Code
+uw_frame_state_for (struct _Unwind_Context *context, _Unwind_FrameState *fs)
+{
+ struct dwarf_fde *fde;
+ struct dwarf_cie *cie;
+ const unsigned char *aug, *insn, *end;
+
+ memset (fs, 0, sizeof (*fs));
+ context->args_size = 0;
+ context->lsda = 0;
+
+ fde = _Unwind_Find_FDE (context->ra - 1, &context->bases);
+ if (fde == NULL)
+ {
+ /* Couldn't find frame unwind info for this function. Try a
+ target-specific fallback mechanism. This will necessarily
+ not provide a personality routine or LSDA. */
+#ifdef MD_FALLBACK_FRAME_STATE_FOR
+ MD_FALLBACK_FRAME_STATE_FOR (context, fs, success);
+ return _URC_END_OF_STACK;
+ success:
+ return _URC_NO_REASON;
+#else
+ return _URC_END_OF_STACK;
+#endif
+ }
+
+ fs->pc = context->bases.func;
+
+ cie = get_cie (fde);
+ insn = extract_cie_info (cie, context, fs);
+ if (insn == NULL)
+ /* CIE contained unknown augmentation. */
+ return _URC_FATAL_PHASE1_ERROR;
+
+ /* First decode all the insns in the CIE. */
+ end = (unsigned char *) next_fde ((struct dwarf_fde *) cie);
+ execute_cfa_program (insn, end, context, fs);
+
+ /* Locate augmentation for the fde. */
+ aug = (unsigned char *) fde + sizeof (*fde);
+ aug += 2 * size_of_encoded_value (fs->fde_encoding);
+ insn = NULL;
+ if (fs->saw_z)
+ {
+ _Unwind_Word i;
+ aug = read_uleb128 (aug, &i);
+ insn = aug + i;
+ }
+ if (fs->lsda_encoding != DW_EH_PE_omit)
+ {
+ _Unwind_Ptr lsda;
+ aug = read_encoded_value (context, fs->lsda_encoding, aug, &lsda);
+ context->lsda = (void *) lsda;
+ }
+
+ /* Then the insns in the FDE up to our target PC. */
+ if (insn == NULL)
+ insn = aug;
+ end = (unsigned char *) next_fde (fde);
+ execute_cfa_program (insn, end, context, fs);
+
+ return _URC_NO_REASON;
+}
+
+typedef struct frame_state
+{
+ void *cfa;
+ void *eh_ptr;
+ long cfa_offset;
+ long args_size;
+ long reg_or_offset[PRE_GCC3_DWARF_FRAME_REGISTERS+1];
+ unsigned short cfa_reg;
+ unsigned short retaddr_column;
+ char saved[PRE_GCC3_DWARF_FRAME_REGISTERS+1];
+} frame_state;
+
+#ifndef STATIC
+# define STATIC
+#endif
+
+STATIC
+struct frame_state * __frame_state_for (void *, struct frame_state *);
+
+/* Called from pre-G++ 3.0 __throw to find the registers to restore for
+ a given PC_TARGET. The caller should allocate a local variable of
+ `struct frame_state' and pass its address to STATE_IN. */
+
+STATIC
+struct frame_state *
+__frame_state_for (void *pc_target, struct frame_state *state_in)
+{
+ struct _Unwind_Context context;
+ _Unwind_FrameState fs;
+ int reg;
+
+ memset (&context, 0, sizeof (struct _Unwind_Context));
+ context.ra = pc_target + 1;
+
+ if (uw_frame_state_for (&context, &fs) != _URC_NO_REASON)
+ return 0;
+
+ /* We have no way to pass a location expression for the CFA to our
+ caller. It wouldn't understand it anyway. */
+ if (fs.cfa_how == CFA_EXP)
+ return 0;
+
+ for (reg = 0; reg < PRE_GCC3_DWARF_FRAME_REGISTERS + 1; reg++)
+ {
+ state_in->saved[reg] = fs.regs.reg[reg].how;
+ switch (state_in->saved[reg])
+ {
+ case REG_SAVED_REG:
+ state_in->reg_or_offset[reg] = fs.regs.reg[reg].loc.reg;
+ break;
+ case REG_SAVED_OFFSET:
+ state_in->reg_or_offset[reg] = fs.regs.reg[reg].loc.offset;
+ break;
+ default:
+ state_in->reg_or_offset[reg] = 0;
+ break;
+ }
+ }
+
+ state_in->cfa_offset = fs.cfa_offset;
+ state_in->cfa_reg = fs.cfa_reg;
+ state_in->retaddr_column = fs.retaddr_column;
+ state_in->args_size = context.args_size;
+ state_in->eh_ptr = fs.eh_ptr;
+
+ return state_in;
+}
+
+#ifndef _LIBC
+
+static void
+uw_update_context_1 (struct _Unwind_Context *context, _Unwind_FrameState *fs)
+{
+ struct _Unwind_Context orig_context = *context;
+ void *cfa;
+ long i;
+
+#ifdef EH_RETURN_STACKADJ_RTX
+ /* Special handling here: Many machines do not use a frame pointer,
+ and track the CFA only through offsets from the stack pointer from
+ one frame to the next. In this case, the stack pointer is never
+ stored, so it has no saved address in the context. What we do
+ have is the CFA from the previous stack frame.
+
+ In very special situations (such as unwind info for signal return),
+ there may be location expressions that use the stack pointer as well.
+
+ Do this conditionally for one frame. This allows the unwind info
+ for one frame to save a copy of the stack pointer from the previous
+ frame, and be able to use much easier CFA mechanisms to do it.
+ Always zap the saved stack pointer value for the next frame; carrying
+ the value over from one frame to another doesn't make sense. */
+
+ _Unwind_Word tmp_sp;
+
+ if (!orig_context.reg[__builtin_dwarf_sp_column ()])
+ {
+ tmp_sp = (_Unwind_Ptr) context->cfa;
+ orig_context.reg[__builtin_dwarf_sp_column ()] = &tmp_sp;
+ }
+ context->reg[__builtin_dwarf_sp_column ()] = NULL;
+#endif
+
+ /* Compute this frame's CFA. */
+ switch (fs->cfa_how)
+ {
+ case CFA_REG_OFFSET:
+ cfa = (void *) (_Unwind_Ptr) _Unwind_GetGR (&orig_context, fs->cfa_reg);
+ cfa += fs->cfa_offset;
+ break;
+
+ case CFA_EXP:
+ {
+ const unsigned char *exp = fs->cfa_exp;
+ _Unwind_Word len;
+
+ exp = read_uleb128 (exp, &len);
+ cfa = (void *) (_Unwind_Ptr)
+ execute_stack_op (exp, exp + len, &orig_context, 0);
+ break;
+ }
+
+ default:
+ abort ();
+ }
+ context->cfa = cfa;
+
+ /* Compute the addresses of all registers saved in this frame. */
+ for (i = 0; i < DWARF_FRAME_REGISTERS + 1; ++i)
+ switch (fs->regs.reg[i].how)
+ {
+ case REG_UNSAVED:
+ break;
+
+ case REG_SAVED_OFFSET:
+ context->reg[i] = cfa + fs->regs.reg[i].loc.offset;
+ break;
+
+ case REG_SAVED_REG:
+ context->reg[i] = orig_context.reg[fs->regs.reg[i].loc.reg];
+ break;
+
+ case REG_SAVED_EXP:
+ {
+ const unsigned char *exp = fs->regs.reg[i].loc.exp;
+ _Unwind_Word len;
+ _Unwind_Ptr val;
+
+ exp = read_uleb128 (exp, &len);
+ val = execute_stack_op (exp, exp + len, &orig_context,
+ (_Unwind_Ptr) cfa);
+ context->reg[i] = (void *) val;
+ }
+ break;
+ }
+}
+
+/* CONTEXT describes the unwind state for a frame, and FS describes the FDE
+ of its caller. Update CONTEXT to refer to the caller as well. Note
+ that the args_size and lsda members are not updated here, but later in
+ uw_frame_state_for. */
+
+static void
+uw_update_context (struct _Unwind_Context *context, _Unwind_FrameState *fs)
+{
+ uw_update_context_1 (context, fs);
+
+ /* Compute the return address now, since the return address column
+ can change from frame to frame. */
+ context->ra = __builtin_extract_return_addr
+ ((void *) (_Unwind_Ptr) _Unwind_GetGR (context, fs->retaddr_column));
+}
+
+/* Fill in CONTEXT for top-of-stack. The only valid registers at this
+ level will be the return address and the CFA. */
+
+#define uw_init_context(CONTEXT) \
+ do \
+ { \
+ /* Do any necessary initialization to access arbitrary stack frames. \
+ On the SPARC, this means flushing the register windows. */ \
+ __builtin_unwind_init (); \
+ uw_init_context_1 (CONTEXT, __builtin_dwarf_cfa (), \
+ __builtin_return_address (0)); \
+ } \
+ while (0)
+
+static void
+uw_init_context_1 (struct _Unwind_Context *context,
+ void *outer_cfa, void *outer_ra)
+{
+ void *ra = __builtin_extract_return_addr (__builtin_return_address (0));
+ _Unwind_FrameState fs;
+ _Unwind_Word sp_slot;
+
+ memset (context, 0, sizeof (struct _Unwind_Context));
+ context->ra = ra;
+
+ if (uw_frame_state_for (context, &fs) != _URC_NO_REASON)
+ abort ();
+
+ /* Force the frame state to use the known cfa value. */
+ sp_slot = (_Unwind_Ptr) outer_cfa;
+ context->reg[__builtin_dwarf_sp_column ()] = &sp_slot;
+ fs.cfa_how = CFA_REG_OFFSET;
+ fs.cfa_reg = __builtin_dwarf_sp_column ();
+ fs.cfa_offset = 0;
+
+ uw_update_context_1 (context, &fs);
+
+ /* If the return address column was saved in a register in the
+ initialization context, then we can't see it in the given
+ call frame data. So have the initialization context tell us. */
+ context->ra = __builtin_extract_return_addr (outer_ra);
+}
+
+
+/* Install TARGET into CURRENT so that we can return to it. This is a
+ macro because __builtin_eh_return must be invoked in the context of
+ our caller. */
+
+#define uw_install_context(CURRENT, TARGET) \
+ do \
+ { \
+ long offset = uw_install_context_1 ((CURRENT), (TARGET)); \
+ void *handler = __builtin_frob_return_addr ((TARGET)->ra); \
+ __builtin_eh_return (offset, handler); \
+ } \
+ while (0)
+
+static inline void
+init_dwarf_reg_size_table (void)
+{
+ __builtin_init_dwarf_reg_size_table (dwarf_reg_size_table);
+}
+
+static long
+uw_install_context_1 (struct _Unwind_Context *current,
+ struct _Unwind_Context *target)
+{
+ long i;
+
+#if __GTHREADS
+ {
+ static __gthread_once_t once_regsizes = __GTHREAD_ONCE_INIT;
+ if (__gthread_once (&once_regsizes, init_dwarf_reg_size_table) != 0
+ || dwarf_reg_size_table[0] == 0)
+ init_dwarf_reg_size_table ();
+ }
+#else
+ if (dwarf_reg_size_table[0] == 0)
+ init_dwarf_reg_size_table ();
+#endif
+
+ for (i = 0; i < DWARF_FRAME_REGISTERS; ++i)
+ {
+ void *c = current->reg[i];
+ void *t = target->reg[i];
+ if (t && c && t != c)
+ memcpy (c, t, dwarf_reg_size_table[i]);
+ }
+
+#ifdef EH_RETURN_STACKADJ_RTX
+ {
+ void *target_cfa;
+
+ /* If the last frame records a saved stack pointer, use it. */
+ if (target->reg[__builtin_dwarf_sp_column ()])
+ target_cfa = (void *)(_Unwind_Ptr)
+ _Unwind_GetGR (target, __builtin_dwarf_sp_column ());
+ else
+ target_cfa = target->cfa;
+
+ /* We adjust SP by the difference between CURRENT and TARGET's CFA. */
+ if (STACK_GROWS_DOWNWARD)
+ return target_cfa - current->cfa + target->args_size;
+ else
+ return current->cfa - target_cfa - target->args_size;
+ }
+#else
+ return 0;
+#endif
+}
+
+static inline _Unwind_Ptr
+uw_identify_context (struct _Unwind_Context *context)
+{
+ return _Unwind_GetIP (context);
+}
+
+
+#include "unwind.inc"
+
+#endif /* _LIBC */
diff --git a/REORG.TODO/sysdeps/generic/unwind-pe.c b/REORG.TODO/sysdeps/generic/unwind-pe.c
new file mode 100644
index 0000000000..4085eb2bd1
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/unwind-pe.c
@@ -0,0 +1,5 @@
+#include <stdlib.h>
+#include <unwind.h>
+
+#define _LIBC_DEFINITIONS
+#include "unwind-pe.h"
diff --git a/REORG.TODO/sysdeps/generic/unwind-pe.h b/REORG.TODO/sysdeps/generic/unwind-pe.h
new file mode 100644
index 0000000000..4e2aa12074
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/unwind-pe.h
@@ -0,0 +1,305 @@
+/* Exception handling and frame unwind runtime interface routines.
+ Copyright (C) 2001-2017 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* @@@ Really this should be out of line, but this also causes link
+ compatibility problems with the base ABI. This is slightly better
+ than duplicating code, however. */
+
+/* If using C++, references to abort have to be qualified with std::. */
+#ifdef __cplusplus
+#define __gxx_abort std::abort
+#else
+#define __gxx_abort abort
+#endif
+
+/* Pointer encodings, from dwarf2.h. */
+#define DW_EH_PE_absptr 0x00
+#define DW_EH_PE_omit 0xff
+
+#define DW_EH_PE_uleb128 0x01
+#define DW_EH_PE_udata2 0x02
+#define DW_EH_PE_udata4 0x03
+#define DW_EH_PE_udata8 0x04
+#define DW_EH_PE_sleb128 0x09
+#define DW_EH_PE_sdata2 0x0A
+#define DW_EH_PE_sdata4 0x0B
+#define DW_EH_PE_sdata8 0x0C
+#define DW_EH_PE_signed 0x08
+
+#define DW_EH_PE_pcrel 0x10
+#define DW_EH_PE_textrel 0x20
+#define DW_EH_PE_datarel 0x30
+#define DW_EH_PE_funcrel 0x40
+#define DW_EH_PE_aligned 0x50
+
+#define DW_EH_PE_indirect 0x80
+
+
+#if defined(_LIBC)
+
+/* Prototypes. */
+extern unsigned int size_of_encoded_value (unsigned char encoding)
+ attribute_hidden;
+
+extern const unsigned char *read_encoded_value_with_base
+ (unsigned char encoding, _Unwind_Ptr base,
+ const unsigned char *p, _Unwind_Ptr *val)
+ attribute_hidden;
+
+extern const unsigned char * read_encoded_value
+ (struct _Unwind_Context *context, unsigned char encoding,
+ const unsigned char *p, _Unwind_Ptr *val)
+ attribute_hidden;
+
+extern const unsigned char * read_uleb128 (const unsigned char *p,
+ _Unwind_Word *val)
+ attribute_hidden;
+extern const unsigned char * read_sleb128 (const unsigned char *p,
+ _Unwind_Sword *val)
+ attribute_hidden;
+
+#endif
+#if defined(_LIBC) && defined(_LIBC_DEFINITIONS)
+
+#ifdef _LIBC
+#define STATIC
+#else
+#define STATIC static
+#endif
+
+/* Given an encoding, return the number of bytes the format occupies.
+ This is only defined for fixed-size encodings, and so does not
+ include leb128. */
+
+STATIC unsigned int
+size_of_encoded_value (unsigned char encoding)
+{
+ if (encoding == DW_EH_PE_omit)
+ return 0;
+
+ switch (encoding & 0x07)
+ {
+ case DW_EH_PE_absptr:
+ return sizeof (void *);
+ case DW_EH_PE_udata2:
+ return 2;
+ case DW_EH_PE_udata4:
+ return 4;
+ case DW_EH_PE_udata8:
+ return 8;
+ }
+ __gxx_abort ();
+}
+
+#ifndef NO_BASE_OF_ENCODED_VALUE
+
+/* Given an encoding and an _Unwind_Context, return the base to which
+ the encoding is relative. This base may then be passed to
+ read_encoded_value_with_base for use when the _Unwind_Context is
+ not available. */
+
+STATIC _Unwind_Ptr
+base_of_encoded_value (unsigned char encoding, struct _Unwind_Context *context)
+{
+ if (encoding == DW_EH_PE_omit)
+ return 0;
+
+ switch (encoding & 0x70)
+ {
+ case DW_EH_PE_absptr:
+ case DW_EH_PE_pcrel:
+ case DW_EH_PE_aligned:
+ return 0;
+
+ case DW_EH_PE_textrel:
+ return _Unwind_GetTextRelBase (context);
+ case DW_EH_PE_datarel:
+ return _Unwind_GetDataRelBase (context);
+ case DW_EH_PE_funcrel:
+ return _Unwind_GetRegionStart (context);
+ }
+ __gxx_abort ();
+}
+
+#endif
+
+/* Read an unsigned leb128 value from P, store the value in VAL, return
+ P incremented past the value. We assume that a word is large enough to
+ hold any value so encoded; if it is smaller than a pointer on some target,
+ pointers should not be leb128 encoded on that target. */
+
+STATIC const unsigned char *
+read_uleb128 (const unsigned char *p, _Unwind_Word *val)
+{
+ unsigned int shift = 0;
+ unsigned char byte;
+ _Unwind_Word result;
+
+ result = 0;
+ do
+ {
+ byte = *p++;
+ result |= (byte & 0x7f) << shift;
+ shift += 7;
+ }
+ while (byte & 0x80);
+
+ *val = result;
+ return p;
+}
+
+/* Similar, but read a signed leb128 value. */
+
+STATIC const unsigned char *
+read_sleb128 (const unsigned char *p, _Unwind_Sword *val)
+{
+ unsigned int shift = 0;
+ unsigned char byte;
+ _Unwind_Word result;
+
+ result = 0;
+ do
+ {
+ byte = *p++;
+ result |= (byte & 0x7f) << shift;
+ shift += 7;
+ }
+ while (byte & 0x80);
+
+ /* Sign-extend a negative value. */
+ if (shift < 8 * sizeof(result) && (byte & 0x40) != 0)
+ result |= -(1L << shift);
+
+ *val = (_Unwind_Sword) result;
+ return p;
+}
+
+/* Load an encoded value from memory at P. The value is returned in VAL;
+ The function returns P incremented past the value. BASE is as given
+ by base_of_encoded_value for this encoding in the appropriate context. */
+
+STATIC const unsigned char *
+read_encoded_value_with_base (unsigned char encoding, _Unwind_Ptr base,
+ const unsigned char *p, _Unwind_Ptr *val)
+{
+ union unaligned
+ {
+ void *ptr;
+ unsigned u2 __attribute__ ((mode (HI)));
+ unsigned u4 __attribute__ ((mode (SI)));
+ unsigned u8 __attribute__ ((mode (DI)));
+ signed s2 __attribute__ ((mode (HI)));
+ signed s4 __attribute__ ((mode (SI)));
+ signed s8 __attribute__ ((mode (DI)));
+ } __attribute__((__packed__));
+
+ union unaligned *u = (union unaligned *) p;
+ _Unwind_Internal_Ptr result;
+
+ if (encoding == DW_EH_PE_aligned)
+ {
+ _Unwind_Internal_Ptr a = (_Unwind_Internal_Ptr) p;
+ a = (a + sizeof (void *) - 1) & - sizeof(void *);
+ result = *(_Unwind_Internal_Ptr *) a;
+ p = (const unsigned char *) (a + sizeof (void *));
+ }
+ else
+ {
+ switch (encoding & 0x0f)
+ {
+ case DW_EH_PE_absptr:
+ result = (_Unwind_Internal_Ptr) u->ptr;
+ p += sizeof (void *);
+ break;
+
+ case DW_EH_PE_uleb128:
+ {
+ _Unwind_Word tmp;
+ p = read_uleb128 (p, &tmp);
+ result = (_Unwind_Internal_Ptr) tmp;
+ }
+ break;
+
+ case DW_EH_PE_sleb128:
+ {
+ _Unwind_Sword tmp;
+ p = read_sleb128 (p, &tmp);
+ result = (_Unwind_Internal_Ptr) tmp;
+ }
+ break;
+
+ case DW_EH_PE_udata2:
+ result = u->u2;
+ p += 2;
+ break;
+ case DW_EH_PE_udata4:
+ result = u->u4;
+ p += 4;
+ break;
+ case DW_EH_PE_udata8:
+ result = u->u8;
+ p += 8;
+ break;
+
+ case DW_EH_PE_sdata2:
+ result = u->s2;
+ p += 2;
+ break;
+ case DW_EH_PE_sdata4:
+ result = u->s4;
+ p += 4;
+ break;
+ case DW_EH_PE_sdata8:
+ result = u->s8;
+ p += 8;
+ break;
+
+ default:
+ __gxx_abort ();
+ }
+
+ if (result != 0)
+ {
+ result += ((encoding & 0x70) == DW_EH_PE_pcrel
+ ? (_Unwind_Internal_Ptr) u : base);
+ if (encoding & DW_EH_PE_indirect)
+ result = *(_Unwind_Internal_Ptr *) result;
+ }
+ }
+
+ *val = result;
+ return p;
+}
+
+#ifndef NO_BASE_OF_ENCODED_VALUE
+
+/* Like read_encoded_value_with_base, but get the base from the context
+ rather than providing it directly. */
+
+STATIC const unsigned char *
+read_encoded_value (struct _Unwind_Context *context, unsigned char encoding,
+ const unsigned char *p, _Unwind_Ptr *val)
+{
+ return read_encoded_value_with_base (encoding,
+ base_of_encoded_value (encoding, context),
+ p, val);
+}
+
+#endif
+#endif /* _LIBC */
diff --git a/REORG.TODO/sysdeps/generic/unwind-resume.h b/REORG.TODO/sysdeps/generic/unwind-resume.h
new file mode 100644
index 0000000000..8da6563fad
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/unwind-resume.h
@@ -0,0 +1,33 @@
+/* Definitions for unwind-resume.c. Generic version.
+ Copyright (C) 2015-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+/* These describe the arguments to unwinder personality functions,
+ specifically __gcc_personality_v0. A machine-specific sysdeps
+ file might define them differently. */
+#define PERSONALITY_PROTO \
+ (int version, _Unwind_Action actions, \
+ _Unwind_Exception_Class exception_class, \
+ struct _Unwind_Exception *ue_header, \
+ struct _Unwind_Context *context)
+#define PERSONALITY_ARGS \
+ (version, actions, exception_class, ue_header, context)
+
+/* This is defined nonzero by a machine-specific sysdeps file if
+ _Unwind_Resume is provided separately and thus the generic C
+ version should not be defined. */
+#define HAVE_ARCH_UNWIND_RESUME 0
diff --git a/REORG.TODO/sysdeps/generic/unwind.h b/REORG.TODO/sysdeps/generic/unwind.h
new file mode 100644
index 0000000000..37ec61e33b
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/unwind.h
@@ -0,0 +1,219 @@
+/* Exception handling and frame unwind runtime interface routines.
+ Copyright (C) 2001-2017 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This is derived from the C++ ABI for IA-64. Where we diverge
+ for cross-architecture compatibility are noted with "@@@". */
+
+#ifndef _UNWIND_H
+#define _UNWIND_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Level 1: Base ABI */
+
+/* @@@ The IA-64 ABI uses uint64 throughout. Most places this is
+ inefficient for 32-bit and smaller machines. */
+typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));
+typedef signed _Unwind_Sword __attribute__((__mode__(__unwind_word__)));
+#if defined(__ia64__) && defined(__hpux__)
+typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__)));
+#else
+typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
+#endif
+typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
+
+/* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and
+ consumer of an exception. We'll go along with this for now even on
+ 32-bit machines. We'll need to provide some other option for
+ 16-bit machines and for machines with > 8 bits per byte. */
+typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
+
+/* The unwind interface uses reason codes in several contexts to
+ identify the reasons for failures or other actions. */
+typedef enum
+{
+ _URC_NO_REASON = 0,
+ _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
+ _URC_FATAL_PHASE2_ERROR = 2,
+ _URC_FATAL_PHASE1_ERROR = 3,
+ _URC_NORMAL_STOP = 4,
+ _URC_END_OF_STACK = 5,
+ _URC_HANDLER_FOUND = 6,
+ _URC_INSTALL_CONTEXT = 7,
+ _URC_CONTINUE_UNWIND = 8
+} _Unwind_Reason_Code;
+
+
+/* The unwind interface uses a pointer to an exception header object
+ as its representation of an exception being thrown. In general, the
+ full representation of an exception object is language- and
+ implementation-specific, but it will be prefixed by a header
+ understood by the unwind interface. */
+
+struct _Unwind_Exception;
+
+typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
+ struct _Unwind_Exception *);
+
+struct _Unwind_Exception
+{
+ _Unwind_Exception_Class exception_class;
+ _Unwind_Exception_Cleanup_Fn exception_cleanup;
+ _Unwind_Word private_1;
+ _Unwind_Word private_2;
+
+ /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
+ Taking that literally does not make much sense generically. Instead we
+ provide the maximum alignment required by any type for the machine. */
+} __attribute__((__aligned__));
+
+
+/* The ACTIONS argument to the personality routine is a bitwise OR of one
+ or more of the following constants. */
+typedef int _Unwind_Action;
+
+#define _UA_SEARCH_PHASE 1
+#define _UA_CLEANUP_PHASE 2
+#define _UA_HANDLER_FRAME 4
+#define _UA_FORCE_UNWIND 8
+#define _UA_END_OF_STACK 16
+
+/* This is an opaque type used to refer to a system-specific data
+ structure used by the system unwinder. This context is created and
+ destroyed by the system, and passed to the personality routine
+ during unwinding. */
+struct _Unwind_Context;
+
+/* Raise an exception, passing along the given exception object. */
+extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
+
+/* Raise an exception for forced unwinding. */
+
+typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
+ (int, _Unwind_Action, _Unwind_Exception_Class,
+ struct _Unwind_Exception *, struct _Unwind_Context *, void *);
+
+extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
+ _Unwind_Stop_Fn,
+ void *);
+
+/* Helper to invoke the exception_cleanup routine. */
+extern void _Unwind_DeleteException (struct _Unwind_Exception *);
+
+/* Resume propagation of an existing exception. This is used after
+ e.g. executing cleanup code, and not to implement rethrowing. */
+extern void _Unwind_Resume (struct _Unwind_Exception *);
+
+/* @@@ Use unwind data to perform a stack backtrace. The trace callback
+ is called for every stack frame in the call chain, but no cleanup
+ actions are performed. */
+typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
+ (struct _Unwind_Context *, void *);
+
+extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
+
+/* These functions are used for communicating information about the unwind
+ context (i.e. the unwind descriptors and the user register state) between
+ the unwind library and the personality routine and landing pad. Only
+ selected registers maybe manipulated. */
+
+extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int);
+extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
+
+extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
+extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
+
+/* @@@ Retrieve the CFA of the given context. */
+extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
+
+extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *);
+
+extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *);
+
+
+/* The personality routine is the function in the C++ (or other language)
+ runtime library which serves as an interface between the system unwind
+ library and language-specific exception handling semantics. It is
+ specific to the code fragment described by an unwind info block, and
+ it is always referenced via the pointer in the unwind info block, and
+ hence it has no ABI-specified name.
+
+ Note that this implies that two different C++ implementations can
+ use different names, and have different contents in the language
+ specific data area. Moreover, that the language specific data
+ area contains no version info because name of the function invoked
+ provides more effective versioning by detecting at link time the
+ lack of code to handle the different data format. */
+
+typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
+ (int, _Unwind_Action, _Unwind_Exception_Class,
+ struct _Unwind_Exception *, struct _Unwind_Context *);
+
+/* @@@ The following alternate entry points are for setjmp/longjmp
+ based unwinding. */
+
+struct SjLj_Function_Context;
+extern void _Unwind_SjLj_Register (struct SjLj_Function_Context *);
+extern void _Unwind_SjLj_Unregister (struct SjLj_Function_Context *);
+
+extern _Unwind_Reason_Code _Unwind_SjLj_RaiseException
+ (struct _Unwind_Exception *);
+extern _Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind
+ (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
+extern void _Unwind_SjLj_Resume (struct _Unwind_Exception *);
+
+/* @@@ The following provide access to the base addresses for text
+ and data-relative addressing in the LDSA. In order to stay link
+ compatible with the standard ABI for IA-64, we inline these. */
+
+#ifdef __ia64__
+#include <stdlib.h>
+
+static inline _Unwind_Ptr
+_Unwind_GetDataRelBase (struct _Unwind_Context *_C)
+{
+ /* The GP is stored in R1. */
+ return _Unwind_GetGR (_C, 1);
+}
+
+static inline _Unwind_Ptr
+_Unwind_GetTextRelBase (struct _Unwind_Context *_C)
+{
+ abort ();
+ return 0;
+}
+
+/* @@@ Retrieve the Backing Store Pointer of the given context. */
+extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *);
+#else
+extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
+extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
+#endif
+
+/* @@@ Given an address, return the entry point of the function that
+ contains it. */
+extern void * _Unwind_FindEnclosingFunction (void *pc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* unwind.h */
diff --git a/REORG.TODO/sysdeps/generic/utmp-equal.h b/REORG.TODO/sysdeps/generic/utmp-equal.h
new file mode 100644
index 0000000000..6205bbb365
--- /dev/null
+++ b/REORG.TODO/sysdeps/generic/utmp-equal.h
@@ -0,0 +1,52 @@
+/* Helper function for utmp functions to see if two entries are equal.
+ Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>
+ and Paul Janzen <pcj@primenet.com>, 1996.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <string.h>
+#include <utmp.h>
+
+#include "utmp-private.h"
+
+/* Test whether two entries match. */
+static int
+__utmp_equal (const struct utmp *entry, const struct utmp *match)
+{
+ return
+ (
+#if _HAVE_UT_TYPE - 0
+ (entry->ut_type == INIT_PROCESS
+ || entry->ut_type == LOGIN_PROCESS
+ || entry->ut_type == USER_PROCESS
+ || entry->ut_type == DEAD_PROCESS)
+ &&
+ (match->ut_type == INIT_PROCESS
+ || match->ut_type == LOGIN_PROCESS
+ || match->ut_type == USER_PROCESS
+ || match->ut_type == DEAD_PROCESS)
+ &&
+#endif
+#if _HAVE_UT_ID - 0
+ (entry->ut_id[0] && match->ut_id[0]
+ ? strncmp (entry->ut_id, match->ut_id, sizeof match->ut_id) == 0
+ : strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line) == 0)
+#else
+ strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line) == 0
+#endif
+ );
+}