* [PATCH 0/2] Accept absolute symbols whose value is zero [BZ #23307]
@ 2018-06-18 18:06 Maciej W. Rozycki
2018-06-18 18:08 ` [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307] Maciej W. Rozycki
` (2 more replies)
0 siblings, 3 replies; 20+ messages in thread
From: Maciej W. Rozycki @ 2018-06-18 18:06 UTC (permalink / raw)
To: libc-alpha; +Cc: Alan Modra
Hi,
With a prototype fix for PR ld/21375 I have triggered another issue with
the dynamic loader, where symbols whose `st_value' is zero are silently
ignored in lookup. Consequently references to a global absolute symbol
whose value is zero cannot be resolved.
I have created a small patch series to address this problem. The first
part is the actual fix. The second part is an ABI bump, so that the
linker can set the minimum ABI required for an absolute symbol created to
address the issue covered in PR ld/21375 and make old dynamic loaders fail
with "ELF file ABI version invalid" rather than confusing "undefined
symbol".
See the individual patch descriptions for further details.
Maciej
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-06-18 18:06 [PATCH 0/2] Accept absolute symbols whose value is zero [BZ #23307] Maciej W. Rozycki
@ 2018-06-18 18:08 ` Maciej W. Rozycki
2018-06-25 20:33 ` Florian Weimer
2018-06-18 18:08 ` [PATCH 1/2] elf: Accept absolute (SHN_ABS) symbols whose value is zero [BZ #23307] Maciej W. Rozycki
2018-06-25 19:14 ` [PING][PATCH 0/2] Accept absolute " Maciej W. Rozycki
2 siblings, 1 reply; 20+ messages in thread
From: Maciej W. Rozycki @ 2018-06-18 18:08 UTC (permalink / raw)
To: libc-alpha; +Cc: Alan Modra
Define a new ABSOLUTE ABI for static linker's use with EI_ABIVERSION
where correct absolute (SHN_ABS) symbol run-time load semantics is
required. This way it can be ensured at static link time that a program
or DSO will not suffer from previous semantics where absolute symbols
were relocated by the base address, or symbols whose `st_value' is zero
silently ignored leading to a confusing "undefined symbol" error message
at load time, and instead "ELF file ABI version invalid" is printed with
old dynamic loaders, making it clear that there is an ABI version
incompatibility.
[BZ #19818]
[BZ #23307]
* libc-abis (ABSOLUTE): New ABI.
* sysdeps/unix/sysv/linux/mips/libc-abis (ABSOLUTE): New ABI.
---
Hi,
Arguably the "ELF file ABI version invalid" message could be improved
too, e.g. I think "Unsupported ELF file ABI version" or even "Unsupported
ELF file ABI version, please upgrade `ld.so'" would make it clearer what
is going on. But that's a matter for a separate change.
OK to apply?
Maciej
---
libc-abis | 2 ++
sysdeps/unix/sysv/linux/mips/libc-abis | 2 ++
2 files changed, 4 insertions(+)
glibc-abi-absolute.diff
Index: glibc/libc-abis
===================================================================
--- glibc.orig/libc-abis 2015-05-20 23:10:30.000000000 +0100
+++ glibc/libc-abis 2018-06-16 20:03:55.899525111 +0100
@@ -46,3 +46,5 @@ IFUNC powerpc64-*-linux*
IFUNC powerpc-*-linux*
IFUNC sparc64-*-linux*
IFUNC sparc-*-linux*
+# Absolute (SHN_ABS) symbols working correctly.
+ABSOLUTE
Index: glibc/sysdeps/unix/sysv/linux/mips/libc-abis
===================================================================
--- glibc.orig/sysdeps/unix/sysv/linux/mips/libc-abis 2015-05-20 23:10:47.000000000 +0100
+++ glibc/sysdeps/unix/sysv/linux/mips/libc-abis 2018-06-16 20:04:29.888042455 +0100
@@ -14,3 +14,5 @@ UNIQUE
#
# MIPS O32 FP64
MIPS_O32_FP64 mips*-*-linux*
+# Absolute (SHN_ABS) symbols working correctly.
+ABSOLUTE
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/2] elf: Accept absolute (SHN_ABS) symbols whose value is zero [BZ #23307]
2018-06-18 18:06 [PATCH 0/2] Accept absolute symbols whose value is zero [BZ #23307] Maciej W. Rozycki
2018-06-18 18:08 ` [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307] Maciej W. Rozycki
@ 2018-06-18 18:08 ` Maciej W. Rozycki
2018-06-25 20:25 ` Florian Weimer
2018-06-25 19:14 ` [PING][PATCH 0/2] Accept absolute " Maciej W. Rozycki
2 siblings, 1 reply; 20+ messages in thread
From: Maciej W. Rozycki @ 2018-06-18 18:08 UTC (permalink / raw)
To: libc-alpha; +Cc: Alan Modra
We have this condition in `check_match' (in elf/dl-lookup.c):
if (__glibc_unlikely ((sym->st_value == 0 /* No value. */
&& stt != STT_TLS)
|| ELF_MACHINE_SYM_NO_MATCH (sym)
|| (type_class & (sym->st_shndx == SHN_UNDEF))))
return NULL;
which causes all !STT_TLS symbols whose value is zero to be silently
ignored in lookup. This may make sense for regular symbols, however not
for absolute (SHN_ABS) ones, where zero is like any value, there's no
special meaning attached to it.
Consequently legitimate programs fail, for example taking the
`elf/tst-absolute-sym' test case, substituting 0 for 0x55aa in
`elf/tst-absolute-sym-lib.lds' and then trying to run the resulting
program we get this:
$ .../elf/tst-absolute-sym
.../elf/tst-absolute-sym: symbol lookup error: .../elf/tst-absolute-sym-lib.so: undefined symbol: absolute
$
even though the symbol clearly is there:
$ readelf --dyn-syms .../elf/tst-absolute-sym-lib.so | grep '\babsolute\b'
7: 00000000 0 NOTYPE GLOBAL DEFAULT ABS absolute
$
The check for the zero value has been there since forever or commit
d66e34cd4234/08162fa88891 ("Implemented runtime dynamic linker to
support ELF shared libraries.") dating back to May 2nd 1995, and the
problem triggers regardless of commit e7feec374c63 ("elf: Correct
absolute (SHN_ABS) symbol run-time calculation [BZ #19818]") being
present or not.
Fix the issue then, by permitting `sym->st_value' to be 0 for SHN_ABS
symbols in lookup.
[BZ #23307]
* elf/dl-lookup.c (check_match): Do not reject a symbol whose
`st_value' is 0 if `st_shndx' is SHN_ABS.
* elf/tst-absolute-zero.c: New file.
* elf/tst-absolute-zero-lib.c: New file.
* elf/tst-absolute-zero-lib.lds: New file.
* elf/Makefile (tests): Add `tst-absolute-zero'.
(modules-names): Add `tst-absolute-zero-lib'.
(LDLIBS-tst-absolute-zero-lib.so): New variable.
($(objpfx)tst-absolute-zero-lib.so): New dependency.
($(objpfx)tst-absolute-zero: New dependency.
---
Hi,
This has been regression-tested successfully with the `mips-linux-gnu'
target and the o32 ABI, big endianness. The new test case fails with an
"undefined symbol" message where the fix included here to `check_match'
has been removed whether commit e7feec374c63 ("elf: Correct absolute
(SHN_ABS) symbol run-time calculation [BZ #19818]") is also present or
not, and it passes with the fix applied.
OK to apply?
Maciej
---
elf/Makefile | 8 ++++++--
elf/dl-lookup.c | 1 +
elf/tst-absolute-zero-lib.c | 25 +++++++++++++++++++++++++
elf/tst-absolute-zero-lib.lds | 1 +
elf/tst-absolute-zero.c | 38 ++++++++++++++++++++++++++++++++++++++
5 files changed, 71 insertions(+), 2 deletions(-)
glibc-elf-shn-abs-zero.diff
Index: glibc/elf/Makefile
===================================================================
--- glibc.orig/elf/Makefile 2018-06-18 18:12:19.911942887 +0100
+++ glibc/elf/Makefile 2018-06-18 18:12:40.092259983 +0100
@@ -186,7 +186,7 @@ tests += restest1 preloadtest loadfail m
tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error tst-noload \
tst-latepthread tst-tls-manydynamic tst-nodelete-dlclose \
- tst-debug1 tst-main1 tst-absolute-sym tst-big-note
+ tst-debug1 tst-main1 tst-absolute-sym tst-absolute-zero tst-big-note
# reldep9
tests-internal += loadtest unload unload2 circleload1 \
neededtest neededtest2 neededtest3 neededtest4 \
@@ -273,7 +273,7 @@ modules-names = testobj1 testobj2 testob
tst-latepthreadmod $(tst-tls-many-dynamic-modules) \
tst-nodelete-dlclose-dso tst-nodelete-dlclose-plugin \
tst-main1mod tst-libc_dlvsym-dso tst-absolute-sym-lib \
- tst-big-note-lib
+ tst-absolute-zero-lib tst-big-note-lib
ifeq (yes,$(have-mtls-dialect-gnu2))
tests += tst-gnu2-tls1
@@ -1456,6 +1456,10 @@ LDLIBS-tst-absolute-sym-lib.so = tst-abs
$(objpfx)tst-absolute-sym-lib.so: $(LDLIBS-tst-absolute-sym-lib.so)
$(objpfx)tst-absolute-sym: $(objpfx)tst-absolute-sym-lib.so
+LDLIBS-tst-absolute-zero-lib.so = tst-absolute-zero-lib.lds
+$(objpfx)tst-absolute-zero-lib.so: $(LDLIBS-tst-absolute-zero-lib.so)
+$(objpfx)tst-absolute-zero: $(objpfx)tst-absolute-zero-lib.so
+
# Both the main program and the DSO for tst-libc_dlvsym need to link
# against libdl.
$(objpfx)tst-libc_dlvsym: $(libdl)
Index: glibc/elf/dl-lookup.c
===================================================================
--- glibc.orig/elf/dl-lookup.c 2018-06-17 09:06:30.202407070 +0100
+++ glibc/elf/dl-lookup.c 2018-06-18 18:12:36.138114433 +0100
@@ -76,6 +76,7 @@ check_match (const char *const undef_nam
unsigned int stt = ELFW(ST_TYPE) (sym->st_info);
assert (ELF_RTYPE_CLASS_PLT == 1);
if (__glibc_unlikely ((sym->st_value == 0 /* No value. */
+ && sym->st_shndx != SHN_ABS
&& stt != STT_TLS)
|| ELF_MACHINE_SYM_NO_MATCH (sym)
|| (type_class & (sym->st_shndx == SHN_UNDEF))))
Index: glibc/elf/tst-absolute-zero-lib.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ glibc/elf/tst-absolute-zero-lib.c 2018-06-18 18:12:40.102324540 +0100
@@ -0,0 +1,25 @@
+/* BZ #xxxxx absolute zero symbol calculation shared module.
+ Copyright (C) 2018 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/>. */
+
+extern char absolute;
+
+void *
+get_absolute (void)
+{
+ return &absolute;
+}
Index: glibc/elf/tst-absolute-zero-lib.lds
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ glibc/elf/tst-absolute-zero-lib.lds 2018-06-18 18:12:40.129495568 +0100
@@ -0,0 +1 @@
+"absolute" = 0;
Index: glibc/elf/tst-absolute-zero.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ glibc/elf/tst-absolute-zero.c 2018-06-18 18:12:40.147611912 +0100
@@ -0,0 +1,38 @@
+/* BZ #xxxxx absolute zero symbol calculation main executable.
+ Copyright (C) 2018 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 <support/check.h>
+#include <support/support.h>
+#include <support/test-driver.h>
+
+void *get_absolute (void);
+
+static int
+do_test (void)
+{
+ void *ref = (void *) 0;
+ void *ptr;
+
+ ptr = get_absolute ();
+ if (ptr != ref)
+ FAIL_EXIT1 ("Got %p, expected %p\n", ptr, ref);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PING][PATCH 0/2] Accept absolute symbols whose value is zero [BZ #23307]
2018-06-18 18:06 [PATCH 0/2] Accept absolute symbols whose value is zero [BZ #23307] Maciej W. Rozycki
2018-06-18 18:08 ` [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307] Maciej W. Rozycki
2018-06-18 18:08 ` [PATCH 1/2] elf: Accept absolute (SHN_ABS) symbols whose value is zero [BZ #23307] Maciej W. Rozycki
@ 2018-06-25 19:14 ` Maciej W. Rozycki
2 siblings, 0 replies; 20+ messages in thread
From: Maciej W. Rozycki @ 2018-06-25 19:14 UTC (permalink / raw)
To: libc-alpha
On Mon, 18 Jun 2018, Maciej W. Rozycki wrote:
> I have created a small patch series to address this problem. The first
> part is the actual fix. The second part is an ABI bump, so that the
> linker can set the minimum ABI required for an absolute symbol created to
> address the issue covered in PR ld/21375 and make old dynamic loaders fail
> with "ELF file ABI version invalid" rather than confusing "undefined
> symbol".
Ping for:
<https://patchwork.sourceware.org/patch/27909/>
<https://patchwork.sourceware.org/patch/27910/>
I'd like to see these changes in 2.28.
Maciej
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] elf: Accept absolute (SHN_ABS) symbols whose value is zero [BZ #23307]
2018-06-18 18:08 ` [PATCH 1/2] elf: Accept absolute (SHN_ABS) symbols whose value is zero [BZ #23307] Maciej W. Rozycki
@ 2018-06-25 20:25 ` Florian Weimer
2018-06-29 16:13 ` [committed v2 " Maciej W. Rozycki
0 siblings, 1 reply; 20+ messages in thread
From: Florian Weimer @ 2018-06-25 20:25 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: libc-alpha, Alan Modra
* Maciej W. Rozycki:
> --- glibc.orig/elf/dl-lookup.c 2018-06-17 09:06:30.202407070 +0100
> +++ glibc/elf/dl-lookup.c 2018-06-18 18:12:36.138114433 +0100
> @@ -76,6 +76,7 @@ check_match (const char *const undef_nam
> unsigned int stt = ELFW(ST_TYPE) (sym->st_info);
> assert (ELF_RTYPE_CLASS_PLT == 1);
> if (__glibc_unlikely ((sym->st_value == 0 /* No value. */
> + && sym->st_shndx != SHN_ABS
> && stt != STT_TLS)
> || ELF_MACHINE_SYM_NO_MATCH (sym)
> || (type_class & (sym->st_shndx == SHN_UNDEF))))
Context here:
unsigned int stt = ELFW(ST_TYPE) (sym->st_info);
assert (ELF_RTYPE_CLASS_PLT == 1);
if (__glibc_unlikely ((sym->st_value == 0 /* No value. */
&& stt != STT_TLS)
|| ELF_MACHINE_SYM_NO_MATCH (sym)
|| (type_class & (sym->st_shndx == SHN_UNDEF))))
return NULL;
So this looks good.
> Index: glibc/elf/tst-absolute-zero-lib.c
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ glibc/elf/tst-absolute-zero-lib.c 2018-06-18 18:12:40.102324540 +0100
> @@ -0,0 +1,25 @@
> +/* BZ #xxxxx absolute zero symbol calculation shared module.
Needs Bugzilla number.
> Index: glibc/elf/tst-absolute-zero.c
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ glibc/elf/tst-absolute-zero.c 2018-06-18 18:12:40.147611912 +0100
> @@ -0,0 +1,38 @@
> +/* BZ #xxxxx absolute zero symbol calculation main executable.
Likewise.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-06-18 18:08 ` [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307] Maciej W. Rozycki
@ 2018-06-25 20:33 ` Florian Weimer
2018-06-27 22:08 ` Maciej W. Rozycki
0 siblings, 1 reply; 20+ messages in thread
From: Florian Weimer @ 2018-06-25 20:33 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: libc-alpha, Alan Modra
* Maciej W. Rozycki:
> Define a new ABSOLUTE ABI for static linker's use with EI_ABIVERSION
> where correct absolute (SHN_ABS) symbol run-time load semantics is
> required. This way it can be ensured at static link time that a program
> or DSO will not suffer from previous semantics where absolute symbols
> were relocated by the base address, or symbols whose `st_value' is zero
> silently ignored leading to a confusing "undefined symbol" error message
> at load time, and instead "ELF file ABI version invalid" is printed with
> old dynamic loaders, making it clear that there is an ABI version
> incompatibility.
Is this really necessary? It essentially precludes backporting the
fixes.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-06-25 20:33 ` Florian Weimer
@ 2018-06-27 22:08 ` Maciej W. Rozycki
2018-06-28 6:59 ` Florian Weimer
0 siblings, 1 reply; 20+ messages in thread
From: Maciej W. Rozycki @ 2018-06-27 22:08 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha, Alan Modra
Hi Florian,
> > Define a new ABSOLUTE ABI for static linker's use with EI_ABIVERSION
> > where correct absolute (SHN_ABS) symbol run-time load semantics is
> > required. This way it can be ensured at static link time that a program
> > or DSO will not suffer from previous semantics where absolute symbols
> > were relocated by the base address, or symbols whose `st_value' is zero
> > silently ignored leading to a confusing "undefined symbol" error message
> > at load time, and instead "ELF file ABI version invalid" is printed with
> > old dynamic loaders, making it clear that there is an ABI version
> > incompatibility.
>
> Is this really necessary? It essentially precludes backporting the
> fixes.
Thank you for your input. Of course bumping up the ABI version is not
itself required for the change to work, and all existing working binaries
will continue to.
Technically it does not preclude backporting either, although of course
it is limited by the previous ABI bump, which is (in the reverse order by
version/date):
* glibc 2.21 for MIPS targets, by commit 12e6ee86c4f2 ("Add support for
MIPS O32 FPXX and .MIPS.abiflags"),
* glibc 2.12 for PowerPC and SPARC targets, by commit 12e6ee86c4f2 ("A few
more archs have IFUNC support."),
* glibc 2.12 for the remaining targets, by commit 92ad15a8f1d3 ("Implement
handling of libc ABI in ELF header."), when the feature was introduced.
I don't believe we backport *that* far in upstream branches, however I'll
be happy to be corrected.
Otherwise whether to backport or not to would be a matter of policy. And
policies are there to make life easier and not more difficult. So what
does our current actually policy say? Well, at:
<https://sourceware.org/glibc/wiki/Release/#General_policy> I read this:
"Patch backports to stable branches are discussed on libc-stable, and any
patch on master that doesn't change ABI or API is immediately suitable for
backporting to a stable branch."
To me it means that a patch which does change an ABI or an API, while not
immediately, can still be suitable for backporting, however consensus has
to be reached.
So what are the pros and the cons of having an ABI defined for absolute
symbol handling?
The pros I can identify are:
1. It matches reality.
Previously absolute symbols were effectively completely not supported.
Not just failing to work in some cases or consistently working
incorrectly, while still being recognised. No, they were not
recognised at all and treated as ordinary symbols that express memory
addresses and, if applicable, are relocated by the base address at load
time.
Yes, from the ELF gABI's point of view this is a conformance bug fix,
however from GNU C library's point of view this is a new feature.
2. It is reported by running `libc.so', e.g. with the patch applied on a
MIPS system you get information like this:
GNU C Library (GNU libc) development release version 2.27.9000.
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 8.0.1 20180410 (experimental).
libc ABIs: MIPS_PLT UNIQUE MIPS_O32_FP64 ABSOLUTE
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
where you can readily determine that the feature is supported, which is
suitable for inclusion in release notes of binary software packages
that have been compiled to require that feature for correct operation.
3. It replaces an obscure "undefined symbol" error message with an
informative "ELF file ABI version invalid" one for absolute symbols
whose value is zero.
Such symbols will be produced by the static linker in MIPS ELF binaries
for undefined weak symbols whose scope is local (and therefore have to
be wired to zero) and which are referred to via the GOT once the
upcoming fix for binutils PR ld/21375 has been applied.
The reason for that solution is that the MIPS psABI makes the GOT
implicitly relocated and consequently undefined weak symbol references
cannot use a local GOT entry, because all such entries are relocated by
the base address at load time. Consequently such references have to be
made to a global GOT entry associated with a global absolute symbol
whose value is zero and remains such at load time.
The usual approach with targets that have the GOT explicitly relocated
(all the non-MIPS targets I believe) is to have no dynamic R_*_RELATIVE
relocation attached to local GOT entries associated with undefined weak
symbols whose scope is local, which prevents them from being relocated
at load time.
NB the fix for binutils PR ld/21375 will strive to avoid using that
global absolute symbol where possible by code relaxation applied to the
usual instructions used for GOT references, but GOT relocations are
generic and if used with an instruction the linker cannot interpret it
will have to stay there and refer to a global GOT entry associated with
such a symbol.
(Granted, the message we print for an attempt to load an ELF file that
requests an ABI version higher than the dynamic loader supports is also
but obscure, however at least it is indicative and we can improve it,
whereas the message printed for a symbol lookup that has failed because
a symbol definition has been ignored is completely useless to whoever
has encountered it.)
4. It prevents software relying on non-zero absolute symbols from
malfunctioning, perhaps in a way that may be difficult to identify.
I have no plans at the moment to arrange for the static linker to
recognise the general case of dynamic absolute symbols being produced
and to adjust the libc ABI requested accordingly. Using dynamic
symbols in such a way would I think be a means to determine the
presence of features or to examine configuration settings among a set
of DSOs whose configuration may vary between builds.
5. This is similar in spirit a change to the dynamic loader to the earlier
addition of the STB_GNU_UNIQUE ELF gABI extenstion.
Likewise we could have no ABI version defined for STB_GNU_UNIQUE and
rely on an obscure error path or the lack of, wherever an old dynamic
loader handles modules using the feature.
The cons I can identify are:
1. It may too unimportant a feature to deserve an ABI bump.
The only user of the feature at the moment is the upcoming fix for
binutils PR ld/21375, which addresses an obscure corner case of the
MIPS psABI. So its use it quite limited.
Overall I think the maximum libc ABI version supported is not a property
of the ABI that should prevent the change introducing it from being
backported:
1. Bumping it up does not affect, in any way, binary software
whose ABI version requested is lower than or equal to the current
maximum ABI version.
2. It does not export itself any extra feature available to binary
software; that is already done by the absolute symbol handling change
itself. It only announces the presence of the change, which would
otherwise be hidden.
3. It does affect newly-built software which will request that ABI version
from the dynamic loader. However that software, in the absence of a
way to request a new ABI version, would not work anyway with an old
dynamic loader.
Therefore I believe there should be no policy issue with backporting the
change. Although I think that consensus is still required on whether the
ABI update is important enough to deserve a new version.
Comments, thoughts, questions?
Maciej
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-06-27 22:08 ` Maciej W. Rozycki
@ 2018-06-28 6:59 ` Florian Weimer
2018-06-28 13:49 ` Maciej W. Rozycki
0 siblings, 1 reply; 20+ messages in thread
From: Florian Weimer @ 2018-06-28 6:59 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: libc-alpha, Alan Modra
On 06/28/2018 12:07 AM, Maciej W. Rozycki wrote:
>> Is this really necessary? It essentially precludes backporting the
>> fixes.
> Thank you for your input. Of course bumping up the ABI version is not
> itself required for the change to work, and all existing working binaries
> will continue to.
>
> Technically it does not preclude backporting either, although of course
> it is limited by the previous ABI bump, which is (in the reverse order by
> version/date):
Maybe I misunderstood what you were trying to do here.
Will the EI_ABIVERSION in created binaries increase if the programmer
simply upgrades binutils? Or will this happen only when particular
features are used?
Thanks,
Florian
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-06-28 6:59 ` Florian Weimer
@ 2018-06-28 13:49 ` Maciej W. Rozycki
2018-06-28 13:54 ` Florian Weimer
0 siblings, 1 reply; 20+ messages in thread
From: Maciej W. Rozycki @ 2018-06-28 13:49 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha, Alan Modra
On Wed, 27 Jun 2018, Florian Weimer wrote:
> > > Is this really necessary? It essentially precludes backporting the
> > > fixes.
> > Thank you for your input. Of course bumping up the ABI version is not
> > itself required for the change to work, and all existing working binaries
> > will continue to.
> >
> > Technically it does not preclude backporting either, although of course
> > it is limited by the previous ABI bump, which is (in the reverse order by
> > version/date):
>
> Maybe I misunderstood what you were trying to do here.
>
> Will the EI_ABIVERSION in created binaries increase if the programmer simply
> upgrades binutils? Or will this happen only when particular features are
> used?
Only when this particular feature is required, like with the older ABI
versions defined so far. I've double-checked with binutils and the MIPS
target is the only one actively switching EI_ABIVERSION; all the remaining
targets appear to have the value fixed and I am not going to change that.
This is how the relevant part of the linker update in question looks
like:
Index: binutils/bfd/elfxx-mips.c
===================================================================
--- binutils.orig/bfd/elfxx-mips.c 2018-06-28 00:44:35.780943617 +0100
+++ binutils/bfd/elfxx-mips.c 2018-06-28 00:44:35.913406279 +0100
@@ -16305,13 +16449,14 @@ enum
MIPS_LIBC_ABI_MIPS_PLT,
MIPS_LIBC_ABI_UNIQUE,
MIPS_LIBC_ABI_MIPS_O32_FP64,
+ MIPS_LIBC_ABI_ABSOLUTE,
MIPS_LIBC_ABI_MAX
};
void
_bfd_mips_post_process_headers (bfd *abfd, struct bfd_link_info *link_info)
{
- struct mips_elf_link_hash_table *htab;
+ struct mips_elf_link_hash_table *htab = NULL;
Elf_Internal_Ehdr *i_ehdrp;
i_ehdrp = elf_elfheader (abfd);
@@ -16319,15 +16464,19 @@ _bfd_mips_post_process_headers (bfd *abf
{
htab = mips_elf_hash_table (link_info);
BFD_ASSERT (htab != NULL);
-
- if (htab->use_plts_and_copy_relocs && !htab->is_vxworks)
- i_ehdrp->e_ident[EI_ABIVERSION] = MIPS_LIBC_ABI_MIPS_PLT;
}
+ if (htab != NULL && htab->use_plts_and_copy_relocs && !htab->is_vxworks)
+ i_ehdrp->e_ident[EI_ABIVERSION] = MIPS_LIBC_ABI_MIPS_PLT;
+
if (mips_elf_tdata (abfd)->abiflags.fp_abi == Val_GNU_MIPS_ABI_FP_64
|| mips_elf_tdata (abfd)->abiflags.fp_abi == Val_GNU_MIPS_ABI_FP_64A)
i_ehdrp->e_ident[EI_ABIVERSION] = MIPS_LIBC_ABI_MIPS_O32_FP64;
+ /* Mark that we need support for absolute symbols in the dynamic loader. */
+ if (htab != NULL && htab->use_absolute_zero)
+ i_ehdrp->e_ident[EI_ABIVERSION] = MIPS_LIBC_ABI_ABSOLUTE;
+
_bfd_elf_post_process_headers (abfd, link_info);
}
and then `htab->use_absolute_zero' will be TRUE iff a GOT relocation has
been calculated to actually refer to a specially-created absolute symbol
used to address the issue covered by binutils PR ld/21375.
The flag will be FALSE if code has been relaxed to avoid referring the
GOT (by using immediate zero instead), in which case no absolute symbol
will have been specially created.
Does this explanation clear your concern?
Maciej
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-06-28 13:49 ` Maciej W. Rozycki
@ 2018-06-28 13:54 ` Florian Weimer
2018-06-28 14:54 ` Maciej W. Rozycki
0 siblings, 1 reply; 20+ messages in thread
From: Florian Weimer @ 2018-06-28 13:54 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: libc-alpha, Alan Modra
On 06/28/2018 03:49 PM, Maciej W. Rozycki wrote:
> + /* Mark that we need support for absolute symbols in the dynamic loader. */
> + if (htab != NULL && htab->use_absolute_zero)
> + i_ehdrp->e_ident[EI_ABIVERSION] = MIPS_LIBC_ABI_ABSOLUTE;
> +
> _bfd_elf_post_process_headers (abfd, link_info);
> }
>
> and then `htab->use_absolute_zero' will be TRUE iff a GOT relocation has
> been calculated to actually refer to a specially-created absolute symbol
> used to address the issue covered by binutils PR ld/21375.
>
> The flag will be FALSE if code has been relaxed to avoid referring the
> GOT (by using immediate zero instead), in which case no absolute symbol
> will have been specially created.
>
> Does this explanation clear your concern?
Yes, I think this is okay then.
We cannot express this change at the RPM dependency level, but I'm not
sure how active the Fedora MIPS port is these days, so it probably does
not matter.
Thanks,
Florian
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-06-28 13:54 ` Florian Weimer
@ 2018-06-28 14:54 ` Maciej W. Rozycki
2018-06-29 16:29 ` Maciej W. Rozycki
0 siblings, 1 reply; 20+ messages in thread
From: Maciej W. Rozycki @ 2018-06-28 14:54 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha, Alan Modra
On Thu, 28 Jun 2018, Florian Weimer wrote:
> On 06/28/2018 03:49 PM, Maciej W. Rozycki wrote:
> > + /* Mark that we need support for absolute symbols in the dynamic loader.
> > */
> > + if (htab != NULL && htab->use_absolute_zero)
> > + i_ehdrp->e_ident[EI_ABIVERSION] = MIPS_LIBC_ABI_ABSOLUTE;
> > +
> > _bfd_elf_post_process_headers (abfd, link_info);
> > }
> > and then `htab->use_absolute_zero' will be TRUE iff a GOT relocation has
> > been calculated to actually refer to a specially-created absolute symbol
> > used to address the issue covered by binutils PR ld/21375.
> >
> > The flag will be FALSE if code has been relaxed to avoid referring the
> > GOT (by using immediate zero instead), in which case no absolute symbol
> > will have been specially created.
> >
> > Does this explanation clear your concern?
>
> Yes, I think this is okay then.
Great!
> We cannot express this change at the RPM dependency level, but I'm not sure
> how active the Fedora MIPS port is these days, so it probably does not matter.
The case of MIPS_LIBC_ABI_ABSOLUTE is supposed to be exceedingly rare.
However I decided to handle it, rather than having the linker fail, be it
with an assertion failure or gracefully.
I think RPM could be easily expanded to include EI_ABIVERSION with its
existing dependency mechanism. The EI_ABIVERSION field is reported by
`readelf -h', so the requirement could be easily extracted from binaries
just like symbol versioning information is.
The only complication is the package supplying the dynamic loader, where
the provision of the maximum value of EI_ABIVERSION supported would I
think have to be entered manually in the package spec.
Decades ago I modified the RPM dependency extraction scripts (`linux.req'
and `linux.prov') to use `readelf' rather than a combination of `objdump'
and `ldd' (although I left the latter as a fallback to keep supporting
a.out dependencies), so that dependencies were right for cross-compiled
packages.
I have never submitted that work back (as I recall it was not exactly
easy to get through), however experience gained with that makes me think
expanding the mechanism to include EI_ABIVERSION should be straightforward
to implement. Perhaps it would be worth doing anyway, just in case?
NB I have no idea what RPM uses these days for dependency tracking and
whether it handles cross-compilation right or not. Work I did back then
remains available from `ftp.linux-mips.org', in the form of RPM 3.0.6 RPM
packages; the GNU GPL applies.
Maciej
^ permalink raw reply [flat|nested] 20+ messages in thread
* [committed v2 1/2] elf: Accept absolute (SHN_ABS) symbols whose value is zero [BZ #23307]
2018-06-25 20:25 ` Florian Weimer
@ 2018-06-29 16:13 ` Maciej W. Rozycki
2018-06-29 17:41 ` Joseph Myers
0 siblings, 1 reply; 20+ messages in thread
From: Maciej W. Rozycki @ 2018-06-29 16:13 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha, Alan Modra
We have this condition in `check_match' (in elf/dl-lookup.c):
if (__glibc_unlikely ((sym->st_value == 0 /* No value. */
&& stt != STT_TLS)
|| ELF_MACHINE_SYM_NO_MATCH (sym)
|| (type_class & (sym->st_shndx == SHN_UNDEF))))
return NULL;
which causes all !STT_TLS symbols whose value is zero to be silently
ignored in lookup. This may make sense for regular symbols, however not
for absolute (SHN_ABS) ones, where zero is like any value, there's no
special meaning attached to it.
Consequently legitimate programs fail, for example taking the
`elf/tst-absolute-sym' test case, substituting 0 for 0x55aa in
`elf/tst-absolute-sym-lib.lds' and then trying to run the resulting
program we get this:
$ .../elf/tst-absolute-sym
.../elf/tst-absolute-sym: symbol lookup error: .../elf/tst-absolute-sym-lib.so: undefined symbol: absolute
$
even though the symbol clearly is there:
$ readelf --dyn-syms .../elf/tst-absolute-sym-lib.so | grep '\babsolute\b'
7: 00000000 0 NOTYPE GLOBAL DEFAULT ABS absolute
$
The check for the zero value has been there since forever or commit
d66e34cd4234/08162fa88891 ("Implemented runtime dynamic linker to
support ELF shared libraries.") dating back to May 2nd 1995, and the
problem triggers regardless of commit e7feec374c63 ("elf: Correct
absolute (SHN_ABS) symbol run-time calculation [BZ #19818]") being
present or not.
Fix the issue then, by permitting `sym->st_value' to be 0 for SHN_ABS
symbols in lookup.
[BZ #23307]
* elf/dl-lookup.c (check_match): Do not reject a symbol whose
`st_value' is 0 if `st_shndx' is SHN_ABS.
* elf/tst-absolute-zero.c: New file.
* elf/tst-absolute-zero-lib.c: New file.
* elf/tst-absolute-zero-lib.lds: New file.
* elf/Makefile (tests): Add `tst-absolute-zero'.
(modules-names): Add `tst-absolute-zero-lib'.
(LDLIBS-tst-absolute-zero-lib.so): New variable.
($(objpfx)tst-absolute-zero-lib.so): New dependency.
($(objpfx)tst-absolute-zero: New dependency.
---
Hi Florian,
> > Index: glibc/elf/tst-absolute-zero-lib.c
> > ===================================================================
> > --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> > +++ glibc/elf/tst-absolute-zero-lib.c 2018-06-18 18:12:40.102324540 +0100
> > @@ -0,0 +1,25 @@
> > +/* BZ #xxxxx absolute zero symbol calculation shared module.
>
> Needs Bugzilla number.
>
> > Index: glibc/elf/tst-absolute-zero.c
> > ===================================================================
> > --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> > +++ glibc/elf/tst-absolute-zero.c 2018-06-18 18:12:40.147611912 +0100
> > @@ -0,0 +1,38 @@
> > +/* BZ #xxxxx absolute zero symbol calculation main executable.
>
> Likewise.
Thank you for your review. I have applied this change now, with these
issues fixed. I'm keeping BZ #23307 open for the outcome with 2/2.
Maciej
---
elf/Makefile | 8 ++++++--
elf/dl-lookup.c | 1 +
elf/tst-absolute-zero-lib.c | 25 +++++++++++++++++++++++++
elf/tst-absolute-zero-lib.lds | 1 +
elf/tst-absolute-zero.c | 38 ++++++++++++++++++++++++++++++++++++++
5 files changed, 71 insertions(+), 2 deletions(-)
glibc-elf-shn-abs-zero.diff
Index: glibc/elf/Makefile
===================================================================
--- glibc.orig/elf/Makefile 2018-06-18 18:12:19.911942887 +0100
+++ glibc/elf/Makefile 2018-06-18 18:12:40.092259983 +0100
@@ -186,7 +186,7 @@ tests += restest1 preloadtest loadfail m
tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error tst-noload \
tst-latepthread tst-tls-manydynamic tst-nodelete-dlclose \
- tst-debug1 tst-main1 tst-absolute-sym tst-big-note
+ tst-debug1 tst-main1 tst-absolute-sym tst-absolute-zero tst-big-note
# reldep9
tests-internal += loadtest unload unload2 circleload1 \
neededtest neededtest2 neededtest3 neededtest4 \
@@ -273,7 +273,7 @@ modules-names = testobj1 testobj2 testob
tst-latepthreadmod $(tst-tls-many-dynamic-modules) \
tst-nodelete-dlclose-dso tst-nodelete-dlclose-plugin \
tst-main1mod tst-libc_dlvsym-dso tst-absolute-sym-lib \
- tst-big-note-lib
+ tst-absolute-zero-lib tst-big-note-lib
ifeq (yes,$(have-mtls-dialect-gnu2))
tests += tst-gnu2-tls1
@@ -1456,6 +1456,10 @@ LDLIBS-tst-absolute-sym-lib.so = tst-abs
$(objpfx)tst-absolute-sym-lib.so: $(LDLIBS-tst-absolute-sym-lib.so)
$(objpfx)tst-absolute-sym: $(objpfx)tst-absolute-sym-lib.so
+LDLIBS-tst-absolute-zero-lib.so = tst-absolute-zero-lib.lds
+$(objpfx)tst-absolute-zero-lib.so: $(LDLIBS-tst-absolute-zero-lib.so)
+$(objpfx)tst-absolute-zero: $(objpfx)tst-absolute-zero-lib.so
+
# Both the main program and the DSO for tst-libc_dlvsym need to link
# against libdl.
$(objpfx)tst-libc_dlvsym: $(libdl)
Index: glibc/elf/dl-lookup.c
===================================================================
--- glibc.orig/elf/dl-lookup.c 2018-06-17 09:06:30.202407070 +0100
+++ glibc/elf/dl-lookup.c 2018-06-18 18:12:36.138114433 +0100
@@ -76,6 +76,7 @@ check_match (const char *const undef_nam
unsigned int stt = ELFW(ST_TYPE) (sym->st_info);
assert (ELF_RTYPE_CLASS_PLT == 1);
if (__glibc_unlikely ((sym->st_value == 0 /* No value. */
+ && sym->st_shndx != SHN_ABS
&& stt != STT_TLS)
|| ELF_MACHINE_SYM_NO_MATCH (sym)
|| (type_class & (sym->st_shndx == SHN_UNDEF))))
Index: glibc/elf/tst-absolute-zero-lib.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ glibc/elf/tst-absolute-zero-lib.c 2018-06-29 16:49:42.817333198 +0100
@@ -0,0 +1,25 @@
+/* BZ #23307 absolute zero symbol calculation shared module.
+ Copyright (C) 2018 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/>. */
+
+extern char absolute;
+
+void *
+get_absolute (void)
+{
+ return &absolute;
+}
Index: glibc/elf/tst-absolute-zero-lib.lds
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ glibc/elf/tst-absolute-zero-lib.lds 2018-06-18 18:12:40.129495568 +0100
@@ -0,0 +1 @@
+"absolute" = 0;
Index: glibc/elf/tst-absolute-zero.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ glibc/elf/tst-absolute-zero.c 2018-06-29 16:49:50.893494243 +0100
@@ -0,0 +1,38 @@
+/* BZ #23307 absolute zero symbol calculation main executable.
+ Copyright (C) 2018 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 <support/check.h>
+#include <support/support.h>
+#include <support/test-driver.h>
+
+void *get_absolute (void);
+
+static int
+do_test (void)
+{
+ void *ref = (void *) 0;
+ void *ptr;
+
+ ptr = get_absolute ();
+ if (ptr != ref)
+ FAIL_EXIT1 ("Got %p, expected %p\n", ptr, ref);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-06-28 14:54 ` Maciej W. Rozycki
@ 2018-06-29 16:29 ` Maciej W. Rozycki
2018-07-03 13:53 ` Carlos O'Donell
0 siblings, 1 reply; 20+ messages in thread
From: Maciej W. Rozycki @ 2018-06-29 16:29 UTC (permalink / raw)
To: libc-alpha; +Cc: Florian Weimer, Alan Modra
On Thu, 28 Jun 2018, Maciej W. Rozycki wrote:
> > > + /* Mark that we need support for absolute symbols in the dynamic loader.
> > > */
> > > + if (htab != NULL && htab->use_absolute_zero)
> > > + i_ehdrp->e_ident[EI_ABIVERSION] = MIPS_LIBC_ABI_ABSOLUTE;
> > > +
> > > _bfd_elf_post_process_headers (abfd, link_info);
> > > }
> > > and then `htab->use_absolute_zero' will be TRUE iff a GOT relocation has
> > > been calculated to actually refer to a specially-created absolute symbol
> > > used to address the issue covered by binutils PR ld/21375.
> > >
> > > The flag will be FALSE if code has been relaxed to avoid referring the
> > > GOT (by using immediate zero instead), in which case no absolute symbol
> > > will have been specially created.
> > >
> > > Does this explanation clear your concern?
> >
> > Yes, I think this is okay then.
>
> Great!
Any further input? Have we reached consensus?
If so, then I think a NEWS entry will be due, such as:
* The maximum libc ABI supported has been increased to reflect absolute
symbol support. This can be used by the static linker in the ELF file
header's EI_ABIVERSION field to indicate such support is required.
which I will include in the actual commit.
Maciej
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [committed v2 1/2] elf: Accept absolute (SHN_ABS) symbols whose value is zero [BZ #23307]
2018-06-29 16:13 ` [committed v2 " Maciej W. Rozycki
@ 2018-06-29 17:41 ` Joseph Myers
2018-06-29 18:05 ` Maciej W. Rozycki
0 siblings, 1 reply; 20+ messages in thread
From: Joseph Myers @ 2018-06-29 17:41 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: Florian Weimer, libc-alpha, Alan Modra
On Fri, 29 Jun 2018, Maciej W. Rozycki wrote:
> issues fixed. I'm keeping BZ #23307 open for the outcome with 2/2.
That's not appropriate. If a bug is resolved (which this is), it needs to
be marked RESOLVED/FIXED with target milestone set, so that the proper
list of fixed bugs is generated for 2.28 even if there is no further
progress on the question of ABI marking.
This does not rule out having a *new* bug opened for the ABI marking
question, but the original bug should be marked as fixed to make sure we
get a proper list of fixed bugs in NEWS for 2.28.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [committed v2 1/2] elf: Accept absolute (SHN_ABS) symbols whose value is zero [BZ #23307]
2018-06-29 17:41 ` Joseph Myers
@ 2018-06-29 18:05 ` Maciej W. Rozycki
0 siblings, 0 replies; 20+ messages in thread
From: Maciej W. Rozycki @ 2018-06-29 18:05 UTC (permalink / raw)
To: Joseph Myers; +Cc: Florian Weimer, libc-alpha, Alan Modra
On Fri, 29 Jun 2018, Joseph Myers wrote:
> > issues fixed. I'm keeping BZ #23307 open for the outcome with 2/2.
>
> That's not appropriate. If a bug is resolved (which this is), it needs to
> be marked RESOLVED/FIXED with target milestone set, so that the proper
> list of fixed bugs is generated for 2.28 even if there is no further
> progress on the question of ABI marking.
OK, done.
Maciej
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-06-29 16:29 ` Maciej W. Rozycki
@ 2018-07-03 13:53 ` Carlos O'Donell
2018-07-05 15:42 ` [PATCH v2 " Maciej W. Rozycki
0 siblings, 1 reply; 20+ messages in thread
From: Carlos O'Donell @ 2018-07-03 13:53 UTC (permalink / raw)
To: Maciej W. Rozycki, libc-alpha; +Cc: Florian Weimer, Alan Modra
On 06/29/2018 12:29 PM, Maciej W. Rozycki wrote:
> On Thu, 28 Jun 2018, Maciej W. Rozycki wrote:
>
>>>> + /* Mark that we need support for absolute symbols in the dynamic loader.
>>>> */
>>>> + if (htab != NULL && htab->use_absolute_zero)
>>>> + i_ehdrp->e_ident[EI_ABIVERSION] = MIPS_LIBC_ABI_ABSOLUTE;
>>>> +
>>>> _bfd_elf_post_process_headers (abfd, link_info);
>>>> }
>>>> and then `htab->use_absolute_zero' will be TRUE iff a GOT relocation has
>>>> been calculated to actually refer to a specially-created absolute symbol
>>>> used to address the issue covered by binutils PR ld/21375.
>>>>
>>>> The flag will be FALSE if code has been relaxed to avoid referring the
>>>> GOT (by using immediate zero instead), in which case no absolute symbol
>>>> will have been specially created.
>>>>
>>>> Does this explanation clear your concern?
>>>
>>> Yes, I think this is okay then.
>>
>> Great!
>
> Any further input? Have we reached consensus?
>
> If so, then I think a NEWS entry will be due, such as:
>
> * The maximum libc ABI supported has been increased to reflect absolute
> symbol support. This can be used by the static linker in the ELF file
> header's EI_ABIVERSION field to indicate such support is required.
Suggest:
* The GNU C Library now has correct support for ABSOLUTE symbols
(SHN_ABS-relative symbols). Previously such ABSOLUTE symbols were relocated
inconsistently or wrongly in some cases. The GNU linker has been enhanced to
fix this issue, but it must communicate these newer semantics to the dynamic
loader by setting the ELF file's identification (EI_ABIVERSION field) to
indicate such support is required.
> which I will include in the actual commit.
This looks good to me.
I don't see an easy way around this problem.
I think bumping EI_ABIVERSION is the best cost/value solution there.
--
Cheers,
Carlos.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-07-03 13:53 ` Carlos O'Donell
@ 2018-07-05 15:42 ` Maciej W. Rozycki
2018-07-05 16:29 ` Carlos O'Donell
0 siblings, 1 reply; 20+ messages in thread
From: Maciej W. Rozycki @ 2018-07-05 15:42 UTC (permalink / raw)
To: Carlos O'Donell; +Cc: libc-alpha, Florian Weimer, Alan Modra
Define a new ABSOLUTE ABI for static linker's use with EI_ABIVERSION
where correct absolute (SHN_ABS) symbol run-time load semantics is
required. This way it can be ensured at static link time that a program
or DSO will not suffer from previous semantics where absolute symbols
were relocated by the base address, or symbols whose `st_value' is zero
silently ignored leading to a confusing "undefined symbol" error message
at load time, and instead "ELF file ABI version invalid" is printed with
old dynamic loaders, making it clear that there is an ABI version
incompatibility.
[BZ #19818]
[BZ #23307]
* libc-abis (ABSOLUTE): New ABI.
* sysdeps/unix/sysv/linux/mips/libc-abis (ABSOLUTE): New ABI.
* NEWS: Mention the new ABI.
---
Hi Carlos,
> > If so, then I think a NEWS entry will be due, such as:
> >
> > * The maximum libc ABI supported has been increased to reflect absolute
> > symbol support. This can be used by the static linker in the ELF file
> > header's EI_ABIVERSION field to indicate such support is required.
>
> Suggest:
>
> * The GNU C Library now has correct support for ABSOLUTE symbols
> (SHN_ABS-relative symbols). Previously such ABSOLUTE symbols were relocated
> inconsistently or wrongly in some cases. The GNU linker has been enhanced to
> fix this issue, but it must communicate these newer semantics to the dynamic
> loader by setting the ELF file's identification (EI_ABIVERSION field) to
> indicate such support is required.
I think it's a bit inaccurate.
First of all the fix to binutils PR ld/21375 is only related to our BZ
#19818 and BZ #23307 in that it makes use of the feature that fixes to our
BZs make work. So I don't think we can call the fix to PR ld/21375 a
linker enhancement addressing (a linker's part of) the issue we have.
Absolute symbols have always worked with the GNU linker (although there
indeed used to be odd corner cases which have since been addressed and
the `LD_FEATURE ("SANE_EXPR")' linker-script command added in the course).
And then I think we can more accurately express what issues we had with
absolute symbols without losing comprehensibility of the release note to
its addressees.
I've included the proposed text in the updated patch carried with this
message. WDYT?
> > which I will include in the actual commit.
>
> This looks good to me.
>
> I don't see an easy way around this problem.
>
> I think bumping EI_ABIVERSION is the best cost/value solution there.
Thank you for your review and assessment of the situation.
As a side note (prompted by how you phrased the release note), neither
the fixes to BZ #19818 and BZ #23307 nor (obviously) this change retains
the old semantics for binaries that carry a lower value in EI_ABIVERSION
(and we actually don't do that for any previously defined EI_ABIVERSION
values either).
I think the chance that a piece of software relies on the broken previous
(lack of) interpretation of absolute symbols is very slim -- after all
what would be the purpose of going through all the arrangement required to
get an absolute dynamic symbol produced in an ELF file only to have it
then interpreted, in a non-compliant way, as far as the ELF gABI is
concerned, as an ordinary relocated one?
So I think it is fine that we consider absolute symbols previously
unsupported and do not provide backwards-compatible semantics for ELF
files carrying a previously defined EI_ABIVERSION value. Having such
support would require engineering effort to conditionalise code at run
time on the value of EI_ABIVERSION, which would also affect performance
(albeit only for absolute symbols, so likely not significantly enough for
that to be a real concern), and then only to support non-compliant code
that may not even exist.
If such code does surface, then we can assess the situation again, and
decide what to do about that.
For the record, in the course of fixing an unrelated issue with section
garbage collection in the GNU linker (binutils commit 12f09816cecc
("MIPS/BFD: Make section GC work with `ict_irix5' targets")), I have come
across these symbols produced for use by the IRIX 5 dynamic loader
(according to `readelf'):
Symbol table '\.dynsym' contains 4 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 SECTION GLOBAL PROTECTED ABS _procedure_table_size
2: 00000000 0 SECTION GLOBAL PROTECTED PRC [0xff02] _procedure_string_table
3: 00000000 0 SECTION GLOBAL PROTECTED PRC [0xff02] _procedure_table
which clearly indicates how at least one non-GNU dynamic loader interprets
absolute symbols (the size of the procedure table, held in
`_procedure_table_size', surely is not supposed to be relocated by the
base address); for the record, `PRC [0xff02]' denotes the special
SHN_MIPS_TEXT section used to hold code in the MIPS/IRIX psABI in place of
the usual `.text' section.
OK for this change with updated NEWS then?
Maciej
Changes from v1:
- NEWS entry added.
---
NEWS | 7 +++++++
libc-abis | 2 ++
sysdeps/unix/sysv/linux/mips/libc-abis | 2 ++
3 files changed, 11 insertions(+)
glibc-abi-absolute.diff
Index: glibc/NEWS
===================================================================
--- glibc.orig/NEWS 2018-07-05 14:21:40.000000000 +0100
+++ glibc/NEWS 2018-07-05 14:58:24.773218263 +0100
@@ -9,6 +9,13 @@ Version 2.28
Major new features:
+* The GNU C Library now has correct support for ABSOLUTE symbols
+ (SHN_ABS-relative symbols). Previously such ABSOLUTE symbols were
+ relocated incorrectly or in some cases discarded. The GNU linker can
+ make use of this newer semantics, but it must communicate it to the
+ dynamic loader by setting the ELF file's identification (EI_ABIVERSION
+ field) to indicate such support is required.
+
* Unicode 11.0.0 Support: Character encoding, character type info, and
transliteration tables are all updated to Unicode 11.0.0, using
generator scripts contributed by Mike FABIAN (Red Hat).
Index: glibc/libc-abis
===================================================================
--- glibc.orig/libc-abis 2018-06-29 16:46:11.558734836 +0100
+++ glibc/libc-abis 2018-07-05 14:28:46.185297779 +0100
@@ -46,3 +46,5 @@ IFUNC powerpc64-*-linux*
IFUNC powerpc-*-linux*
IFUNC sparc64-*-linux*
IFUNC sparc-*-linux*
+# Absolute (SHN_ABS) symbols working correctly.
+ABSOLUTE
Index: glibc/sysdeps/unix/sysv/linux/mips/libc-abis
===================================================================
--- glibc.orig/sysdeps/unix/sysv/linux/mips/libc-abis 2018-06-29 16:46:11.594994206 +0100
+++ glibc/sysdeps/unix/sysv/linux/mips/libc-abis 2018-07-05 14:28:46.394860228 +0100
@@ -14,3 +14,5 @@ UNIQUE
#
# MIPS O32 FP64
MIPS_O32_FP64 mips*-*-linux*
+# Absolute (SHN_ABS) symbols working correctly.
+ABSOLUTE
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-07-05 15:42 ` [PATCH v2 " Maciej W. Rozycki
@ 2018-07-05 16:29 ` Carlos O'Donell
2018-07-05 17:10 ` Maciej W. Rozycki
0 siblings, 1 reply; 20+ messages in thread
From: Carlos O'Donell @ 2018-07-05 16:29 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: libc-alpha, Florian Weimer, Alan Modra
On 07/05/2018 11:41 AM, Maciej W. Rozycki wrote:
> Define a new ABSOLUTE ABI for static linker's use with EI_ABIVERSION
> where correct absolute (SHN_ABS) symbol run-time load semantics is
> required. This way it can be ensured at static link time that a program
> or DSO will not suffer from previous semantics where absolute symbols
> were relocated by the base address, or symbols whose `st_value' is zero
> silently ignored leading to a confusing "undefined symbol" error message
> at load time, and instead "ELF file ABI version invalid" is printed with
> old dynamic loaders, making it clear that there is an ABI version
> incompatibility.
OK.
> [BZ #19818]
> [BZ #23307]
> * libc-abis (ABSOLUTE): New ABI.
> * sysdeps/unix/sysv/linux/mips/libc-abis (ABSOLUTE): New ABI.
> * NEWS: Mention the new ABI.
> ---
> Hi Carlos,
>
>>> If so, then I think a NEWS entry will be due, such as:
>>>
>>> * The maximum libc ABI supported has been increased to reflect absolute
>>> symbol support. This can be used by the static linker in the ELF file
>>> header's EI_ABIVERSION field to indicate such support is required.
>>
>> Suggest:
>>
>> * The GNU C Library now has correct support for ABSOLUTE symbols
>> (SHN_ABS-relative symbols). Previously such ABSOLUTE symbols were relocated
>> inconsistently or wrongly in some cases. The GNU linker has been enhanced to
>> fix this issue, but it must communicate these newer semantics to the dynamic
>> loader by setting the ELF file's identification (EI_ABIVERSION field) to
>> indicate such support is required.
>
> I think it's a bit inaccurate.
>
> First of all the fix to binutils PR ld/21375 is only related to our BZ
> #19818 and BZ #23307 in that it makes use of the feature that fixes to our
> BZs make work. So I don't think we can call the fix to PR ld/21375 a
> linker enhancement addressing (a linker's part of) the issue we have.
> Absolute symbols have always worked with the GNU linker (although there
> indeed used to be odd corner cases which have since been addressed and
> the `LD_FEATURE ("SANE_EXPR")' linker-script command added in the course).
Sure, that sounds OK to me.
> And then I think we can more accurately express what issues we had with
> absolute symbols without losing comprehensibility of the release note to
> its addressees.
>
> I've included the proposed text in the updated patch carried with this
> message. WDYT?
Looks good with a minor change.
>>> which I will include in the actual commit.
>>
>> This looks good to me.
>>
>> I don't see an easy way around this problem.
>>
>> I think bumping EI_ABIVERSION is the best cost/value solution there.
>
> Thank you for your review and assessment of the situation.
>
> As a side note (prompted by how you phrased the release note), neither
> the fixes to BZ #19818 and BZ #23307 nor (obviously) this change retains
> the old semantics for binaries that carry a lower value in EI_ABIVERSION
> (and we actually don't do that for any previously defined EI_ABIVERSION
> values either).
OK.
> I think the chance that a piece of software relies on the broken previous
> (lack of) interpretation of absolute symbols is very slim -- after all
> what would be the purpose of going through all the arrangement required to
> get an absolute dynamic symbol produced in an ELF file only to have it
> then interpreted, in a non-compliant way, as far as the ELF gABI is
> concerned, as an ordinary relocated one?
Agreed.
In the case where SHN_ABS-relative symbols could not have possible worked
as intended there is no reason to have backwards compatibility.
Similarly we had ELF gABI issues parsing DSTs and I didn't keep the old
parsing code, I just updated it to sensibly meet the requirements of the
gABI. Old code would have been really convoluted to have wanted untranslated
DSTs show up in their output (it would have to have been some kind of auto
generated filename with $ and { and } in the name, and we've never seen
that).
> So I think it is fine that we consider absolute symbols previously
> unsupported and do not provide backwards-compatible semantics for ELF
> files carrying a previously defined EI_ABIVERSION value. Having such
> support would require engineering effort to conditionalise code at run
> time on the value of EI_ABIVERSION, which would also affect performance
> (albeit only for absolute symbols, so likely not significantly enough for
> that to be a real concern), and then only to support non-compliant code
> that may not even exist.
Correct. I agree with your position.
> If such code does surface, then we can assess the situation again, and
> decide what to do about that.
Correct. We can still make that change in theory. Binaries without the
new EI_ABIVERSION can be handled differently.
> For the record, in the course of fixing an unrelated issue with section
> garbage collection in the GNU linker (binutils commit 12f09816cecc
> ("MIPS/BFD: Make section GC work with `ict_irix5' targets")), I have come
> across these symbols produced for use by the IRIX 5 dynamic loader
> (according to `readelf'):
>
> Symbol table '\.dynsym' contains 4 entries:
> Num: Value Size Type Bind Vis Ndx Name
> 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
> 1: 00000000 0 SECTION GLOBAL PROTECTED ABS _procedure_table_size
> 2: 00000000 0 SECTION GLOBAL PROTECTED PRC [0xff02] _procedure_string_table
> 3: 00000000 0 SECTION GLOBAL PROTECTED PRC [0xff02] _procedure_table
>
> which clearly indicates how at least one non-GNU dynamic loader interprets
> absolute symbols (the size of the procedure table, held in
> `_procedure_table_size', surely is not supposed to be relocated by the
> base address); for the record, `PRC [0xff02]' denotes the special
> SHN_MIPS_TEXT section used to hold code in the MIPS/IRIX psABI in place of
> the usual `.text' section.
>
> OK for this change with updated NEWS then?
OK with minor change in the NEWS entry (fixes the grammatical mistake of this->the).
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> Maciej
>
> Changes from v1:
>
> - NEWS entry added.
> ---
> NEWS | 7 +++++++
> libc-abis | 2 ++
> sysdeps/unix/sysv/linux/mips/libc-abis | 2 ++
> 3 files changed, 11 insertions(+)
>
> glibc-abi-absolute.diff
> Index: glibc/NEWS
> ===================================================================
> --- glibc.orig/NEWS 2018-07-05 14:21:40.000000000 +0100
> +++ glibc/NEWS 2018-07-05 14:58:24.773218263 +0100
> @@ -9,6 +9,13 @@ Version 2.28
>
> Major new features:
>
> +* The GNU C Library now has correct support for ABSOLUTE symbols
> + (SHN_ABS-relative symbols). Previously such ABSOLUTE symbols were
> + relocated incorrectly or in some cases discarded. The GNU linker can
> + make use of this newer semantics, but it must communicate it to the
Suggest:
"make use of the corrected semantics, ..."
> + dynamic loader by setting the ELF file's identification (EI_ABIVERSION
> + field) to indicate such support is required.
> +
> * Unicode 11.0.0 Support: Character encoding, character type info, and
> transliteration tables are all updated to Unicode 11.0.0, using
> generator scripts contributed by Mike FABIAN (Red Hat).
> Index: glibc/libc-abis
> ===================================================================
> --- glibc.orig/libc-abis 2018-06-29 16:46:11.558734836 +0100
> +++ glibc/libc-abis 2018-07-05 14:28:46.185297779 +0100
> @@ -46,3 +46,5 @@ IFUNC powerpc64-*-linux*
> IFUNC powerpc-*-linux*
> IFUNC sparc64-*-linux*
> IFUNC sparc-*-linux*
> +# Absolute (SHN_ABS) symbols working correctly.
> +ABSOLUTE
> Index: glibc/sysdeps/unix/sysv/linux/mips/libc-abis
> ===================================================================
> --- glibc.orig/sysdeps/unix/sysv/linux/mips/libc-abis 2018-06-29 16:46:11.594994206 +0100
> +++ glibc/sysdeps/unix/sysv/linux/mips/libc-abis 2018-07-05 14:28:46.394860228 +0100
> @@ -14,3 +14,5 @@ UNIQUE
> #
> # MIPS O32 FP64
> MIPS_O32_FP64 mips*-*-linux*
> +# Absolute (SHN_ABS) symbols working correctly.
> +ABSOLUTE
>
--
Cheers,
Carlos.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-07-05 16:29 ` Carlos O'Donell
@ 2018-07-05 17:10 ` Maciej W. Rozycki
2018-07-05 18:02 ` Carlos O'Donell
0 siblings, 1 reply; 20+ messages in thread
From: Maciej W. Rozycki @ 2018-07-05 17:10 UTC (permalink / raw)
To: Carlos O'Donell; +Cc: libc-alpha, Florian Weimer, Alan Modra
Hi Carlos,
> > +* The GNU C Library now has correct support for ABSOLUTE symbols
> > + (SHN_ABS-relative symbols). Previously such ABSOLUTE symbols were
> > + relocated incorrectly or in some cases discarded. The GNU linker can
> > + make use of this newer semantics, but it must communicate it to the
>
> Suggest:
> "make use of the corrected semantics, ..."
Hmm, "semantics" is uncountable rather than plural[1], so I'm not sure if
"this semantics" is actually a grammatical mistake (just like "Can I drink
this milk?" is fine), but I'm fine with your suggestion. I actually
considered using "the" to avoid having this discussion. ;)
Committed with your suggestion applied then. Thank you for your review.
Maciej
References:
[1] <https://www.oxfordlearnersdictionaries.com/definition/american_english/semantics>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
2018-07-05 17:10 ` Maciej W. Rozycki
@ 2018-07-05 18:02 ` Carlos O'Donell
0 siblings, 0 replies; 20+ messages in thread
From: Carlos O'Donell @ 2018-07-05 18:02 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: libc-alpha, Florian Weimer, Alan Modra
On 07/05/2018 01:09 PM, Maciej W. Rozycki wrote:
> Hi Carlos,
>
>>> +* The GNU C Library now has correct support for ABSOLUTE symbols
>>> + (SHN_ABS-relative symbols). Previously such ABSOLUTE symbols were
>>> + relocated incorrectly or in some cases discarded. The GNU linker can
>>> + make use of this newer semantics, but it must communicate it to the
>>
>> Suggest:
>> "make use of the corrected semantics, ..."
>
> Hmm, "semantics" is uncountable rather than plural[1], so I'm not sure if
> "this semantics" is actually a grammatical mistake (just like "Can I drink
> this milk?" is fine), but I'm fine with your suggestion. I actually
> considered using "the" to avoid having this discussion. ;)
The use of 'the' with countable nouns is allowed when they refer to a
specific example, like in this case, and I find English speakers prefer
this form.
You are correct though, it's not a grammatical mistake to use 'this'
with the uncounted noun, I had forgotten about this completely.
Thank you for elightening me! :-)
> Committed with your suggestion applied then. Thank you for your review.
My key motivation was to avoid the use of "newer" since this temporal
reference becomes difficult to understand at a later time and
"corrected" is, well, always correct.
--
Cheers,
Carlos.
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2018-07-05 18:02 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-18 18:06 [PATCH 0/2] Accept absolute symbols whose value is zero [BZ #23307] Maciej W. Rozycki
2018-06-18 18:08 ` [PATCH 2/2] libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307] Maciej W. Rozycki
2018-06-25 20:33 ` Florian Weimer
2018-06-27 22:08 ` Maciej W. Rozycki
2018-06-28 6:59 ` Florian Weimer
2018-06-28 13:49 ` Maciej W. Rozycki
2018-06-28 13:54 ` Florian Weimer
2018-06-28 14:54 ` Maciej W. Rozycki
2018-06-29 16:29 ` Maciej W. Rozycki
2018-07-03 13:53 ` Carlos O'Donell
2018-07-05 15:42 ` [PATCH v2 " Maciej W. Rozycki
2018-07-05 16:29 ` Carlos O'Donell
2018-07-05 17:10 ` Maciej W. Rozycki
2018-07-05 18:02 ` Carlos O'Donell
2018-06-18 18:08 ` [PATCH 1/2] elf: Accept absolute (SHN_ABS) symbols whose value is zero [BZ #23307] Maciej W. Rozycki
2018-06-25 20:25 ` Florian Weimer
2018-06-29 16:13 ` [committed v2 " Maciej W. Rozycki
2018-06-29 17:41 ` Joseph Myers
2018-06-29 18:05 ` Maciej W. Rozycki
2018-06-25 19:14 ` [PING][PATCH 0/2] Accept absolute " Maciej W. Rozycki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).