e354a5
commit edd8d70b91e1ccef549a7c668499596cc4d56ad1
e354a5
Author: Mihailo Stojanovic <mihailo.stojanovic@rt-rk.com>
e354a5
Date:   Fri Aug 23 16:47:27 2019 +0000
e354a5
e354a5
    [MIPS] Raise highest supported EI_ABIVERSION value [BZ #24916]
e354a5
    
e354a5
    This bumps the highest valid EI_ABIVERSION value to ABSOLUTE ABI.
e354a5
    
e354a5
    New testcase loads the symbol from the GOT with the "lb" instruction
e354a5
    so that the EI_ABIVERSION header field of the shared object is set
e354a5
    to ABSOLUTE (it doesn't actually check the value of the symbol), and
e354a5
    makes sure that the main executable is executed without "ABI version
e354a5
    invalid" error.
e354a5
    
e354a5
    Tested for all three ABIs (o32, n32, n64) using both static linker which
e354a5
    handles undefined weak symbols correctly [1] (and sets the EI_ABIVERSION
e354a5
    of the test module) and the one that doesn't (EI_ABIVERSION left as 0).
e354a5
    
e354a5
    [1] https://sourceware.org/ml/binutils/2018-07/msg00268.html
e354a5
    
e354a5
            [BZ #24916]
e354a5
            * sysdeps/mips/Makefile [$(subdir) = elf] (tests): Add
e354a5
            tst-undefined-weak.
e354a5
            [$(subdir) = elf] (modules-names): Add tst-undefined-weak-lib.
e354a5
            [$(subdir) = elf] ($(objpfx)tst-undefined-weak): Add dependency.
e354a5
            * sysdeps/mips/tst-undefined-weak-lib.S: New file.
e354a5
            * sysdeps/mips/tst-undefined-weak.c: Likewise.
e354a5
            * sysdeps/unix/sysv/linux/mips/ldsodefs.h (VALID_ELF_ABIVERSION):
e354a5
            Increment highest valid ABIVERSION value.
e354a5
e354a5
diff --git a/sysdeps/mips/Makefile b/sysdeps/mips/Makefile
e354a5
index 7ac6fa50311d60b7..6ad69e9ef9e88728 100644
e354a5
--- a/sysdeps/mips/Makefile
e354a5
+++ b/sysdeps/mips/Makefile
e354a5
@@ -82,3 +82,10 @@ $(objpfx)tst-mode-switch-2: $(shared-thread-library)
e354a5
 endif
e354a5
 endif
e354a5
 endif
e354a5
+
e354a5
+ifeq ($(subdir),elf)
e354a5
+tests += tst-undefined-weak
e354a5
+modules-names += tst-undefined-weak-lib
e354a5
+
e354a5
+$(objpfx)tst-undefined-weak: $(objpfx)tst-undefined-weak-lib.so
e354a5
+endif
e354a5
diff --git a/sysdeps/mips/tst-undefined-weak-lib.S b/sysdeps/mips/tst-undefined-weak-lib.S
e354a5
new file mode 100644
e354a5
index 0000000000000000..a175ebf90e01b372
e354a5
--- /dev/null
e354a5
+++ b/sysdeps/mips/tst-undefined-weak-lib.S
e354a5
@@ -0,0 +1,43 @@
e354a5
+/* Undefined weak symbol loading shared module.
e354a5
+   Copyright (C) 2019 Free Software Foundation, Inc.
e354a5
+   This file is part of the GNU C Library.
e354a5
+
e354a5
+   The GNU C Library is free software; you can redistribute it and/or
e354a5
+   modify it under the terms of the GNU Lesser General Public
e354a5
+   License as published by the Free Software Foundation; either
e354a5
+   version 2.1 of the License, or (at your option) any later version.
e354a5
+
e354a5
+   The GNU C Library is distributed in the hope that it will be useful,
e354a5
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
e354a5
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e354a5
+   Lesser General Public License for more details.
e354a5
+
e354a5
+   You should have received a copy of the GNU Lesser General Public
e354a5
+   License along with the GNU C Library; if not, see
e354a5
+   <http://www.gnu.org/licenses/>.  */
e354a5
+
e354a5
+#include <sgidefs.h>
e354a5
+
e354a5
+    .text
e354a5
+    .globl	x
e354a5
+    .set	nomips16
e354a5
+    .set	nomicromips
e354a5
+    .ent	x
e354a5
+    .type	x, @function
e354a5
+x:
e354a5
+    .set noreorder
e354a5
+#if _MIPS_SIM == _ABIO32
e354a5
+    .cpload  $25
e354a5
+    jr  $31
e354a5
+    lb  $2,%got(a)($28)
e354a5
+#else
e354a5
+    .cpsetup  $25,$24,x
e354a5
+    lb  $2,%got_disp(a)($28)
e354a5
+    jr  $31
e354a5
+    .cpreturn
e354a5
+#endif
e354a5
+    .set reorder
e354a5
+    .end	x
e354a5
+    .size	x, .-x
e354a5
+    .weak	a
e354a5
+    .hidden	a
e354a5
diff --git a/sysdeps/mips/tst-undefined-weak.c b/sysdeps/mips/tst-undefined-weak.c
e354a5
new file mode 100644
e354a5
index 0000000000000000..1231da6912508c19
e354a5
--- /dev/null
e354a5
+++ b/sysdeps/mips/tst-undefined-weak.c
e354a5
@@ -0,0 +1,28 @@
e354a5
+/* Undefined weak symbol loading main executable.
e354a5
+   Copyright (C) 2019 Free Software Foundation, Inc.
e354a5
+   This file is part of the GNU C Library.
e354a5
+
e354a5
+   The GNU C Library is free software; you can redistribute it and/or
e354a5
+   modify it under the terms of the GNU Lesser General Public
e354a5
+   License as published by the Free Software Foundation; either
e354a5
+   version 2.1 of the License, or (at your option) any later version.
e354a5
+
e354a5
+   The GNU C Library is distributed in the hope that it will be useful,
e354a5
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
e354a5
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e354a5
+   Lesser General Public License for more details.
e354a5
+
e354a5
+   You should have received a copy of the GNU Lesser General Public
e354a5
+   License along with the GNU C Library; if not, see
e354a5
+   <http://www.gnu.org/licenses/>.  */
e354a5
+
e354a5
+int *x (void);
e354a5
+
e354a5
+int
e354a5
+do_test (void)
e354a5
+{
e354a5
+  x ();
e354a5
+  return 0;
e354a5
+}
e354a5
+
e354a5
+#include <support/test-driver.c>
e354a5
diff --git a/sysdeps/unix/sysv/linux/mips/ldsodefs.h b/sysdeps/unix/sysv/linux/mips/ldsodefs.h
e354a5
index 68a0a99bb1f1ec85..d2912cadabfd6877 100644
e354a5
--- a/sysdeps/unix/sysv/linux/mips/ldsodefs.h
e354a5
+++ b/sysdeps/unix/sysv/linux/mips/ldsodefs.h
e354a5
@@ -34,7 +34,7 @@ extern void _dl_static_init (struct link_map *map);
e354a5
 #undef VALID_ELF_ABIVERSION
e354a5
 #define VALID_ELF_ABIVERSION(osabi,ver)			\
e354a5
   (ver == 0						\
e354a5
-   || (osabi == ELFOSABI_SYSV && ver < 4)		\
e354a5
+   || (osabi == ELFOSABI_SYSV && ver < 5)		\
e354a5
    || (osabi == ELFOSABI_GNU && ver < LIBC_ABI_MAX))
e354a5
 
e354a5
 #endif /* ldsodefs.h */