mirror of
https://git.yoctoproject.org/poky
synced 2026-02-25 02:49:40 +01:00
(From OE-Core rev: f4cc0df90197e031326a3f823b37cc138950ca70) Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
141 lines
3.5 KiB
Diff
141 lines
3.5 KiB
Diff
From f4ca9db9d38f865505322595a8a1e8f69d5bb87c Mon Sep 17 00:00:00 2001
|
|
From: Hongxu Jia <hongxu.jia@windriver.com>
|
|
Date: Fri, 23 Aug 2019 10:18:47 +0800
|
|
Subject: [PATCH] musl-libs
|
|
|
|
Collection of fixes needed to compile libelf and other libraries
|
|
provided by elfutils for musl targets
|
|
|
|
error is glibc specific API, so this patch will mostly not accepted
|
|
upstream given that elfutils has been closely tied to glibc
|
|
|
|
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
|
Upstream-Status: Inappropriate [workaround for musl]
|
|
|
|
Rebase to 0.177
|
|
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
|
|
|
|
---
|
|
lib/error.h | 27 +++++++++++++++++++++++++++
|
|
lib/fixedsizehash.h | 1 -
|
|
lib/libeu.h | 1 +
|
|
libdwfl/dwfl_error.c | 9 +++++++++
|
|
libdwfl/linux-kernel-modules.c | 1 +
|
|
libelf/elf.h | 7 +++++++
|
|
6 files changed, 45 insertions(+), 1 deletion(-)
|
|
create mode 100644 lib/error.h
|
|
|
|
diff --git a/lib/error.h b/lib/error.h
|
|
new file mode 100644
|
|
index 0000000..ef06827
|
|
--- /dev/null
|
|
+++ b/lib/error.h
|
|
@@ -0,0 +1,27 @@
|
|
+#ifndef _ERROR_H_
|
|
+#define _ERROR_H_
|
|
+
|
|
+#include <stdarg.h>
|
|
+#include <stdio.h>
|
|
+#include <stdlib.h>
|
|
+#include <string.h>
|
|
+#include <errno.h>
|
|
+
|
|
+static unsigned int error_message_count = 0;
|
|
+
|
|
+static inline void error(int status, int errnum, const char* format, ...)
|
|
+{
|
|
+ va_list ap;
|
|
+ fprintf(stderr, "%s: ", program_invocation_name);
|
|
+ va_start(ap, format);
|
|
+ vfprintf(stderr, format, ap);
|
|
+ va_end(ap);
|
|
+ if (errnum)
|
|
+ fprintf(stderr, ": %s", strerror(errnum));
|
|
+ fprintf(stderr, "\n");
|
|
+ error_message_count++;
|
|
+ if (status)
|
|
+ exit(status);
|
|
+}
|
|
+
|
|
+#endif /* _ERROR_H_ */
|
|
diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h
|
|
index dac2a5f..43016fc 100644
|
|
--- a/lib/fixedsizehash.h
|
|
+++ b/lib/fixedsizehash.h
|
|
@@ -30,7 +30,6 @@
|
|
#include <errno.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
-#include <sys/cdefs.h>
|
|
|
|
#include <system.h>
|
|
|
|
diff --git a/lib/libeu.h b/lib/libeu.h
|
|
index ecb4d01..edc85e3 100644
|
|
--- a/lib/libeu.h
|
|
+++ b/lib/libeu.h
|
|
@@ -29,6 +29,7 @@
|
|
#ifndef LIBEU_H
|
|
#define LIBEU_H
|
|
|
|
+#include "system.h"
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
|
|
index 7bcf61c..11dcc8b 100644
|
|
--- a/libdwfl/dwfl_error.c
|
|
+++ b/libdwfl/dwfl_error.c
|
|
@@ -154,7 +154,16 @@ dwfl_errmsg (int error)
|
|
switch (error &~ 0xffff)
|
|
{
|
|
case OTHER_ERROR (ERRNO):
|
|
+#if defined(__GLIBC__)
|
|
return strerror_r (error & 0xffff, "bad", 0);
|
|
+#else
|
|
+ {
|
|
+ static __thread char buf[128] = "";
|
|
+ if (strerror_r (error & 0xffff, buf, sizeof(buf)) == 0)
|
|
+ return buf;
|
|
+ }
|
|
+ return "strerror_r() failed";
|
|
+#endif
|
|
case OTHER_ERROR (LIBELF):
|
|
return elf_errmsg (error & 0xffff);
|
|
case OTHER_ERROR (LIBDW):
|
|
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
|
|
index 6edb27f..f331e3c 100644
|
|
--- a/libdwfl/linux-kernel-modules.c
|
|
+++ b/libdwfl/linux-kernel-modules.c
|
|
@@ -50,6 +50,7 @@
|
|
#include <sys/utsname.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
+#include "system.h"
|
|
|
|
/* If fts.h is included before config.h, its indirect inclusions may not
|
|
give us the right LFS aliases of these functions, so map them manually. */
|
|
diff --git a/libelf/elf.h b/libelf/elf.h
|
|
index 6439c1a..a87c589 100644
|
|
--- a/libelf/elf.h
|
|
+++ b/libelf/elf.h
|
|
@@ -19,6 +19,10 @@
|
|
#ifndef _ELF_H
|
|
#define _ELF_H 1
|
|
|
|
+#ifdef __cplusplus
|
|
+extern "C" {
|
|
+#endif
|
|
+
|
|
/* Standard ELF types. */
|
|
|
|
#include <stdint.h>
|
|
@@ -4101,4 +4105,7 @@ enum
|
|
#define R_ARC_TLS_LE_S9 0x4a
|
|
#define R_ARC_TLS_LE_32 0x4b
|
|
|
|
+#ifdef __cplusplus
|
|
+}
|
|
+#endif
|
|
#endif /* elf.h */
|