[meta-xilinx] [RFC] glibc_2.24.bbappend: Fix compiler error for MB

Nathan Rossi nathan at nathanrossi.com
Sat Jul 16 12:00:27 PDT 2016


Hi Manju,

This patch works fine to resolve the build issue, however there
appears to be something significantly more broken with regards to
glibc 2.24 and/or gcc 6 for microblaze.

When booting the default qemumicroblaze build in qemu userspace
appears broken. Resulting in a kernel panic on init.

[    2.631858] Kernel panic - not syncing: Attempted to kill init!
exitcode=0x0000000b
[    2.631858]
[    2.632325] ---[ end Kernel panic - not syncing: Attempted to kill
init! exitcode=0x0000000b

I tried with a static build of busybox which did not change the
result, so I had a quick look where it was dying in busybox and it
appears that it is segfaulting early in glibc codebase.

Here is the backtrace when running busybox in qemu linux user
(./tmp-glibc/sysroots/x86_64-linux/usr/bin/qemu-microblazeel -g 12345
-L ./tmp-glibc/sysroots/qemumicroblaze/
./tmp-glibc/work/microblazeel-v8.50-bs-cmp-re-mh-div-fb-oe-linux/busybox/1.24.1-r0/image/bin/busybox
sh)

Program received signal SIGSEGV, Segmentation fault.
__tls_get_addr (ti=0x101b50ac) at ../sysdeps/microblaze/libc-tls.c:31
31      ../sysdeps/microblaze/libc-tls.c: No such file or directory.
(gdb) bt
#0  __tls_get_addr (ti=0x101b50ac) at ../sysdeps/microblaze/libc-tls.c:31
#1  0x100f2be4 in ptmalloc_init () at arena.c:274
#2  0x100f3008 in ptmalloc_init () at hooks.c:33
#3  malloc_hook_ini (sz=<optimized out>, caller=<optimized out>) at hooks.c:31
#4  0x100f1ae4 in __libc_malloc (bytes=bytes at entry=111) at malloc.c:2901
#5  0x1016161c in _dl_get_origin () at ../sysdeps/unix/sysv/linux/dl-origin.c:50
#6  0x10139500 in _dl_non_dynamic_init () at dl-support.c:310
#7  0x1013a7fc in __libc_init_first (argc=argc at entry=1,
argv=argv at entry=0xf6ffedc4, envp=0xf6ffedcc) at init-first.c:79
#8  0x100c58ec in __libc_start_main (main=0x10001550 <main>, argc=1,
argv=0xf6ffedc4, init=0x100c5eb0 <__libc_csu_init>, fini=0x100c5f9c
<__libc_csu_fini>, rtld_fini=0x0,
    stack_end=0xf6ffeec0) at libc-start.c:225
#9  0x00000008 in ?? ()
Backtrace stopped: frame did not save the PC

I also gave it a test with musl, it gets further into execution and
fails elsewhere in a different libc call.

Program received signal SIGSEGV, Segmentation fault.
__strchrnul (s=s at entry=0x2 <error: Cannot access memory at address
0x2>, c=c at entry=61) at src/string/strchrnul.c:19
19      src/string/strchrnul.c: No such file or directory.
(gdb) bt
#0  __strchrnul (s=s at entry=0x2 <error: Cannot access memory at address
0x2>, c=c at entry=61) at src/string/strchrnul.c:19
#1  0x100b3b20 in strchr (s=s at entry=0x2 <error: Cannot access memory
at address 0x2>, c=c at entry=61) at src/string/strchr.c:7
#2  0x1003bd88 in init () at shell/ash.c:12937
#3  ash_main (argc=argc at entry=1, argv=argv at entry=0xf6ffeda8) at
shell/ash.c:13151
#4  0x10000b08 in run_applet_no_and_exit (applet_no=122,
argv=argv at entry=0xf6ffeda8) at libbb/appletlib.c:774
#5  0x10000d38 in run_applet_and_exit (name=0xf6ffef1f "sh",
argv=argv at entry=0xf6ffeda8) at libbb/appletlib.c:781
#6  0x10000f54 in busybox_main (argv=0xf6ffeda8) at libbb/appletlib.c:730
#7  run_applet_and_exit (name=<optimized out>, argv=<optimized out>)
at libbb/appletlib.c:783
#8  0x10001018 in main (argc=<optimized out>, argv=<optimized out>) at
libbb/appletlib.c:838

