openwrt/package/libs/elfutils/patches/100-musl-compat.patch
Rosen Penev f4da28c301 elfutils: Add host build
Needed for glib2 host build:

gresource-tool.c:32:20: fatal error: libelf.h: No such file or directory
 #include <libelf.h>

Changed PKG_LICENSE to the SPDX version.

Switched build dependency for argp-standalone to !USE_GLIBC. argp is a
glibc extension. Treat it as such.

Adjusted patch to use strerror_l, which works properly with both glibc
and musl. The patch errors under glibc with:

dwfl_error.c:158:7: error: ignoring return value of 'strerror_r', declared
with attribute warn_unused_result [-Werror=unused-result]
       strerror_r (error & 0xffff, s, sizeof(s));

void casting does not fix the error.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-09-21 01:09:30 +02:00

56 lines
1.3 KiB
Diff

https://sourceware.org/bugzilla/show_bug.cgi?id=21002
--- a/lib/system.h
+++ b/lib/system.h
@@ -30,7 +30,18 @@
#define LIB_SYSTEM_H 1
#include <errno.h>
-#include <error.h>
+#ifdef HAVE_ERROR_H
+#include "error.h"
+#else
+#include "err.h"
+#include <stdio.h>
+#define error(status, errno, ...) \
+ do { \
+ fflush(stdout); \
+ warn(__VA_ARGS__); \
+ if (status) exit(status); \
+ } while(0)
+#endif
#include <stddef.h>
#include <stdint.h>
#include <sys/param.h>
@@ -38,6 +49,10 @@
#include <byteswap.h>
#include <unistd.h>
+#ifndef __GLIBC__
+#define canonicalize_file_name(name) realpath(name,NULL)
+#endif
+
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define LE32(n) (n)
# define LE64(n) (n)
--- a/libdw/libdw_alloc.c
+++ b/libdw/libdw_alloc.c
@@ -73,5 +73,5 @@ __attribute ((noreturn)) attribute_hidde
__libdw_oom (void)
{
while (1)
- error (EXIT_FAILURE, ENOMEM, "libdw");
+ error (EXIT_FAILURE, errno, gettext ("cannot allocate memory"));
}
--- a/libdwfl/dwfl_error.c
+++ b/libdwfl/dwfl_error.c
@@ -154,7 +154,7 @@ dwfl_errmsg (int error)
switch (error &~ 0xffff)
{
case OTHER_ERROR (ERRNO):
- return strerror_r (error & 0xffff, "bad", 0);
+ return strerror_l (error & 0xffff, LC_GLOBAL_LOCALE);
case OTHER_ERROR (LIBELF):
return elf_errmsg (error & 0xffff);
case OTHER_ERROR (LIBDW):