[meta-xilinx] [PATCH] glibc: Fix up MicroBlaze pt-vfork compat symbols

Nathan Rossi nathan at nathanrossi.com
Thu Dec 1 05:18:14 PST 2016


Merged.

Regards,
Nathan

On 24 November 2016 at 21:38, Nathan Rossi <nathan at nathanrossi.com> wrote:
> A bug has been present in glibc for a while where a symbol is emitted in
> libpthread.so which is corrupt. Whilst previously this has not been an
> issue due to how binutils has handled it, recent binutils behaviour has
> changed enough to make this bug surface as a linker error.
>
> Depending on the host (behaviour and native dependencies) the cross
> binutils that is built may emit different values for the corrupt symbol.
> This appears as an error similar to the following when linking against
> libpthread.so (e.g. librt links against libpthread in glibc):
>
>     invalid string offset 1843814912 >= 4913 for section `.dynstr'
>
> This patch fixes up the symbols emitted for libpthread.so without
> breaking any libpthread or libc ABI. See the glibc patch for more
> specifics.
>
> Signed-off-by: Nathan Rossi <nathan at nathanrossi.com>
> ---
>  ...oBlaze-fix-up-pt-vfork-symbol-definitions.patch | 105 +++++++++++++++++++++
>  .../glibc/glibc-initial_2.24.bbappend              |   4 +
>  recipes-microblaze/glibc/glibc_2.24.bbappend       |   4 +
>  3 files changed, 113 insertions(+)
>  create mode 100644 recipes-microblaze/glibc/files/MicroBlaze-fix-up-pt-vfork-symbol-definitions.patch
>  create mode 100644 recipes-microblaze/glibc/glibc-initial_2.24.bbappend
>  create mode 100644 recipes-microblaze/glibc/glibc_2.24.bbappend
>
> diff --git a/recipes-microblaze/glibc/files/MicroBlaze-fix-up-pt-vfork-symbol-definitions.patch b/recipes-microblaze/glibc/files/MicroBlaze-fix-up-pt-vfork-symbol-definitions.patch
> new file mode 100644
> index 0000000000..ed37d6349f
> --- /dev/null
> +++ b/recipes-microblaze/glibc/files/MicroBlaze-fix-up-pt-vfork-symbol-definitions.patch
> @@ -0,0 +1,105 @@
> +From 873fc4bf58d6cc8d579a65224350ce3adddc6c2a Mon Sep 17 00:00:00 2001
> +From: Nathan Rossi <nathan at nathanrossi.com>
> +Date: Wed, 23 Nov 2016 22:30:29 +1000
> +Subject: [PATCH] MicroBlaze: fix up pt-vfork symbol definitions
> +
> +Due to the reuse of the alpha/pt-vfork.S implementation additional
> +symbols are emitted for libpthread which are invalid due to the
> +non-existence of a '__libc_vfork' symbol/implementation. A symbol is
> +emitted which references __libc_vfork and is invalid which causes the
> +linker to emit a corrupt symbol entry:
> +
> +    180: 00000000 0x24a91 NOTYPE  LOCAL  DEFAULT  UND <corrupt>
> +
> +Depending on the internals of the linker this corrupt symbol is either a
> +valid symbol as above or an completely invalid symbol that causes issues
> +when linking against libpthread.so:
> +
> +    179: 0000564b 0x825fd688 <OS specific>: 11 <unknown>: 4 HIDDEN
> +        [<other>: 54]   UND <corrupt>
> +
> +In both cases this is the 'vfork at GLIBC_2.18' compat_symbol which is
> +aliased as the local '__libc_vfork'. (in libpthread.so)
> +
> +    12: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND vfork at GLIBC_2.18
> +
> +Due to how MicroBlaze differs from other architectures, it is special in
> +that it only implements '__vfork' and due to the weak_alias in vfork.S
> +also defines 'vfork' for both libc and libpthread. No other symbols
> +(e.g. '__vfork_compat') are part of the ABI.
> +
> +This change removes the compatible symbol generation provided by
> +alpha/pt-vfork.S and sets up the 'vfork' and '__vfork' symbols to be
> +provided in libpthread based on SHLIB_COMPAT. This avoids the generation
> +of invalid symbols but maintains the expected libc and libpthread vfork
> +ABIs.
> +
> +Signed-off-by: Nathan Rossi <nathan at nathanrossi.com>
> +Upstream-Status: Pending
> +---
> + sysdeps/unix/sysv/linux/microblaze/pt-vfork.S | 40 ++++++++++++++++++++++++++-
> + sysdeps/unix/sysv/linux/microblaze/vfork.S    |  4 ++-
> + 2 files changed, 42 insertions(+), 2 deletions(-)
> +
> +diff --git a/sysdeps/unix/sysv/linux/microblaze/pt-vfork.S b/sysdeps/unix/sysv/linux/microblaze/pt-vfork.S
> +index 65cc3823ac..82bc36eecc 100644
> +--- a/sysdeps/unix/sysv/linux/microblaze/pt-vfork.S
> ++++ b/sysdeps/unix/sysv/linux/microblaze/pt-vfork.S
> +@@ -1 +1,39 @@
> +-#include <sysdeps/unix/sysv/linux/alpha/pt-vfork.S>
> ++/* vfork ABI-compatibility entry points for libpthread.
> ++   Copyright (C) 2014-2016 Free Software Foundation, Inc.
> ++   This file is part of the GNU C Library.
> ++
> ++   The GNU C Library is free software; you can redistribute it and/or
> ++   modify it under the terms of the GNU Lesser General Public
> ++   License as published by the Free Software Foundation; either
> ++   version 2.1 of the License, or (at your option) any later version.
> ++
> ++   The GNU C Library is distributed in the hope that it will be useful,
> ++   but WITHOUT ANY WARRANTY; without even the implied warranty of
> ++   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> ++   Lesser General Public License for more details.
> ++
> ++   You should have received a copy of the GNU Lesser General Public
> ++   License along with the GNU C Library; if not, see
> ++   <http://www.gnu.org/licenses/>.  */
> ++
> ++#include <shlib-compat.h>
> ++
> ++/* libpthread used to have its own vfork implementation that differed
> ++   from libc's only in having a pointless micro-optimization.  There
> ++   is no longer any use to having a separate copy in libpthread, but
> ++   the historical ABI requires it.  For static linking, there is no
> ++   need to provide anything here--the libc version will be linked in.
> ++   For shared library ABI compatibility, there must be __vfork and
> ++   vfork symbols in libpthread.so.  */
> ++
> ++#if (SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20) \
> ++     || SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20))
> ++
> ++#include <vfork.S>
> ++
> ++#endif
> ++
> ++#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20)
> ++weak_alias (__vfork, vfork)
> ++#endif
> ++
> +diff --git a/sysdeps/unix/sysv/linux/microblaze/vfork.S b/sysdeps/unix/sysv/linux/microblaze/vfork.S
> +index 9592cb4f28..b537f1ce34 100644
> +--- a/sysdeps/unix/sysv/linux/microblaze/vfork.S
> ++++ b/sysdeps/unix/sysv/linux/microblaze/vfork.S
> +@@ -40,6 +40,8 @@ ENTRY (__vfork)
> +       nop
> +
> + PSEUDO_END (__vfork)
> +-libc_hidden_def (__vfork)
> +
> ++#if IS_IN (libc)
> + weak_alias (__vfork, vfork)
> ++libc_hidden_def (__vfork)
> ++#endif
> +--
> +2.10.2
> +
> diff --git a/recipes-microblaze/glibc/glibc-initial_2.24.bbappend b/recipes-microblaze/glibc/glibc-initial_2.24.bbappend
> new file mode 100644
> index 0000000000..a4beb0b8d7
> --- /dev/null
> +++ b/recipes-microblaze/glibc/glibc-initial_2.24.bbappend
> @@ -0,0 +1,4 @@
> +
> +FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
> +SRC_URI += "file://MicroBlaze-fix-up-pt-vfork-symbol-definitions.patch"
> +
> diff --git a/recipes-microblaze/glibc/glibc_2.24.bbappend b/recipes-microblaze/glibc/glibc_2.24.bbappend
> new file mode 100644
> index 0000000000..a4beb0b8d7
> --- /dev/null
> +++ b/recipes-microblaze/glibc/glibc_2.24.bbappend
> @@ -0,0 +1,4 @@
> +
> +FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
> +SRC_URI += "file://MicroBlaze-fix-up-pt-vfork-symbol-definitions.patch"
> +
> --
> 2.10.2
>



More information about the meta-xilinx mailing list