I don't see these issues with musl or glibc using gcc 5.4, so it makes
me suspect that there is some sort of regression in gcc 6 for
microblaze, maybe related to TLS?

Regards,
Nathan

On Tue, Jul 12, 2016 at 8:11 AM, Manjukumar Matha
<manjukumar.harthikote-matha at xilinx.com> wrote:
> MB is failing to compile stating "ret" variable is a register. However renaming
> the variable from ret to any other name fixes this issue. I think it might be a
> GCC issue, but I am unable to re-create this corner case to report it to GCC.
>
> Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha at xilinx.com>
> ---
>  .../glibc/files/microblaze-gcc-ret-fix.patch       | 120 +++++++++++++++++++++
>  recipes-microblaze/glibc/glibc_2.24.bbappend       |   5 +
>  2 files changed, 125 insertions(+)
>  create mode 100644 recipes-microblaze/glibc/files/microblaze-gcc-ret-fix.patch
>  create mode 100644 recipes-microblaze/glibc/glibc_2.24.bbappend
>
> diff --git a/recipes-microblaze/glibc/files/microblaze-gcc-ret-fix.patch b/recipes-microblaze/glibc/files/microblaze-gcc-ret-fix.patch
> new file mode 100644
> index 0000000..12ed783
> --- /dev/null
> +++ b/recipes-microblaze/glibc/files/microblaze-gcc-ret-fix.patch
> @@ -0,0 +1,120 @@
> +diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
> +index ee05de5..08aecee 100644
> +--- a/sysdeps/unix/sysv/linux/spawni.c
> ++++ b/sysdeps/unix/sysv/linux/spawni.c
> +@@ -126,7 +126,7 @@ __spawni_child (void *arguments)
> +   const posix_spawnattr_t *restrict attr = args->attr;
> +   const posix_spawn_file_actions_t *file_actions = args->fa;
> +   int p = args->pipe[1];
> +-  int ret;
> ++  int retVal;
> +
> +   close_not_cancel (args->pipe[0]);
> +
> +@@ -171,25 +171,25 @@ __spawni_child (void *arguments)
> +   if ((attr->__flags & (POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER))
> +       == POSIX_SPAWN_SETSCHEDPARAM)
> +     {
> +-      if ((ret = __sched_setparam (0, &attr->__sp)) == -1)
> ++      if ((retVal = __sched_setparam (0, &attr->__sp)) == -1)
> +       goto fail;
> +     }
> +   else if ((attr->__flags & POSIX_SPAWN_SETSCHEDULER) != 0)
> +     {
> +-      if ((ret = __sched_setscheduler (0, attr->__policy, &attr->__sp)) == -1)
> ++      if ((retVal = __sched_setscheduler (0, attr->__policy, &attr->__sp)) == -1)
> +       goto fail;
> +     }
> + #endif
> +
> +   /* Set the process group ID.  */
> +   if ((attr->__flags & POSIX_SPAWN_SETPGROUP) != 0
> +-      && (ret = __setpgid (0, attr->__pgrp)) != 0)
> ++      && (retVal = __setpgid (0, attr->__pgrp)) != 0)
> +     goto fail;
> +
> +   /* Set the effective user and group IDs.  */
> +   if ((attr->__flags & POSIX_SPAWN_RESETIDS) != 0
> +-      && ((ret = local_seteuid (__getuid ())) != 0
> +-        || (ret = local_setegid (__getgid ())) != 0))
> ++      && ((retVal = local_seteuid (__getuid ())) != 0
> ++        || (retVal = local_setegid (__getgid ())) != 0))
> +     goto fail;
> +
> +   /* Execute the file actions.  */
> +@@ -209,15 +209,15 @@ __spawni_child (void *arguments)
> +             || (action->action.open_action.fd == p)
> +             || (action->action.dup2_action.fd == p))
> +           {
> +-            if ((ret = __dup (p)) < 0)
> ++            if ((retVal = __dup (p)) < 0)
> +               goto fail;
> +-            p = ret;
> ++            p = retVal;
> +           }
> +
> +         switch (action->tag)
> +           {
> +           case spawn_do_close:
> +-            if ((ret =
> ++            if ((retVal =
> +                  close_not_cancel (action->action.close_action.fd)) != 0)
> +               {
> +                 if (!have_fdlimit)
> +@@ -235,31 +235,31 @@ __spawni_child (void *arguments)
> +
> +           case spawn_do_open:
> +             {
> +-              ret = open_not_cancel (action->action.open_action.path,
> ++              retVal = open_not_cancel (action->action.open_action.path,
> +                                      action->action.
> +                                      open_action.oflag | O_LARGEFILE,
> +                                      action->action.open_action.mode);
> +
> +-              if (ret == -1)
> ++              if (retVal == -1)
> +                 goto fail;
> +
> +-              int new_fd = ret;
> ++              int new_fd = retVal;
> +
> +               /* Make sure the desired file descriptor is used.  */
> +-              if (ret != action->action.open_action.fd)
> ++              if (retVal != action->action.open_action.fd)
> +                 {
> +-                  if ((ret = __dup2 (new_fd, action->action.open_action.fd))
> ++                  if ((retVal = __dup2 (new_fd, action->action.open_action.fd))
> +                       != action->action.open_action.fd)
> +                     goto fail;
> +
> +-                  if ((ret = close_not_cancel (new_fd)) != 0)
> ++                  if ((retVal = close_not_cancel (new_fd)) != 0)
> +                     goto fail;
> +                 }
> +             }
> +             break;
> +
> +           case spawn_do_dup2:
> +-            if ((ret = __dup2 (action->action.dup2_action.fd,
> ++            if ((retVal = __dup2 (action->action.dup2_action.fd,
> +                                action->action.dup2_action.newfd))
> +                 != action->action.dup2_action.newfd)
> +               goto fail;
> +@@ -280,13 +280,13 @@ __spawni_child (void *arguments)
> +      (2.15).  */
> +   maybe_script_execute (args);
> +
> +-  ret = -errno;
> ++  retVal = -errno;
> +
> + fail:
> +   /* Since sizeof errno < PIPE_BUF, the write is atomic. */
> +-  ret = -ret;
> +-  if (ret)
> +-    while (write_not_cancel (p, &ret, sizeof ret) < 0)
> ++  retVal = -retVal;
> ++  if (retVal)
> ++    while (write_not_cancel (p, &retVal, sizeof retVal) < 0)
> +       continue;
> +   exit (SPAWN_ERROR);
> + }
> diff --git a/recipes-microblaze/glibc/glibc_2.24.bbappend b/recipes-microblaze/glibc/glibc_2.24.bbappend
> new file mode 100644
> index 0000000..bf54619
> --- /dev/null
> +++ b/recipes-microblaze/glibc/glibc_2.24.bbappend
> @@ -0,0 +1,5 @@
> +# Add MicroBlaze Patches
> +FILESEXTRAPATHS_append := "${THISDIR}/files:"
> +SRC_URI_append_microblaze = " \
> +               file://microblaze-gcc-ret-fix.patch \
> +               "
> --
> 2.7.4
>
> --
> _______________________________________________
> meta-xilinx mailing list
> meta-xilinx at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/meta-xilinx



More information about the meta-xilinx mailing list