crosstool-ng/packages/binutils/2.38/0005-Darwin-Two-fixes-from-Android-NDK-PTHREAD_ONCE_INIT-wcsncasecmp.patch
Hans-Christian Noren Egtvedt ba680a3e5b packages/binutils: add binutils-2.38
Binutils version 2.38 has been released
https://www.phoronix.com/scan.php?page=news_item&px=GNU-Binutils-2.38
https://sourceware.org/pipermail/binutils/2022-February/119721.html

Patches 0000 to 0008 from binutils-2.37 applied clean, so forward ported
them.

The following patches are now applied from upstream, hence dropped:
0010-change-uint-to-unsigned.patch
0011-bfd-close-the-file-descriptor-if-there-is-no-archive-fd.patch
0012-pr28391-strip-objcopy-preserve-dates-a-cannot-set-time.patch
0013-ld-pru-fix-resource_table-output-section-alignment.patch
0014-pr28422-build_id-use-after-free.patch
0015-pr28459-readelf-issues-bogus-warning.patch
0016-pr28417-std-string-no-longer-allows-accepting-nullptr_t.patch
0017-pr28540-segmentation-fault-on-NULL-byte_get.patch
0018-gold-place-note-gnu-property-section-before-other-note-sections.patch
0019-waddress-warning-in-ldelf.c.patch

Signed-off-by: Hans-Christian Noren Egtvedt <hegtvedt@cisco.com>
2022-02-13 20:47:12 +13:00

71 lines
1.7 KiB
Diff

From c39479f4ab4d372b518957871e1f205a03e7c3d6 Mon Sep 17 00:00:00 2001
From: Andrew Hsieh <andrewhsieh@google.com>
Date: Wed, 18 Mar 2015 10:57:24 +0800
Subject: [PATCH] Fix darwin build
1. In Drawin PTHREAD_ONCE_INIT is {0x30B1BCBA, {0}} and the GCC < 4.4
doesn't support ended initializer list
2. wcsncasecmp doesn't exist in MacSDK10.6.x
Change-Id: I69204a72f853f5263dffedc448379d75ed4eca2e
---
bfd/peXXigen.c | 22 ++++++++++++++++++++++
gold/gold-threads.cc | 15 ++++++++++++---
2 files changed, 34 insertions(+), 3 deletions(-)
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -3617,6 +3617,28 @@
}
#endif /* not Cygwin/Mingw */
+#if defined __APPLE__ && __DARWIN_C_LEVEL < 200809L
+/* wcsncasecmp isn't always defined in Mac SDK */
+static int
+wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
+{
+ wchar_t c1, c2;
+
+ if (n == 0)
+ return (0);
+ for (; *s1; s1++, s2++)
+ {
+ c1 = towlower(*s1);
+ c2 = towlower(*s2);
+ if (c1 != c2)
+ return ((int)c1 - c2);
+ if (--n == 0)
+ return (0);
+ }
+ return (-*s2);
+}
+#endif
+
/* Perform a comparison of two entries. */
static signed int
rsrc_cmp (bool is_name, rsrc_entry * a, rsrc_entry * b)
--- a/gold/gold-threads.cc
+++ b/gold/gold-threads.cc
@@ -284,9 +284,18 @@
class Once_initialize
{
public:
- Once_initialize()
- : once_(PTHREAD_ONCE_INIT)
- { }
+ Once_initialize()
+#if !defined(__APPLE__)
+ : once_(PTHREAD_ONCE_INIT)
+ { }
+#else
+// In Drawin PTHREAD_ONCE_INIT is {0x30B1BCBA, {0}} and the GCC < 4.4 doesn't support
+// extended initializer list as above */
+ {
+ pthread_once_t once_2 = PTHREAD_ONCE_INIT;
+ once_ = once_2;
+ }
+#endif
// Return a pointer to the pthread_once_t variable.
pthread_once_t*