diff --git a/ChangeLog b/ChangeLog index 09543433ac..566b5e00ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2018-06-29 Maciej W. Rozycki + + [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. + 2018-06-29 Zack Weinberg * configure.ac: New command-line option --disable-crypt. diff --git a/elf/Makefile b/elf/Makefile index 0eb7c8114e..41cc3681be 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -186,7 +186,7 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \ 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 testobj3 testobj4 testobj5 testobj6 \ 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 @@ -1467,6 +1467,10 @@ LDLIBS-tst-absolute-sym-lib.so = tst-absolute-sym-lib.lds $(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) diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index 401bc87c90..68ecc6179f 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -76,6 +76,7 @@ check_match (const char *const undef_name, 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)))) diff --git a/elf/tst-absolute-zero-lib.c b/elf/tst-absolute-zero-lib.c new file mode 100644 index 0000000000..fba2af0bc5 --- /dev/null +++ b/elf/tst-absolute-zero-lib.c @@ -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 + . */ + +extern char absolute; + +void * +get_absolute (void) +{ + return &absolute; +} diff --git a/elf/tst-absolute-zero-lib.lds b/elf/tst-absolute-zero-lib.lds new file mode 100644 index 0000000000..2fa65dc3f9 --- /dev/null +++ b/elf/tst-absolute-zero-lib.lds @@ -0,0 +1 @@ +"absolute" = 0; diff --git a/elf/tst-absolute-zero.c b/elf/tst-absolute-zero.c new file mode 100644 index 0000000000..6b998ba69e --- /dev/null +++ b/elf/tst-absolute-zero.c @@ -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 + . */ + +#include +#include +#include + +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