summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/glibc/glibc
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2019-12-07 10:40:41 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-12-28 23:25:34 +0000
commit85b86bc810dcde3357d681ca8043883f2f4fdba0 (patch)
tree1d098e39d4bc694425893a04fbb7201ad6515e53 /meta/recipes-core/glibc/glibc
parent6e57378d4c5ffc3317298f8c0a844bfee479a098 (diff)
downloadopenembedded-core-contrib-85b86bc810dcde3357d681ca8043883f2f4fdba0.tar.gz
cross-localedef: Re-arrange patches
Patches are currently, crossing across repo boundaries, between glibc and localedef, therefore it is better to divide the patches accordiningly, with this patchset makery patch is spun out since that applies to localedef alone. There are no other code changes Signed-off-by: Khem Raj <raj.khem@gmail.com> Cc: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/recipes-core/glibc/glibc')
-rw-r--r--meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch (renamed from meta/recipes-core/glibc/glibc/add-cross-localedef-hardlink.patch)915
-rw-r--r--meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch (renamed from meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch)50
-rw-r--r--meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch55
3 files changed, 551 insertions, 469 deletions
diff --git a/meta/recipes-core/glibc/glibc/add-cross-localedef-hardlink.patch b/meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch
index 8471121949..b7fb0321c4 100644
--- a/meta/recipes-core/glibc/glibc/add-cross-localedef-hardlink.patch
+++ b/meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch
@@ -1,10 +1,467 @@
+From 9e5e5297d9a5ef66b3920313356bf7f25955dff3 Mon Sep 17 00:00:00 2001
+From: Jason Wessel <jason.wessel@windriver.com>
+Date: Sat, 7 Dec 2019 09:59:22 -0800
+Subject: [PATCH] Add hardlink resolver from util-linux
+
+The hard link resolver that is built into localedef cannot be run in
+parallel. It will search sibling directories (which are be processed
+in parallel) and perform a creation of a .tmp file and remove the
+original and move the .tmp file in. The problem is that if a probe
+occurs a hard link can be requested to the file that is being removed.
+This will lead to a stray copy or potentially, on a loaded system
+cause race condition which pseudo cannot deal with, where it is left
+with a hard link request to a file that no longer exists. In this
+situation psuedo will inherit the permissions of what ever the target
+inode had to offer.
+
+In short, there are two problems:
+
+1) You will be left with stray copies when using the hard link
+resolution that is built in while running in parallel with
+localedef.
+
+2) When running under pseudo the possibility exists for uid/gid
+leakage when the source file is removed before the hard link can
+be completed.
+
+The solution is to call localedef with --no-hard-links and separately
+process the hardlinks at a later point. To do this requires the
+inclusion of the hardlink utility found in modern versions of
+util-linux. Most host systems do not have this, so it will be
+included with the cross-localedef binary.
+
+[YOCTO #11299]
+[YOCTO #12434]
+
+Upstream-Status: Pending
+
+Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
- locale/programs/c.h | 407 ++++++++++++++++++++++
- locale/programs/cross-localedef-hardlink.c | 528 +++++++++++++++++++++++++++++
- locale/programs/xalloc.h | 129 +++++++
- localedef/Makefile.in | 8
- 4 files changed, 1071 insertions(+), 1 deletion(-)
+ locale/programs/c.h | 407 ++++++++++++++++
+ locale/programs/cross-localedef-hardlink.c | 528 +++++++++++++++++++++
+ locale/programs/xalloc.h | 129 +++++
+ 3 files changed, 1064 insertions(+)
+ create mode 100644 locale/programs/c.h
+ create mode 100644 locale/programs/cross-localedef-hardlink.c
+ create mode 100644 locale/programs/xalloc.h
+diff --git a/locale/programs/c.h b/locale/programs/c.h
+new file mode 100644
+index 0000000000..d0a402e90e
+--- /dev/null
++++ b/locale/programs/c.h
+@@ -0,0 +1,407 @@
++/*
++ * Fundamental C definitions.
++ */
++
++#ifndef UTIL_LINUX_C_H
++#define UTIL_LINUX_C_H
++
++#include <limits.h>
++#include <stddef.h>
++#include <stdint.h>
++#include <stdio.h>
++#include <unistd.h>
++#include <stdarg.h>
++#include <stdlib.h>
++#include <string.h>
++#include <errno.h>
++
++#include <assert.h>
++
++#ifdef HAVE_ERR_H
++# include <err.h>
++#endif
++
++#ifdef HAVE_SYS_SYSMACROS_H
++# include <sys/sysmacros.h> /* for major, minor */
++#endif
++
++#ifndef LOGIN_NAME_MAX
++# define LOGIN_NAME_MAX 256
++#endif
++
++#ifndef NAME_MAX
++# define NAME_MAX PATH_MAX
++#endif
++
++/*
++ * __GNUC_PREREQ is deprecated in favour of __has_attribute() and
++ * __has_feature(). The __has macros are supported by clang and gcc>=5.
++ */
++#ifndef __GNUC_PREREQ
++# if defined __GNUC__ && defined __GNUC_MINOR__
++# define __GNUC_PREREQ(maj, min) \
++ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
++# else
++# define __GNUC_PREREQ(maj, min) 0
++# endif
++#endif
++
++#ifdef __GNUC__
++
++/* &a[0] degrades to a pointer: a different type from an array */
++# define __must_be_array(a) \
++ UL_BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(__typeof__(a), __typeof__(&a[0])))
++
++# define ignore_result(x) __extension__ ({ \
++ __typeof__(x) __dummy __attribute__((__unused__)) = (x); (void) __dummy; \
++})
++
++#else /* !__GNUC__ */
++# define __must_be_array(a) 0
++# define __attribute__(_arg_)
++# define ignore_result(x) ((void) (x))
++#endif /* !__GNUC__ */
++
++/*
++ * It evaluates to 1 if the attribute/feature is supported by the current
++ * compilation targed. Fallback for old compilers.
++ */
++#ifndef __has_attribute
++ #define __has_attribute(x) 0
++#endif
++
++#ifndef __has_feature
++ #define __has_feature(x) 0
++#endif
++
++/*
++ * Function attributes
++ */
++#ifndef __ul_alloc_size
++# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3)
++# define __ul_alloc_size(s) __attribute__((alloc_size(s), warn_unused_result))
++# else
++# define __ul_alloc_size(s)
++# endif
++#endif
++
++#ifndef __ul_calloc_size
++# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3)
++# define __ul_calloc_size(n, s) __attribute__((alloc_size(n, s), warn_unused_result))
++# else
++# define __ul_calloc_size(n, s)
++# endif
++#endif
++
++#if __has_attribute(returns_nonnull) || __GNUC_PREREQ (4, 9)
++# define __ul_returns_nonnull __attribute__((returns_nonnull))
++#else
++# define __ul_returns_nonnull
++#endif
++
++/*
++ * Force a compilation error if condition is true, but also produce a
++ * result (of value 0 and type size_t), so the expression can be used
++ * e.g. in a structure initializer (or wherever else comma expressions
++ * aren't permitted).
++ */
++#define UL_BUILD_BUG_ON_ZERO(e) __extension__ (sizeof(struct { int:-!!(e); }))
++#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
++
++#ifndef ARRAY_SIZE
++# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
++#endif
++
++#ifndef PATH_MAX
++# define PATH_MAX 4096
++#endif
++
++#ifndef TRUE
++# define TRUE 1
++#endif
++
++#ifndef FALSE
++# define FALSE 0
++#endif
++
++#ifndef min
++# define min(x, y) __extension__ ({ \
++ __typeof__(x) _min1 = (x); \
++ __typeof__(y) _min2 = (y); \
++ (void) (&_min1 == &_min2); \
++ _min1 < _min2 ? _min1 : _min2; })
++#endif
++
++#ifndef max
++# define max(x, y) __extension__ ({ \
++ __typeof__(x) _max1 = (x); \
++ __typeof__(y) _max2 = (y); \
++ (void) (&_max1 == &_max2); \
++ _max1 > _max2 ? _max1 : _max2; })
++#endif
++
++#ifndef cmp_numbers
++# define cmp_numbers(x, y) __extension__ ({ \
++ __typeof__(x) _a = (x); \
++ __typeof__(y) _b = (y); \
++ (void) (&_a == &_b); \
++ _a == _b ? 0 : _a > _b ? 1 : -1; })
++#endif
++
++#ifndef offsetof
++#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
++#endif
++
++/*
++ * container_of - cast a member of a structure out to the containing structure
++ * @ptr: the pointer to the member.
++ * @type: the type of the container struct this is embedded in.
++ * @member: the name of the member within the struct.
++ */
++#ifndef container_of
++#define container_of(ptr, type, member) __extension__ ({ \
++ const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
++ (type *)( (char *)__mptr - offsetof(type,member) );})
++#endif
++
++#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
++# ifdef HAVE___PROGNAME
++extern char *__progname;
++# define program_invocation_short_name __progname
++# else
++# ifdef HAVE_GETEXECNAME
++# define program_invocation_short_name \
++ prog_inv_sh_nm_from_file(getexecname(), 0)
++# else
++# define program_invocation_short_name \
++ prog_inv_sh_nm_from_file(__FILE__, 1)
++# endif
++static char prog_inv_sh_nm_buf[256];
++static inline char *
++prog_inv_sh_nm_from_file(char *f, char stripext)
++{
++ char *t;
++
++ if ((t = strrchr(f, '/')) != NULL)
++ t++;
++ else
++ t = f;
++
++ strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1);
++ prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0';
++
++ if (stripext && (t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL)
++ *t = '\0';
++
++ return prog_inv_sh_nm_buf;
++}
++# endif
++#endif
++
++
++#ifndef HAVE_ERR_H
++static inline void
++errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
++{
++ fprintf(stderr, "%s: ", program_invocation_short_name);
++ if (fmt != NULL) {
++ va_list argp;
++ va_start(argp, fmt);
++ vfprintf(stderr, fmt, argp);
++ va_end(argp);
++ if (adderr)
++ fprintf(stderr, ": ");
++ }
++ if (adderr)
++ fprintf(stderr, "%m");
++ fprintf(stderr, "\n");
++ if (doexit)
++ exit(excode);
++}
++
++#ifndef HAVE_ERR
++# define err(E, FMT...) errmsg(1, E, 1, FMT)
++#endif
++
++#ifndef HAVE_ERRX
++# define errx(E, FMT...) errmsg(1, E, 0, FMT)
++#endif
++
++#ifndef HAVE_WARN
++# define warn(FMT...) errmsg(0, 0, 1, FMT)
++#endif
++
++#ifndef HAVE_WARNX
++# define warnx(FMT...) errmsg(0, 0, 0, FMT)
++#endif
++#endif /* !HAVE_ERR_H */
++
++
++/* Don't use inline function to avoid '#include "nls.h"' in c.h
++ */
++#define errtryhelp(eval) __extension__ ({ \
++ fprintf(stderr, _("Try '%s --help' for more information.\n"), \
++ program_invocation_short_name); \
++ exit(eval); \
++})
++
++/* After failed execvp() */
++#define EX_EXEC_FAILED 126 /* Program located, but not usable. */
++#define EX_EXEC_ENOENT 127 /* Could not find program to exec. */
++#define errexec(name) err(errno == ENOENT ? EX_EXEC_ENOENT : EX_EXEC_FAILED, \
++ _("failed to execute %s"), name)
++
++
++static inline __attribute__((const)) int is_power_of_2(unsigned long num)
++{
++ return (num != 0 && ((num & (num - 1)) == 0));
++}
++
++#ifndef HAVE_LOFF_T
++typedef int64_t loff_t;
++#endif
++
++#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD)
++#include <sys/types.h>
++#include <dirent.h>
++static inline int dirfd(DIR *d)
++{
++ return d->dd_fd;
++}
++#endif
++
++/*
++ * Fallback defines for old versions of glibc
++ */
++#include <fcntl.h>
++
++#ifdef O_CLOEXEC
++#define UL_CLOEXECSTR "e"
++#else
++#define UL_CLOEXECSTR ""
++#endif
++
++#ifndef O_CLOEXEC
++#define O_CLOEXEC 0
++#endif
++
++#ifdef __FreeBSD_kernel__
++#ifndef F_DUPFD_CLOEXEC
++#define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */
++#endif
++#endif
++
++
++#ifndef AI_ADDRCONFIG
++#define AI_ADDRCONFIG 0x0020
++#endif
++
++#ifndef IUTF8
++#define IUTF8 0040000
++#endif
++
++/*
++ * MAXHOSTNAMELEN replacement
++ */
++static inline size_t get_hostname_max(void)
++{
++ long len = sysconf(_SC_HOST_NAME_MAX);
++
++ if (0 < len)
++ return len;
++
++#ifdef MAXHOSTNAMELEN
++ return MAXHOSTNAMELEN;
++#elif HOST_NAME_MAX
++ return HOST_NAME_MAX;
++#endif
++ return 64;
++}
++
++
++/*
++ * Constant strings for usage() functions. For more info see
++ * Documentation/{howto-usage-function.txt,boilerplate.c}
++ */
++#define USAGE_HEADER ("\nUsage:\n")
++#define USAGE_OPTIONS ("\nOptions:\n")
++#define USAGE_FUNCTIONS ("\nFunctions:\n")
++#define USAGE_COMMANDS ("\nCommands:\n")
++#define USAGE_COLUMNS ("\nAvailable output columns:\n")
++#define USAGE_SEPARATOR "\n"
++
++#define USAGE_OPTSTR_HELP ("display this help")
++#define USAGE_OPTSTR_VERSION ("display version")
++
++#define USAGE_HELP_OPTIONS(marg_dsc) \
++ "%-" #marg_dsc "s%s\n" \
++ "%-" #marg_dsc "s%s\n" \
++ , " -h, --help", USAGE_OPTSTR_HELP \
++ , " -V, --version", USAGE_OPTSTR_VERSION
++
++#define USAGE_MAN_TAIL(_man) ("\nFor more details see %s.\n"), _man
++
++#define UTIL_LINUX_VERSION ("%s from %s\n"), program_invocation_short_name, PACKAGE_STRING
++
++#define print_version(eval) __extension__ ({ \
++ printf(UTIL_LINUX_VERSION); \
++ exit(eval); \
++})
++
++/*
++ * scanf modifiers for "strings allocation"
++ */
++#ifdef HAVE_SCANF_MS_MODIFIER
++#define UL_SCNsA "%ms"
++#elif defined(HAVE_SCANF_AS_MODIFIER)
++#define UL_SCNsA "%as"
++#endif
++
++/*
++ * seek stuff
++ */
++#ifndef SEEK_DATA
++# define SEEK_DATA 3
++#endif
++#ifndef SEEK_HOLE
++# define SEEK_HOLE 4
++#endif
++
++
++/*
++ * Macros to convert #define'itions to strings, for example
++ * #define XYXXY 42
++ * printf ("%s=%s\n", stringify(XYXXY), stringify_value(XYXXY));
++ */
++#define stringify_value(s) stringify(s)
++#define stringify(s) #s
++
++/*
++ * UL_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time
++ * instrumentation shipped with Clang and GCC) to not instrument the
++ * annotated function. Furthermore, it will prevent the compiler from
++ * inlining the function because inlining currently breaks the blacklisting
++ * mechanism of AddressSanitizer.
++ */
++#if __has_feature(address_sanitizer) && __has_attribute(no_sanitize_memory) && __has_attribute(no_sanitize_address)
++# define UL_ASAN_BLACKLIST __attribute__((noinline)) __attribute__((no_sanitize_memory)) __attribute__((no_sanitize_address))
++#else
++# define UL_ASAN_BLACKLIST /* nothing */
++#endif
++
++/*
++ * Note that sysconf(_SC_GETPW_R_SIZE_MAX) returns *initial* suggested size for
++ * pwd buffer and in some cases it is not large enough. See POSIX and
++ * getpwnam_r man page for more details.
++ */
++#define UL_GETPW_BUFSIZ (16 * 1024)
++
++/*
++ * Darwin or other BSDs may only have MAP_ANON. To get it on Darwin we must
++ * define _DARWIN_C_SOURCE before including sys/mman.h. We do this in config.h.
++ */
++#if !defined MAP_ANONYMOUS && defined MAP_ANON
++# define MAP_ANONYMOUS (MAP_ANON)
++#endif
++
++#endif /* UTIL_LINUX_C_H */
+diff --git a/locale/programs/cross-localedef-hardlink.c b/locale/programs/cross-localedef-hardlink.c
+new file mode 100644
+index 0000000000..63615896b0
--- /dev/null
+++ b/locale/programs/cross-localedef-hardlink.c
@@ -0,0 +1,528 @@
@@ -536,451 +993,9 @@
+
+ return 0;
+}
---- a/localedef/Makefile.in
-+++ b/localedef/Makefile.in
-@@ -40,6 +40,8 @@ WARNFLAGS = -Wall -Wno-format
- FULLCC = $(CC) $(CPPFLAGS) $(CFLAGS) \
- $(DEFINES) $(INCLUDES) $(WARNFLAGS)
-
-+CROSS_LOCALEDEF_HARDLINK_OBJS = cross-localedef-hardlink.o
-+
- LOCALEDEF_OBJS = charmap.o charmap-dir.o ld-address.o ld-collate.o \
- ld-ctype.o ld-identification.o ld-measurement.o \
- ld-messages.o ld-monetary.o ld-name.o ld-numeric.o \
-@@ -54,11 +56,14 @@ LOCALEDEF_OBJS = charmap.o charmap-dir.o
- asprintf.o getdelim.o localedef_extra.o \
- obstack_printf.o vasprintf.o
-
--all: localedef$(EXEEXT)
-+all: localedef$(EXEEXT) cross-localedef-hardlink$(EXEEXT)
-
- localedef$(EXEEXT): $(LOCALEDEF_OBJS)
- $(CC) -o $@ $(LOCALEDEF_OBJS) $(LIBS)
-
-+cross-localedef-hardlink$(EXEEXT): $(CROSS_LOCALEDEF_HARDLINK_OBJS)
-+ $(CC) -o $@ $(CROSS_LOCALEDEF_HARDLINK_OBJS) $(LIBS)
-+
- clean:
- rm -f locale$(EXEEXT) $(LOCALEDEF_OBJS)
-
-@@ -77,6 +82,7 @@ clean:
- %.o: $(srcdir)/%.c
- $(FULLCC) -c -o $@ $<
-
-+cross-localedef-hardlink.o: glibc/locale/programs/cross-localedef-hardlink.c
- charmap.o: glibc/locale/programs/charmap.c
- charmap-dir.o: glibc/locale/programs/charmap-dir.c
- ld-address.o: glibc/locale/programs/ld-address.c
---- /dev/null
-+++ b/locale/programs/c.h
-@@ -0,0 +1,407 @@
-+/*
-+ * Fundamental C definitions.
-+ */
-+
-+#ifndef UTIL_LINUX_C_H
-+#define UTIL_LINUX_C_H
-+
-+#include <limits.h>
-+#include <stddef.h>
-+#include <stdint.h>
-+#include <stdio.h>
-+#include <unistd.h>
-+#include <stdarg.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <errno.h>
-+
-+#include <assert.h>
-+
-+#ifdef HAVE_ERR_H
-+# include <err.h>
-+#endif
-+
-+#ifdef HAVE_SYS_SYSMACROS_H
-+# include <sys/sysmacros.h> /* for major, minor */
-+#endif
-+
-+#ifndef LOGIN_NAME_MAX
-+# define LOGIN_NAME_MAX 256
-+#endif
-+
-+#ifndef NAME_MAX
-+# define NAME_MAX PATH_MAX
-+#endif
-+
-+/*
-+ * __GNUC_PREREQ is deprecated in favour of __has_attribute() and
-+ * __has_feature(). The __has macros are supported by clang and gcc>=5.
-+ */
-+#ifndef __GNUC_PREREQ
-+# if defined __GNUC__ && defined __GNUC_MINOR__
-+# define __GNUC_PREREQ(maj, min) \
-+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-+# else
-+# define __GNUC_PREREQ(maj, min) 0
-+# endif
-+#endif
-+
-+#ifdef __GNUC__
-+
-+/* &a[0] degrades to a pointer: a different type from an array */
-+# define __must_be_array(a) \
-+ UL_BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(__typeof__(a), __typeof__(&a[0])))
-+
-+# define ignore_result(x) __extension__ ({ \
-+ __typeof__(x) __dummy __attribute__((__unused__)) = (x); (void) __dummy; \
-+})
-+
-+#else /* !__GNUC__ */
-+# define __must_be_array(a) 0
-+# define __attribute__(_arg_)
-+# define ignore_result(x) ((void) (x))
-+#endif /* !__GNUC__ */
-+
-+/*
-+ * It evaluates to 1 if the attribute/feature is supported by the current
-+ * compilation targed. Fallback for old compilers.
-+ */
-+#ifndef __has_attribute
-+ #define __has_attribute(x) 0
-+#endif
-+
-+#ifndef __has_feature
-+ #define __has_feature(x) 0
-+#endif
-+
-+/*
-+ * Function attributes
-+ */
-+#ifndef __ul_alloc_size
-+# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3)
-+# define __ul_alloc_size(s) __attribute__((alloc_size(s), warn_unused_result))
-+# else
-+# define __ul_alloc_size(s)
-+# endif
-+#endif
-+
-+#ifndef __ul_calloc_size
-+# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3)
-+# define __ul_calloc_size(n, s) __attribute__((alloc_size(n, s), warn_unused_result))
-+# else
-+# define __ul_calloc_size(n, s)
-+# endif
-+#endif
-+
-+#if __has_attribute(returns_nonnull) || __GNUC_PREREQ (4, 9)
-+# define __ul_returns_nonnull __attribute__((returns_nonnull))
-+#else
-+# define __ul_returns_nonnull
-+#endif
-+
-+/*
-+ * Force a compilation error if condition is true, but also produce a
-+ * result (of value 0 and type size_t), so the expression can be used
-+ * e.g. in a structure initializer (or wherever else comma expressions
-+ * aren't permitted).
-+ */
-+#define UL_BUILD_BUG_ON_ZERO(e) __extension__ (sizeof(struct { int:-!!(e); }))
-+#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
-+
-+#ifndef ARRAY_SIZE
-+# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
-+#endif
-+
-+#ifndef PATH_MAX
-+# define PATH_MAX 4096
-+#endif
-+
-+#ifndef TRUE
-+# define TRUE 1
-+#endif
-+
-+#ifndef FALSE
-+# define FALSE 0
-+#endif
-+
-+#ifndef min
-+# define min(x, y) __extension__ ({ \
-+ __typeof__(x) _min1 = (x); \
-+ __typeof__(y) _min2 = (y); \
-+ (void) (&_min1 == &_min2); \
-+ _min1 < _min2 ? _min1 : _min2; })
-+#endif
-+
-+#ifndef max
-+# define max(x, y) __extension__ ({ \
-+ __typeof__(x) _max1 = (x); \
-+ __typeof__(y) _max2 = (y); \
-+ (void) (&_max1 == &_max2); \
-+ _max1 > _max2 ? _max1 : _max2; })
-+#endif
-+
-+#ifndef cmp_numbers
-+# define cmp_numbers(x, y) __extension__ ({ \
-+ __typeof__(x) _a = (x); \
-+ __typeof__(y) _b = (y); \
-+ (void) (&_a == &_b); \
-+ _a == _b ? 0 : _a > _b ? 1 : -1; })
-+#endif
-+
-+#ifndef offsetof
-+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-+#endif
-+
-+/*
-+ * container_of - cast a member of a structure out to the containing structure
-+ * @ptr: the pointer to the member.
-+ * @type: the type of the container struct this is embedded in.
-+ * @member: the name of the member within the struct.
-+ */
-+#ifndef container_of
-+#define container_of(ptr, type, member) __extension__ ({ \
-+ const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
-+ (type *)( (char *)__mptr - offsetof(type,member) );})
-+#endif
-+
-+#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
-+# ifdef HAVE___PROGNAME
-+extern char *__progname;
-+# define program_invocation_short_name __progname
-+# else
-+# ifdef HAVE_GETEXECNAME
-+# define program_invocation_short_name \
-+ prog_inv_sh_nm_from_file(getexecname(), 0)
-+# else
-+# define program_invocation_short_name \
-+ prog_inv_sh_nm_from_file(__FILE__, 1)
-+# endif
-+static char prog_inv_sh_nm_buf[256];
-+static inline char *
-+prog_inv_sh_nm_from_file(char *f, char stripext)
-+{
-+ char *t;
-+
-+ if ((t = strrchr(f, '/')) != NULL)
-+ t++;
-+ else
-+ t = f;
-+
-+ strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1);
-+ prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0';
-+
-+ if (stripext && (t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL)
-+ *t = '\0';
-+
-+ return prog_inv_sh_nm_buf;
-+}
-+# endif
-+#endif
-+
-+
-+#ifndef HAVE_ERR_H
-+static inline void
-+errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
-+{
-+ fprintf(stderr, "%s: ", program_invocation_short_name);
-+ if (fmt != NULL) {
-+ va_list argp;
-+ va_start(argp, fmt);
-+ vfprintf(stderr, fmt, argp);
-+ va_end(argp);
-+ if (adderr)
-+ fprintf(stderr, ": ");
-+ }
-+ if (adderr)
-+ fprintf(stderr, "%m");
-+ fprintf(stderr, "\n");
-+ if (doexit)
-+ exit(excode);
-+}
-+
-+#ifndef HAVE_ERR
-+# define err(E, FMT...) errmsg(1, E, 1, FMT)
-+#endif
-+
-+#ifndef HAVE_ERRX
-+# define errx(E, FMT...) errmsg(1, E, 0, FMT)
-+#endif
-+
-+#ifndef HAVE_WARN
-+# define warn(FMT...) errmsg(0, 0, 1, FMT)
-+#endif
-+
-+#ifndef HAVE_WARNX
-+# define warnx(FMT...) errmsg(0, 0, 0, FMT)
-+#endif
-+#endif /* !HAVE_ERR_H */
-+
-+
-+/* Don't use inline function to avoid '#include "nls.h"' in c.h
-+ */
-+#define errtryhelp(eval) __extension__ ({ \
-+ fprintf(stderr, _("Try '%s --help' for more information.\n"), \
-+ program_invocation_short_name); \
-+ exit(eval); \
-+})
-+
-+/* After failed execvp() */
-+#define EX_EXEC_FAILED 126 /* Program located, but not usable. */
-+#define EX_EXEC_ENOENT 127 /* Could not find program to exec. */
-+#define errexec(name) err(errno == ENOENT ? EX_EXEC_ENOENT : EX_EXEC_FAILED, \
-+ _("failed to execute %s"), name)
-+
-+
-+static inline __attribute__((const)) int is_power_of_2(unsigned long num)
-+{
-+ return (num != 0 && ((num & (num - 1)) == 0));
-+}
-+
-+#ifndef HAVE_LOFF_T
-+typedef int64_t loff_t;
-+#endif
-+
-+#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD)
-+#include <sys/types.h>
-+#include <dirent.h>
-+static inline int dirfd(DIR *d)
-+{
-+ return d->dd_fd;
-+}
-+#endif
-+
-+/*
-+ * Fallback defines for old versions of glibc
-+ */
-+#include <fcntl.h>
-+
-+#ifdef O_CLOEXEC
-+#define UL_CLOEXECSTR "e"
-+#else
-+#define UL_CLOEXECSTR ""
-+#endif
-+
-+#ifndef O_CLOEXEC
-+#define O_CLOEXEC 0
-+#endif
-+
-+#ifdef __FreeBSD_kernel__
-+#ifndef F_DUPFD_CLOEXEC
-+#define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */
-+#endif
-+#endif
-+
-+
-+#ifndef AI_ADDRCONFIG
-+#define AI_ADDRCONFIG 0x0020
-+#endif
-+
-+#ifndef IUTF8
-+#define IUTF8 0040000
-+#endif
-+
-+/*
-+ * MAXHOSTNAMELEN replacement
-+ */
-+static inline size_t get_hostname_max(void)
-+{
-+ long len = sysconf(_SC_HOST_NAME_MAX);
-+
-+ if (0 < len)
-+ return len;
-+
-+#ifdef MAXHOSTNAMELEN
-+ return MAXHOSTNAMELEN;
-+#elif HOST_NAME_MAX
-+ return HOST_NAME_MAX;
-+#endif
-+ return 64;
-+}
-+
-+
-+/*
-+ * Constant strings for usage() functions. For more info see
-+ * Documentation/{howto-usage-function.txt,boilerplate.c}
-+ */
-+#define USAGE_HEADER ("\nUsage:\n")
-+#define USAGE_OPTIONS ("\nOptions:\n")
-+#define USAGE_FUNCTIONS ("\nFunctions:\n")
-+#define USAGE_COMMANDS ("\nCommands:\n")
-+#define USAGE_COLUMNS ("\nAvailable output columns:\n")
-+#define USAGE_SEPARATOR "\n"
-+
-+#define USAGE_OPTSTR_HELP ("display this help")
-+#define USAGE_OPTSTR_VERSION ("display version")
-+
-+#define USAGE_HELP_OPTIONS(marg_dsc) \
-+ "%-" #marg_dsc "s%s\n" \
-+ "%-" #marg_dsc "s%s\n" \
-+ , " -h, --help", USAGE_OPTSTR_HELP \
-+ , " -V, --version", USAGE_OPTSTR_VERSION
-+
-+#define USAGE_MAN_TAIL(_man) ("\nFor more details see %s.\n"), _man
-+
-+#define UTIL_LINUX_VERSION ("%s from %s\n"), program_invocation_short_name, PACKAGE_STRING
-+
-+#define print_version(eval) __extension__ ({ \
-+ printf(UTIL_LINUX_VERSION); \
-+ exit(eval); \
-+})
-+
-+/*
-+ * scanf modifiers for "strings allocation"
-+ */
-+#ifdef HAVE_SCANF_MS_MODIFIER
-+#define UL_SCNsA "%ms"
-+#elif defined(HAVE_SCANF_AS_MODIFIER)
-+#define UL_SCNsA "%as"
-+#endif
-+
-+/*
-+ * seek stuff
-+ */
-+#ifndef SEEK_DATA
-+# define SEEK_DATA 3
-+#endif
-+#ifndef SEEK_HOLE
-+# define SEEK_HOLE 4
-+#endif
-+
-+
-+/*
-+ * Macros to convert #define'itions to strings, for example
-+ * #define XYXXY 42
-+ * printf ("%s=%s\n", stringify(XYXXY), stringify_value(XYXXY));
-+ */
-+#define stringify_value(s) stringify(s)
-+#define stringify(s) #s
-+
-+/*
-+ * UL_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time
-+ * instrumentation shipped with Clang and GCC) to not instrument the
-+ * annotated function. Furthermore, it will prevent the compiler from
-+ * inlining the function because inlining currently breaks the blacklisting
-+ * mechanism of AddressSanitizer.
-+ */
-+#if __has_feature(address_sanitizer) && __has_attribute(no_sanitize_memory) && __has_attribute(no_sanitize_address)
-+# define UL_ASAN_BLACKLIST __attribute__((noinline)) __attribute__((no_sanitize_memory)) __attribute__((no_sanitize_address))
-+#else
-+# define UL_ASAN_BLACKLIST /* nothing */
-+#endif
-+
-+/*
-+ * Note that sysconf(_SC_GETPW_R_SIZE_MAX) returns *initial* suggested size for
-+ * pwd buffer and in some cases it is not large enough. See POSIX and
-+ * getpwnam_r man page for more details.
-+ */
-+#define UL_GETPW_BUFSIZ (16 * 1024)
-+
-+/*
-+ * Darwin or other BSDs may only have MAP_ANON. To get it on Darwin we must
-+ * define _DARWIN_C_SOURCE before including sys/mman.h. We do this in config.h.
-+ */
-+#if !defined MAP_ANONYMOUS && defined MAP_ANON
-+# define MAP_ANONYMOUS (MAP_ANON)
-+#endif
-+
-+#endif /* UTIL_LINUX_C_H */
+diff --git a/locale/programs/xalloc.h b/locale/programs/xalloc.h
+new file mode 100644
+index 0000000000..0129a85e2e
--- /dev/null
+++ b/locale/programs/xalloc.h
@@ -0,0 +1,129 @@
diff --git a/meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch b/meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch
index 1148ebfcc7..1a5f6b6825 100644
--- a/meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch
+++ b/meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch
@@ -1,8 +1,31 @@
+From d08f436635cb9d627ebae4512105708d28fc36fe Mon Sep 17 00:00:00 2001
+From: Jason Wessel <jason.wessel@windriver.com>
+Date: Sat, 7 Dec 2019 10:01:37 -0800
+Subject: [PATCH] hardlink: fix-ups to make it compile
+
+Upstream-Status: Pending
+Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
- locale/programs/c.h | 2
- locale/programs/cross-localedef-hardlink.c | 79 +++++++++++++----------------
+ locale/programs/c.h | 2 +-
+ locale/programs/cross-localedef-hardlink.c | 79 +++++++++++-----------
2 files changed, 39 insertions(+), 42 deletions(-)
+diff --git a/locale/programs/c.h b/locale/programs/c.h
+index d0a402e90e..1804d31c73 100644
+--- a/locale/programs/c.h
++++ b/locale/programs/c.h
+@@ -240,7 +240,7 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
+ /* Don't use inline function to avoid '#include "nls.h"' in c.h
+ */
+ #define errtryhelp(eval) __extension__ ({ \
+- fprintf(stderr, _("Try '%s --help' for more information.\n"), \
++ fprintf(stderr, ("Try '%s --help' for more information.\n"), \
+ program_invocation_short_name); \
+ exit(eval); \
+ })
+diff --git a/locale/programs/cross-localedef-hardlink.c b/locale/programs/cross-localedef-hardlink.c
+index 63615896b0..726e6dd948 100644
--- a/locale/programs/cross-localedef-hardlink.c
+++ b/locale/programs/cross-localedef-hardlink.c
@@ -20,6 +20,8 @@
@@ -75,7 +98,7 @@
fputs(USAGE_SEPARATOR, stdout);
printf(USAGE_HELP_OPTIONS(16)); /* char offset to align option descriptions */
-@@ -164,7 +166,7 @@ static inline size_t add2(size_t a, size
+@@ -164,7 +166,7 @@ static inline size_t add2(size_t a, size_t b)
size_t sum = a + b;
if (sum < a)
@@ -84,7 +107,7 @@
return sum;
}
-@@ -193,7 +195,7 @@ static void process_path(struct hardlink
+@@ -193,7 +195,7 @@ static void process_path(struct hardlink_ctl *ctl, const char *name)
if (st.st_dev != ctl->dev && !ctl->force) {
if (ctl->dev)
errx(EXIT_FAILURE,
@@ -93,7 +116,7 @@
"(use -f option to override)."), name);
ctl->dev = st.st_dev;
}
-@@ -287,9 +289,9 @@ static void process_path(struct hardlink
+@@ -287,9 +289,9 @@ static void process_path(struct hardlink_ctl *ctl, const char *name)
(ssize_t) sizeof(ctl->iobuf1) : fsize;
if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize)
@@ -105,7 +128,7 @@
if (xsz != rsize) {
close(fd);
-@@ -303,13 +305,13 @@ static void process_path(struct hardlink
+@@ -303,13 +305,13 @@ static void process_path(struct hardlink_ctl *ctl, const char *name)
if (fsize > 0)
continue;
if (lstat(name, &st3)) {
@@ -121,7 +144,7 @@
close(fd);
return;
}
-@@ -329,18 +331,18 @@ static void process_path(struct hardlink
+@@ -329,18 +331,18 @@ static void process_path(struct hardlink_ctl *ctl, const char *name)
suffixlen + 1);
/* First create a temporary link to n1 under a new name */
if (link(n1, nam2.buf)) {
@@ -143,7 +166,7 @@
free(nam2.buf);
continue;
}
-@@ -351,16 +353,16 @@ static void process_path(struct hardlink
+@@ -351,16 +353,16 @@ static void process_path(struct hardlink_ctl *ctl, const char *name)
/* We actually did not save anything this time, since the link second argument
had some other links as well. */
if (ctl->verbose > 1)
@@ -213,14 +236,3 @@
}
continue;
}
---- a/locale/programs/c.h
-+++ b/locale/programs/c.h
-@@ -240,7 +240,7 @@ errmsg(char doexit, int excode, char add
- /* Don't use inline function to avoid '#include "nls.h"' in c.h
- */
- #define errtryhelp(eval) __extension__ ({ \
-- fprintf(stderr, _("Try '%s --help' for more information.\n"), \
-+ fprintf(stderr, ("Try '%s --help' for more information.\n"), \
- program_invocation_short_name); \
- exit(eval); \
- })
diff --git a/meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch b/meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch
new file mode 100644
index 0000000000..e87a3bfb6f
--- /dev/null
+++ b/meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch
@@ -0,0 +1,55 @@
+From 1ef58f566e6ed575f7caee35308025e2b0f4101c Mon Sep 17 00:00:00 2001
+From: Jason Wessel <jason.wessel@windriver.com>
+Date: Sat, 7 Dec 2019 09:56:23 -0800
+Subject: [PATCH] Add hardlink resolver to build
+
+The sourcecode for this is imported from util-linux and is kept with
+glibc sources
+
+Upstream-Status: Pending
+Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ Makefile.in | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/localedef/Makefile.in b/localedef/Makefile.in
+index 77fbded..a87e5b2 100644
+--- a/localedef/Makefile.in
++++ b/localedef/Makefile.in
+@@ -40,6 +40,8 @@ WARNFLAGS = -Wall -Wno-format
+ FULLCC = $(CC) $(CPPFLAGS) $(CFLAGS) \
+ $(DEFINES) $(INCLUDES) $(WARNFLAGS)
+
++CROSS_LOCALEDEF_HARDLINK_OBJS = cross-localedef-hardlink.o
++
+ LOCALEDEF_OBJS = charmap.o charmap-dir.o ld-address.o ld-collate.o \
+ ld-ctype.o ld-identification.o ld-measurement.o \
+ ld-messages.o ld-monetary.o ld-name.o ld-numeric.o \
+@@ -54,11 +56,14 @@ LOCALEDEF_OBJS = charmap.o charmap-dir.o ld-address.o ld-collate.o \
+ asprintf.o getdelim.o localedef_extra.o \
+ obstack_printf.o vasprintf.o
+
+-all: localedef$(EXEEXT)
++all: localedef$(EXEEXT) cross-localedef-hardlink$(EXEEXT)
+
+ localedef$(EXEEXT): $(LOCALEDEF_OBJS)
+ $(CC) -o $@ $(LOCALEDEF_OBJS) $(LIBS)
+
++cross-localedef-hardlink$(EXEEXT): $(CROSS_LOCALEDEF_HARDLINK_OBJS)
++ $(CC) -o $@ $(CROSS_LOCALEDEF_HARDLINK_OBJS) $(LIBS)
++
+ clean:
+ rm -f locale$(EXEEXT) $(LOCALEDEF_OBJS)
+
+@@ -77,6 +82,7 @@ clean:
+ %.o: $(srcdir)/%.c
+ $(FULLCC) -c -o $@ $<
+
++cross-localedef-hardlink.o: glibc/locale/programs/cross-localedef-hardlink.c
+ charmap.o: glibc/locale/programs/charmap.c
+ charmap-dir.o: glibc/locale/programs/charmap-dir.c
+ ld-address.o: glibc/locale/programs/ld-address.c
+--
+2.24.0
+