]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix musl build on Linux
authorDongsheng Song <dongsheng.song@gmail.com>
Tue, 14 Feb 2023 11:51:29 +0000 (12:51 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Tue, 14 Feb 2023 11:54:37 +0000 (12:54 +0100)
The commit "ada: Add PIE support to backtraces on Linux" uses
_r_debug under Linux unconditionally. It is incorrect since musl
libc does not define _r_debug like glibc.

gcc/ada/
* adaint.c [Linux]: Include <features.h>.
(__gnat_get_executable_load_address) [Linux]: Enable only for
glibc and uClibc.

gcc/ada/adaint.c

index 1c23d15846b1476846e88831f4fabc90584d7749..8522094164e07f92afe345a49b35967237d65b5e 100644 (file)
@@ -3526,6 +3526,7 @@ __gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
 #if defined (__APPLE__)
 #include <mach-o/dyld.h>
 #elif defined (__linux__)
+#include <features.h>
 #include <link.h>
 #endif
 
@@ -3535,7 +3536,7 @@ __gnat_get_executable_load_address (void)
 #if defined (__APPLE__)
   return _dyld_get_image_header (0);
 
-#elif defined (__linux__)
+#elif defined (__linux__) && (defined (__GLIBC__) || defined (__UCLIBC__))
   struct link_map *map = _r_debug.r_map;
   return (const void *)map->l_addr;