]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
[MIPS] Raise highest supported EI_ABIVERSION value [BZ #24916]
authorMihailo Stojanovic <mihailo.stojanovic@rt-rk.com>
Fri, 23 Aug 2019 16:47:27 +0000 (16:47 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Fri, 23 Aug 2019 16:47:27 +0000 (16:47 +0000)
This bumps the highest valid EI_ABIVERSION value to ABSOLUTE ABI.

New testcase loads the symbol from the GOT with the "lb" instruction
so that the EI_ABIVERSION header field of the shared object is set
to ABSOLUTE (it doesn't actually check the value of the symbol), and
makes sure that the main executable is executed without "ABI version
invalid" error.

Tested for all three ABIs (o32, n32, n64) using both static linker which
handles undefined weak symbols correctly [1] (and sets the EI_ABIVERSION
of the test module) and the one that doesn't (EI_ABIVERSION left as 0).

[1] https://sourceware.org/ml/binutils/2018-07/msg00268.html

[BZ #24916]
* sysdeps/mips/Makefile [$(subdir) = elf] (tests): Add
tst-undefined-weak.
[$(subdir) = elf] (modules-names): Add tst-undefined-weak-lib.
[$(subdir) = elf] ($(objpfx)tst-undefined-weak): Add dependency.
* sysdeps/mips/tst-undefined-weak-lib.S: New file.
* sysdeps/mips/tst-undefined-weak.c: Likewise.
* sysdeps/unix/sysv/linux/mips/ldsodefs.h (VALID_ELF_ABIVERSION):
Increment highest valid ABIVERSION value.

ChangeLog
sysdeps/mips/Makefile
sysdeps/mips/tst-undefined-weak-lib.S [new file with mode: 0644]
sysdeps/mips/tst-undefined-weak.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/mips/ldsodefs.h

index bd4071ac286b9b235c8cdf20f79e1e8d73311ccb..61ffd520ebb4d34360f918106d96b0c2737d829c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2019-08-23  Mihailo Stojanovic  <mihailo.stojanovic@rt-rk.com>
+
+       [BZ #24916]
+       * sysdeps/mips/Makefile [$(subdir) = elf] (tests): Add
+       tst-undefined-weak.
+       [$(subdir) = elf] (modules-names): Add tst-undefined-weak-lib.
+       [$(subdir) = elf] ($(objpfx)tst-undefined-weak): Add dependency.
+       * sysdeps/mips/tst-undefined-weak-lib.S: New file.
+       * sysdeps/mips/tst-undefined-weak.c: Likewise.
+       * sysdeps/unix/sysv/linux/mips/ldsodefs.h (VALID_ELF_ABIVERSION):
+       Increment highest valid ABIVERSION value.
+
 2019-08-23  Dragan Mladjenovic  <dmladjenovic@wavecomp.com>
 
        * sysdeps/unix/sysv/linux/mips/Makefile
index 7ac6fa50311d60b75b5551bcfa37c59c5d3318d6..6ad69e9ef9e8872830a299c130fc56806adeec2a 100644 (file)
@@ -82,3 +82,10 @@ $(objpfx)tst-mode-switch-2: $(shared-thread-library)
 endif
 endif
 endif
+
+ifeq ($(subdir),elf)
+tests += tst-undefined-weak
+modules-names += tst-undefined-weak-lib
+
+$(objpfx)tst-undefined-weak: $(objpfx)tst-undefined-weak-lib.so
+endif
diff --git a/sysdeps/mips/tst-undefined-weak-lib.S b/sysdeps/mips/tst-undefined-weak-lib.S
new file mode 100644 (file)
index 0000000..a175ebf
--- /dev/null
@@ -0,0 +1,43 @@
+/* Undefined weak symbol loading shared module.
+   Copyright (C) 2019 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 <sgidefs.h>
+
+    .text
+    .globl     x
+    .set       nomips16
+    .set       nomicromips
+    .ent       x
+    .type      x, @function
+x:
+    .set noreorder
+#if _MIPS_SIM == _ABIO32
+    .cpload  $25
+    jr  $31
+    lb  $2,%got(a)($28)
+#else
+    .cpsetup  $25,$24,x
+    lb  $2,%got_disp(a)($28)
+    jr  $31
+    .cpreturn
+#endif
+    .set reorder
+    .end       x
+    .size      x, .-x
+    .weak      a
+    .hidden    a
diff --git a/sysdeps/mips/tst-undefined-weak.c b/sysdeps/mips/tst-undefined-weak.c
new file mode 100644 (file)
index 0000000..1231da6
--- /dev/null
@@ -0,0 +1,28 @@
+/* Undefined weak symbol loading main executable.
+   Copyright (C) 2019 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/>.  */
+
+int *x (void);
+
+int
+do_test (void)
+{
+  x ();
+  return 0;
+}
+
+#include <support/test-driver.c>
index 8dde8557540a27992af88f47b9155936140519a7..28257f83ae7255074dd8b93549f5630415d8c21f 100644 (file)
@@ -34,7 +34,7 @@ extern void _dl_static_init (struct link_map *map);
 #undef VALID_ELF_ABIVERSION
 #define VALID_ELF_ABIVERSION(osabi,ver)                        \
   (ver == 0                                            \
-   || (osabi == ELFOSABI_SYSV && ver < 4)              \
+   || (osabi == ELFOSABI_SYSV && ver < 5)              \
    || (osabi == ELFOSABI_GNU && ver < LIBC_ABI_MAX))
 
 #endif /* ldsodefs.h */