CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
python3: updated to 3.9.4
[ports/core-arm64.git] / glibc / glibc-2.32-3.patch
1 diff --git a/NEWS b/NEWS
2 index 485b8ddffa..f278041512 100644
3 --- a/NEWS
4 +++ b/NEWS
5 @@ -5,6 +5,25 @@ See the end for copying conditions.
6 Please send GNU C library bug reports via <https://sourceware.org/bugzilla/>
7 using `glibc' in the "product" field.
8 \f
9 +The following bugs are resolved with this release:
10 +
11 + [20019] NULL pointer dereference in libc.so.6 IFUNC due to uninitialized GOT
12 + [26224] iconv hangs when converting some invalid inputs from several IBM
13 + character sets (CVE-2020-27618)
14 + [26534] libm.so 2.32 SIGILL in pow() due to FMA4 instruction on non-FMA4
15 + system
16 + [26555] string: strerrorname_np does not return the documented value
17 + [26600] Transaction ID collisions cause slow DNS lookups in getaddrinfo
18 + [26636] libc: 32-bit shmctl(IPC_INFO) crashes when shminfo struct is
19 + at the end of a memory mapping
20 + [26637] libc: semctl SEM_STAT_ANY fails to pass the buffer specified
21 + by the caller to the kernel
22 + [26639] libc: msgctl IPC_INFO and MSG_INFO return garbage
23 + [26853] aarch64: Missing unwind information in statically linked startup code
24 + [26932] libc: sh: Multiple floating point functions defined as stubs only
25 + [27130] "rep movsb" performance issue
26 + [27177] GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on doesn't work
27 +
28 Version 2.32
29
30 Major new features:
31 @@ -185,6 +204,10 @@ Security related changes:
32 Dytrych of the Cisco Security Assessment and Penetration Team (See
33 TALOS-2020-1019).
34
35 + CVE-2020-27618: An infinite loop has been fixed in the iconv program when
36 + invoked with input containing redundant shift sequences in the IBM1364,
37 + IBM1371, IBM1388, IBM1390, or IBM1399 character sets.
38 +
39 The following bugs are resolved with this release:
40
41 [9809] localedata: ckb_IQ: new Kurdish Sorani locale
42 diff --git a/Rules b/Rules
43 index 8b771f6095..beab969fde 100644
44 --- a/Rules
45 +++ b/Rules
46 @@ -155,6 +155,7 @@ xtests: tests $(xtests-special)
47 else
48 tests: $(tests:%=$(objpfx)%.out) $(tests-internal:%=$(objpfx)%.out) \
49 $(tests-container:%=$(objpfx)%.out) \
50 + $(tests-mcheck:%=$(objpfx)%-mcheck.out) \
51 $(tests-special) $(tests-printers-out)
52 xtests: tests $(xtests:%=$(objpfx)%.out) $(xtests-special)
53 endif
54 @@ -165,7 +166,7 @@ ifeq ($(run-built-tests),no)
55 tests-expected =
56 else
57 tests-expected = $(tests) $(tests-internal) $(tests-printers) \
58 - $(tests-container)
59 + $(tests-container) $(tests-mcheck:%=%-mcheck)
60 endif
61 tests:
62 $(..)scripts/merge-test-results.sh -s $(objpfx) $(subdir) \
63 @@ -191,6 +192,7 @@ else
64 binaries-pie-tests =
65 binaries-pie-notests =
66 endif
67 +binaries-mcheck-tests = $(tests-mcheck:%=%-mcheck)
68 else
69 binaries-all-notests =
70 binaries-all-tests = $(tests) $(tests-internal) $(xtests) $(test-srcs)
71 @@ -200,6 +202,7 @@ binaries-static-tests =
72 binaries-static =
73 binaries-pie-tests =
74 binaries-pie-notests =
75 +binaries-mcheck-tests =
76 endif
77
78 binaries-pie = $(binaries-pie-tests) $(binaries-pie-notests)
79 @@ -223,6 +226,14 @@ $(addprefix $(objpfx),$(binaries-shared-tests)): %: %.o \
80 $(+link-tests)
81 endif
82
83 +ifneq "$(strip $(binaries-mcheck-tests))" ""
84 +$(addprefix $(objpfx),$(binaries-mcheck-tests)): %-mcheck: %.o \
85 + $(link-extra-libs-tests) \
86 + $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
87 + $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
88 + $(+link-tests)
89 +endif
90 +
91 ifneq "$(strip $(binaries-pie-tests))" ""
92 $(addprefix $(objpfx),$(binaries-pie-tests)): %: %.o \
93 $(link-extra-libs-tests) \
94 @@ -253,6 +264,12 @@ $(addprefix $(objpfx),$(binaries-static-tests)): %: %.o \
95 $(+link-static-tests)
96 endif
97
98 +# All mcheck tests will be run with MALLOC_CHECK_=3
99 +define mcheck-ENVS
100 +$(1)-mcheck-ENV = MALLOC_CHECK_=3
101 +endef
102 +$(foreach t,$(tests-mcheck),$(eval $(call mcheck-ENVS,$(t))))
103 +
104 ifneq "$(strip $(tests) $(tests-internal) $(xtests) $(test-srcs))" ""
105 # These are the implicit rules for making test outputs
106 # from the test programs and whatever input files are present.
107 diff --git a/debug/Makefile b/debug/Makefile
108 index 3a60d7af7a..0036edd187 100644
109 --- a/debug/Makefile
110 +++ b/debug/Makefile
111 @@ -51,7 +51,7 @@ routines = backtrace backtracesyms backtracesymsfd noophooks \
112 explicit_bzero_chk \
113 stack_chk_fail fortify_fail \
114 $(static-only-routines)
115 -static-only-routines := warning-nop stack_chk_fail_local
116 +static-only-routines := stack_chk_fail_local
117
118 # Don't add stack_chk_fail_local.o to libc.a since __stack_chk_fail_local
119 # is an alias of __stack_chk_fail in stack_chk_fail.o.
120 diff --git a/debug/warning-nop.c b/debug/warning-nop.c
121 deleted file mode 100644
122 index 4ab7e182b7..0000000000
123 --- a/debug/warning-nop.c
124 +++ /dev/null
125 @@ -1,70 +0,0 @@
126 -/* Dummy nop functions to elicit link-time warnings.
127 - Copyright (C) 2005-2020 Free Software Foundation, Inc.
128 - This file is part of the GNU C Library.
129 -
130 - The GNU C Library is free software; you can redistribute it and/or
131 - modify it under the terms of the GNU Lesser General Public
132 - License as published by the Free Software Foundation; either
133 - version 2.1 of the License, or (at your option) any later version.
134 -
135 - In addition to the permissions in the GNU Lesser General Public
136 - License, the Free Software Foundation gives you unlimited
137 - permission to link the compiled version of this file with other
138 - programs, and to distribute those programs without any restriction
139 - coming from the use of this file. (The GNU Lesser General Public
140 - License restrictions do apply in other respects; for example, they
141 - cover modification of the file, and distribution when not linked
142 - into another program.)
143 -
144 - Note that people who make modified versions of this file are not
145 - obligated to grant this special exception for their modified
146 - versions; it is their choice whether to do so. The GNU Lesser
147 - General Public License gives permission to release a modified
148 - version without this exception; this exception also makes it
149 - possible to release a modified version which carries forward this
150 - exception.
151 -
152 - The GNU C Library is distributed in the hope that it will be useful,
153 - but WITHOUT ANY WARRANTY; without even the implied warranty of
154 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
155 - Lesser General Public License for more details.
156 -
157 - You should have received a copy of the GNU Lesser General Public
158 - License along with the GNU C Library; if not, see
159 - <https://www.gnu.org/licenses/>. */
160 -
161 -#include <sys/cdefs.h>
162 -
163 -static void
164 -__attribute__ ((used))
165 -nop (void)
166 -{
167 -}
168 -
169 -/* Don't insert any other #include's before this #undef! */
170 -
171 -#undef __warndecl
172 -#define __warndecl(name, msg) \
173 - extern void name (void) __attribute__ ((alias ("nop"))) attribute_hidden; \
174 - link_warning (name, msg)
175 -
176 -#undef __USE_FORTIFY_LEVEL
177 -#define __USE_FORTIFY_LEVEL 99
178 -
179 -/* Following here we need an #include for each public header file
180 - that uses __warndecl. */
181 -
182 -/* Define away to avoid warnings with compilers that do not have these
183 - builtins. */
184 -#define __builtin___memcpy_chk(dest, src, len, bos) NULL
185 -#define __builtin___memmove_chk(dest, src, len, bos) NULL
186 -#define __builtin___mempcpy_chk(dest, src, len, bos) NULL
187 -#define __builtin___memset_chk(dest, ch, len, bos) NULL
188 -#define __builtin___stpcpy_chk(dest, src, bos) NULL
189 -#define __builtin___strcat_chk(dest, src, bos) NULL
190 -#define __builtin___strcpy_chk(dest, src, bos) NULL
191 -#define __builtin___strncat_chk(dest, src, len, bos) NULL
192 -#define __builtin___strncpy_chk(dest, src, len, bos) NULL
193 -#define __builtin_object_size(bos, level) 0
194 -
195 -#include <string.h>
196 diff --git a/elf/Makefile b/elf/Makefile
197 index 0b78721848..355e70037b 100644
198 --- a/elf/Makefile
199 +++ b/elf/Makefile
200 @@ -1381,6 +1381,8 @@ CFLAGS-ifuncmain7pie.c += $(pie-ccflag)
201 CFLAGS-ifuncmain9pie.c += $(pie-ccflag)
202 CFLAGS-tst-ifunc-textrel.c += $(pic-ccflag)
203
204 +LDFLAGS-ifuncmain6pie = -Wl,-z,lazy
205 +
206 $(objpfx)ifuncmain1pie: $(objpfx)ifuncmod1.so
207 $(objpfx)ifuncmain1staticpie: $(objpfx)ifuncdep1pic.o
208 $(objpfx)ifuncmain1vispie: $(objpfx)ifuncmod1.so
209 diff --git a/elf/dl-load.c b/elf/dl-load.c
210 index e39980fb19..71867e7c1a 100644
211 --- a/elf/dl-load.c
212 +++ b/elf/dl-load.c
213 @@ -855,10 +855,12 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l,
214
215 /* Process PT_GNU_PROPERTY program header PH in module L after
216 PT_LOAD segments are mapped. Only one NT_GNU_PROPERTY_TYPE_0
217 - note is handled which contains processor specific properties. */
218 + note is handled which contains processor specific properties.
219 + FD is -1 for the kernel mapped main executable otherwise it is
220 + the fd used for loading module L. */
221
222 void
223 -_dl_process_pt_gnu_property (struct link_map *l, const ElfW(Phdr) *ph)
224 +_dl_process_pt_gnu_property (struct link_map *l, int fd, const ElfW(Phdr) *ph)
225 {
226 const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr);
227 const ElfW(Addr) size = ph->p_memsz;
228 @@ -905,7 +907,7 @@ _dl_process_pt_gnu_property (struct link_map *l, const ElfW(Phdr) *ph)
229 last_type = type;
230
231 /* Target specific property processing. */
232 - if (_dl_process_gnu_property (l, type, datasz, ptr) == 0)
233 + if (_dl_process_gnu_property (l, fd, type, datasz, ptr) == 0)
234 return;
235
236 /* Check the next property item. */
237 @@ -1251,21 +1253,6 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
238 maplength, has_holes, loader);
239 if (__glibc_unlikely (errstring != NULL))
240 goto call_lose;
241 -
242 - /* Process program headers again after load segments are mapped in
243 - case processing requires accessing those segments. Scan program
244 - headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY
245 - exits. */
246 - for (ph = &phdr[l->l_phnum]; ph != phdr; --ph)
247 - switch (ph[-1].p_type)
248 - {
249 - case PT_NOTE:
250 - _dl_process_pt_note (l, &ph[-1]);
251 - break;
252 - case PT_GNU_PROPERTY:
253 - _dl_process_pt_gnu_property (l, &ph[-1]);
254 - break;
255 - }
256 }
257
258 if (l->l_ld == 0)
259 @@ -1377,6 +1364,21 @@ cannot enable executable stack as shared object requires");
260 if (l->l_tls_initimage != NULL)
261 l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr;
262
263 + /* Process program headers again after load segments are mapped in
264 + case processing requires accessing those segments. Scan program
265 + headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY
266 + exits. */
267 + for (ph = &l->l_phdr[l->l_phnum]; ph != l->l_phdr; --ph)
268 + switch (ph[-1].p_type)
269 + {
270 + case PT_NOTE:
271 + _dl_process_pt_note (l, fd, &ph[-1]);
272 + break;
273 + case PT_GNU_PROPERTY:
274 + _dl_process_pt_gnu_property (l, fd, &ph[-1]);
275 + break;
276 + }
277 +
278 /* We are done mapping in the file. We no longer need the descriptor. */
279 if (__glibc_unlikely (__close_nocancel (fd) != 0))
280 {
281 diff --git a/elf/ifuncmain6pie.c b/elf/ifuncmain6pie.c
282 index 04faeb86ef..4a01906836 100644
283 --- a/elf/ifuncmain6pie.c
284 +++ b/elf/ifuncmain6pie.c
285 @@ -9,7 +9,6 @@
286 #include "ifunc-sel.h"
287
288 typedef int (*foo_p) (void);
289 -extern foo_p foo_ptr;
290
291 static int
292 one (void)
293 @@ -28,20 +27,17 @@ foo_ifunc (void)
294 }
295
296 extern int foo (void);
297 -extern foo_p get_foo (void);
298 +extern int call_foo (void);
299 extern foo_p get_foo_p (void);
300
301 -foo_p my_foo_ptr = foo;
302 +foo_p foo_ptr = foo;
303
304 int
305 main (void)
306 {
307 foo_p p;
308
309 - p = get_foo ();
310 - if (p != foo)
311 - abort ();
312 - if ((*p) () != -30)
313 + if (call_foo () != -30)
314 abort ();
315
316 p = get_foo_p ();
317 @@ -52,12 +48,8 @@ main (void)
318
319 if (foo_ptr != foo)
320 abort ();
321 - if (my_foo_ptr != foo)
322 - abort ();
323 if ((*foo_ptr) () != -30)
324 abort ();
325 - if ((*my_foo_ptr) () != -30)
326 - abort ();
327 if (foo () != -30)
328 abort ();
329
330 diff --git a/elf/ifuncmod6.c b/elf/ifuncmod6.c
331 index 2e16c1d06d..2f6d0715e6 100644
332 --- a/elf/ifuncmod6.c
333 +++ b/elf/ifuncmod6.c
334 @@ -4,7 +4,7 @@ extern int foo (void);
335
336 typedef int (*foo_p) (void);
337
338 -foo_p foo_ptr = foo;
339 +extern foo_p foo_ptr;
340
341 foo_p
342 get_foo_p (void)
343 @@ -12,8 +12,8 @@ get_foo_p (void)
344 return foo_ptr;
345 }
346
347 -foo_p
348 -get_foo (void)
349 +int
350 +call_foo (void)
351 {
352 - return foo;
353 + return foo ();
354 }
355 diff --git a/elf/rtld.c b/elf/rtld.c
356 index 5b882163fa..14a42ed00a 100644
357 --- a/elf/rtld.c
358 +++ b/elf/rtld.c
359 @@ -1534,10 +1534,10 @@ of this helper program; chances are you did not intend to run this program.\n\
360 switch (ph[-1].p_type)
361 {
362 case PT_NOTE:
363 - _dl_process_pt_note (main_map, &ph[-1]);
364 + _dl_process_pt_note (main_map, -1, &ph[-1]);
365 break;
366 case PT_GNU_PROPERTY:
367 - _dl_process_pt_gnu_property (main_map, &ph[-1]);
368 + _dl_process_pt_gnu_property (main_map, -1, &ph[-1]);
369 break;
370 }
371
372 diff --git a/iconv/Versions b/iconv/Versions
373 index 8a5f4cf780..d51af52fa3 100644
374 --- a/iconv/Versions
375 +++ b/iconv/Versions
376 @@ -6,7 +6,9 @@ libc {
377 GLIBC_PRIVATE {
378 # functions shared with iconv program
379 __gconv_get_alias_db; __gconv_get_cache; __gconv_get_modules_db;
380 - __gconv_open; __gconv_create_spec;
381 +
382 + # functions used elsewhere in glibc
383 + __gconv_open; __gconv_create_spec; __gconv_destroy_spec;
384
385 # function used by the gconv modules
386 __gconv_transliterate;
387 diff --git a/iconv/gconv_charset.c b/iconv/gconv_charset.c
388 index 6ccd0773cc..4ba0aa99f5 100644
389 --- a/iconv/gconv_charset.c
390 +++ b/iconv/gconv_charset.c
391 @@ -216,3 +216,13 @@ out:
392 return ret;
393 }
394 libc_hidden_def (__gconv_create_spec)
395 +
396 +
397 +void
398 +__gconv_destroy_spec (struct gconv_spec *conv_spec)
399 +{
400 + free (conv_spec->fromcode);
401 + free (conv_spec->tocode);
402 + return;
403 +}
404 +libc_hidden_def (__gconv_destroy_spec)
405 diff --git a/iconv/gconv_charset.h b/iconv/gconv_charset.h
406 index b39b09aea1..e9c122cf7e 100644
407 --- a/iconv/gconv_charset.h
408 +++ b/iconv/gconv_charset.h
409 @@ -48,33 +48,6 @@
410 #define GCONV_IGNORE_ERRORS_SUFFIX "IGNORE"
411
412
413 -/* This function accepts the charset names of the source and destination of the
414 - conversion and populates *conv_spec with an equivalent conversion
415 - specification that may later be used by __gconv_open. The charset names
416 - might contain options in the form of suffixes that alter the conversion,
417 - e.g. "ISO-10646/UTF-8/TRANSLIT". It processes the charset names, ignoring
418 - and truncating any suffix options in fromcode, and processing and truncating
419 - any suffix options in tocode. Supported suffix options ("TRANSLIT" or
420 - "IGNORE") when found in tocode lead to the corresponding flag in *conv_spec
421 - to be set to true. Unrecognized suffix options are silently discarded. If
422 - the function succeeds, it returns conv_spec back to the caller. It returns
423 - NULL upon failure. */
424 -struct gconv_spec *
425 -__gconv_create_spec (struct gconv_spec *conv_spec, const char *fromcode,
426 - const char *tocode);
427 -libc_hidden_proto (__gconv_create_spec)
428 -
429 -
430 -/* This function frees all heap memory allocated by __gconv_create_spec. */
431 -static void __attribute__ ((unused))
432 -gconv_destroy_spec (struct gconv_spec *conv_spec)
433 -{
434 - free (conv_spec->fromcode);
435 - free (conv_spec->tocode);
436 - return;
437 -}
438 -
439 -
440 /* This function copies in-order, characters from the source 's' that are
441 either alpha-numeric or one in one of these: "_-.,:/" - into the destination
442 'wp' while dropping all other characters. In the process, it converts all
443 diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h
444 index e86938dae7..f721ce30ff 100644
445 --- a/iconv/gconv_int.h
446 +++ b/iconv/gconv_int.h
447 @@ -152,6 +152,27 @@ extern int __gconv_open (struct gconv_spec *conv_spec,
448 __gconv_t *handle, int flags);
449 libc_hidden_proto (__gconv_open)
450
451 +/* This function accepts the charset names of the source and destination of the
452 + conversion and populates *conv_spec with an equivalent conversion
453 + specification that may later be used by __gconv_open. The charset names
454 + might contain options in the form of suffixes that alter the conversion,
455 + e.g. "ISO-10646/UTF-8/TRANSLIT". It processes the charset names, ignoring
456 + and truncating any suffix options in fromcode, and processing and truncating
457 + any suffix options in tocode. Supported suffix options ("TRANSLIT" or
458 + "IGNORE") when found in tocode lead to the corresponding flag in *conv_spec
459 + to be set to true. Unrecognized suffix options are silently discarded. If
460 + the function succeeds, it returns conv_spec back to the caller. It returns
461 + NULL upon failure. */
462 +extern struct gconv_spec *
463 +__gconv_create_spec (struct gconv_spec *conv_spec, const char *fromcode,
464 + const char *tocode);
465 +libc_hidden_proto (__gconv_create_spec)
466 +
467 +/* This function frees all heap memory allocated by __gconv_create_spec. */
468 +extern void
469 +__gconv_destroy_spec (struct gconv_spec *conv_spec);
470 +libc_hidden_proto (__gconv_destroy_spec)
471 +
472 /* Free resources associated with transformation descriptor CD. */
473 extern int __gconv_close (__gconv_t cd)
474 attribute_hidden;
475 diff --git a/iconv/iconv_open.c b/iconv/iconv_open.c
476 index dd54bc12e0..5b30055c04 100644
477 --- a/iconv/iconv_open.c
478 +++ b/iconv/iconv_open.c
479 @@ -39,7 +39,7 @@ iconv_open (const char *tocode, const char *fromcode)
480
481 int res = __gconv_open (&conv_spec, &cd, 0);
482
483 - gconv_destroy_spec (&conv_spec);
484 + __gconv_destroy_spec (&conv_spec);
485
486 if (__builtin_expect (res, __GCONV_OK) != __GCONV_OK)
487 {
488 diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c
489 index b4334faa57..d59979759c 100644
490 --- a/iconv/iconv_prog.c
491 +++ b/iconv/iconv_prog.c
492 @@ -184,7 +184,7 @@ main (int argc, char *argv[])
493 /* Let's see whether we have these coded character sets. */
494 res = __gconv_open (&conv_spec, &cd, 0);
495
496 - gconv_destroy_spec (&conv_spec);
497 + __gconv_destroy_spec (&conv_spec);
498
499 if (res != __GCONV_OK)
500 {
501 diff --git a/iconv/tst-iconv_prog.sh b/iconv/tst-iconv_prog.sh
502 index 8298136b7f..d8db7b335c 100644
503 --- a/iconv/tst-iconv_prog.sh
504 +++ b/iconv/tst-iconv_prog.sh
505 @@ -102,12 +102,16 @@ hangarray=(
506 "\x00\x80;-c;IBM1161;UTF-8//TRANSLIT//IGNORE"
507 "\x00\xdb;-c;IBM1162;UTF-8//TRANSLIT//IGNORE"
508 "\x00\x70;-c;IBM12712;UTF-8//TRANSLIT//IGNORE"
509 -# These are known hangs that are yet to be fixed:
510 -# "\x00\x0f;-c;IBM1364;UTF-8"
511 -# "\x00\x0f;-c;IBM1371;UTF-8"
512 -# "\x00\x0f;-c;IBM1388;UTF-8"
513 -# "\x00\x0f;-c;IBM1390;UTF-8"
514 -# "\x00\x0f;-c;IBM1399;UTF-8"
515 +"\x00\x0f;-c;IBM1364;UTF-8"
516 +"\x0e\x0e;-c;IBM1364;UTF-8"
517 +"\x00\x0f;-c;IBM1371;UTF-8"
518 +"\x0e\x0e;-c;IBM1371;UTF-8"
519 +"\x00\x0f;-c;IBM1388;UTF-8"
520 +"\x0e\x0e;-c;IBM1388;UTF-8"
521 +"\x00\x0f;-c;IBM1390;UTF-8"
522 +"\x0e\x0e;-c;IBM1390;UTF-8"
523 +"\x00\x0f;-c;IBM1399;UTF-8"
524 +"\x0e\x0e;-c;IBM1399;UTF-8"
525 "\x00\x53;-c;IBM16804;UTF-8//TRANSLIT//IGNORE"
526 "\x00\x41;-c;IBM274;UTF-8//TRANSLIT//IGNORE"
527 "\x00\x41;-c;IBM275;UTF-8//TRANSLIT//IGNORE"
528 diff --git a/iconvdata/Makefile b/iconvdata/Makefile
529 index 4ec2741cdc..4eef07557e 100644
530 --- a/iconvdata/Makefile
531 +++ b/iconvdata/Makefile
532 @@ -73,7 +73,8 @@ modules.so := $(addsuffix .so, $(modules))
533 ifeq (yes,$(build-shared))
534 tests = bug-iconv1 bug-iconv2 tst-loading tst-e2big tst-iconv4 bug-iconv4 \
535 tst-iconv6 bug-iconv5 bug-iconv6 tst-iconv7 bug-iconv8 bug-iconv9 \
536 - bug-iconv10 bug-iconv11 bug-iconv12 tst-iconv-big5-hkscs-to-2ucs4
537 + bug-iconv10 bug-iconv11 bug-iconv12 tst-iconv-big5-hkscs-to-2ucs4 \
538 + bug-iconv13 bug-iconv14
539 ifeq ($(have-thread-library),yes)
540 tests += bug-iconv3
541 endif
542 @@ -321,6 +322,8 @@ $(objpfx)bug-iconv10.out: $(objpfx)gconv-modules \
543 $(addprefix $(objpfx),$(modules.so))
544 $(objpfx)bug-iconv12.out: $(objpfx)gconv-modules \
545 $(addprefix $(objpfx),$(modules.so))
546 +$(objpfx)bug-iconv14.out: $(objpfx)gconv-modules \
547 + $(addprefix $(objpfx),$(modules.so))
548
549 $(objpfx)iconv-test.out: run-iconv-test.sh $(objpfx)gconv-modules \
550 $(addprefix $(objpfx),$(modules.so)) \
551 diff --git a/iconvdata/bug-iconv13.c b/iconvdata/bug-iconv13.c
552 new file mode 100644
553 index 0000000000..87aaff398e
554 --- /dev/null
555 +++ b/iconvdata/bug-iconv13.c
556 @@ -0,0 +1,53 @@
557 +/* bug 24973: Test EUC-KR module
558 + Copyright (C) 2020 Free Software Foundation, Inc.
559 + This file is part of the GNU C Library.
560 +
561 + The GNU C Library is free software; you can redistribute it and/or
562 + modify it under the terms of the GNU Lesser General Public
563 + License as published by the Free Software Foundation; either
564 + version 2.1 of the License, or (at your option) any later version.
565 +
566 + The GNU C Library is distributed in the hope that it will be useful,
567 + but WITHOUT ANY WARRANTY; without even the implied warranty of
568 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
569 + Lesser General Public License for more details.
570 +
571 + You should have received a copy of the GNU Lesser General Public
572 + License along with the GNU C Library; if not, see
573 + <https://www.gnu.org/licenses/>. */
574 +
575 +#include <errno.h>
576 +#include <iconv.h>
577 +#include <stdio.h>
578 +#include <support/check.h>
579 +
580 +static int
581 +do_test (void)
582 +{
583 + iconv_t cd = iconv_open ("UTF-8//IGNORE", "EUC-KR");
584 + TEST_VERIFY_EXIT (cd != (iconv_t) -1);
585 +
586 + /* 0xfe (->0x7e : row 94) and 0xc9 (->0x49 : row 41) are user-defined
587 + areas, which are not allowed and should be skipped over due to
588 + //IGNORE. The trailing 0xfe also is an incomplete sequence, which
589 + should be checked first. */
590 + char input[4] = { '\xc9', '\xa1', '\0', '\xfe' };
591 + char *inptr = input;
592 + size_t insize = sizeof (input);
593 + char output[4];
594 + char *outptr = output;
595 + size_t outsize = sizeof (output);
596 +
597 + /* This used to crash due to buffer overrun. */
598 + TEST_VERIFY (iconv (cd, &inptr, &insize, &outptr, &outsize) == (size_t) -1);
599 + TEST_VERIFY (errno == EINVAL);
600 + /* The conversion should produce one character, the converted null
601 + character. */
602 + TEST_VERIFY (sizeof (output) - outsize == 1);
603 +
604 + TEST_VERIFY_EXIT (iconv_close (cd) != -1);
605 +
606 + return 0;
607 +}
608 +
609 +#include <support/test-driver.c>
610 diff --git a/iconvdata/bug-iconv14.c b/iconvdata/bug-iconv14.c
611 new file mode 100644
612 index 0000000000..902f140fa9
613 --- /dev/null
614 +++ b/iconvdata/bug-iconv14.c
615 @@ -0,0 +1,127 @@
616 +/* Assertion in ISO-2022-JP-3 due to two-character sequence (bug 27256).
617 + Copyright (C) 2021 Free Software Foundation, Inc.
618 + This file is part of the GNU C Library.
619 +
620 + The GNU C Library is free software; you can redistribute it and/or
621 + modify it under the terms of the GNU Lesser General Public
622 + License as published by the Free Software Foundation; either
623 + version 2.1 of the License, or (at your option) any later version.
624 +
625 + The GNU C Library is distributed in the hope that it will be useful,
626 + but WITHOUT ANY WARRANTY; without even the implied warranty of
627 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
628 + Lesser General Public License for more details.
629 +
630 + You should have received a copy of the GNU Lesser General Public
631 + License along with the GNU C Library; if not, see
632 + <https://www.gnu.org/licenses/>. */
633 +
634 +#include <iconv.h>
635 +#include <string.h>
636 +#include <errno.h>
637 +#include <support/check.h>
638 +
639 +/* Use an escape sequence to return to the initial state. */
640 +static void
641 +with_escape_sequence (void)
642 +{
643 + iconv_t c = iconv_open ("UTF-8", "ISO-2022-JP-3");
644 + TEST_VERIFY_EXIT (c != (iconv_t) -1);
645 +
646 + char in[] = "\e$(O+D\e(B";
647 + char *inbuf = in;
648 + size_t inleft = strlen (in);
649 + char out[3]; /* Space for one output character. */
650 + char *outbuf;
651 + size_t outleft;
652 +
653 + outbuf = out;
654 + outleft = sizeof (out);
655 + TEST_COMPARE (iconv (c, &inbuf, &inleft, &outbuf, &outleft), (size_t) -1);
656 + TEST_COMPARE (errno, E2BIG);
657 + TEST_COMPARE (inleft, 3);
658 + TEST_COMPARE (inbuf - in, strlen (in) - 3);
659 + TEST_COMPARE (outleft, sizeof (out) - 2);
660 + TEST_COMPARE (outbuf - out, 2);
661 + TEST_COMPARE (out[0] & 0xff, 0xc3);
662 + TEST_COMPARE (out[1] & 0xff, 0xa6);
663 +
664 + /* Return to the initial shift state, producing the pending
665 + character. */
666 + outbuf = out;
667 + outleft = sizeof (out);
668 + TEST_COMPARE (iconv (c, &inbuf, &inleft, &outbuf, &outleft), 0);
669 + TEST_COMPARE (inleft, 0);
670 + TEST_COMPARE (inbuf - in, strlen (in));
671 + TEST_COMPARE (outleft, sizeof (out) - 2);
672 + TEST_COMPARE (outbuf - out, 2);
673 + TEST_COMPARE (out[0] & 0xff, 0xcc);
674 + TEST_COMPARE (out[1] & 0xff, 0x80);
675 +
676 + /* Nothing should be flushed the second time. */
677 + outbuf = out;
678 + outleft = sizeof (out);
679 + TEST_COMPARE (iconv (c, NULL, 0, &outbuf, &outleft), 0);
680 + TEST_COMPARE (outleft, sizeof (out));
681 + TEST_COMPARE (outbuf - out, 0);
682 + TEST_COMPARE (out[0] & 0xff, 0xcc);
683 + TEST_COMPARE (out[1] & 0xff, 0x80);
684 +
685 + TEST_COMPARE (iconv_close (c), 0);
686 +}
687 +
688 +/* Use an explicit flush to return to the initial state. */
689 +static void
690 +with_flush (void)
691 +{
692 + iconv_t c = iconv_open ("UTF-8", "ISO-2022-JP-3");
693 + TEST_VERIFY_EXIT (c != (iconv_t) -1);
694 +
695 + char in[] = "\e$(O+D";
696 + char *inbuf = in;
697 + size_t inleft = strlen (in);
698 + char out[3]; /* Space for one output character. */
699 + char *outbuf;
700 + size_t outleft;
701 +
702 + outbuf = out;
703 + outleft = sizeof (out);
704 + TEST_COMPARE (iconv (c, &inbuf, &inleft, &outbuf, &outleft), (size_t) -1);
705 + TEST_COMPARE (errno, E2BIG);
706 + TEST_COMPARE (inleft, 0);
707 + TEST_COMPARE (inbuf - in, strlen (in));
708 + TEST_COMPARE (outleft, sizeof (out) - 2);
709 + TEST_COMPARE (outbuf - out, 2);
710 + TEST_COMPARE (out[0] & 0xff, 0xc3);
711 + TEST_COMPARE (out[1] & 0xff, 0xa6);
712 +
713 + /* Flush the pending character. */
714 + outbuf = out;
715 + outleft = sizeof (out);
716 + TEST_COMPARE (iconv (c, NULL, 0, &outbuf, &outleft), 0);
717 + TEST_COMPARE (outleft, sizeof (out) - 2);
718 + TEST_COMPARE (outbuf - out, 2);
719 + TEST_COMPARE (out[0] & 0xff, 0xcc);
720 + TEST_COMPARE (out[1] & 0xff, 0x80);
721 +
722 + /* Nothing should be flushed the second time. */
723 + outbuf = out;
724 + outleft = sizeof (out);
725 + TEST_COMPARE (iconv (c, NULL, 0, &outbuf, &outleft), 0);
726 + TEST_COMPARE (outleft, sizeof (out));
727 + TEST_COMPARE (outbuf - out, 0);
728 + TEST_COMPARE (out[0] & 0xff, 0xcc);
729 + TEST_COMPARE (out[1] & 0xff, 0x80);
730 +
731 + TEST_COMPARE (iconv_close (c), 0);
732 +}
733 +
734 +static int
735 +do_test (void)
736 +{
737 + with_escape_sequence ();
738 + with_flush ();
739 + return 0;
740 +}
741 +
742 +#include <support/test-driver.c>
743 diff --git a/iconvdata/euc-kr.c b/iconvdata/euc-kr.c
744 index b0d56cf3ee..1045bae926 100644
745 --- a/iconvdata/euc-kr.c
746 +++ b/iconvdata/euc-kr.c
747 @@ -80,11 +80,7 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
748 \
749 if (ch <= 0x9f) \
750 ++inptr; \
751 - /* 0xfe(->0x7e : row 94) and 0xc9(->0x59 : row 41) are \
752 - user-defined areas. */ \
753 - else if (__builtin_expect (ch == 0xa0, 0) \
754 - || __builtin_expect (ch > 0xfe, 0) \
755 - || __builtin_expect (ch == 0xc9, 0)) \
756 + else if (__glibc_unlikely (ch == 0xa0)) \
757 { \
758 /* This is illegal. */ \
759 STANDARD_FROM_LOOP_ERR_HANDLER (1); \
760 diff --git a/iconvdata/ibm1364.c b/iconvdata/ibm1364.c
761 index 49e7267ab4..521f0825b7 100644
762 --- a/iconvdata/ibm1364.c
763 +++ b/iconvdata/ibm1364.c
764 @@ -158,24 +158,14 @@ enum
765 \
766 if (__builtin_expect (ch, 0) == SO) \
767 { \
768 - /* Shift OUT, change to DBCS converter. */ \
769 - if (curcs == db) \
770 - { \
771 - result = __GCONV_ILLEGAL_INPUT; \
772 - break; \
773 - } \
774 + /* Shift OUT, change to DBCS converter (redundant escape okay). */ \
775 curcs = db; \
776 ++inptr; \
777 continue; \
778 } \
779 if (__builtin_expect (ch, 0) == SI) \
780 { \
781 - /* Shift IN, change to SBCS converter. */ \
782 - if (curcs == sb) \
783 - { \
784 - result = __GCONV_ILLEGAL_INPUT; \
785 - break; \
786 - } \
787 + /* Shift IN, change to SBCS converter (redundant escape okay). */ \
788 curcs = sb; \
789 ++inptr; \
790 continue; \
791 diff --git a/iconvdata/iso-2022-jp-3.c b/iconvdata/iso-2022-jp-3.c
792 index 8c3b7e627e..62cbc54a11 100644
793 --- a/iconvdata/iso-2022-jp-3.c
794 +++ b/iconvdata/iso-2022-jp-3.c
795 @@ -67,23 +67,34 @@ enum
796 CURRENT_SEL_MASK = 7 << 3
797 };
798
799 -/* During UCS-4 to ISO-2022-JP-3 conversion, the COUNT element of the state
800 - also contains the last two bytes to be output, shifted by 6 bits, and a
801 - one-bit indicator whether they must be preceded by the shift sequence,
802 - in bit 22. */
803 +/* During UCS-4 to ISO-2022-JP-3 conversion, the COUNT element of the
804 + state also contains the last two bytes to be output, shifted by 6
805 + bits, and a one-bit indicator whether they must be preceded by the
806 + shift sequence, in bit 22. During ISO-2022-JP-3 to UCS-4
807 + conversion, COUNT may also contain a non-zero pending wide
808 + character, shifted by six bits. This happens for certain inputs in
809 + JISX0213_1_2004_set and JISX0213_2_set if the second wide character
810 + in a combining sequence cannot be written because the buffer is
811 + full. */
812
813 /* Since this is a stateful encoding we have to provide code which resets
814 the output state to the initial state. This has to be done during the
815 flushing. */
816 #define EMIT_SHIFT_TO_INIT \
817 - if ((data->__statep->__count & ~7) != ASCII_set) \
818 + if (data->__statep->__count != ASCII_set) \
819 { \
820 if (FROM_DIRECTION) \
821 { \
822 - /* It's easy, we don't have to emit anything, we just reset the \
823 - state for the input. */ \
824 - data->__statep->__count &= 7; \
825 - data->__statep->__count |= ASCII_set; \
826 + if (__glibc_likely (outbuf + 4 <= outend)) \
827 + { \
828 + /* Write out the last character. */ \
829 + *((uint32_t *) outbuf) = data->__statep->__count >> 6; \
830 + outbuf += sizeof (uint32_t); \
831 + data->__statep->__count = ASCII_set; \
832 + } \
833 + else \
834 + /* We don't have enough room in the output buffer. */ \
835 + status = __GCONV_FULL_OUTPUT; \
836 } \
837 else \
838 { \
839 @@ -151,7 +162,21 @@ enum
840 #define LOOPFCT FROM_LOOP
841 #define BODY \
842 { \
843 - uint32_t ch = *inptr; \
844 + uint32_t ch; \
845 + \
846 + /* Output any pending character. */ \
847 + ch = set >> 6; \
848 + if (__glibc_unlikely (ch != 0)) \
849 + { \
850 + put32 (outptr, ch); \
851 + outptr += 4; \
852 + /* Remove the pending character, but preserve state bits. */ \
853 + set &= (1 << 6) - 1; \
854 + continue; \
855 + } \
856 + \
857 + /* Otherwise read the next input byte. */ \
858 + ch = *inptr; \
859 \
860 /* Recognize escape sequences. */ \
861 if (__glibc_unlikely (ch == ESC)) \
862 @@ -297,21 +322,25 @@ enum
863 uint32_t u1 = __jisx0213_to_ucs_combining[ch - 1][0]; \
864 uint32_t u2 = __jisx0213_to_ucs_combining[ch - 1][1]; \
865 \
866 + inptr += 2; \
867 + \
868 + put32 (outptr, u1); \
869 + outptr += 4; \
870 + \
871 /* See whether we have room for two characters. */ \
872 - if (outptr + 8 <= outend) \
873 + if (outptr + 4 <= outend) \
874 { \
875 - inptr += 2; \
876 - put32 (outptr, u1); \
877 - outptr += 4; \
878 put32 (outptr, u2); \
879 outptr += 4; \
880 continue; \
881 } \
882 - else \
883 - { \
884 - result = __GCONV_FULL_OUTPUT; \
885 - break; \
886 - } \
887 + \
888 + /* Otherwise store only the first character now, and \
889 + put the second one into the queue. */ \
890 + set |= u2 << 6; \
891 + /* Tell the caller why we terminate the loop. */ \
892 + result = __GCONV_FULL_OUTPUT; \
893 + break; \
894 } \
895 \
896 inptr += 2; \
897 diff --git a/iconvdata/ksc5601.h b/iconvdata/ksc5601.h
898 index d3eb3a4ff8..f5cdc72797 100644
899 --- a/iconvdata/ksc5601.h
900 +++ b/iconvdata/ksc5601.h
901 @@ -50,15 +50,15 @@ ksc5601_to_ucs4 (const unsigned char **s, size_t avail, unsigned char offset)
902 unsigned char ch2;
903 int idx;
904
905 + if (avail < 2)
906 + return 0;
907 +
908 /* row 94(0x7e) and row 41(0x49) are user-defined area in KS C 5601 */
909
910 if (ch < offset || (ch - offset) <= 0x20 || (ch - offset) >= 0x7e
911 || (ch - offset) == 0x49)
912 return __UNKNOWN_10646_CHAR;
913
914 - if (avail < 2)
915 - return 0;
916 -
917 ch2 = (*s)[1];
918 if (ch2 < offset || (ch2 - offset) <= 0x20 || (ch2 - offset) >= 0x7f)
919 return __UNKNOWN_10646_CHAR;
920 diff --git a/intl/dcigettext.c b/intl/dcigettext.c
921 index 2e7c662bc7..bd332e71da 100644
922 --- a/intl/dcigettext.c
923 +++ b/intl/dcigettext.c
924 @@ -1120,15 +1120,18 @@ _nl_find_msg (struct loaded_l10nfile *domain_file,
925
926 # ifdef _LIBC
927
928 - struct gconv_spec conv_spec
929 - = { .fromcode = norm_add_slashes (charset, ""),
930 - .tocode = norm_add_slashes (outcharset, ""),
931 - /* We always want to use transliteration. */
932 - .translit = true,
933 - .ignore = false
934 - };
935 + struct gconv_spec conv_spec;
936 +
937 + __gconv_create_spec (&conv_spec, charset, outcharset);
938 +
939 + /* We always want to use transliteration. */
940 + conv_spec.translit = true;
941 +
942 int r = __gconv_open (&conv_spec, &convd->conv,
943 GCONV_AVOID_NOCONV);
944 +
945 + __gconv_destroy_spec (&conv_spec);
946 +
947 if (__builtin_expect (r != __GCONV_OK, 0))
948 {
949 /* If the output encoding is the same there is
950 diff --git a/intl/tst-codeset.c b/intl/tst-codeset.c
951 index fd70432eca..e9f6e5e09f 100644
952 --- a/intl/tst-codeset.c
953 +++ b/intl/tst-codeset.c
954 @@ -22,13 +22,11 @@
955 #include <stdio.h>
956 #include <stdlib.h>
957 #include <string.h>
958 +#include <support/check.h>
959
960 static int
961 do_test (void)
962 {
963 - char *s;
964 - int result = 0;
965 -
966 unsetenv ("LANGUAGE");
967 unsetenv ("OUTPUT_CHARSET");
968 setlocale (LC_ALL, "de_DE.ISO-8859-1");
969 @@ -36,25 +34,21 @@ do_test (void)
970 bindtextdomain ("codeset", OBJPFX "domaindir");
971
972 /* Here we expect output in ISO-8859-1. */
973 - s = gettext ("cheese");
974 - if (strcmp (s, "K\344se"))
975 - {
976 - printf ("call 1 returned: %s\n", s);
977 - result = 1;
978 - }
979 + TEST_COMPARE_STRING (gettext ("cheese"), "K\344se");
980
981 + /* Here we expect output in UTF-8. */
982 bind_textdomain_codeset ("codeset", "UTF-8");
983 + TEST_COMPARE_STRING (gettext ("cheese"), "K\303\244se");
984
985 - /* Here we expect output in UTF-8. */
986 - s = gettext ("cheese");
987 - if (strcmp (s, "K\303\244se"))
988 - {
989 - printf ("call 2 returned: %s\n", s);
990 - result = 1;
991 - }
992 -
993 - return result;
994 + /* `a with umlaut' is transliterated to `ae'. */
995 + bind_textdomain_codeset ("codeset", "ASCII//TRANSLIT");
996 + TEST_COMPARE_STRING (gettext ("cheese"), "Kaese");
997 +
998 + /* Transliteration also works by default even if not set. */
999 + bind_textdomain_codeset ("codeset", "ASCII");
1000 + TEST_COMPARE_STRING (gettext ("cheese"), "Kaese");
1001 +
1002 + return 0;
1003 }
1004
1005 -#define TEST_FUNCTION do_test ()
1006 -#include "../test-skeleton.c"
1007 +#include <support/test-driver.c>
1008 diff --git a/malloc/Makefile b/malloc/Makefile
1009 index e22cbde22d..5093e8730e 100644
1010 --- a/malloc/Makefile
1011 +++ b/malloc/Makefile
1012 @@ -62,6 +62,16 @@ endif
1013 tests += $(tests-static)
1014 test-srcs = tst-mtrace
1015
1016 +# These tests either are run with MALLOC_CHECK_=3 by default or do not work
1017 +# with MALLOC_CHECK_=3 because they expect a specific failure.
1018 +tests-exclude-mcheck = tst-mcheck tst-malloc-usable \
1019 + tst-interpose-nothread tst-interpose-static-nothread \
1020 + tst-interpose-static-thread tst-malloc-too-large \
1021 + tst-mxfast tst-safe-linking
1022 +
1023 +# Run all tests with MALLOC_CHECK_=3
1024 +tests-mcheck = $(filter-out $(tests-exclude-mcheck),$(tests))
1025 +
1026 routines = malloc morecore mcheck mtrace obstack reallocarray \
1027 scratch_buffer_grow scratch_buffer_grow_preserve \
1028 scratch_buffer_set_array_size \
1029 @@ -100,6 +110,11 @@ $(objpfx)tst-malloc-thread-exit: $(shared-thread-library)
1030 $(objpfx)tst-malloc-thread-fail: $(shared-thread-library)
1031 $(objpfx)tst-malloc-fork-deadlock: $(shared-thread-library)
1032 $(objpfx)tst-malloc-stats-cancellation: $(shared-thread-library)
1033 +$(objpfx)tst-malloc-backtrace-mcheck: $(shared-thread-library)
1034 +$(objpfx)tst-malloc-thread-exit-mcheck: $(shared-thread-library)
1035 +$(objpfx)tst-malloc-thread-fail-mcheck: $(shared-thread-library)
1036 +$(objpfx)tst-malloc-fork-deadlock-mcheck: $(shared-thread-library)
1037 +$(objpfx)tst-malloc-stats-cancellation-mcheck: $(shared-thread-library)
1038
1039 # Export the __malloc_initialize_hook variable to libc.so.
1040 LDFLAGS-tst-mallocstate = -rdynamic
1041 @@ -239,6 +254,8 @@ $(tests:%=$(objpfx)%.o): CPPFLAGS += -DTEST_NO_MALLOPT
1042 $(objpfx)tst-interpose-nothread: $(objpfx)tst-interpose-aux-nothread.o
1043 $(objpfx)tst-interpose-thread: \
1044 $(objpfx)tst-interpose-aux-thread.o $(shared-thread-library)
1045 +$(objpfx)tst-interpose-thread-mcheck: \
1046 + $(objpfx)tst-interpose-aux-thread.o $(shared-thread-library)
1047 $(objpfx)tst-interpose-static-nothread: $(objpfx)tst-interpose-aux-nothread.o
1048 $(objpfx)tst-interpose-static-thread: \
1049 $(objpfx)tst-interpose-aux-thread.o $(static-thread-library)
1050 @@ -256,3 +273,6 @@ $(objpfx)tst-dynarray-fail-mem.out: $(objpfx)tst-dynarray-fail.out
1051 $(objpfx)tst-malloc-tcache-leak: $(shared-thread-library)
1052 $(objpfx)tst-malloc_info: $(shared-thread-library)
1053 $(objpfx)tst-mallocfork2: $(shared-thread-library)
1054 +$(objpfx)tst-malloc-tcache-leak-mcheck: $(shared-thread-library)
1055 +$(objpfx)tst-malloc_info-mcheck: $(shared-thread-library)
1056 +$(objpfx)tst-mallocfork2-mcheck: $(shared-thread-library)
1057 diff --git a/manual/tunables.texi b/manual/tunables.texi
1058 index 23ef0d40e7..d72d7a5ec0 100644
1059 --- a/manual/tunables.texi
1060 +++ b/manual/tunables.texi
1061 @@ -432,7 +432,11 @@ set shared cache size in bytes for use in memory and string routines.
1062
1063 @deftp Tunable glibc.cpu.x86_non_temporal_threshold
1064 The @code{glibc.cpu.x86_non_temporal_threshold} tunable allows the user
1065 -to set threshold in bytes for non temporal store.
1066 +to set threshold in bytes for non temporal store. Non temporal stores
1067 +give a hint to the hardware to move data directly to memory without
1068 +displacing other data from the cache. This tunable is used by some
1069 +platforms to determine when to use non temporal stores in operations
1070 +like memmove and memcpy.
1071
1072 This tunable is specific to i386 and x86-64.
1073 @end deftp
1074 diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
1075 index 19d9cc5cfe..38221d0b2a 100644
1076 --- a/misc/sys/cdefs.h
1077 +++ b/misc/sys/cdefs.h
1078 @@ -124,13 +124,10 @@
1079 #define __bos0(ptr) __builtin_object_size (ptr, 0)
1080
1081 #if __GNUC_PREREQ (4,3)
1082 -# define __warndecl(name, msg) \
1083 - extern void name (void) __attribute__((__warning__ (msg)))
1084 # define __warnattr(msg) __attribute__((__warning__ (msg)))
1085 # define __errordecl(name, msg) \
1086 extern void name (void) __attribute__((__error__ (msg)))
1087 #else
1088 -# define __warndecl(name, msg) extern void name (void)
1089 # define __warnattr(msg)
1090 # define __errordecl(name, msg) extern void name (void)
1091 #endif
1092 diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
1093 index 88c69d1e9c..381aa721ef 100644
1094 --- a/nscd/netgroupcache.c
1095 +++ b/nscd/netgroupcache.c
1096 @@ -248,7 +248,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
1097 : NULL);
1098 ndomain = (ndomain ? newbuf + ndomaindiff
1099 : NULL);
1100 - buffer = newbuf;
1101 + *tofreep = buffer = newbuf;
1102 }
1103
1104 nhost = memcpy (buffer + bufused,
1105 @@ -319,7 +319,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
1106 else if (status == NSS_STATUS_TRYAGAIN && e == ERANGE)
1107 {
1108 buflen *= 2;
1109 - buffer = xrealloc (buffer, buflen);
1110 + *tofreep = buffer = xrealloc (buffer, buflen);
1111 }
1112 else if (status == NSS_STATUS_RETURN
1113 || status == NSS_STATUS_NOTFOUND
1114 diff --git a/resolv/Makefile b/resolv/Makefile
1115 index b61c0c3e0c..dbd8f8bf4f 100644
1116 --- a/resolv/Makefile
1117 +++ b/resolv/Makefile
1118 @@ -61,6 +61,11 @@ tests += \
1119 tst-resolv-search \
1120 tst-resolv-trailing \
1121
1122 +# This test calls __res_context_send directly, which is not exported
1123 +# from libresolv.
1124 +tests-internal += tst-resolv-txnid-collision
1125 +tests-static += tst-resolv-txnid-collision
1126 +
1127 # These tests need libdl.
1128 ifeq (yes,$(build-shared))
1129 tests += \
1130 @@ -191,6 +196,8 @@ $(objpfx)tst-resolv-search: $(objpfx)libresolv.so $(shared-thread-library)
1131 $(objpfx)tst-resolv-trailing: $(objpfx)libresolv.so $(shared-thread-library)
1132 $(objpfx)tst-resolv-threads: \
1133 $(libdl) $(objpfx)libresolv.so $(shared-thread-library)
1134 +$(objpfx)tst-resolv-txnid-collision: $(objpfx)libresolv.a \
1135 + $(static-thread-library)
1136 $(objpfx)tst-resolv-canonname: \
1137 $(libdl) $(objpfx)libresolv.so $(shared-thread-library)
1138 $(objpfx)tst-resolv-trustad: $(objpfx)libresolv.so $(shared-thread-library)
1139 diff --git a/resolv/res_send.c b/resolv/res_send.c
1140 index 7e5fec6646..70e5066031 100644
1141 --- a/resolv/res_send.c
1142 +++ b/resolv/res_send.c
1143 @@ -1342,15 +1342,6 @@ send_dg(res_state statp,
1144 *terrno = EMSGSIZE;
1145 return close_and_return_error (statp, resplen2);
1146 }
1147 - if ((recvresp1 || hp->id != anhp->id)
1148 - && (recvresp2 || hp2->id != anhp->id)) {
1149 - /*
1150 - * response from old query, ignore it.
1151 - * XXX - potential security hazard could
1152 - * be detected here.
1153 - */
1154 - goto wait;
1155 - }
1156
1157 /* Paranoia check. Due to the connected UDP socket,
1158 the kernel has already filtered invalid addresses
1159 @@ -1360,15 +1351,24 @@ send_dg(res_state statp,
1160
1161 /* Check for the correct header layout and a matching
1162 question. */
1163 - if ((recvresp1 || !res_queriesmatch(buf, buf + buflen,
1164 - *thisansp,
1165 - *thisansp
1166 - + *thisanssizp))
1167 - && (recvresp2 || !res_queriesmatch(buf2, buf2 + buflen2,
1168 - *thisansp,
1169 - *thisansp
1170 - + *thisanssizp)))
1171 - goto wait;
1172 + int matching_query = 0; /* Default to no matching query. */
1173 + if (!recvresp1
1174 + && anhp->id == hp->id
1175 + && res_queriesmatch (buf, buf + buflen,
1176 + *thisansp, *thisansp + *thisanssizp))
1177 + matching_query = 1;
1178 + if (!recvresp2
1179 + && anhp->id == hp2->id
1180 + && res_queriesmatch (buf2, buf2 + buflen2,
1181 + *thisansp, *thisansp + *thisanssizp))
1182 + matching_query = 2;
1183 + if (matching_query == 0)
1184 + /* Spurious UDP packet. Drop it and continue
1185 + waiting. */
1186 + {
1187 + need_recompute = 1;
1188 + goto wait;
1189 + }
1190
1191 if (anhp->rcode == SERVFAIL ||
1192 anhp->rcode == NOTIMP ||
1193 @@ -1383,7 +1383,7 @@ send_dg(res_state statp,
1194 /* No data from the first reply. */
1195 resplen = 0;
1196 /* We are waiting for a possible second reply. */
1197 - if (hp->id == anhp->id)
1198 + if (matching_query == 1)
1199 recvresp1 = 1;
1200 else
1201 recvresp2 = 1;
1202 @@ -1414,7 +1414,7 @@ send_dg(res_state statp,
1203 return (1);
1204 }
1205 /* Mark which reply we received. */
1206 - if (recvresp1 == 0 && hp->id == anhp->id)
1207 + if (matching_query == 1)
1208 recvresp1 = 1;
1209 else
1210 recvresp2 = 1;
1211 diff --git a/resolv/tst-resolv-txnid-collision.c b/resolv/tst-resolv-txnid-collision.c
1212 new file mode 100644
1213 index 0000000000..189b76f126
1214 --- /dev/null
1215 +++ b/resolv/tst-resolv-txnid-collision.c
1216 @@ -0,0 +1,334 @@
1217 +/* Test parallel queries with transaction ID collisions.
1218 + Copyright (C) 2020 Free Software Foundation, Inc.
1219 + This file is part of the GNU C Library.
1220 +
1221 + The GNU C Library is free software; you can redistribute it and/or
1222 + modify it under the terms of the GNU Lesser General Public
1223 + License as published by the Free Software Foundation; either
1224 + version 2.1 of the License, or (at your option) any later version.
1225 +
1226 + The GNU C Library is distributed in the hope that it will be useful,
1227 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1228 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1229 + Lesser General Public License for more details.
1230 +
1231 + You should have received a copy of the GNU Lesser General Public
1232 + License along with the GNU C Library; if not, see
1233 + <https://www.gnu.org/licenses/>. */
1234 +
1235 +#include <arpa/nameser.h>
1236 +#include <array_length.h>
1237 +#include <resolv-internal.h>
1238 +#include <resolv_context.h>
1239 +#include <stdbool.h>
1240 +#include <stdio.h>
1241 +#include <string.h>
1242 +#include <support/check.h>
1243 +#include <support/check_nss.h>
1244 +#include <support/resolv_test.h>
1245 +#include <support/support.h>
1246 +#include <support/test-driver.h>
1247 +
1248 +/* Result of parsing a DNS question name.
1249 +
1250 + A question name has the form reorder-N-M-rcode-C.example.net, where
1251 + N and M are either 0 and 1, corresponding to the reorder member,
1252 + and C is a number that will be stored in the rcode field.
1253 +
1254 + Also see parse_qname below. */
1255 +struct parsed_qname
1256 +{
1257 + /* The DNS response code requested from the first server. The
1258 + second server always responds with RCODE zero. */
1259 + int rcode;
1260 +
1261 + /* Indicates whether to perform reordering in the responses from the
1262 + respective server. */
1263 + bool reorder[2];
1264 +};
1265 +
1266 +/* Fills *PARSED based on QNAME. */
1267 +static void
1268 +parse_qname (struct parsed_qname *parsed, const char *qname)
1269 +{
1270 + int reorder0;
1271 + int reorder1;
1272 + int rcode;
1273 + char *suffix;
1274 + if (sscanf (qname, "reorder-%d-%d.rcode-%d.%ms",
1275 + &reorder0, &reorder1, &rcode, &suffix) == 4)
1276 + {
1277 + if (reorder0 != 0)
1278 + TEST_COMPARE (reorder0, 1);
1279 + if (reorder1 != 0)
1280 + TEST_COMPARE (reorder1, 1);
1281 + TEST_VERIFY (rcode >= 0 && rcode <= 15);
1282 + TEST_COMPARE_STRING (suffix, "example.net");
1283 + free (suffix);
1284 +
1285 + parsed->rcode = rcode;
1286 + parsed->reorder[0] = reorder0;
1287 + parsed->reorder[1] = reorder1;
1288 + }
1289 + else
1290 + FAIL_EXIT1 ("unexpected query: %s", qname);
1291 +}
1292 +
1293 +/* Used to construct a response. The first server responds with an
1294 + error, the second server succeeds. */
1295 +static void
1296 +build_response (const struct resolv_response_context *ctx,
1297 + struct resolv_response_builder *b,
1298 + const char *qname, uint16_t qclass, uint16_t qtype)
1299 +{
1300 + struct parsed_qname parsed;
1301 + parse_qname (&parsed, qname);
1302 +
1303 + switch (ctx->server_index)
1304 + {
1305 + case 0:
1306 + {
1307 + struct resolv_response_flags flags = { 0 };
1308 + if (parsed.rcode == 0)
1309 + /* Simulate a delegation in case a NODATA (RCODE zero)
1310 + response is requested. */
1311 + flags.clear_ra = true;
1312 + else
1313 + flags.rcode = parsed.rcode;
1314 +
1315 + resolv_response_init (b, flags);
1316 + resolv_response_add_question (b, qname, qclass, qtype);
1317 + }
1318 + break;
1319 +
1320 + case 1:
1321 + {
1322 + struct resolv_response_flags flags = { 0, };
1323 + resolv_response_init (b, flags);
1324 + resolv_response_add_question (b, qname, qclass, qtype);
1325 +
1326 + resolv_response_section (b, ns_s_an);
1327 + resolv_response_open_record (b, qname, qclass, qtype, 0);
1328 + if (qtype == T_A)
1329 + {
1330 + char ipv4[4] = { 192, 0, 2, 1 };
1331 + resolv_response_add_data (b, &ipv4, sizeof (ipv4));
1332 + }
1333 + else
1334 + {
1335 + char ipv6[16]
1336 + = { 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
1337 + resolv_response_add_data (b, &ipv6, sizeof (ipv6));
1338 + }
1339 + resolv_response_close_record (b);
1340 + }
1341 + break;
1342 + }
1343 +}
1344 +
1345 +/* Used to reorder responses. */
1346 +struct resolv_response_context *previous_query;
1347 +
1348 +/* Used to keep track of the queries received. */
1349 +static int previous_server_index = -1;
1350 +static uint16_t previous_qtype;
1351 +
1352 +/* For each server, buffer the first query and then send both answers
1353 + to the second query, reordered if requested. */
1354 +static void
1355 +response (const struct resolv_response_context *ctx,
1356 + struct resolv_response_builder *b,
1357 + const char *qname, uint16_t qclass, uint16_t qtype)
1358 +{
1359 + TEST_VERIFY (qtype == T_A || qtype == T_AAAA);
1360 + if (ctx->server_index != 0)
1361 + TEST_COMPARE (ctx->server_index, 1);
1362 +
1363 + struct parsed_qname parsed;
1364 + parse_qname (&parsed, qname);
1365 +
1366 + if (previous_query == NULL)
1367 + {
1368 + /* No buffered query. Record this query and do not send a
1369 + response. */
1370 + TEST_COMPARE (previous_qtype, 0);
1371 + previous_query = resolv_response_context_duplicate (ctx);
1372 + previous_qtype = qtype;
1373 + resolv_response_drop (b);
1374 + previous_server_index = ctx->server_index;
1375 +
1376 + if (test_verbose)
1377 + printf ("info: buffering first query for: %s\n", qname);
1378 + }
1379 + else
1380 + {
1381 + TEST_VERIFY (previous_query != 0);
1382 + TEST_COMPARE (ctx->server_index, previous_server_index);
1383 + TEST_VERIFY (previous_qtype != qtype); /* Not a duplicate. */
1384 +
1385 + /* If reordering, send a response for this query explicitly, and
1386 + then skip the implicit send. */
1387 + if (parsed.reorder[ctx->server_index])
1388 + {
1389 + if (test_verbose)
1390 + printf ("info: sending reordered second response for: %s\n",
1391 + qname);
1392 + build_response (ctx, b, qname, qclass, qtype);
1393 + resolv_response_send_udp (ctx, b);
1394 + resolv_response_drop (b);
1395 + }
1396 +
1397 + /* Build a response for the previous query and send it, thus
1398 + reordering the two responses. */
1399 + {
1400 + if (test_verbose)
1401 + printf ("info: sending first response for: %s\n", qname);
1402 + struct resolv_response_builder *btmp
1403 + = resolv_response_builder_allocate (previous_query->query_buffer,
1404 + previous_query->query_length);
1405 + build_response (ctx, btmp, qname, qclass, previous_qtype);
1406 + resolv_response_send_udp (ctx, btmp);
1407 + resolv_response_builder_free (btmp);
1408 + }
1409 +
1410 + /* If not reordering, send the reply as usual. */
1411 + if (!parsed.reorder[ctx->server_index])
1412 + {
1413 + if (test_verbose)
1414 + printf ("info: sending non-reordered second response for: %s\n",
1415 + qname);
1416 + build_response (ctx, b, qname, qclass, qtype);
1417 + }
1418 +
1419 + /* Unbuffer the response and prepare for the next query. */
1420 + resolv_response_context_free (previous_query);
1421 + previous_query = NULL;
1422 + previous_qtype = 0;
1423 + previous_server_index = -1;
1424 + }
1425 +}
1426 +
1427 +/* Runs a query for QNAME and checks for the expected reply. See
1428 + struct parsed_qname for the expected format for QNAME. */
1429 +static void
1430 +test_qname (const char *qname, int rcode)
1431 +{
1432 + struct resolv_context *ctx = __resolv_context_get ();
1433 + TEST_VERIFY_EXIT (ctx != NULL);
1434 +
1435 + unsigned char q1[512];
1436 + int q1len = res_mkquery (QUERY, qname, C_IN, T_A, NULL, 0, NULL,
1437 + q1, sizeof (q1));
1438 + TEST_VERIFY_EXIT (q1len > 12);
1439 +
1440 + unsigned char q2[512];
1441 + int q2len = res_mkquery (QUERY, qname, C_IN, T_AAAA, NULL, 0, NULL,
1442 + q2, sizeof (q2));
1443 + TEST_VERIFY_EXIT (q2len > 12);
1444 +
1445 + /* Produce a transaction ID collision. */
1446 + memcpy (q2, q1, 2);
1447 +
1448 + unsigned char ans1[512];
1449 + unsigned char *ans1p = ans1;
1450 + unsigned char *ans2p = NULL;
1451 + int nans2p = 0;
1452 + int resplen2 = 0;
1453 + int ans2p_malloced = 0;
1454 +
1455 + /* Perform a parallel A/AAAA query. */
1456 + int resplen1 = __res_context_send (ctx, q1, q1len, q2, q2len,
1457 + ans1, sizeof (ans1), &ans1p,
1458 + &ans2p, &nans2p,
1459 + &resplen2, &ans2p_malloced);
1460 +
1461 + TEST_VERIFY (resplen1 > 12);
1462 + TEST_VERIFY (resplen2 > 12);
1463 + if (resplen1 <= 12 || resplen2 <= 12)
1464 + return;
1465 +
1466 + if (rcode == 1 || rcode == 3)
1467 + {
1468 + /* Format Error and Name Error responses does not trigger
1469 + switching to the next server. */
1470 + TEST_COMPARE (ans1p[3] & 0x0f, rcode);
1471 + TEST_COMPARE (ans2p[3] & 0x0f, rcode);
1472 + return;
1473 + }
1474 +
1475 + /* The response should be successful. */
1476 + TEST_COMPARE (ans1p[3] & 0x0f, 0);
1477 + TEST_COMPARE (ans2p[3] & 0x0f, 0);
1478 +
1479 + /* Due to bug 19691, the answer may not be in the slot matching the
1480 + query. Assume that the AAAA response is the longer one. */
1481 + unsigned char *a_answer;
1482 + int a_answer_length;
1483 + unsigned char *aaaa_answer;
1484 + int aaaa_answer_length;
1485 + if (resplen2 > resplen1)
1486 + {
1487 + a_answer = ans1p;
1488 + a_answer_length = resplen1;
1489 + aaaa_answer = ans2p;
1490 + aaaa_answer_length = resplen2;
1491 + }
1492 + else
1493 + {
1494 + a_answer = ans2p;
1495 + a_answer_length = resplen2;
1496 + aaaa_answer = ans1p;
1497 + aaaa_answer_length = resplen1;
1498 + }
1499 +
1500 + {
1501 + char *expected = xasprintf ("name: %s\n"
1502 + "address: 192.0.2.1\n",
1503 + qname);
1504 + check_dns_packet (qname, a_answer, a_answer_length, expected);
1505 + free (expected);
1506 + }
1507 + {
1508 + char *expected = xasprintf ("name: %s\n"
1509 + "address: 2001:db8::1\n",
1510 + qname);
1511 + check_dns_packet (qname, aaaa_answer, aaaa_answer_length, expected);
1512 + free (expected);
1513 + }
1514 +
1515 + if (ans2p_malloced)
1516 + free (ans2p);
1517 +
1518 + __resolv_context_put (ctx);
1519 +}
1520 +
1521 +static int
1522 +do_test (void)
1523 +{
1524 + struct resolv_test *aux = resolv_test_start
1525 + ((struct resolv_redirect_config)
1526 + {
1527 + .response_callback = response,
1528 +
1529 + /* The response callback use global state (the previous_*
1530 + variables), and query processing must therefore be
1531 + serialized. */
1532 + .single_thread_udp = true,
1533 + });
1534 +
1535 + for (int rcode = 0; rcode <= 5; ++rcode)
1536 + for (int do_reorder_0 = 0; do_reorder_0 < 2; ++do_reorder_0)
1537 + for (int do_reorder_1 = 0; do_reorder_1 < 2; ++do_reorder_1)
1538 + {
1539 + char *qname = xasprintf ("reorder-%d-%d.rcode-%d.example.net",
1540 + do_reorder_0, do_reorder_1, rcode);
1541 + test_qname (qname, rcode);
1542 + free (qname);
1543 + }
1544 +
1545 + resolv_test_end (aux);
1546 +
1547 + return 0;
1548 +}
1549 +
1550 +#include <support/test-driver.c>
1551 diff --git a/stdio-common/Makefile b/stdio-common/Makefile
1552 index 8475fd1f09..eff0c98d82 100644
1553 --- a/stdio-common/Makefile
1554 +++ b/stdio-common/Makefile
1555 @@ -69,7 +69,8 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
1556 tst-printf-bz25691 \
1557 tst-vfprintf-width-prec-alloc \
1558 tst-printf-fp-free \
1559 - tst-printf-fp-leak
1560 + tst-printf-fp-leak \
1561 + test-strerr
1562
1563
1564 test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble
1565 diff --git a/stdio-common/errlist.c b/stdio-common/errlist.c
1566 index d15f13a22a..2ecf121674 100644
1567 --- a/stdio-common/errlist.c
1568 +++ b/stdio-common/errlist.c
1569 @@ -20,9 +20,13 @@
1570 #include <libintl.h>
1571 #include <array_length.h>
1572
1573 +#ifndef ERR_MAP
1574 +# define ERR_MAP(n) n
1575 +#endif
1576 +
1577 const char *const _sys_errlist_internal[] =
1578 {
1579 -#define _S(n, str) [n] = str,
1580 +#define _S(n, str) [ERR_MAP(n)] = str,
1581 #include <errlist.h>
1582 #undef _S
1583 };
1584 @@ -41,20 +45,21 @@ static const union sys_errname_t
1585 {
1586 #define MSGSTRFIELD1(line) str##line
1587 #define MSGSTRFIELD(line) MSGSTRFIELD1(line)
1588 -#define _S(n, str) char MSGSTRFIELD(__LINE__)[sizeof(str)];
1589 +#define _S(n, str) char MSGSTRFIELD(__LINE__)[sizeof(#n)];
1590 #include <errlist.h>
1591 #undef _S
1592 };
1593 char str[0];
1594 } _sys_errname = { {
1595 -#define _S(n, s) s,
1596 +#define _S(n, s) #n,
1597 #include <errlist.h>
1598 #undef _S
1599 } };
1600
1601 static const unsigned short _sys_errnameidx[] =
1602 {
1603 -#define _S(n, s) [n] = offsetof(union sys_errname_t, MSGSTRFIELD(__LINE__)),
1604 +#define _S(n, s) \
1605 + [ERR_MAP(n)] = offsetof(union sys_errname_t, MSGSTRFIELD(__LINE__)),
1606 #include <errlist.h>
1607 #undef _S
1608 };
1609 diff --git a/stdio-common/test-strerr.c b/stdio-common/test-strerr.c
1610 index fded208118..d77b81d507 100644
1611 --- a/stdio-common/test-strerr.c
1612 +++ b/stdio-common/test-strerr.c
1613 @@ -18,46 +18,672 @@
1614
1615 #include <string.h>
1616 #include <errno.h>
1617 -#include <array_length.h>
1618
1619 #include <support/support.h>
1620 #include <support/check.h>
1621
1622 -#define N_(name) name
1623 -
1624 -static const char *const errlist[] =
1625 - {
1626 -/* This file is auto-generated from errlist.def. */
1627 -#include <errlist.h>
1628 - };
1629 -
1630 -#define MSGSTR_T errname_t
1631 -#define MSGSTR errname
1632 -#define MSGIDX errnameidx
1633 -#include <errlist-name.h>
1634 -#undef MSGSTR
1635 -#undef MSGIDX
1636 -
1637 static int
1638 do_test (void)
1639 {
1640 - TEST_VERIFY (strerrordesc_np (-1) == NULL);
1641 - TEST_VERIFY (strerrordesc_np (array_length (errlist)) == NULL);
1642 - for (size_t i = 0; i < array_length (errlist); i++)
1643 - {
1644 - if (errlist[i] == NULL)
1645 - continue;
1646 - TEST_COMPARE_STRING (strerrordesc_np (i), errlist[i]);
1647 - }
1648 + TEST_COMPARE_STRING (strerrordesc_np (0), "Success");
1649 + TEST_COMPARE_STRING (strerrorname_np (0), "0");
1650
1651 - TEST_VERIFY (strerrorname_np (-1) == NULL);
1652 - TEST_VERIFY (strerrorname_np (array_length (errlist)) == NULL);
1653 - for (size_t i = 0; i < array_length (errlist); i++)
1654 - {
1655 - if (errlist[i] == NULL)
1656 - continue;
1657 - TEST_COMPARE_STRING (strerrorname_np (i), errname.str + errnameidx[i]);
1658 - }
1659 +#ifdef EPERM
1660 + TEST_COMPARE_STRING (strerrordesc_np (EPERM), "Operation not permitted");
1661 + TEST_COMPARE_STRING (strerrorname_np (EPERM), "EPERM");
1662 +#endif
1663 +#ifdef ENOENT
1664 + TEST_COMPARE_STRING (strerrordesc_np (ENOENT),
1665 + "No such file or directory");
1666 + TEST_COMPARE_STRING (strerrorname_np (ENOENT), "ENOENT");
1667 +#endif
1668 +#ifdef ESRCH
1669 + TEST_COMPARE_STRING (strerrordesc_np (ESRCH), "No such process");
1670 + TEST_COMPARE_STRING (strerrorname_np (ESRCH), "ESRCH");
1671 +#endif
1672 +#ifdef EINTR
1673 + TEST_COMPARE_STRING (strerrordesc_np (EINTR), "Interrupted system call");
1674 + TEST_COMPARE_STRING (strerrorname_np (EINTR), "EINTR");
1675 +#endif
1676 +#ifdef EIO
1677 + TEST_COMPARE_STRING (strerrordesc_np (EIO), "Input/output error");
1678 + TEST_COMPARE_STRING (strerrorname_np (EIO), "EIO");
1679 +#endif
1680 +#ifdef ENXIO
1681 + TEST_COMPARE_STRING (strerrordesc_np (ENXIO), "No such device or address");
1682 + TEST_COMPARE_STRING (strerrorname_np (ENXIO), "ENXIO");
1683 +#endif
1684 +#ifdef E2BIG
1685 + TEST_COMPARE_STRING (strerrordesc_np (E2BIG), "Argument list too long");
1686 + TEST_COMPARE_STRING (strerrorname_np (E2BIG), "E2BIG");
1687 +#endif
1688 +#ifdef ENOEXEC
1689 + TEST_COMPARE_STRING (strerrordesc_np (ENOEXEC), "Exec format error");
1690 + TEST_COMPARE_STRING (strerrorname_np (ENOEXEC), "ENOEXEC");
1691 +#endif
1692 +#ifdef EBADF
1693 + TEST_COMPARE_STRING (strerrordesc_np (EBADF), "Bad file descriptor");
1694 + TEST_COMPARE_STRING (strerrorname_np (EBADF), "EBADF");
1695 +#endif
1696 +#ifdef ECHILD
1697 + TEST_COMPARE_STRING (strerrordesc_np (ECHILD), "No child processes");
1698 + TEST_COMPARE_STRING (strerrorname_np (ECHILD), "ECHILD");
1699 +#endif
1700 +#ifdef EDEADLK
1701 + TEST_COMPARE_STRING (strerrordesc_np (EDEADLK),
1702 + "Resource deadlock avoided");
1703 + TEST_COMPARE_STRING (strerrorname_np (EDEADLK), "EDEADLK");
1704 +#endif
1705 +#ifdef ENOMEM
1706 + TEST_COMPARE_STRING (strerrordesc_np (ENOMEM), "Cannot allocate memory");
1707 + TEST_COMPARE_STRING (strerrorname_np (ENOMEM), "ENOMEM");
1708 +#endif
1709 +#ifdef EACCES
1710 + TEST_COMPARE_STRING (strerrordesc_np (EACCES), "Permission denied");
1711 + TEST_COMPARE_STRING (strerrorname_np (EACCES), "EACCES");
1712 +#endif
1713 +#ifdef EFAULT
1714 + TEST_COMPARE_STRING (strerrordesc_np (EFAULT), "Bad address");
1715 + TEST_COMPARE_STRING (strerrorname_np (EFAULT), "EFAULT");
1716 +#endif
1717 +#ifdef ENOTBLK
1718 + TEST_COMPARE_STRING (strerrordesc_np (ENOTBLK), "Block device required");
1719 + TEST_COMPARE_STRING (strerrorname_np (ENOTBLK), "ENOTBLK");
1720 +#endif
1721 +#ifdef EBUSY
1722 + TEST_COMPARE_STRING (strerrordesc_np (EBUSY), "Device or resource busy");
1723 + TEST_COMPARE_STRING (strerrorname_np (EBUSY), "EBUSY");
1724 +#endif
1725 +#ifdef EEXIST
1726 + TEST_COMPARE_STRING (strerrordesc_np (EEXIST), "File exists");
1727 + TEST_COMPARE_STRING (strerrorname_np (EEXIST), "EEXIST");
1728 +#endif
1729 +#ifdef EXDEV
1730 + TEST_COMPARE_STRING (strerrordesc_np (EXDEV), "Invalid cross-device link");
1731 + TEST_COMPARE_STRING (strerrorname_np (EXDEV), "EXDEV");
1732 +#endif
1733 +#ifdef ENODEV
1734 + TEST_COMPARE_STRING (strerrordesc_np (ENODEV), "No such device");
1735 + TEST_COMPARE_STRING (strerrorname_np (ENODEV), "ENODEV");
1736 +#endif
1737 +#ifdef ENOTDIR
1738 + TEST_COMPARE_STRING (strerrordesc_np (ENOTDIR), "Not a directory");
1739 + TEST_COMPARE_STRING (strerrorname_np (ENOTDIR), "ENOTDIR");
1740 +#endif
1741 +#ifdef EISDIR
1742 + TEST_COMPARE_STRING (strerrordesc_np (EISDIR), "Is a directory");
1743 + TEST_COMPARE_STRING (strerrorname_np (EISDIR), "EISDIR");
1744 +#endif
1745 +#ifdef EINVAL
1746 + TEST_COMPARE_STRING (strerrordesc_np (EINVAL), "Invalid argument");
1747 + TEST_COMPARE_STRING (strerrorname_np (EINVAL), "EINVAL");
1748 +#endif
1749 +#ifdef EMFILE
1750 + TEST_COMPARE_STRING (strerrordesc_np (EMFILE), "Too many open files");
1751 + TEST_COMPARE_STRING (strerrorname_np (EMFILE), "EMFILE");
1752 +#endif
1753 +#ifdef ENFILE
1754 + TEST_COMPARE_STRING (strerrordesc_np (ENFILE),
1755 + "Too many open files in system");
1756 + TEST_COMPARE_STRING (strerrorname_np (ENFILE), "ENFILE");
1757 +#endif
1758 +#ifdef ENOTTY
1759 + TEST_COMPARE_STRING (strerrordesc_np (ENOTTY),
1760 + "Inappropriate ioctl for device");
1761 + TEST_COMPARE_STRING (strerrorname_np (ENOTTY), "ENOTTY");
1762 +#endif
1763 +#ifdef ETXTBSY
1764 + TEST_COMPARE_STRING (strerrordesc_np (ETXTBSY), "Text file busy");
1765 + TEST_COMPARE_STRING (strerrorname_np (ETXTBSY), "ETXTBSY");
1766 +#endif
1767 +#ifdef EFBIG
1768 + TEST_COMPARE_STRING (strerrordesc_np (EFBIG), "File too large");
1769 + TEST_COMPARE_STRING (strerrorname_np (EFBIG), "EFBIG");
1770 +#endif
1771 +#ifdef ENOSPC
1772 + TEST_COMPARE_STRING (strerrordesc_np (ENOSPC), "No space left on device");
1773 + TEST_COMPARE_STRING (strerrorname_np (ENOSPC), "ENOSPC");
1774 +#endif
1775 +#ifdef ESPIPE
1776 + TEST_COMPARE_STRING (strerrordesc_np (ESPIPE), "Illegal seek");
1777 + TEST_COMPARE_STRING (strerrorname_np (ESPIPE), "ESPIPE");
1778 +#endif
1779 +#ifdef EROFS
1780 + TEST_COMPARE_STRING (strerrordesc_np (EROFS), "Read-only file system");
1781 + TEST_COMPARE_STRING (strerrorname_np (EROFS), "EROFS");
1782 +#endif
1783 +#ifdef EMLINK
1784 + TEST_COMPARE_STRING (strerrordesc_np (EMLINK), "Too many links");
1785 + TEST_COMPARE_STRING (strerrorname_np (EMLINK), "EMLINK");
1786 +#endif
1787 +#ifdef EPIPE
1788 + TEST_COMPARE_STRING (strerrordesc_np (EPIPE), "Broken pipe");
1789 + TEST_COMPARE_STRING (strerrorname_np (EPIPE), "EPIPE");
1790 +#endif
1791 +#ifdef EDOM
1792 + TEST_COMPARE_STRING (strerrordesc_np (EDOM),
1793 + "Numerical argument out of domain");
1794 + TEST_COMPARE_STRING (strerrorname_np (EDOM), "EDOM");
1795 +#endif
1796 +#ifdef ERANGE
1797 + TEST_COMPARE_STRING (strerrordesc_np (ERANGE),
1798 + "Numerical result out of range");
1799 + TEST_COMPARE_STRING (strerrorname_np (ERANGE), "ERANGE");
1800 +#endif
1801 +#ifdef EAGAIN
1802 + TEST_COMPARE_STRING (strerrordesc_np (EAGAIN),
1803 + "Resource temporarily unavailable");
1804 + TEST_COMPARE_STRING (strerrorname_np (EAGAIN), "EAGAIN");
1805 +#endif
1806 +#ifdef EINPROGRESS
1807 + TEST_COMPARE_STRING (strerrordesc_np (EINPROGRESS),
1808 + "Operation now in progress");
1809 + TEST_COMPARE_STRING (strerrorname_np (EINPROGRESS), "EINPROGRESS");
1810 +#endif
1811 +#ifdef EALREADY
1812 + TEST_COMPARE_STRING (strerrordesc_np (EALREADY),
1813 + "Operation already in progress");
1814 + TEST_COMPARE_STRING (strerrorname_np (EALREADY), "EALREADY");
1815 +#endif
1816 +#ifdef ENOTSOCK
1817 + TEST_COMPARE_STRING (strerrordesc_np (ENOTSOCK),
1818 + "Socket operation on non-socket");
1819 + TEST_COMPARE_STRING (strerrorname_np (ENOTSOCK), "ENOTSOCK");
1820 +#endif
1821 +#ifdef EMSGSIZE
1822 + TEST_COMPARE_STRING (strerrordesc_np (EMSGSIZE), "Message too long");
1823 + TEST_COMPARE_STRING (strerrorname_np (EMSGSIZE), "EMSGSIZE");
1824 +#endif
1825 +#ifdef EPROTOTYPE
1826 + TEST_COMPARE_STRING (strerrordesc_np (EPROTOTYPE),
1827 + "Protocol wrong type for socket");
1828 + TEST_COMPARE_STRING (strerrorname_np (EPROTOTYPE), "EPROTOTYPE");
1829 +#endif
1830 +#ifdef ENOPROTOOPT
1831 + TEST_COMPARE_STRING (strerrordesc_np (ENOPROTOOPT),
1832 + "Protocol not available");
1833 + TEST_COMPARE_STRING (strerrorname_np (ENOPROTOOPT), "ENOPROTOOPT");
1834 +#endif
1835 +#ifdef EPROTONOSUPPORT
1836 + TEST_COMPARE_STRING (strerrordesc_np (EPROTONOSUPPORT),
1837 + "Protocol not supported");
1838 + TEST_COMPARE_STRING (strerrorname_np (EPROTONOSUPPORT), "EPROTONOSUPPORT");
1839 +#endif
1840 +#ifdef ESOCKTNOSUPPORT
1841 + TEST_COMPARE_STRING (strerrordesc_np (ESOCKTNOSUPPORT),
1842 + "Socket type not supported");
1843 + TEST_COMPARE_STRING (strerrorname_np (ESOCKTNOSUPPORT), "ESOCKTNOSUPPORT");
1844 +#endif
1845 +#ifdef EOPNOTSUPP
1846 + TEST_COMPARE_STRING (strerrordesc_np (EOPNOTSUPP),
1847 + "Operation not supported");
1848 + TEST_COMPARE_STRING (strerrorname_np (EOPNOTSUPP), "EOPNOTSUPP");
1849 +#endif
1850 +#ifdef EPFNOSUPPORT
1851 + TEST_COMPARE_STRING (strerrordesc_np (EPFNOSUPPORT),
1852 + "Protocol family not supported");
1853 + TEST_COMPARE_STRING (strerrorname_np (EPFNOSUPPORT), "EPFNOSUPPORT");
1854 +#endif
1855 +#ifdef EAFNOSUPPORT
1856 + TEST_COMPARE_STRING (strerrordesc_np (EAFNOSUPPORT),
1857 + "Address family not supported by protocol");
1858 + TEST_COMPARE_STRING (strerrorname_np (EAFNOSUPPORT), "EAFNOSUPPORT");
1859 +#endif
1860 +#ifdef EADDRINUSE
1861 + TEST_COMPARE_STRING (strerrordesc_np (EADDRINUSE),
1862 + "Address already in use");
1863 + TEST_COMPARE_STRING (strerrorname_np (EADDRINUSE), "EADDRINUSE");
1864 +#endif
1865 +#ifdef EADDRNOTAVAIL
1866 + TEST_COMPARE_STRING (strerrordesc_np (EADDRNOTAVAIL),
1867 + "Cannot assign requested address");
1868 + TEST_COMPARE_STRING (strerrorname_np (EADDRNOTAVAIL), "EADDRNOTAVAIL");
1869 +#endif
1870 +#ifdef ENETDOWN
1871 + TEST_COMPARE_STRING (strerrordesc_np (ENETDOWN), "Network is down");
1872 + TEST_COMPARE_STRING (strerrorname_np (ENETDOWN), "ENETDOWN");
1873 +#endif
1874 +#ifdef ENETUNREACH
1875 + TEST_COMPARE_STRING (strerrordesc_np (ENETUNREACH),
1876 + "Network is unreachable");
1877 + TEST_COMPARE_STRING (strerrorname_np (ENETUNREACH), "ENETUNREACH");
1878 +#endif
1879 +#ifdef ENETRESET
1880 + TEST_COMPARE_STRING (strerrordesc_np (ENETRESET),
1881 + "Network dropped connection on reset");
1882 + TEST_COMPARE_STRING (strerrorname_np (ENETRESET), "ENETRESET");
1883 +#endif
1884 +#ifdef ECONNABORTED
1885 + TEST_COMPARE_STRING (strerrordesc_np (ECONNABORTED),
1886 + "Software caused connection abort");
1887 + TEST_COMPARE_STRING (strerrorname_np (ECONNABORTED), "ECONNABORTED");
1888 +#endif
1889 +#ifdef ECONNRESET
1890 + TEST_COMPARE_STRING (strerrordesc_np (ECONNRESET),
1891 + "Connection reset by peer");
1892 + TEST_COMPARE_STRING (strerrorname_np (ECONNRESET), "ECONNRESET");
1893 +#endif
1894 +#ifdef ENOBUFS
1895 + TEST_COMPARE_STRING (strerrordesc_np (ENOBUFS),
1896 + "No buffer space available");
1897 + TEST_COMPARE_STRING (strerrorname_np (ENOBUFS), "ENOBUFS");
1898 +#endif
1899 +#ifdef EISCONN
1900 + TEST_COMPARE_STRING (strerrordesc_np (EISCONN),
1901 + "Transport endpoint is already connected");
1902 + TEST_COMPARE_STRING (strerrorname_np (EISCONN), "EISCONN");
1903 +#endif
1904 +#ifdef ENOTCONN
1905 + TEST_COMPARE_STRING (strerrordesc_np (ENOTCONN),
1906 + "Transport endpoint is not connected");
1907 + TEST_COMPARE_STRING (strerrorname_np (ENOTCONN), "ENOTCONN");
1908 +#endif
1909 +#ifdef EDESTADDRREQ
1910 + TEST_COMPARE_STRING (strerrordesc_np (EDESTADDRREQ),
1911 + "Destination address required");
1912 + TEST_COMPARE_STRING (strerrorname_np (EDESTADDRREQ), "EDESTADDRREQ");
1913 +#endif
1914 +#ifdef ESHUTDOWN
1915 + TEST_COMPARE_STRING (strerrordesc_np (ESHUTDOWN),
1916 + "Cannot send after transport endpoint shutdown");
1917 + TEST_COMPARE_STRING (strerrorname_np (ESHUTDOWN), "ESHUTDOWN");
1918 +#endif
1919 +#ifdef ETOOMANYREFS
1920 + TEST_COMPARE_STRING (strerrordesc_np (ETOOMANYREFS),
1921 + "Too many references: cannot splice");
1922 + TEST_COMPARE_STRING (strerrorname_np (ETOOMANYREFS), "ETOOMANYREFS");
1923 +#endif
1924 +#ifdef ETIMEDOUT
1925 + TEST_COMPARE_STRING (strerrordesc_np (ETIMEDOUT), "Connection timed out");
1926 + TEST_COMPARE_STRING (strerrorname_np (ETIMEDOUT), "ETIMEDOUT");
1927 +#endif
1928 +#ifdef ECONNREFUSED
1929 + TEST_COMPARE_STRING (strerrordesc_np (ECONNREFUSED), "Connection refused");
1930 + TEST_COMPARE_STRING (strerrorname_np (ECONNREFUSED), "ECONNREFUSED");
1931 +#endif
1932 +#ifdef ELOOP
1933 + TEST_COMPARE_STRING (strerrordesc_np (ELOOP),
1934 + "Too many levels of symbolic links");
1935 + TEST_COMPARE_STRING (strerrorname_np (ELOOP), "ELOOP");
1936 +#endif
1937 +#ifdef ENAMETOOLONG
1938 + TEST_COMPARE_STRING (strerrordesc_np (ENAMETOOLONG), "File name too long");
1939 + TEST_COMPARE_STRING (strerrorname_np (ENAMETOOLONG), "ENAMETOOLONG");
1940 +#endif
1941 +#ifdef EHOSTDOWN
1942 + TEST_COMPARE_STRING (strerrordesc_np (EHOSTDOWN), "Host is down");
1943 + TEST_COMPARE_STRING (strerrorname_np (EHOSTDOWN), "EHOSTDOWN");
1944 +#endif
1945 +#ifdef EHOSTUNREACH
1946 + TEST_COMPARE_STRING (strerrordesc_np (EHOSTUNREACH), "No route to host");
1947 + TEST_COMPARE_STRING (strerrorname_np (EHOSTUNREACH), "EHOSTUNREACH");
1948 +#endif
1949 +#ifdef ENOTEMPTY
1950 + TEST_COMPARE_STRING (strerrordesc_np (ENOTEMPTY), "Directory not empty");
1951 + TEST_COMPARE_STRING (strerrorname_np (ENOTEMPTY), "ENOTEMPTY");
1952 +#endif
1953 +#ifdef EUSERS
1954 + TEST_COMPARE_STRING (strerrordesc_np (EUSERS), "Too many users");
1955 + TEST_COMPARE_STRING (strerrorname_np (EUSERS), "EUSERS");
1956 +#endif
1957 +#ifdef EDQUOT
1958 + TEST_COMPARE_STRING (strerrordesc_np (EDQUOT), "Disk quota exceeded");
1959 + TEST_COMPARE_STRING (strerrorname_np (EDQUOT), "EDQUOT");
1960 +#endif
1961 +#ifdef ESTALE
1962 + TEST_COMPARE_STRING (strerrordesc_np (ESTALE), "Stale file handle");
1963 + TEST_COMPARE_STRING (strerrorname_np (ESTALE), "ESTALE");
1964 +#endif
1965 +#ifdef EREMOTE
1966 + TEST_COMPARE_STRING (strerrordesc_np (EREMOTE), "Object is remote");
1967 + TEST_COMPARE_STRING (strerrorname_np (EREMOTE), "EREMOTE");
1968 +#endif
1969 +#ifdef ENOLCK
1970 + TEST_COMPARE_STRING (strerrordesc_np (ENOLCK), "No locks available");
1971 + TEST_COMPARE_STRING (strerrorname_np (ENOLCK), "ENOLCK");
1972 +#endif
1973 +#ifdef ENOSYS
1974 + TEST_COMPARE_STRING (strerrordesc_np (ENOSYS), "Function not implemented");
1975 + TEST_COMPARE_STRING (strerrorname_np (ENOSYS), "ENOSYS");
1976 +#endif
1977 +#ifdef EILSEQ
1978 + TEST_COMPARE_STRING (strerrordesc_np (EILSEQ),
1979 + "Invalid or incomplete multibyte or wide character");
1980 + TEST_COMPARE_STRING (strerrorname_np (EILSEQ), "EILSEQ");
1981 +#endif
1982 +#ifdef EBADMSG
1983 + TEST_COMPARE_STRING (strerrordesc_np (EBADMSG), "Bad message");
1984 + TEST_COMPARE_STRING (strerrorname_np (EBADMSG), "EBADMSG");
1985 +#endif
1986 +#ifdef EIDRM
1987 + TEST_COMPARE_STRING (strerrordesc_np (EIDRM), "Identifier removed");
1988 + TEST_COMPARE_STRING (strerrorname_np (EIDRM), "EIDRM");
1989 +#endif
1990 +#ifdef EMULTIHOP
1991 + TEST_COMPARE_STRING (strerrordesc_np (EMULTIHOP), "Multihop attempted");
1992 + TEST_COMPARE_STRING (strerrorname_np (EMULTIHOP), "EMULTIHOP");
1993 +#endif
1994 +#ifdef ENODATA
1995 + TEST_COMPARE_STRING (strerrordesc_np (ENODATA), "No data available");
1996 + TEST_COMPARE_STRING (strerrorname_np (ENODATA), "ENODATA");
1997 +#endif
1998 +#ifdef ENOLINK
1999 + TEST_COMPARE_STRING (strerrordesc_np (ENOLINK), "Link has been severed");
2000 + TEST_COMPARE_STRING (strerrorname_np (ENOLINK), "ENOLINK");
2001 +#endif
2002 +#ifdef ENOMSG
2003 + TEST_COMPARE_STRING (strerrordesc_np (ENOMSG),
2004 + "No message of desired type");
2005 + TEST_COMPARE_STRING (strerrorname_np (ENOMSG), "ENOMSG");
2006 +#endif
2007 +#ifdef ENOSR
2008 + TEST_COMPARE_STRING (strerrordesc_np (ENOSR), "Out of streams resources");
2009 + TEST_COMPARE_STRING (strerrorname_np (ENOSR), "ENOSR");
2010 +#endif
2011 +#ifdef ENOSTR
2012 + TEST_COMPARE_STRING (strerrordesc_np (ENOSTR), "Device not a stream");
2013 + TEST_COMPARE_STRING (strerrorname_np (ENOSTR), "ENOSTR");
2014 +#endif
2015 +#ifdef EOVERFLOW
2016 + TEST_COMPARE_STRING (strerrordesc_np (EOVERFLOW),
2017 + "Value too large for defined data type");
2018 + TEST_COMPARE_STRING (strerrorname_np (EOVERFLOW), "EOVERFLOW");
2019 +#endif
2020 +#ifdef EPROTO
2021 + TEST_COMPARE_STRING (strerrordesc_np (EPROTO), "Protocol error");
2022 + TEST_COMPARE_STRING (strerrorname_np (EPROTO), "EPROTO");
2023 +#endif
2024 +#ifdef ETIME
2025 + TEST_COMPARE_STRING (strerrordesc_np (ETIME), "Timer expired");
2026 + TEST_COMPARE_STRING (strerrorname_np (ETIME), "ETIME");
2027 +#endif
2028 +#ifdef ECANCELED
2029 + TEST_COMPARE_STRING (strerrordesc_np (ECANCELED), "Operation canceled");
2030 + TEST_COMPARE_STRING (strerrorname_np (ECANCELED), "ECANCELED");
2031 +#endif
2032 +#ifdef EOWNERDEAD
2033 + TEST_COMPARE_STRING (strerrordesc_np (EOWNERDEAD), "Owner died");
2034 + TEST_COMPARE_STRING (strerrorname_np (EOWNERDEAD), "EOWNERDEAD");
2035 +#endif
2036 +#ifdef ENOTRECOVERABLE
2037 + TEST_COMPARE_STRING (strerrordesc_np (ENOTRECOVERABLE),
2038 + "State not recoverable");
2039 + TEST_COMPARE_STRING (strerrorname_np (ENOTRECOVERABLE), "ENOTRECOVERABLE");
2040 +#endif
2041 +#ifdef ERESTART
2042 + TEST_COMPARE_STRING (strerrordesc_np (ERESTART),
2043 + "Interrupted system call should be restarted");
2044 + TEST_COMPARE_STRING (strerrorname_np (ERESTART), "ERESTART");
2045 +#endif
2046 +#ifdef ECHRNG
2047 + TEST_COMPARE_STRING (strerrordesc_np (ECHRNG),
2048 + "Channel number out of range");
2049 + TEST_COMPARE_STRING (strerrorname_np (ECHRNG), "ECHRNG");
2050 +#endif
2051 +#ifdef EL2NSYNC
2052 + TEST_COMPARE_STRING (strerrordesc_np (EL2NSYNC),
2053 + "Level 2 not synchronized");
2054 + TEST_COMPARE_STRING (strerrorname_np (EL2NSYNC), "EL2NSYNC");
2055 +#endif
2056 +#ifdef EL3HLT
2057 + TEST_COMPARE_STRING (strerrordesc_np (EL3HLT), "Level 3 halted");
2058 + TEST_COMPARE_STRING (strerrorname_np (EL3HLT), "EL3HLT");
2059 +#endif
2060 +#ifdef EL3RST
2061 + TEST_COMPARE_STRING (strerrordesc_np (EL3RST), "Level 3 reset");
2062 + TEST_COMPARE_STRING (strerrorname_np (EL3RST), "EL3RST");
2063 +#endif
2064 +#ifdef ELNRNG
2065 + TEST_COMPARE_STRING (strerrordesc_np (ELNRNG), "Link number out of range");
2066 + TEST_COMPARE_STRING (strerrorname_np (ELNRNG), "ELNRNG");
2067 +#endif
2068 +#ifdef EUNATCH
2069 + TEST_COMPARE_STRING (strerrordesc_np (EUNATCH),
2070 + "Protocol driver not attached");
2071 + TEST_COMPARE_STRING (strerrorname_np (EUNATCH), "EUNATCH");
2072 +#endif
2073 +#ifdef ENOCSI
2074 + TEST_COMPARE_STRING (strerrordesc_np (ENOCSI),
2075 + "No CSI structure available");
2076 + TEST_COMPARE_STRING (strerrorname_np (ENOCSI), "ENOCSI");
2077 +#endif
2078 +#ifdef EL2HLT
2079 + TEST_COMPARE_STRING (strerrordesc_np (EL2HLT), "Level 2 halted");
2080 + TEST_COMPARE_STRING (strerrorname_np (EL2HLT), "EL2HLT");
2081 +#endif
2082 +#ifdef EBADE
2083 + TEST_COMPARE_STRING (strerrordesc_np (EBADE), "Invalid exchange");
2084 + TEST_COMPARE_STRING (strerrorname_np (EBADE), "EBADE");
2085 +#endif
2086 +#ifdef EBADR
2087 + TEST_COMPARE_STRING (strerrordesc_np (EBADR),
2088 + "Invalid request descriptor");
2089 + TEST_COMPARE_STRING (strerrorname_np (EBADR), "EBADR");
2090 +#endif
2091 +#ifdef EXFULL
2092 + TEST_COMPARE_STRING (strerrordesc_np (EXFULL), "Exchange full");
2093 + TEST_COMPARE_STRING (strerrorname_np (EXFULL), "EXFULL");
2094 +#endif
2095 +#ifdef ENOANO
2096 + TEST_COMPARE_STRING (strerrordesc_np (ENOANO), "No anode");
2097 + TEST_COMPARE_STRING (strerrorname_np (ENOANO), "ENOANO");
2098 +#endif
2099 +#ifdef EBADRQC
2100 + TEST_COMPARE_STRING (strerrordesc_np (EBADRQC), "Invalid request code");
2101 + TEST_COMPARE_STRING (strerrorname_np (EBADRQC), "EBADRQC");
2102 +#endif
2103 +#ifdef EBADSLT
2104 + TEST_COMPARE_STRING (strerrordesc_np (EBADSLT), "Invalid slot");
2105 + TEST_COMPARE_STRING (strerrorname_np (EBADSLT), "EBADSLT");
2106 +#endif
2107 +#ifdef EBFONT
2108 + TEST_COMPARE_STRING (strerrordesc_np (EBFONT), "Bad font file format");
2109 + TEST_COMPARE_STRING (strerrorname_np (EBFONT), "EBFONT");
2110 +#endif
2111 +#ifdef ENONET
2112 + TEST_COMPARE_STRING (strerrordesc_np (ENONET),
2113 + "Machine is not on the network");
2114 + TEST_COMPARE_STRING (strerrorname_np (ENONET), "ENONET");
2115 +#endif
2116 +#ifdef ENOPKG
2117 + TEST_COMPARE_STRING (strerrordesc_np (ENOPKG), "Package not installed");
2118 + TEST_COMPARE_STRING (strerrorname_np (ENOPKG), "ENOPKG");
2119 +#endif
2120 +#ifdef EADV
2121 + TEST_COMPARE_STRING (strerrordesc_np (EADV), "Advertise error");
2122 + TEST_COMPARE_STRING (strerrorname_np (EADV), "EADV");
2123 +#endif
2124 +#ifdef ESRMNT
2125 + TEST_COMPARE_STRING (strerrordesc_np (ESRMNT), "Srmount error");
2126 + TEST_COMPARE_STRING (strerrorname_np (ESRMNT), "ESRMNT");
2127 +#endif
2128 +#ifdef ECOMM
2129 + TEST_COMPARE_STRING (strerrordesc_np (ECOMM),
2130 + "Communication error on send");
2131 + TEST_COMPARE_STRING (strerrorname_np (ECOMM), "ECOMM");
2132 +#endif
2133 +#ifdef EDOTDOT
2134 + TEST_COMPARE_STRING (strerrordesc_np (EDOTDOT), "RFS specific error");
2135 + TEST_COMPARE_STRING (strerrorname_np (EDOTDOT), "EDOTDOT");
2136 +#endif
2137 +#ifdef ENOTUNIQ
2138 + TEST_COMPARE_STRING (strerrordesc_np (ENOTUNIQ),
2139 + "Name not unique on network");
2140 + TEST_COMPARE_STRING (strerrorname_np (ENOTUNIQ), "ENOTUNIQ");
2141 +#endif
2142 +#ifdef EBADFD
2143 + TEST_COMPARE_STRING (strerrordesc_np (EBADFD),
2144 + "File descriptor in bad state");
2145 + TEST_COMPARE_STRING (strerrorname_np (EBADFD), "EBADFD");
2146 +#endif
2147 +#ifdef EREMCHG
2148 + TEST_COMPARE_STRING (strerrordesc_np (EREMCHG), "Remote address changed");
2149 + TEST_COMPARE_STRING (strerrorname_np (EREMCHG), "EREMCHG");
2150 +#endif
2151 +#ifdef ELIBACC
2152 + TEST_COMPARE_STRING (strerrordesc_np (ELIBACC),
2153 + "Can not access a needed shared library");
2154 + TEST_COMPARE_STRING (strerrorname_np (ELIBACC), "ELIBACC");
2155 +#endif
2156 +#ifdef ELIBBAD
2157 + TEST_COMPARE_STRING (strerrordesc_np (ELIBBAD),
2158 + "Accessing a corrupted shared library");
2159 + TEST_COMPARE_STRING (strerrorname_np (ELIBBAD), "ELIBBAD");
2160 +#endif
2161 +#ifdef ELIBSCN
2162 + TEST_COMPARE_STRING (strerrordesc_np (ELIBSCN),
2163 + ".lib section in a.out corrupted");
2164 + TEST_COMPARE_STRING (strerrorname_np (ELIBSCN), "ELIBSCN");
2165 +#endif
2166 +#ifdef ELIBMAX
2167 + TEST_COMPARE_STRING (strerrordesc_np (ELIBMAX),
2168 + "Attempting to link in too many shared libraries");
2169 + TEST_COMPARE_STRING (strerrorname_np (ELIBMAX), "ELIBMAX");
2170 +#endif
2171 +#ifdef ELIBEXEC
2172 + TEST_COMPARE_STRING (strerrordesc_np (ELIBEXEC),
2173 + "Cannot exec a shared library directly");
2174 + TEST_COMPARE_STRING (strerrorname_np (ELIBEXEC), "ELIBEXEC");
2175 +#endif
2176 +#ifdef ESTRPIPE
2177 + TEST_COMPARE_STRING (strerrordesc_np (ESTRPIPE), "Streams pipe error");
2178 + TEST_COMPARE_STRING (strerrorname_np (ESTRPIPE), "ESTRPIPE");
2179 +#endif
2180 +#ifdef EUCLEAN
2181 + TEST_COMPARE_STRING (strerrordesc_np (EUCLEAN),
2182 + "Structure needs cleaning");
2183 + TEST_COMPARE_STRING (strerrorname_np (EUCLEAN), "EUCLEAN");
2184 +#endif
2185 +#ifdef ENOTNAM
2186 + TEST_COMPARE_STRING (strerrordesc_np (ENOTNAM),
2187 + "Not a XENIX named type file");
2188 + TEST_COMPARE_STRING (strerrorname_np (ENOTNAM), "ENOTNAM");
2189 +#endif
2190 +#ifdef ENAVAIL
2191 + TEST_COMPARE_STRING (strerrordesc_np (ENAVAIL),
2192 + "No XENIX semaphores available");
2193 + TEST_COMPARE_STRING (strerrorname_np (ENAVAIL), "ENAVAIL");
2194 +#endif
2195 +#ifdef EISNAM
2196 + TEST_COMPARE_STRING (strerrordesc_np (EISNAM), "Is a named type file");
2197 + TEST_COMPARE_STRING (strerrorname_np (EISNAM), "EISNAM");
2198 +#endif
2199 +#ifdef EREMOTEIO
2200 + TEST_COMPARE_STRING (strerrordesc_np (EREMOTEIO), "Remote I/O error");
2201 + TEST_COMPARE_STRING (strerrorname_np (EREMOTEIO), "EREMOTEIO");
2202 +#endif
2203 +#ifdef ENOMEDIUM
2204 + TEST_COMPARE_STRING (strerrordesc_np (ENOMEDIUM), "No medium found");
2205 + TEST_COMPARE_STRING (strerrorname_np (ENOMEDIUM), "ENOMEDIUM");
2206 +#endif
2207 +#ifdef EMEDIUMTYPE
2208 + TEST_COMPARE_STRING (strerrordesc_np (EMEDIUMTYPE), "Wrong medium type");
2209 + TEST_COMPARE_STRING (strerrorname_np (EMEDIUMTYPE), "EMEDIUMTYPE");
2210 +#endif
2211 +#ifdef ENOKEY
2212 + TEST_COMPARE_STRING (strerrordesc_np (ENOKEY),
2213 + "Required key not available");
2214 + TEST_COMPARE_STRING (strerrorname_np (ENOKEY), "ENOKEY");
2215 +#endif
2216 +#ifdef EKEYEXPIRED
2217 + TEST_COMPARE_STRING (strerrordesc_np (EKEYEXPIRED), "Key has expired");
2218 + TEST_COMPARE_STRING (strerrorname_np (EKEYEXPIRED), "EKEYEXPIRED");
2219 +#endif
2220 +#ifdef EKEYREVOKED
2221 + TEST_COMPARE_STRING (strerrordesc_np (EKEYREVOKED),
2222 + "Key has been revoked");
2223 + TEST_COMPARE_STRING (strerrorname_np (EKEYREVOKED), "EKEYREVOKED");
2224 +#endif
2225 +#ifdef EKEYREJECTED
2226 + TEST_COMPARE_STRING (strerrordesc_np (EKEYREJECTED),
2227 + "Key was rejected by service");
2228 + TEST_COMPARE_STRING (strerrorname_np (EKEYREJECTED), "EKEYREJECTED");
2229 +#endif
2230 +#ifdef ERFKILL
2231 + TEST_COMPARE_STRING (strerrordesc_np (ERFKILL),
2232 + "Operation not possible due to RF-kill");
2233 + TEST_COMPARE_STRING (strerrorname_np (ERFKILL), "ERFKILL");
2234 +#endif
2235 +#ifdef EHWPOISON
2236 + TEST_COMPARE_STRING (strerrordesc_np (EHWPOISON),
2237 + "Memory page has hardware error");
2238 + TEST_COMPARE_STRING (strerrorname_np (EHWPOISON), "EHWPOISON");
2239 +#endif
2240 +#ifdef EBADRPC
2241 + TEST_COMPARE_STRING (strerrordesc_np (EBADRPC), "RPC struct is bad");
2242 + TEST_COMPARE_STRING (strerrorname_np (EBADRPC), "EBADRPC");
2243 +#endif
2244 +#ifdef EFTYPE
2245 + TEST_COMPARE_STRING (strerrordesc_np (EFTYPE),
2246 + "Inappropriate file type or format");
2247 + TEST_COMPARE_STRING (strerrorname_np (EFTYPE), "EFTYPE");
2248 +#endif
2249 +#ifdef EPROCUNAVAIL
2250 + TEST_COMPARE_STRING (strerrordesc_np (EPROCUNAVAIL),
2251 + "RPC bad procedure for program");
2252 + TEST_COMPARE_STRING (strerrorname_np (EPROCUNAVAIL), "EPROCUNAVAIL");
2253 +#endif
2254 +#ifdef EAUTH
2255 + TEST_COMPARE_STRING (strerrordesc_np (EAUTH), "Authentication error");
2256 + TEST_COMPARE_STRING (strerrorname_np (EAUTH), "EAUTH");
2257 +#endif
2258 +#ifdef EDIED
2259 + TEST_COMPARE_STRING (strerrordesc_np (EDIED), "Translator died");
2260 + TEST_COMPARE_STRING (strerrorname_np (EDIED), "EDIED");
2261 +#endif
2262 +#ifdef ERPCMISMATCH
2263 + TEST_COMPARE_STRING (strerrordesc_np (ERPCMISMATCH), "RPC version wrong");
2264 + TEST_COMPARE_STRING (strerrorname_np (ERPCMISMATCH), "ERPCMISMATCH");
2265 +#endif
2266 +#ifdef EGREGIOUS
2267 + TEST_COMPARE_STRING (strerrordesc_np (EGREGIOUS),
2268 + "You really blew it this time");
2269 + TEST_COMPARE_STRING (strerrorname_np (EGREGIOUS), "EGREGIOUS");
2270 +#endif
2271 +#ifdef EPROCLIM
2272 + TEST_COMPARE_STRING (strerrordesc_np (EPROCLIM), "Too many processes");
2273 + TEST_COMPARE_STRING (strerrorname_np (EPROCLIM), "EPROCLIM");
2274 +#endif
2275 +#ifdef EGRATUITOUS
2276 + TEST_COMPARE_STRING (strerrordesc_np (EGRATUITOUS), "Gratuitous error");
2277 + TEST_COMPARE_STRING (strerrorname_np (EGRATUITOUS), "EGRATUITOUS");
2278 +#endif
2279 +#if defined (ENOTSUP) && ENOTSUP != EOPNOTSUPP
2280 + TEST_COMPARE_STRING (strerrordesc_np (ENOTSUP), "Not supported");
2281 + TEST_COMPARE_STRING (strerrorname_np (ENOTSUP), "ENOTSUP");
2282 +#endif
2283 +#ifdef EPROGMISMATCH
2284 + TEST_COMPARE_STRING (strerrordesc_np (EPROGMISMATCH),
2285 + "RPC program version wrong");
2286 + TEST_COMPARE_STRING (strerrorname_np (EPROGMISMATCH), "EPROGMISMATCH");
2287 +#endif
2288 +#ifdef EBACKGROUND
2289 + TEST_COMPARE_STRING (strerrordesc_np (EBACKGROUND),
2290 + "Inappropriate operation for background process");
2291 + TEST_COMPARE_STRING (strerrorname_np (EBACKGROUND), "EBACKGROUND");
2292 +#endif
2293 +#ifdef EIEIO
2294 + TEST_COMPARE_STRING (strerrordesc_np (EIEIO), "Computer bought the farm");
2295 + TEST_COMPARE_STRING (strerrorname_np (EIEIO), "EIEIO");
2296 +#endif
2297 +#if defined (EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
2298 + TEST_COMPARE_STRING (strerrordesc_np (EWOULDBLOCK),
2299 + "Operation would block");
2300 + TEST_COMPARE_STRING (strerrorname_np (EWOULDBLOCK), "EWOULDBLOCK");
2301 +#endif
2302 +#ifdef ENEEDAUTH
2303 + TEST_COMPARE_STRING (strerrordesc_np (ENEEDAUTH), "Need authenticator");
2304 + TEST_COMPARE_STRING (strerrorname_np (ENEEDAUTH), "ENEEDAUTH");
2305 +#endif
2306 +#ifdef ED
2307 + TEST_COMPARE_STRING (strerrordesc_np (ED), "?");
2308 + TEST_COMPARE_STRING (strerrorname_np (ED), "ED");
2309 +#endif
2310 +#ifdef EPROGUNAVAIL
2311 + TEST_COMPARE_STRING (strerrordesc_np (EPROGUNAVAIL),
2312 + "RPC program not available");
2313 + TEST_COMPARE_STRING (strerrorname_np (EPROGUNAVAIL), "EPROGUNAVAIL");
2314 +#endif
2315
2316 return 0;
2317 }
2318 diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c
2319 index 95b46dcbeb..3a323547f9 100644
2320 --- a/stdio-common/vfscanf-internal.c
2321 +++ b/stdio-common/vfscanf-internal.c
2322 @@ -277,7 +277,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
2323 #endif
2324 {
2325 va_list arg;
2326 - const CHAR_T *f = format;
2327 + const UCHAR_T *f = (const UCHAR_T *) format;
2328 UCHAR_T fc; /* Current character of the format. */
2329 WINT_T done = 0; /* Assignments done. */
2330 size_t read_in = 0; /* Chars read in. */
2331 @@ -415,10 +415,11 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
2332 #endif
2333
2334 #ifndef COMPILE_WSCANF
2335 - if (!isascii ((unsigned char) *f))
2336 + if (!isascii (*f))
2337 {
2338 /* Non-ASCII, may be a multibyte. */
2339 - int len = __mbrlen (f, strlen (f), &state);
2340 + int len = __mbrlen ((const char *) f, strlen ((const char *) f),
2341 + &state);
2342 if (len > 0)
2343 {
2344 do
2345 @@ -426,7 +427,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
2346 c = inchar ();
2347 if (__glibc_unlikely (c == EOF))
2348 input_error ();
2349 - else if (c != (unsigned char) *f++)
2350 + else if (c != *f++)
2351 {
2352 ungetc_not_eof (c, s);
2353 conv_error ();
2354 @@ -484,9 +485,9 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
2355 char_buffer_rewind (&charbuf);
2356
2357 /* Check for a positional parameter specification. */
2358 - if (ISDIGIT ((UCHAR_T) *f))
2359 + if (ISDIGIT (*f))
2360 {
2361 - argpos = read_int ((const UCHAR_T **) &f);
2362 + argpos = read_int (&f);
2363 if (*f == L_('$'))
2364 ++f;
2365 else
2366 @@ -521,8 +522,8 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
2367
2368 /* Find the maximum field width. */
2369 width = 0;
2370 - if (ISDIGIT ((UCHAR_T) *f))
2371 - width = read_int ((const UCHAR_T **) &f);
2372 + if (ISDIGIT (*f))
2373 + width = read_int (&f);
2374 got_width:
2375 if (width == 0)
2376 width = -1;
2377 @@ -2522,12 +2523,11 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
2378 }
2379
2380 while ((fc = *f++) != '\0' && fc != ']')
2381 - if (fc == '-' && *f != '\0' && *f != ']'
2382 - && (unsigned char) f[-2] <= (unsigned char) *f)
2383 + if (fc == '-' && *f != '\0' && *f != ']' && f[-2] <= *f)
2384 {
2385 /* Add all characters from the one before the '-'
2386 up to (but not including) the next format char. */
2387 - for (fc = (unsigned char) f[-2]; fc < (unsigned char) *f; ++fc)
2388 + for (fc = f[-2]; fc < *f; ++fc)
2389 ((char *)charbuf.scratch.data)[fc] = 1;
2390 }
2391 else
2392 diff --git a/string/bits/string_fortified.h b/string/bits/string_fortified.h
2393 index 309d0f39b2..c8d3051af8 100644
2394 --- a/string/bits/string_fortified.h
2395 +++ b/string/bits/string_fortified.h
2396 @@ -22,11 +22,6 @@
2397 # error "Never use <bits/string_fortified.h> directly; include <string.h> instead."
2398 #endif
2399
2400 -#if !__GNUC_PREREQ (5,0)
2401 -__warndecl (__warn_memset_zero_len,
2402 - "memset used with constant zero length parameter; this could be due to transposed parameters");
2403 -#endif
2404 -
2405 __fortify_function void *
2406 __NTH (memcpy (void *__restrict __dest, const void *__restrict __src,
2407 size_t __len))
2408 @@ -58,16 +53,6 @@ __NTH (mempcpy (void *__restrict __dest, const void *__restrict __src,
2409 __fortify_function void *
2410 __NTH (memset (void *__dest, int __ch, size_t __len))
2411 {
2412 - /* GCC-5.0 and newer implements these checks in the compiler, so we don't
2413 - need them here. */
2414 -#if !__GNUC_PREREQ (5,0)
2415 - if (__builtin_constant_p (__len) && __len == 0
2416 - && (!__builtin_constant_p (__ch) || __ch != 0))
2417 - {
2418 - __warn_memset_zero_len ();
2419 - return __dest;
2420 - }
2421 -#endif
2422 return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
2423 }
2424
2425 diff --git a/support/Makefile b/support/Makefile
2426 index 93faafddf9..4154863511 100644
2427 --- a/support/Makefile
2428 +++ b/support/Makefile
2429 @@ -35,6 +35,8 @@ libsupport-routines = \
2430 ignore_stderr \
2431 next_to_fault \
2432 oom_error \
2433 + resolv_response_context_duplicate \
2434 + resolv_response_context_free \
2435 resolv_test \
2436 set_fortify_handler \
2437 support-xfstat \
2438 diff --git a/support/resolv_response_context_duplicate.c b/support/resolv_response_context_duplicate.c
2439 new file mode 100644
2440 index 0000000000..f9c5c3462a
2441 --- /dev/null
2442 +++ b/support/resolv_response_context_duplicate.c
2443 @@ -0,0 +1,37 @@
2444 +/* Duplicate a response context used in DNS resolver tests.
2445 + Copyright (C) 2020 Free Software Foundation, Inc.
2446 + This file is part of the GNU C Library.
2447 +
2448 + The GNU C Library is free software; you can redistribute it and/or
2449 + modify it under the terms of the GNU Lesser General Public
2450 + License as published by the Free Software Foundation; either
2451 + version 2.1 of the License, or (at your option) any later version.
2452 +
2453 + The GNU C Library is distributed in the hope that it will be useful,
2454 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2455 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2456 + Lesser General Public License for more details.
2457 +
2458 + You should have received a copy of the GNU Lesser General Public
2459 + License along with the GNU C Library; if not, see
2460 + <https://www.gnu.org/licenses/>. */
2461 +
2462 +#include <string.h>
2463 +#include <support/resolv_test.h>
2464 +#include <support/support.h>
2465 +
2466 +struct resolv_response_context *
2467 +resolv_response_context_duplicate (const struct resolv_response_context *ctx)
2468 +{
2469 + struct resolv_response_context *result = xmalloc (sizeof (*result));
2470 + memcpy (result, ctx, sizeof (*result));
2471 + if (result->client_address != NULL)
2472 + {
2473 + result->client_address = xmalloc (result->client_address_length);
2474 + memcpy (result->client_address, ctx->client_address,
2475 + result->client_address_length);
2476 + }
2477 + result->query_buffer = xmalloc (result->query_length);
2478 + memcpy (result->query_buffer, ctx->query_buffer, result->query_length);
2479 + return result;
2480 +}
2481 diff --git a/support/resolv_response_context_free.c b/support/resolv_response_context_free.c
2482 new file mode 100644
2483 index 0000000000..b88c05ffd4
2484 --- /dev/null
2485 +++ b/support/resolv_response_context_free.c
2486 @@ -0,0 +1,28 @@
2487 +/* Free a response context used in DNS resolver tests.
2488 + Copyright (C) 2020 Free Software Foundation, Inc.
2489 + This file is part of the GNU C Library.
2490 +
2491 + The GNU C Library is free software; you can redistribute it and/or
2492 + modify it under the terms of the GNU Lesser General Public
2493 + License as published by the Free Software Foundation; either
2494 + version 2.1 of the License, or (at your option) any later version.
2495 +
2496 + The GNU C Library is distributed in the hope that it will be useful,
2497 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2498 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2499 + Lesser General Public License for more details.
2500 +
2501 + You should have received a copy of the GNU Lesser General Public
2502 + License along with the GNU C Library; if not, see
2503 + <https://www.gnu.org/licenses/>. */
2504 +
2505 +#include <stdlib.h>
2506 +#include <support/resolv_test.h>
2507 +
2508 +void
2509 +resolv_response_context_free (struct resolv_response_context *ctx)
2510 +{
2511 + free (ctx->query_buffer);
2512 + free (ctx->client_address);
2513 + free (ctx);
2514 +}
2515 diff --git a/support/resolv_test.c b/support/resolv_test.c
2516 index 53b7fc41ab..9878a040a3 100644
2517 --- a/support/resolv_test.c
2518 +++ b/support/resolv_test.c
2519 @@ -181,7 +181,9 @@ resolv_response_init (struct resolv_response_builder *b,
2520 b->buffer[2] |= b->query_buffer[2] & 0x01; /* Copy the RD bit. */
2521 if (flags.tc)
2522 b->buffer[2] |= 0x02;
2523 - b->buffer[3] = 0x80 | flags.rcode; /* Always set RA. */
2524 + b->buffer[3] = flags.rcode;
2525 + if (!flags.clear_ra)
2526 + b->buffer[3] |= 0x80;
2527 if (flags.ad)
2528 b->buffer[3] |= 0x20;
2529
2530 @@ -434,9 +436,9 @@ resolv_response_buffer (const struct resolv_response_builder *b)
2531 return result;
2532 }
2533
2534 -static struct resolv_response_builder *
2535 -response_builder_allocate
2536 - (const unsigned char *query_buffer, size_t query_length)
2537 +struct resolv_response_builder *
2538 +resolv_response_builder_allocate (const unsigned char *query_buffer,
2539 + size_t query_length)
2540 {
2541 struct resolv_response_builder *b = xmalloc (sizeof (*b));
2542 memset (b, 0, offsetof (struct resolv_response_builder, buffer));
2543 @@ -445,8 +447,8 @@ response_builder_allocate
2544 return b;
2545 }
2546
2547 -static void
2548 -response_builder_free (struct resolv_response_builder *b)
2549 +void
2550 +resolv_response_builder_free (struct resolv_response_builder *b)
2551 {
2552 tdestroy (b->compression_offsets, free);
2553 free (b);
2554 @@ -661,13 +663,17 @@ server_thread_udp_process_one (struct resolv_test *obj, int server_index)
2555
2556 struct resolv_response_context ctx =
2557 {
2558 + .test = obj,
2559 + .client_address = &peer,
2560 + .client_address_length = peerlen,
2561 .query_buffer = query,
2562 .query_length = length,
2563 .server_index = server_index,
2564 .tcp = false,
2565 .edns = qinfo.edns,
2566 };
2567 - struct resolv_response_builder *b = response_builder_allocate (query, length);
2568 + struct resolv_response_builder *b
2569 + = resolv_response_builder_allocate (query, length);
2570 obj->config.response_callback
2571 (&ctx, b, qinfo.qname, qinfo.qclass, qinfo.qtype);
2572
2573 @@ -684,7 +690,7 @@ server_thread_udp_process_one (struct resolv_test *obj, int server_index)
2574 if (b->offset >= 12)
2575 printf ("info: UDP server %d: sending response:"
2576 " %zu bytes, RCODE %d (for %s/%u/%u)\n",
2577 - server_index, b->offset, b->buffer[3] & 0x0f,
2578 + ctx.server_index, b->offset, b->buffer[3] & 0x0f,
2579 qinfo.qname, qinfo.qclass, qinfo.qtype);
2580 else
2581 printf ("info: UDP server %d: sending response: %zu bytes"
2582 @@ -694,23 +700,31 @@ server_thread_udp_process_one (struct resolv_test *obj, int server_index)
2583 if (b->truncate_bytes > 0)
2584 printf ("info: truncated by %u bytes\n", b->truncate_bytes);
2585 }
2586 - size_t to_send = b->offset;
2587 - if (to_send < b->truncate_bytes)
2588 - to_send = 0;
2589 - else
2590 - to_send -= b->truncate_bytes;
2591 -
2592 - /* Ignore most errors here because the other end may have closed
2593 - the socket. */
2594 - if (sendto (obj->servers[server_index].socket_udp,
2595 - b->buffer, to_send, 0,
2596 - (struct sockaddr *) &peer, peerlen) < 0)
2597 - TEST_VERIFY_EXIT (errno != EBADF);
2598 + resolv_response_send_udp (&ctx, b);
2599 }
2600 - response_builder_free (b);
2601 + resolv_response_builder_free (b);
2602 return true;
2603 }
2604
2605 +void
2606 +resolv_response_send_udp (const struct resolv_response_context *ctx,
2607 + struct resolv_response_builder *b)
2608 +{
2609 + TEST_VERIFY_EXIT (!ctx->tcp);
2610 + size_t to_send = b->offset;
2611 + if (to_send < b->truncate_bytes)
2612 + to_send = 0;
2613 + else
2614 + to_send -= b->truncate_bytes;
2615 +
2616 + /* Ignore most errors here because the other end may have closed
2617 + the socket. */
2618 + if (sendto (ctx->test->servers[ctx->server_index].socket_udp,
2619 + b->buffer, to_send, 0,
2620 + ctx->client_address, ctx->client_address_length) < 0)
2621 + TEST_VERIFY_EXIT (errno != EBADF);
2622 +}
2623 +
2624 /* UDP thread_callback function. Variant for one thread per
2625 server. */
2626 static void
2627 @@ -897,14 +911,15 @@ server_thread_tcp_client (void *arg)
2628
2629 struct resolv_response_context ctx =
2630 {
2631 + .test = closure->obj,
2632 .query_buffer = query_buffer,
2633 .query_length = query_length,
2634 .server_index = closure->server_index,
2635 .tcp = true,
2636 .edns = qinfo.edns,
2637 };
2638 - struct resolv_response_builder *b = response_builder_allocate
2639 - (query_buffer, query_length);
2640 + struct resolv_response_builder *b
2641 + = resolv_response_builder_allocate (query_buffer, query_length);
2642 closure->obj->config.response_callback
2643 (&ctx, b, qinfo.qname, qinfo.qclass, qinfo.qtype);
2644
2645 @@ -936,7 +951,7 @@ server_thread_tcp_client (void *arg)
2646 writev_fully (closure->client_socket, buffers, 2);
2647 }
2648 bool close_flag = b->close;
2649 - response_builder_free (b);
2650 + resolv_response_builder_free (b);
2651 free (query_buffer);
2652 if (close_flag)
2653 break;
2654 diff --git a/support/resolv_test.h b/support/resolv_test.h
2655 index 67819469a0..31a5c1c3e7 100644
2656 --- a/support/resolv_test.h
2657 +++ b/support/resolv_test.h
2658 @@ -35,25 +35,36 @@ struct resolv_edns_info
2659 uint16_t payload_size;
2660 };
2661
2662 +/* This opaque struct collects information about the resolver testing
2663 + currently in progress. */
2664 +struct resolv_test;
2665 +
2666 /* This struct provides context information when the response callback
2667 specified in struct resolv_redirect_config is invoked. */
2668 struct resolv_response_context
2669 {
2670 - const unsigned char *query_buffer;
2671 + struct resolv_test *test;
2672 + void *client_address;
2673 + size_t client_address_length;
2674 + unsigned char *query_buffer;
2675 size_t query_length;
2676 int server_index;
2677 bool tcp;
2678 struct resolv_edns_info edns;
2679 };
2680
2681 +/* Produces a deep copy of the context. */
2682 +struct resolv_response_context *
2683 + resolv_response_context_duplicate (const struct resolv_response_context *);
2684 +
2685 +/* Frees the copy. For the context passed to the response function,
2686 + this happens implicitly. */
2687 +void resolv_response_context_free (struct resolv_response_context *);
2688 +
2689 /* This opaque struct is used to construct responses from within the
2690 response callback function. */
2691 struct resolv_response_builder;
2692
2693 -/* This opaque struct collects information about the resolver testing
2694 - currently in progress. */
2695 -struct resolv_test;
2696 -
2697 enum
2698 {
2699 /* Maximum number of test servers supported by the framework. */
2700 @@ -137,6 +148,10 @@ struct resolv_response_flags
2701 /* If true, the AD (authenticated data) flag will be set. */
2702 bool ad;
2703
2704 + /* If true, do not set the RA (recursion available) flag in the
2705 + response. */
2706 + bool clear_ra;
2707 +
2708 /* Initial section count values. Can be used to artificially
2709 increase the counts, for malformed packet testing.*/
2710 unsigned short qdcount;
2711 @@ -188,6 +203,22 @@ void resolv_response_close (struct resolv_response_builder *);
2712 /* The size of the response packet built so far. */
2713 size_t resolv_response_length (const struct resolv_response_builder *);
2714
2715 +/* Allocates a response builder tied to a specific query packet,
2716 + starting at QUERY_BUFFER, containing QUERY_LENGTH bytes. */
2717 +struct resolv_response_builder *
2718 + resolv_response_builder_allocate (const unsigned char *query_buffer,
2719 + size_t query_length);
2720 +
2721 +/* Deallocates a response buffer. */
2722 +void resolv_response_builder_free (struct resolv_response_builder *);
2723 +
2724 +/* Sends a UDP response using a specific context. This can be used to
2725 + reorder or duplicate responses, along with
2726 + resolv_response_context_duplicate and
2727 + response_builder_allocate. */
2728 +void resolv_response_send_udp (const struct resolv_response_context *,
2729 + struct resolv_response_builder *);
2730 +
2731 __END_DECLS
2732
2733 #endif /* SUPPORT_RESOLV_TEST_H */
2734 diff --git a/sysdeps/aarch64/dl-bti.c b/sysdeps/aarch64/dl-bti.c
2735 index 196e462520..cf7624aaa2 100644
2736 --- a/sysdeps/aarch64/dl-bti.c
2737 +++ b/sysdeps/aarch64/dl-bti.c
2738 @@ -19,43 +19,76 @@
2739 #include <errno.h>
2740 #include <libintl.h>
2741 #include <ldsodefs.h>
2742 +#include <sys/mman.h>
2743
2744 -static int
2745 -enable_bti (struct link_map *map, const char *program)
2746 +/* See elf/dl-load.h. */
2747 +#ifndef MAP_COPY
2748 +# define MAP_COPY (MAP_PRIVATE | MAP_DENYWRITE)
2749 +#endif
2750 +
2751 +/* Enable BTI protection for MAP. */
2752 +
2753 +void
2754 +_dl_bti_protect (struct link_map *map, int fd)
2755 {
2756 + const size_t pagesz = GLRO(dl_pagesize);
2757 const ElfW(Phdr) *phdr;
2758 - unsigned prot;
2759
2760 for (phdr = map->l_phdr; phdr < &map->l_phdr[map->l_phnum]; ++phdr)
2761 if (phdr->p_type == PT_LOAD && (phdr->p_flags & PF_X))
2762 {
2763 - void *start = (void *) (phdr->p_vaddr + map->l_addr);
2764 - size_t len = phdr->p_memsz;
2765 + size_t vstart = ALIGN_DOWN (phdr->p_vaddr, pagesz);
2766 + size_t vend = ALIGN_UP (phdr->p_vaddr + phdr->p_filesz, pagesz);
2767 + off_t off = ALIGN_DOWN (phdr->p_offset, pagesz);
2768 + void *start = (void *) (vstart + map->l_addr);
2769 + size_t len = vend - vstart;
2770
2771 - prot = PROT_EXEC | PROT_BTI;
2772 + unsigned prot = PROT_EXEC | PROT_BTI;
2773 if (phdr->p_flags & PF_R)
2774 prot |= PROT_READ;
2775 if (phdr->p_flags & PF_W)
2776 prot |= PROT_WRITE;
2777
2778 - if (__mprotect (start, len, prot) < 0)
2779 - {
2780 - if (program)
2781 - _dl_fatal_printf ("%s: mprotect failed to turn on BTI\n",
2782 - map->l_name);
2783 - else
2784 - _dl_signal_error (errno, map->l_name, "dlopen",
2785 - N_("mprotect failed to turn on BTI"));
2786 - }
2787 + if (fd == -1)
2788 + /* Ignore failures for kernel mapped binaries. */
2789 + __mprotect (start, len, prot);
2790 + else
2791 + map->l_mach.bti_fail = __mmap (start, len, prot,
2792 + MAP_FIXED|MAP_COPY|MAP_FILE,
2793 + fd, off) == MAP_FAILED;
2794 }
2795 - return 0;
2796 }
2797
2798 -/* Enable BTI for L if required. */
2799 +
2800 +static void
2801 +bti_failed (struct link_map *l, const char *program)
2802 +{
2803 + if (program)
2804 + _dl_fatal_printf ("%s: %s: failed to turn on BTI protection\n",
2805 + program, l->l_name);
2806 + else
2807 + /* Note: the errno value is not available any more. */
2808 + _dl_signal_error (0, l->l_name, "dlopen",
2809 + N_("failed to turn on BTI protection"));
2810 +}
2811 +
2812 +
2813 +/* Enable BTI for L and its dependencies. */
2814
2815 void
2816 _dl_bti_check (struct link_map *l, const char *program)
2817 {
2818 - if (GLRO(dl_aarch64_cpu_features).bti && l->l_mach.bti)
2819 - enable_bti (l, program);
2820 + if (!GLRO(dl_aarch64_cpu_features).bti)
2821 + return;
2822 +
2823 + if (l->l_mach.bti_fail)
2824 + bti_failed (l, program);
2825 +
2826 + unsigned int i = l->l_searchlist.r_nlist;
2827 + while (i-- > 0)
2828 + {
2829 + struct link_map *dep = l->l_initfini[i];
2830 + if (dep->l_mach.bti_fail)
2831 + bti_failed (dep, program);
2832 + }
2833 }
2834 diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
2835 index 70b9ed3925..fde7cfd9e2 100644
2836 --- a/sysdeps/aarch64/dl-machine.h
2837 +++ b/sysdeps/aarch64/dl-machine.h
2838 @@ -395,13 +395,6 @@ elf_machine_lazy_rel (struct link_map *map,
2839 /* Check for unexpected PLT reloc type. */
2840 if (__builtin_expect (r_type == AARCH64_R(JUMP_SLOT), 1))
2841 {
2842 - if (map->l_mach.plt == 0)
2843 - {
2844 - /* Prelinking. */
2845 - *reloc_addr += l_addr;
2846 - return;
2847 - }
2848 -
2849 if (__glibc_unlikely (map->l_info[DT_AARCH64 (VARIANT_PCS)] != NULL))
2850 {
2851 /* Check the symbol table for variant PCS symbols. */
2852 @@ -425,7 +418,10 @@ elf_machine_lazy_rel (struct link_map *map,
2853 }
2854 }
2855
2856 - *reloc_addr = map->l_mach.plt;
2857 + if (map->l_mach.plt == 0)
2858 + *reloc_addr += l_addr;
2859 + else
2860 + *reloc_addr = map->l_mach.plt;
2861 }
2862 else if (__builtin_expect (r_type == AARCH64_R(TLSDESC), 1))
2863 {
2864 diff --git a/sysdeps/aarch64/dl-prop.h b/sysdeps/aarch64/dl-prop.h
2865 index b0785bda83..e926e54984 100644
2866 --- a/sysdeps/aarch64/dl-prop.h
2867 +++ b/sysdeps/aarch64/dl-prop.h
2868 @@ -19,6 +19,8 @@
2869 #ifndef _DL_PROP_H
2870 #define _DL_PROP_H
2871
2872 +extern void _dl_bti_protect (struct link_map *, int) attribute_hidden;
2873 +
2874 extern void _dl_bti_check (struct link_map *, const char *)
2875 attribute_hidden;
2876
2877 @@ -35,14 +37,18 @@ _dl_open_check (struct link_map *m)
2878 }
2879
2880 static inline void __attribute__ ((always_inline))
2881 -_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph)
2882 +_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph)
2883 {
2884 }
2885
2886 static inline int
2887 -_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz,
2888 - void *data)
2889 +_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
2890 + uint32_t datasz, void *data)
2891 {
2892 + if (!GLRO(dl_aarch64_cpu_features).bti)
2893 + /* Skip note processing. */
2894 + return 0;
2895 +
2896 if (type == GNU_PROPERTY_AARCH64_FEATURE_1_AND)
2897 {
2898 /* Stop if the property note is ill-formed. */
2899 @@ -51,7 +57,7 @@ _dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz,
2900
2901 unsigned int feature_1 = *(unsigned int *) data;
2902 if (feature_1 & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)
2903 - l->l_mach.bti = true;
2904 + _dl_bti_protect (l, fd);
2905
2906 /* Stop if we processed the property note. */
2907 return 0;
2908 diff --git a/sysdeps/aarch64/linkmap.h b/sysdeps/aarch64/linkmap.h
2909 index 847a03ace2..b3f7663b07 100644
2910 --- a/sysdeps/aarch64/linkmap.h
2911 +++ b/sysdeps/aarch64/linkmap.h
2912 @@ -22,5 +22,5 @@ struct link_map_machine
2913 {
2914 ElfW(Addr) plt; /* Address of .plt */
2915 void *tlsdesc_table; /* Address of TLS descriptor hash table. */
2916 - bool bti; /* Branch Target Identification is enabled. */
2917 + bool bti_fail; /* Failed to enable Branch Target Identification. */
2918 };
2919 diff --git a/sysdeps/aarch64/multiarch/memcpy.c b/sysdeps/aarch64/multiarch/memcpy.c
2920 index 7cf5f033e8..799d60c98c 100644
2921 --- a/sysdeps/aarch64/multiarch/memcpy.c
2922 +++ b/sysdeps/aarch64/multiarch/memcpy.c
2923 @@ -41,7 +41,8 @@ libc_ifunc (__libc_memcpy,
2924 ? __memcpy_falkor
2925 : (IS_THUNDERX2 (midr) || IS_THUNDERX2PA (midr)
2926 ? __memcpy_thunderx2
2927 - : (IS_NEOVERSE_N1 (midr)
2928 + : (IS_NEOVERSE_N1 (midr) || IS_NEOVERSE_N2 (midr)
2929 + || IS_NEOVERSE_V1 (midr)
2930 ? __memcpy_simd
2931 : __memcpy_generic)))));
2932
2933 diff --git a/sysdeps/aarch64/multiarch/memcpy_advsimd.S b/sysdeps/aarch64/multiarch/memcpy_advsimd.S
2934 index d4ba747777..48bb6d7ca4 100644
2935 --- a/sysdeps/aarch64/multiarch/memcpy_advsimd.S
2936 +++ b/sysdeps/aarch64/multiarch/memcpy_advsimd.S
2937 @@ -223,12 +223,13 @@ L(copy_long_backwards):
2938 b.ls L(copy64_from_start)
2939
2940 L(loop64_backwards):
2941 - stp A_q, B_q, [dstend, -32]
2942 + str B_q, [dstend, -16]
2943 + str A_q, [dstend, -32]
2944 ldp A_q, B_q, [srcend, -96]
2945 - stp C_q, D_q, [dstend, -64]
2946 + str D_q, [dstend, -48]
2947 + str C_q, [dstend, -64]!
2948 ldp C_q, D_q, [srcend, -128]
2949 sub srcend, srcend, 64
2950 - sub dstend, dstend, 64
2951 subs count, count, 64
2952 b.hi L(loop64_backwards)
2953
2954 diff --git a/sysdeps/aarch64/multiarch/memmove.c b/sysdeps/aarch64/multiarch/memmove.c
2955 index ad10aa8ac6..46a4cb3a54 100644
2956 --- a/sysdeps/aarch64/multiarch/memmove.c
2957 +++ b/sysdeps/aarch64/multiarch/memmove.c
2958 @@ -41,7 +41,8 @@ libc_ifunc (__libc_memmove,
2959 ? __memmove_falkor
2960 : (IS_THUNDERX2 (midr) || IS_THUNDERX2PA (midr)
2961 ? __memmove_thunderx2
2962 - : (IS_NEOVERSE_N1 (midr)
2963 + : (IS_NEOVERSE_N1 (midr) || IS_NEOVERSE_N2 (midr)
2964 + || IS_NEOVERSE_V1 (midr)
2965 ? __memmove_simd
2966 : __memmove_generic)))));
2967
2968 diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S
2969 index 75393e1c18..1998ea95d4 100644
2970 --- a/sysdeps/aarch64/start.S
2971 +++ b/sysdeps/aarch64/start.S
2972 @@ -43,11 +43,9 @@
2973 */
2974
2975 .text
2976 - .globl _start
2977 - .type _start,#function
2978 -_start:
2979 - BTI_C
2980 +ENTRY(_start)
2981 /* Create an initial frame with 0 LR and FP */
2982 + cfi_undefined (x30)
2983 mov x29, #0
2984 mov x30, #0
2985
2986 @@ -101,8 +99,10 @@ _start:
2987 because crt1.o and rcrt1.o share code and the later must avoid the
2988 use of GOT relocations before __libc_start_main is called. */
2989 __wrap_main:
2990 + BTI_C
2991 b main
2992 #endif
2993 +END(_start)
2994
2995 /* Define a symbol for the first piece of initialized data. */
2996 .data
2997 diff --git a/sysdeps/generic/dl-prop.h b/sysdeps/generic/dl-prop.h
2998 index f1cf576fe3..df27ff8e6a 100644
2999 --- a/sysdeps/generic/dl-prop.h
3000 +++ b/sysdeps/generic/dl-prop.h
3001 @@ -37,15 +37,15 @@ _dl_open_check (struct link_map *m)
3002 }
3003
3004 static inline void __attribute__ ((always_inline))
3005 -_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph)
3006 +_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph)
3007 {
3008 }
3009
3010 /* Called for each property in the NT_GNU_PROPERTY_TYPE_0 note of L,
3011 processing of the properties continues until this returns 0. */
3012 static inline int __attribute__ ((always_inline))
3013 -_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz,
3014 - void *data)
3015 +_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
3016 + uint32_t datasz, void *data)
3017 {
3018 return 0;
3019 }
3020 diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
3021 index ba114ab4b1..62ac40d81b 100644
3022 --- a/sysdeps/generic/ldsodefs.h
3023 +++ b/sysdeps/generic/ldsodefs.h
3024 @@ -919,8 +919,9 @@ extern void _dl_rtld_di_serinfo (struct link_map *loader,
3025 Dl_serinfo *si, bool counting);
3026
3027 /* Process PT_GNU_PROPERTY program header PH in module L after
3028 - PT_LOAD segments are mapped. */
3029 -void _dl_process_pt_gnu_property (struct link_map *l, const ElfW(Phdr) *ph);
3030 + PT_LOAD segments are mapped from file FD. */
3031 +void _dl_process_pt_gnu_property (struct link_map *l, int fd,
3032 + const ElfW(Phdr) *ph);
3033
3034
3035 /* Search loaded objects' symbol tables for a definition of the symbol
3036 diff --git a/sysdeps/generic/unwind.h b/sysdeps/generic/unwind.h
3037 index b667a5b652..c229603af3 100644
3038 --- a/sysdeps/generic/unwind.h
3039 +++ b/sysdeps/generic/unwind.h
3040 @@ -75,15 +75,21 @@ typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
3041
3042 struct _Unwind_Exception
3043 {
3044 - _Unwind_Exception_Class exception_class;
3045 - _Unwind_Exception_Cleanup_Fn exception_cleanup;
3046 - _Unwind_Word private_1;
3047 - _Unwind_Word private_2;
3048 -
3049 - /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
3050 - Taking that literally does not make much sense generically. Instead we
3051 - provide the maximum alignment required by any type for the machine. */
3052 -} __attribute__((__aligned__));
3053 + union
3054 + {
3055 + struct
3056 + {
3057 + _Unwind_Exception_Class exception_class;
3058 + _Unwind_Exception_Cleanup_Fn exception_cleanup;
3059 + _Unwind_Word private_1;
3060 + _Unwind_Word private_2;
3061 + };
3062 +
3063 + /* The IA-64 ABI says that this structure must be double-word aligned. */
3064 + _Unwind_Word unwind_exception_align[2]
3065 + __attribute__ ((__aligned__ (2 * sizeof (_Unwind_Word))));
3066 + };
3067 +};
3068
3069
3070 /* The ACTIONS argument to the personality routine is a bitwise OR of one
3071 diff --git a/sysdeps/gnu/errlist.h b/sysdeps/gnu/errlist.h
3072 index 5d11ed723d..6329e5f393 100644
3073 --- a/sysdeps/gnu/errlist.h
3074 +++ b/sysdeps/gnu/errlist.h
3075 @@ -1,24 +1,21 @@
3076 -#ifndef ERR_MAP
3077 -#define ERR_MAP(value) value
3078 -#endif
3079 -_S(ERR_MAP(0), N_("Success"))
3080 +_S(0, N_("Success"))
3081 #ifdef EPERM
3082 /*
3083 TRANS Only the owner of the file (or other resource)
3084 TRANS or processes with special privileges can perform the operation. */
3085 -_S(ERR_MAP(EPERM), N_("Operation not permitted"))
3086 +_S(EPERM, N_("Operation not permitted"))
3087 #endif
3088 #ifdef ENOENT
3089 /*
3090 TRANS This is a ``file doesn't exist'' error
3091 TRANS for ordinary files that are referenced in contexts where they are
3092 TRANS expected to already exist. */
3093 -_S(ERR_MAP(ENOENT), N_("No such file or directory"))
3094 +_S(ENOENT, N_("No such file or directory"))
3095 #endif
3096 #ifdef ESRCH
3097 /*
3098 TRANS No process matches the specified process ID. */
3099 -_S(ERR_MAP(ESRCH), N_("No such process"))
3100 +_S(ESRCH, N_("No such process"))
3101 #endif
3102 #ifdef EINTR
3103 /*
3104 @@ -29,12 +26,12 @@ TRANS
3105 TRANS You can choose to have functions resume after a signal that is handled,
3106 TRANS rather than failing with @code{EINTR}; see @ref{Interrupted
3107 TRANS Primitives}. */
3108 -_S(ERR_MAP(EINTR), N_("Interrupted system call"))
3109 +_S(EINTR, N_("Interrupted system call"))
3110 #endif
3111 #ifdef EIO
3112 /*
3113 TRANS Usually used for physical read or write errors. */
3114 -_S(ERR_MAP(EIO), N_("Input/output error"))
3115 +_S(EIO, N_("Input/output error"))
3116 #endif
3117 #ifdef ENXIO
3118 /*
3119 @@ -43,7 +40,7 @@ TRANS represented by a file you specified, and it couldn't find the device.
3120 TRANS This can mean that the device file was installed incorrectly, or that
3121 TRANS the physical device is missing or not correctly attached to the
3122 TRANS computer. */
3123 -_S(ERR_MAP(ENXIO), N_("No such device or address"))
3124 +_S(ENXIO, N_("No such device or address"))
3125 #endif
3126 #ifdef E2BIG
3127 /*
3128 @@ -51,27 +48,27 @@ TRANS Used when the arguments passed to a new program
3129 TRANS being executed with one of the @code{exec} functions (@pxref{Executing a
3130 TRANS File}) occupy too much memory space. This condition never arises on
3131 TRANS @gnuhurdsystems{}. */
3132 -_S(ERR_MAP(E2BIG), N_("Argument list too long"))
3133 +_S(E2BIG, N_("Argument list too long"))
3134 #endif
3135 #ifdef ENOEXEC
3136 /*
3137 TRANS Invalid executable file format. This condition is detected by the
3138 TRANS @code{exec} functions; see @ref{Executing a File}. */
3139 -_S(ERR_MAP(ENOEXEC), N_("Exec format error"))
3140 +_S(ENOEXEC, N_("Exec format error"))
3141 #endif
3142 #ifdef EBADF
3143 /*
3144 TRANS For example, I/O on a descriptor that has been
3145 TRANS closed or reading from a descriptor open only for writing (or vice
3146 TRANS versa). */
3147 -_S(ERR_MAP(EBADF), N_("Bad file descriptor"))
3148 +_S(EBADF, N_("Bad file descriptor"))
3149 #endif
3150 #ifdef ECHILD
3151 /*
3152 TRANS This error happens on operations that are
3153 TRANS supposed to manipulate child processes, when there aren't any processes
3154 TRANS to manipulate. */
3155 -_S(ERR_MAP(ECHILD), N_("No child processes"))
3156 +_S(ECHILD, N_("No child processes"))
3157 #endif
3158 #ifdef EDEADLK
3159 /*
3160 @@ -79,74 +76,74 @@ TRANS Allocating a system resource would have resulted in a
3161 TRANS deadlock situation. The system does not guarantee that it will notice
3162 TRANS all such situations. This error means you got lucky and the system
3163 TRANS noticed; it might just hang. @xref{File Locks}, for an example. */
3164 -_S(ERR_MAP(EDEADLK), N_("Resource deadlock avoided"))
3165 +_S(EDEADLK, N_("Resource deadlock avoided"))
3166 #endif
3167 #ifdef ENOMEM
3168 /*
3169 TRANS The system cannot allocate more virtual memory
3170 TRANS because its capacity is full. */
3171 -_S(ERR_MAP(ENOMEM), N_("Cannot allocate memory"))
3172 +_S(ENOMEM, N_("Cannot allocate memory"))
3173 #endif
3174 #ifdef EACCES
3175 /*
3176 TRANS The file permissions do not allow the attempted operation. */
3177 -_S(ERR_MAP(EACCES), N_("Permission denied"))
3178 +_S(EACCES, N_("Permission denied"))
3179 #endif
3180 #ifdef EFAULT
3181 /*
3182 TRANS An invalid pointer was detected.
3183 TRANS On @gnuhurdsystems{}, this error never happens; you get a signal instead. */
3184 -_S(ERR_MAP(EFAULT), N_("Bad address"))
3185 +_S(EFAULT, N_("Bad address"))
3186 #endif
3187 #ifdef ENOTBLK
3188 /*
3189 TRANS A file that isn't a block special file was given in a situation that
3190 TRANS requires one. For example, trying to mount an ordinary file as a file
3191 TRANS system in Unix gives this error. */
3192 -_S(ERR_MAP(ENOTBLK), N_("Block device required"))
3193 +_S(ENOTBLK, N_("Block device required"))
3194 #endif
3195 #ifdef EBUSY
3196 /*
3197 TRANS A system resource that can't be shared is already in use.
3198 TRANS For example, if you try to delete a file that is the root of a currently
3199 TRANS mounted filesystem, you get this error. */
3200 -_S(ERR_MAP(EBUSY), N_("Device or resource busy"))
3201 +_S(EBUSY, N_("Device or resource busy"))
3202 #endif
3203 #ifdef EEXIST
3204 /*
3205 TRANS An existing file was specified in a context where it only
3206 TRANS makes sense to specify a new file. */
3207 -_S(ERR_MAP(EEXIST), N_("File exists"))
3208 +_S(EEXIST, N_("File exists"))
3209 #endif
3210 #ifdef EXDEV
3211 /*
3212 TRANS An attempt to make an improper link across file systems was detected.
3213 TRANS This happens not only when you use @code{link} (@pxref{Hard Links}) but
3214 TRANS also when you rename a file with @code{rename} (@pxref{Renaming Files}). */
3215 -_S(ERR_MAP(EXDEV), N_("Invalid cross-device link"))
3216 +_S(EXDEV, N_("Invalid cross-device link"))
3217 #endif
3218 #ifdef ENODEV
3219 /*
3220 TRANS The wrong type of device was given to a function that expects a
3221 TRANS particular sort of device. */
3222 -_S(ERR_MAP(ENODEV), N_("No such device"))
3223 +_S(ENODEV, N_("No such device"))
3224 #endif
3225 #ifdef ENOTDIR
3226 /*
3227 TRANS A file that isn't a directory was specified when a directory is required. */
3228 -_S(ERR_MAP(ENOTDIR), N_("Not a directory"))
3229 +_S(ENOTDIR, N_("Not a directory"))
3230 #endif
3231 #ifdef EISDIR
3232 /*
3233 TRANS You cannot open a directory for writing,
3234 TRANS or create or remove hard links to it. */
3235 -_S(ERR_MAP(EISDIR), N_("Is a directory"))
3236 +_S(EISDIR, N_("Is a directory"))
3237 #endif
3238 #ifdef EINVAL
3239 /*
3240 TRANS This is used to indicate various kinds of problems
3241 TRANS with passing the wrong argument to a library function. */
3242 -_S(ERR_MAP(EINVAL), N_("Invalid argument"))
3243 +_S(EINVAL, N_("Invalid argument"))
3244 #endif
3245 #ifdef EMFILE
3246 /*
3247 @@ -157,20 +154,20 @@ TRANS In BSD and GNU, the number of open files is controlled by a resource
3248 TRANS limit that can usually be increased. If you get this error, you might
3249 TRANS want to increase the @code{RLIMIT_NOFILE} limit or make it unlimited;
3250 TRANS @pxref{Limits on Resources}. */
3251 -_S(ERR_MAP(EMFILE), N_("Too many open files"))
3252 +_S(EMFILE, N_("Too many open files"))
3253 #endif
3254 #ifdef ENFILE
3255 /*
3256 TRANS There are too many distinct file openings in the entire system. Note
3257 TRANS that any number of linked channels count as just one file opening; see
3258 TRANS @ref{Linked Channels}. This error never occurs on @gnuhurdsystems{}. */
3259 -_S(ERR_MAP(ENFILE), N_("Too many open files in system"))
3260 +_S(ENFILE, N_("Too many open files in system"))
3261 #endif
3262 #ifdef ENOTTY
3263 /*
3264 TRANS Inappropriate I/O control operation, such as trying to set terminal
3265 TRANS modes on an ordinary file. */
3266 -_S(ERR_MAP(ENOTTY), N_("Inappropriate ioctl for device"))
3267 +_S(ENOTTY, N_("Inappropriate ioctl for device"))
3268 #endif
3269 #ifdef ETXTBSY
3270 /*
3271 @@ -179,35 +176,35 @@ TRANS write to a file that is currently being executed. Often using a
3272 TRANS debugger to run a program is considered having it open for writing and
3273 TRANS will cause this error. (The name stands for ``text file busy''.) This
3274 TRANS is not an error on @gnuhurdsystems{}; the text is copied as necessary. */
3275 -_S(ERR_MAP(ETXTBSY), N_("Text file busy"))
3276 +_S(ETXTBSY, N_("Text file busy"))
3277 #endif
3278 #ifdef EFBIG
3279 /*
3280 TRANS The size of a file would be larger than allowed by the system. */
3281 -_S(ERR_MAP(EFBIG), N_("File too large"))
3282 +_S(EFBIG, N_("File too large"))
3283 #endif
3284 #ifdef ENOSPC
3285 /*
3286 TRANS Write operation on a file failed because the
3287 TRANS disk is full. */
3288 -_S(ERR_MAP(ENOSPC), N_("No space left on device"))
3289 +_S(ENOSPC, N_("No space left on device"))
3290 #endif
3291 #ifdef ESPIPE
3292 /*
3293 TRANS Invalid seek operation (such as on a pipe). */
3294 -_S(ERR_MAP(ESPIPE), N_("Illegal seek"))
3295 +_S(ESPIPE, N_("Illegal seek"))
3296 #endif
3297 #ifdef EROFS
3298 /*
3299 TRANS An attempt was made to modify something on a read-only file system. */
3300 -_S(ERR_MAP(EROFS), N_("Read-only file system"))
3301 +_S(EROFS, N_("Read-only file system"))
3302 #endif
3303 #ifdef EMLINK
3304 /*
3305 TRANS The link count of a single file would become too large.
3306 TRANS @code{rename} can cause this error if the file being renamed already has
3307 TRANS as many links as it can take (@pxref{Renaming Files}). */
3308 -_S(ERR_MAP(EMLINK), N_("Too many links"))
3309 +_S(EMLINK, N_("Too many links"))
3310 #endif
3311 #ifdef EPIPE
3312 /*
3313 @@ -216,19 +213,19 @@ TRANS Every library function that returns this error code also generates a
3314 TRANS @code{SIGPIPE} signal; this signal terminates the program if not handled
3315 TRANS or blocked. Thus, your program will never actually see @code{EPIPE}
3316 TRANS unless it has handled or blocked @code{SIGPIPE}. */
3317 -_S(ERR_MAP(EPIPE), N_("Broken pipe"))
3318 +_S(EPIPE, N_("Broken pipe"))
3319 #endif
3320 #ifdef EDOM
3321 /*
3322 TRANS Used by mathematical functions when an argument value does
3323 TRANS not fall into the domain over which the function is defined. */
3324 -_S(ERR_MAP(EDOM), N_("Numerical argument out of domain"))
3325 +_S(EDOM, N_("Numerical argument out of domain"))
3326 #endif
3327 #ifdef ERANGE
3328 /*
3329 TRANS Used by mathematical functions when the result value is
3330 TRANS not representable because of overflow or underflow. */
3331 -_S(ERR_MAP(ERANGE), N_("Numerical result out of range"))
3332 +_S(ERANGE, N_("Numerical result out of range"))
3333 #endif
3334 #ifdef EAGAIN
3335 /*
3336 @@ -261,7 +258,7 @@ TRANS Such shortages are usually fairly serious and affect the whole system,
3337 TRANS so usually an interactive program should report the error to the user
3338 TRANS and return to its command loop.
3339 TRANS @end itemize */
3340 -_S(ERR_MAP(EAGAIN), N_("Resource temporarily unavailable"))
3341 +_S(EAGAIN, N_("Resource temporarily unavailable"))
3342 #endif
3343 #ifdef EINPROGRESS
3344 /*
3345 @@ -273,47 +270,47 @@ TRANS the operation has begun and will take some time. Attempts to manipulate
3346 TRANS the object before the call completes return @code{EALREADY}. You can
3347 TRANS use the @code{select} function to find out when the pending operation
3348 TRANS has completed; @pxref{Waiting for I/O}. */
3349 -_S(ERR_MAP(EINPROGRESS), N_("Operation now in progress"))
3350 +_S(EINPROGRESS, N_("Operation now in progress"))
3351 #endif
3352 #ifdef EALREADY
3353 /*
3354 TRANS An operation is already in progress on an object that has non-blocking
3355 TRANS mode selected. */
3356 -_S(ERR_MAP(EALREADY), N_("Operation already in progress"))
3357 +_S(EALREADY, N_("Operation already in progress"))
3358 #endif
3359 #ifdef ENOTSOCK
3360 /*
3361 TRANS A file that isn't a socket was specified when a socket is required. */
3362 -_S(ERR_MAP(ENOTSOCK), N_("Socket operation on non-socket"))
3363 +_S(ENOTSOCK, N_("Socket operation on non-socket"))
3364 #endif
3365 #ifdef EMSGSIZE
3366 /*
3367 TRANS The size of a message sent on a socket was larger than the supported
3368 TRANS maximum size. */
3369 -_S(ERR_MAP(EMSGSIZE), N_("Message too long"))
3370 +_S(EMSGSIZE, N_("Message too long"))
3371 #endif
3372 #ifdef EPROTOTYPE
3373 /*
3374 TRANS The socket type does not support the requested communications protocol. */
3375 -_S(ERR_MAP(EPROTOTYPE), N_("Protocol wrong type for socket"))
3376 +_S(EPROTOTYPE, N_("Protocol wrong type for socket"))
3377 #endif
3378 #ifdef ENOPROTOOPT
3379 /*
3380 TRANS You specified a socket option that doesn't make sense for the
3381 TRANS particular protocol being used by the socket. @xref{Socket Options}. */
3382 -_S(ERR_MAP(ENOPROTOOPT), N_("Protocol not available"))
3383 +_S(ENOPROTOOPT, N_("Protocol not available"))
3384 #endif
3385 #ifdef EPROTONOSUPPORT
3386 /*
3387 TRANS The socket domain does not support the requested communications protocol
3388 TRANS (perhaps because the requested protocol is completely invalid).
3389 TRANS @xref{Creating a Socket}. */
3390 -_S(ERR_MAP(EPROTONOSUPPORT), N_("Protocol not supported"))
3391 +_S(EPROTONOSUPPORT, N_("Protocol not supported"))
3392 #endif
3393 #ifdef ESOCKTNOSUPPORT
3394 /*
3395 TRANS The socket type is not supported. */
3396 -_S(ERR_MAP(ESOCKTNOSUPPORT), N_("Socket type not supported"))
3397 +_S(ESOCKTNOSUPPORT, N_("Socket type not supported"))
3398 #endif
3399 #ifdef EOPNOTSUPP
3400 /*
3401 @@ -323,71 +320,71 @@ TRANS implemented for all communications protocols. On @gnuhurdsystems{}, this
3402 TRANS error can happen for many calls when the object does not support the
3403 TRANS particular operation; it is a generic indication that the server knows
3404 TRANS nothing to do for that call. */
3405 -_S(ERR_MAP(EOPNOTSUPP), N_("Operation not supported"))
3406 +_S(EOPNOTSUPP, N_("Operation not supported"))
3407 #endif
3408 #ifdef EPFNOSUPPORT
3409 /*
3410 TRANS The socket communications protocol family you requested is not supported. */
3411 -_S(ERR_MAP(EPFNOSUPPORT), N_("Protocol family not supported"))
3412 +_S(EPFNOSUPPORT, N_("Protocol family not supported"))
3413 #endif
3414 #ifdef EAFNOSUPPORT
3415 /*
3416 TRANS The address family specified for a socket is not supported; it is
3417 TRANS inconsistent with the protocol being used on the socket. @xref{Sockets}. */
3418 -_S(ERR_MAP(EAFNOSUPPORT), N_("Address family not supported by protocol"))
3419 +_S(EAFNOSUPPORT, N_("Address family not supported by protocol"))
3420 #endif
3421 #ifdef EADDRINUSE
3422 /*
3423 TRANS The requested socket address is already in use. @xref{Socket Addresses}. */
3424 -_S(ERR_MAP(EADDRINUSE), N_("Address already in use"))
3425 +_S(EADDRINUSE, N_("Address already in use"))
3426 #endif
3427 #ifdef EADDRNOTAVAIL
3428 /*
3429 TRANS The requested socket address is not available; for example, you tried
3430 TRANS to give a socket a name that doesn't match the local host name.
3431 TRANS @xref{Socket Addresses}. */
3432 -_S(ERR_MAP(EADDRNOTAVAIL), N_("Cannot assign requested address"))
3433 +_S(EADDRNOTAVAIL, N_("Cannot assign requested address"))
3434 #endif
3435 #ifdef ENETDOWN
3436 /*
3437 TRANS A socket operation failed because the network was down. */
3438 -_S(ERR_MAP(ENETDOWN), N_("Network is down"))
3439 +_S(ENETDOWN, N_("Network is down"))
3440 #endif
3441 #ifdef ENETUNREACH
3442 /*
3443 TRANS A socket operation failed because the subnet containing the remote host
3444 TRANS was unreachable. */
3445 -_S(ERR_MAP(ENETUNREACH), N_("Network is unreachable"))
3446 +_S(ENETUNREACH, N_("Network is unreachable"))
3447 #endif
3448 #ifdef ENETRESET
3449 /*
3450 TRANS A network connection was reset because the remote host crashed. */
3451 -_S(ERR_MAP(ENETRESET), N_("Network dropped connection on reset"))
3452 +_S(ENETRESET, N_("Network dropped connection on reset"))
3453 #endif
3454 #ifdef ECONNABORTED
3455 /*
3456 TRANS A network connection was aborted locally. */
3457 -_S(ERR_MAP(ECONNABORTED), N_("Software caused connection abort"))
3458 +_S(ECONNABORTED, N_("Software caused connection abort"))
3459 #endif
3460 #ifdef ECONNRESET
3461 /*
3462 TRANS A network connection was closed for reasons outside the control of the
3463 TRANS local host, such as by the remote machine rebooting or an unrecoverable
3464 TRANS protocol violation. */
3465 -_S(ERR_MAP(ECONNRESET), N_("Connection reset by peer"))
3466 +_S(ECONNRESET, N_("Connection reset by peer"))
3467 #endif
3468 #ifdef ENOBUFS
3469 /*
3470 TRANS The kernel's buffers for I/O operations are all in use. In GNU, this
3471 TRANS error is always synonymous with @code{ENOMEM}; you may get one or the
3472 TRANS other from network operations. */
3473 -_S(ERR_MAP(ENOBUFS), N_("No buffer space available"))
3474 +_S(ENOBUFS, N_("No buffer space available"))
3475 #endif
3476 #ifdef EISCONN
3477 /*
3478 TRANS You tried to connect a socket that is already connected.
3479 TRANS @xref{Connecting}. */
3480 -_S(ERR_MAP(EISCONN), N_("Transport endpoint is already connected"))
3481 +_S(EISCONN, N_("Transport endpoint is already connected"))
3482 #endif
3483 #ifdef ENOTCONN
3484 /*
3485 @@ -395,74 +392,74 @@ TRANS The socket is not connected to anything. You get this error when you
3486 TRANS try to transmit data over a socket, without first specifying a
3487 TRANS destination for the data. For a connectionless socket (for datagram
3488 TRANS protocols, such as UDP), you get @code{EDESTADDRREQ} instead. */
3489 -_S(ERR_MAP(ENOTCONN), N_("Transport endpoint is not connected"))
3490 +_S(ENOTCONN, N_("Transport endpoint is not connected"))
3491 #endif
3492 #ifdef EDESTADDRREQ
3493 /*
3494 TRANS No default destination address was set for the socket. You get this
3495 TRANS error when you try to transmit data over a connectionless socket,
3496 TRANS without first specifying a destination for the data with @code{connect}. */
3497 -_S(ERR_MAP(EDESTADDRREQ), N_("Destination address required"))
3498 +_S(EDESTADDRREQ, N_("Destination address required"))
3499 #endif
3500 #ifdef ESHUTDOWN
3501 /*
3502 TRANS The socket has already been shut down. */
3503 -_S(ERR_MAP(ESHUTDOWN), N_("Cannot send after transport endpoint shutdown"))
3504 +_S(ESHUTDOWN, N_("Cannot send after transport endpoint shutdown"))
3505 #endif
3506 #ifdef ETOOMANYREFS
3507 -_S(ERR_MAP(ETOOMANYREFS), N_("Too many references: cannot splice"))
3508 +_S(ETOOMANYREFS, N_("Too many references: cannot splice"))
3509 #endif
3510 #ifdef ETIMEDOUT
3511 /*
3512 TRANS A socket operation with a specified timeout received no response during
3513 TRANS the timeout period. */
3514 -_S(ERR_MAP(ETIMEDOUT), N_("Connection timed out"))
3515 +_S(ETIMEDOUT, N_("Connection timed out"))
3516 #endif
3517 #ifdef ECONNREFUSED
3518 /*
3519 TRANS A remote host refused to allow the network connection (typically because
3520 TRANS it is not running the requested service). */
3521 -_S(ERR_MAP(ECONNREFUSED), N_("Connection refused"))
3522 +_S(ECONNREFUSED, N_("Connection refused"))
3523 #endif
3524 #ifdef ELOOP
3525 /*
3526 TRANS Too many levels of symbolic links were encountered in looking up a file name.
3527 TRANS This often indicates a cycle of symbolic links. */
3528 -_S(ERR_MAP(ELOOP), N_("Too many levels of symbolic links"))
3529 +_S(ELOOP, N_("Too many levels of symbolic links"))
3530 #endif
3531 #ifdef ENAMETOOLONG
3532 /*
3533 TRANS Filename too long (longer than @code{PATH_MAX}; @pxref{Limits for
3534 TRANS Files}) or host name too long (in @code{gethostname} or
3535 TRANS @code{sethostname}; @pxref{Host Identification}). */
3536 -_S(ERR_MAP(ENAMETOOLONG), N_("File name too long"))
3537 +_S(ENAMETOOLONG, N_("File name too long"))
3538 #endif
3539 #ifdef EHOSTDOWN
3540 /*
3541 TRANS The remote host for a requested network connection is down. */
3542 -_S(ERR_MAP(EHOSTDOWN), N_("Host is down"))
3543 +_S(EHOSTDOWN, N_("Host is down"))
3544 #endif
3545 /*
3546 TRANS The remote host for a requested network connection is not reachable. */
3547 #ifdef EHOSTUNREACH
3548 -_S(ERR_MAP(EHOSTUNREACH), N_("No route to host"))
3549 +_S(EHOSTUNREACH, N_("No route to host"))
3550 #endif
3551 #ifdef ENOTEMPTY
3552 /*
3553 TRANS Directory not empty, where an empty directory was expected. Typically,
3554 TRANS this error occurs when you are trying to delete a directory. */
3555 -_S(ERR_MAP(ENOTEMPTY), N_("Directory not empty"))
3556 +_S(ENOTEMPTY, N_("Directory not empty"))
3557 #endif
3558 #ifdef EUSERS
3559 /*
3560 TRANS The file quota system is confused because there are too many users.
3561 TRANS @c This can probably happen in a GNU system when using NFS. */
3562 -_S(ERR_MAP(EUSERS), N_("Too many users"))
3563 +_S(EUSERS, N_("Too many users"))
3564 #endif
3565 #ifdef EDQUOT
3566 /*
3567 TRANS The user's disk quota was exceeded. */
3568 -_S(ERR_MAP(EDQUOT), N_("Disk quota exceeded"))
3569 +_S(EDQUOT, N_("Disk quota exceeded"))
3570 #endif
3571 #ifdef ESTALE
3572 /*
3573 @@ -471,7 +468,7 @@ TRANS file system which is due to file system rearrangements on the server host
3574 TRANS for NFS file systems or corruption in other file systems.
3575 TRANS Repairing this condition usually requires unmounting, possibly repairing
3576 TRANS and remounting the file system. */
3577 -_S(ERR_MAP(ESTALE), N_("Stale file handle"))
3578 +_S(ESTALE, N_("Stale file handle"))
3579 #endif
3580 #ifdef EREMOTE
3581 /*
3582 @@ -479,7 +476,7 @@ TRANS An attempt was made to NFS-mount a remote file system with a file name tha
3583 TRANS already specifies an NFS-mounted file.
3584 TRANS (This is an error on some operating systems, but we expect it to work
3585 TRANS properly on @gnuhurdsystems{}, making this error code impossible.) */
3586 -_S(ERR_MAP(EREMOTE), N_("Object is remote"))
3587 +_S(EREMOTE, N_("Object is remote"))
3588 #endif
3589 #ifdef ENOLCK
3590 /*
3591 @@ -487,7 +484,7 @@ TRANS This is used by the file locking facilities; see
3592 TRANS @ref{File Locks}. This error is never generated by @gnuhurdsystems{}, but
3593 TRANS it can result from an operation to an NFS server running another
3594 TRANS operating system. */
3595 -_S(ERR_MAP(ENOLCK), N_("No locks available"))
3596 +_S(ENOLCK, N_("No locks available"))
3597 #endif
3598 #ifdef ENOSYS
3599 /*
3600 @@ -496,46 +493,46 @@ TRANS not implemented at all, either in the C library itself or in the
3601 TRANS operating system. When you get this error, you can be sure that this
3602 TRANS particular function will always fail with @code{ENOSYS} unless you
3603 TRANS install a new version of the C library or the operating system. */
3604 -_S(ERR_MAP(ENOSYS), N_("Function not implemented"))
3605 +_S(ENOSYS, N_("Function not implemented"))
3606 #endif
3607 #ifdef EILSEQ
3608 /*
3609 TRANS While decoding a multibyte character the function came along an invalid
3610 TRANS or an incomplete sequence of bytes or the given wide character is invalid. */
3611 -_S(ERR_MAP(EILSEQ), N_("Invalid or incomplete multibyte or wide character"))
3612 +_S(EILSEQ, N_("Invalid or incomplete multibyte or wide character"))
3613 #endif
3614 #ifdef EBADMSG
3615 -_S(ERR_MAP(EBADMSG), N_("Bad message"))
3616 +_S(EBADMSG, N_("Bad message"))
3617 #endif
3618 #ifdef EIDRM
3619 -_S(ERR_MAP(EIDRM), N_("Identifier removed"))
3620 +_S(EIDRM, N_("Identifier removed"))
3621 #endif
3622 #ifdef EMULTIHOP
3623 -_S(ERR_MAP(EMULTIHOP), N_("Multihop attempted"))
3624 +_S(EMULTIHOP, N_("Multihop attempted"))
3625 #endif
3626 #ifdef ENODATA
3627 -_S(ERR_MAP(ENODATA), N_("No data available"))
3628 +_S(ENODATA, N_("No data available"))
3629 #endif
3630 #ifdef ENOLINK
3631 -_S(ERR_MAP(ENOLINK), N_("Link has been severed"))
3632 +_S(ENOLINK, N_("Link has been severed"))
3633 #endif
3634 #ifdef ENOMSG
3635 -_S(ERR_MAP(ENOMSG), N_("No message of desired type"))
3636 +_S(ENOMSG, N_("No message of desired type"))
3637 #endif
3638 #ifdef ENOSR
3639 -_S(ERR_MAP(ENOSR), N_("Out of streams resources"))
3640 +_S(ENOSR, N_("Out of streams resources"))
3641 #endif
3642 #ifdef ENOSTR
3643 -_S(ERR_MAP(ENOSTR), N_("Device not a stream"))
3644 +_S(ENOSTR, N_("Device not a stream"))
3645 #endif
3646 #ifdef EOVERFLOW
3647 -_S(ERR_MAP(EOVERFLOW), N_("Value too large for defined data type"))
3648 +_S(EOVERFLOW, N_("Value too large for defined data type"))
3649 #endif
3650 #ifdef EPROTO
3651 -_S(ERR_MAP(EPROTO), N_("Protocol error"))
3652 +_S(EPROTO, N_("Protocol error"))
3653 #endif
3654 #ifdef ETIME
3655 -_S(ERR_MAP(ETIME), N_("Timer expired"))
3656 +_S(ETIME, N_("Timer expired"))
3657 #endif
3658 #ifdef ECANCELED
3659 /*
3660 @@ -543,148 +540,148 @@ TRANS An asynchronous operation was canceled before it
3661 TRANS completed. @xref{Asynchronous I/O}. When you call @code{aio_cancel},
3662 TRANS the normal result is for the operations affected to complete with this
3663 TRANS error; @pxref{Cancel AIO Operations}. */
3664 -_S(ERR_MAP(ECANCELED), N_("Operation canceled"))
3665 +_S(ECANCELED, N_("Operation canceled"))
3666 #endif
3667 #ifdef EOWNERDEAD
3668 -_S(ERR_MAP(EOWNERDEAD), N_("Owner died"))
3669 +_S(EOWNERDEAD, N_("Owner died"))
3670 #endif
3671 #ifdef ENOTRECOVERABLE
3672 -_S(ERR_MAP(ENOTRECOVERABLE), N_("State not recoverable"))
3673 +_S(ENOTRECOVERABLE, N_("State not recoverable"))
3674 #endif
3675 #ifdef ERESTART
3676 -_S(ERR_MAP(ERESTART), N_("Interrupted system call should be restarted"))
3677 +_S(ERESTART, N_("Interrupted system call should be restarted"))
3678 #endif
3679 #ifdef ECHRNG
3680 -_S(ERR_MAP(ECHRNG), N_("Channel number out of range"))
3681 +_S(ECHRNG, N_("Channel number out of range"))
3682 #endif
3683 #ifdef EL2NSYNC
3684 -_S(ERR_MAP(EL2NSYNC), N_("Level 2 not synchronized"))
3685 +_S(EL2NSYNC, N_("Level 2 not synchronized"))
3686 #endif
3687 #ifdef EL3HLT
3688 -_S(ERR_MAP(EL3HLT), N_("Level 3 halted"))
3689 +_S(EL3HLT, N_("Level 3 halted"))
3690 #endif
3691 #ifdef EL3RST
3692 -_S(ERR_MAP(EL3RST), N_("Level 3 reset"))
3693 +_S(EL3RST, N_("Level 3 reset"))
3694 #endif
3695 #ifdef ELNRNG
3696 -_S(ERR_MAP(ELNRNG), N_("Link number out of range"))
3697 +_S(ELNRNG, N_("Link number out of range"))
3698 #endif
3699 #ifdef EUNATCH
3700 -_S(ERR_MAP(EUNATCH), N_("Protocol driver not attached"))
3701 +_S(EUNATCH, N_("Protocol driver not attached"))
3702 #endif
3703 #ifdef ENOCSI
3704 -_S(ERR_MAP(ENOCSI), N_("No CSI structure available"))
3705 +_S(ENOCSI, N_("No CSI structure available"))
3706 #endif
3707 #ifdef EL2HLT
3708 -_S(ERR_MAP(EL2HLT), N_("Level 2 halted"))
3709 +_S(EL2HLT, N_("Level 2 halted"))
3710 #endif
3711 #ifdef EBADE
3712 -_S(ERR_MAP(EBADE), N_("Invalid exchange"))
3713 +_S(EBADE, N_("Invalid exchange"))
3714 #endif
3715 #ifdef EBADR
3716 -_S(ERR_MAP(EBADR), N_("Invalid request descriptor"))
3717 +_S(EBADR, N_("Invalid request descriptor"))
3718 #endif
3719 #ifdef EXFULL
3720 -_S(ERR_MAP(EXFULL), N_("Exchange full"))
3721 +_S(EXFULL, N_("Exchange full"))
3722 #endif
3723 #ifdef ENOANO
3724 -_S(ERR_MAP(ENOANO), N_("No anode"))
3725 +_S(ENOANO, N_("No anode"))
3726 #endif
3727 #ifdef EBADRQC
3728 -_S(ERR_MAP(EBADRQC), N_("Invalid request code"))
3729 +_S(EBADRQC, N_("Invalid request code"))
3730 #endif
3731 #ifdef EBADSLT
3732 -_S(ERR_MAP(EBADSLT), N_("Invalid slot"))
3733 +_S(EBADSLT, N_("Invalid slot"))
3734 #endif
3735 #ifdef EBFONT
3736 -_S(ERR_MAP(EBFONT), N_("Bad font file format"))
3737 +_S(EBFONT, N_("Bad font file format"))
3738 #endif
3739 #ifdef ENONET
3740 -_S(ERR_MAP(ENONET), N_("Machine is not on the network"))
3741 +_S(ENONET, N_("Machine is not on the network"))
3742 #endif
3743 #ifdef ENOPKG
3744 -_S(ERR_MAP(ENOPKG), N_("Package not installed"))
3745 +_S(ENOPKG, N_("Package not installed"))
3746 #endif
3747 #ifdef EADV
3748 -_S(ERR_MAP(EADV), N_("Advertise error"))
3749 +_S(EADV, N_("Advertise error"))
3750 #endif
3751 #ifdef ESRMNT
3752 -_S(ERR_MAP(ESRMNT), N_("Srmount error"))
3753 +_S(ESRMNT, N_("Srmount error"))
3754 #endif
3755 #ifdef ECOMM
3756 -_S(ERR_MAP(ECOMM), N_("Communication error on send"))
3757 +_S(ECOMM, N_("Communication error on send"))
3758 #endif
3759 #ifdef EDOTDOT
3760 -_S(ERR_MAP(EDOTDOT), N_("RFS specific error"))
3761 +_S(EDOTDOT, N_("RFS specific error"))
3762 #endif
3763 #ifdef ENOTUNIQ
3764 -_S(ERR_MAP(ENOTUNIQ), N_("Name not unique on network"))
3765 +_S(ENOTUNIQ, N_("Name not unique on network"))
3766 #endif
3767 #ifdef EBADFD
3768 -_S(ERR_MAP(EBADFD), N_("File descriptor in bad state"))
3769 +_S(EBADFD, N_("File descriptor in bad state"))
3770 #endif
3771 #ifdef EREMCHG
3772 -_S(ERR_MAP(EREMCHG), N_("Remote address changed"))
3773 +_S(EREMCHG, N_("Remote address changed"))
3774 #endif
3775 #ifdef ELIBACC
3776 -_S(ERR_MAP(ELIBACC), N_("Can not access a needed shared library"))
3777 +_S(ELIBACC, N_("Can not access a needed shared library"))
3778 #endif
3779 #ifdef ELIBBAD
3780 -_S(ERR_MAP(ELIBBAD), N_("Accessing a corrupted shared library"))
3781 +_S(ELIBBAD, N_("Accessing a corrupted shared library"))
3782 #endif
3783 #ifdef ELIBSCN
3784 -_S(ERR_MAP(ELIBSCN), N_(".lib section in a.out corrupted"))
3785 +_S(ELIBSCN, N_(".lib section in a.out corrupted"))
3786 #endif
3787 #ifdef ELIBMAX
3788 -_S(ERR_MAP(ELIBMAX), N_("Attempting to link in too many shared libraries"))
3789 +_S(ELIBMAX, N_("Attempting to link in too many shared libraries"))
3790 #endif
3791 #ifdef ELIBEXEC
3792 -_S(ERR_MAP(ELIBEXEC), N_("Cannot exec a shared library directly"))
3793 +_S(ELIBEXEC, N_("Cannot exec a shared library directly"))
3794 #endif
3795 #ifdef ESTRPIPE
3796 -_S(ERR_MAP(ESTRPIPE), N_("Streams pipe error"))
3797 +_S(ESTRPIPE, N_("Streams pipe error"))
3798 #endif
3799 #ifdef EUCLEAN
3800 -_S(ERR_MAP(EUCLEAN), N_("Structure needs cleaning"))
3801 +_S(EUCLEAN, N_("Structure needs cleaning"))
3802 #endif
3803 #ifdef ENOTNAM
3804 -_S(ERR_MAP(ENOTNAM), N_("Not a XENIX named type file"))
3805 +_S(ENOTNAM, N_("Not a XENIX named type file"))
3806 #endif
3807 #ifdef ENAVAIL
3808 -_S(ERR_MAP(ENAVAIL), N_("No XENIX semaphores available"))
3809 +_S(ENAVAIL, N_("No XENIX semaphores available"))
3810 #endif
3811 #ifdef EISNAM
3812 -_S(ERR_MAP(EISNAM), N_("Is a named type file"))
3813 +_S(EISNAM, N_("Is a named type file"))
3814 #endif
3815 #ifdef EREMOTEIO
3816 -_S(ERR_MAP(EREMOTEIO), N_("Remote I/O error"))
3817 +_S(EREMOTEIO, N_("Remote I/O error"))
3818 #endif
3819 #ifdef ENOMEDIUM
3820 -_S(ERR_MAP(ENOMEDIUM), N_("No medium found"))
3821 +_S(ENOMEDIUM, N_("No medium found"))
3822 #endif
3823 #ifdef EMEDIUMTYPE
3824 -_S(ERR_MAP(EMEDIUMTYPE), N_("Wrong medium type"))
3825 +_S(EMEDIUMTYPE, N_("Wrong medium type"))
3826 #endif
3827 #ifdef ENOKEY
3828 -_S(ERR_MAP(ENOKEY), N_("Required key not available"))
3829 +_S(ENOKEY, N_("Required key not available"))
3830 #endif
3831 #ifdef EKEYEXPIRED
3832 -_S(ERR_MAP(EKEYEXPIRED), N_("Key has expired"))
3833 +_S(EKEYEXPIRED, N_("Key has expired"))
3834 #endif
3835 #ifdef EKEYREVOKED
3836 -_S(ERR_MAP(EKEYREVOKED), N_("Key has been revoked"))
3837 +_S(EKEYREVOKED, N_("Key has been revoked"))
3838 #endif
3839 #ifdef EKEYREJECTED
3840 -_S(ERR_MAP(EKEYREJECTED), N_("Key was rejected by service"))
3841 +_S(EKEYREJECTED, N_("Key was rejected by service"))
3842 #endif
3843 #ifdef ERFKILL
3844 -_S(ERR_MAP(ERFKILL), N_("Operation not possible due to RF-kill"))
3845 +_S(ERFKILL, N_("Operation not possible due to RF-kill"))
3846 #endif
3847 #ifdef EHWPOISON
3848 -_S(ERR_MAP(EHWPOISON), N_("Memory page has hardware error"))
3849 +_S(EHWPOISON, N_("Memory page has hardware error"))
3850 #endif
3851 #ifdef EBADRPC
3852 -_S(ERR_MAP(EBADRPC), N_("RPC struct is bad"))
3853 +_S(EBADRPC, N_("RPC struct is bad"))
3854 #endif
3855 #ifdef EFTYPE
3856 /*
3857 @@ -693,40 +690,40 @@ TRANS operation, or a data file had the wrong format.
3858 TRANS
3859 TRANS On some systems @code{chmod} returns this error if you try to set the
3860 TRANS sticky bit on a non-directory file; @pxref{Setting Permissions}. */
3861 -_S(ERR_MAP(EFTYPE), N_("Inappropriate file type or format"))
3862 +_S(EFTYPE, N_("Inappropriate file type or format"))
3863 #endif
3864 #ifdef EPROCUNAVAIL
3865 -_S(ERR_MAP(EPROCUNAVAIL), N_("RPC bad procedure for program"))
3866 +_S(EPROCUNAVAIL, N_("RPC bad procedure for program"))
3867 #endif
3868 #ifdef EAUTH
3869 -_S(ERR_MAP(EAUTH), N_("Authentication error"))
3870 +_S(EAUTH, N_("Authentication error"))
3871 #endif
3872 #ifdef EDIED
3873 /*
3874 TRANS On @gnuhurdsystems{}, opening a file returns this error when the file is
3875 TRANS translated by a program and the translator program dies while starting
3876 TRANS up, before it has connected to the file. */
3877 -_S(ERR_MAP(EDIED), N_("Translator died"))
3878 +_S(EDIED, N_("Translator died"))
3879 #endif
3880 #ifdef ERPCMISMATCH
3881 -_S(ERR_MAP(ERPCMISMATCH), N_("RPC version wrong"))
3882 +_S(ERPCMISMATCH, N_("RPC version wrong"))
3883 #endif
3884 #ifdef EGREGIOUS
3885 /*
3886 TRANS You did @strong{what}? */
3887 -_S(ERR_MAP(EGREGIOUS), N_("You really blew it this time"))
3888 +_S(EGREGIOUS, N_("You really blew it this time"))
3889 #endif
3890 #ifdef EPROCLIM
3891 /*
3892 TRANS This means that the per-user limit on new process would be exceeded by
3893 TRANS an attempted @code{fork}. @xref{Limits on Resources}, for details on
3894 TRANS the @code{RLIMIT_NPROC} limit. */
3895 -_S(ERR_MAP(EPROCLIM), N_("Too many processes"))
3896 +_S(EPROCLIM, N_("Too many processes"))
3897 #endif
3898 #ifdef EGRATUITOUS
3899 /*
3900 TRANS This error code has no purpose. */
3901 -_S(ERR_MAP(EGRATUITOUS), N_("Gratuitous error"))
3902 +_S(EGRATUITOUS, N_("Gratuitous error"))
3903 #endif
3904 #if defined (ENOTSUP) && ENOTSUP != EOPNOTSUPP
3905 /*
3906 @@ -742,10 +739,10 @@ TRANS values.
3907 TRANS
3908 TRANS If the entire function is not available at all in the implementation,
3909 TRANS it returns @code{ENOSYS} instead. */
3910 -_S(ERR_MAP(ENOTSUP), N_("Not supported"))
3911 +_S(ENOTSUP, N_("Not supported"))
3912 #endif
3913 #ifdef EPROGMISMATCH
3914 -_S(ERR_MAP(EPROGMISMATCH), N_("RPC program version wrong"))
3915 +_S(EPROGMISMATCH, N_("RPC program version wrong"))
3916 #endif
3917 #ifdef EBACKGROUND
3918 /*
3919 @@ -755,7 +752,7 @@ TRANS foreground process group of the terminal. Users do not usually see this
3920 TRANS error because functions such as @code{read} and @code{write} translate
3921 TRANS it into a @code{SIGTTIN} or @code{SIGTTOU} signal. @xref{Job Control},
3922 TRANS for information on process groups and these signals. */
3923 -_S(ERR_MAP(EBACKGROUND), N_("Inappropriate operation for background process"))
3924 +_S(EBACKGROUND, N_("Inappropriate operation for background process"))
3925 #endif
3926 #ifdef EIEIO
3927 /*
3928 @@ -773,7 +770,7 @@ TRANS @c "bought the farm" means "died". -jtobey
3929 TRANS @c
3930 TRANS @c Translators, please do not translate this litteraly, translate it into
3931 TRANS @c an idiomatic funny way of saying that the computer died. */
3932 -_S(ERR_MAP(EIEIO), N_("Computer bought the farm"))
3933 +_S(EIEIO, N_("Computer bought the farm"))
3934 #endif
3935 #if defined (EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
3936 /*
3937 @@ -782,18 +779,18 @@ TRANS The values are always the same, on every operating system.
3938 TRANS
3939 TRANS C libraries in many older Unix systems have @code{EWOULDBLOCK} as a
3940 TRANS separate error code. */
3941 -_S(ERR_MAP(EWOULDBLOCK), N_("Operation would block"))
3942 +_S(EWOULDBLOCK, N_("Operation would block"))
3943 #endif
3944 #ifdef ENEEDAUTH
3945 -_S(ERR_MAP(ENEEDAUTH), N_("Need authenticator"))
3946 +_S(ENEEDAUTH, N_("Need authenticator"))
3947 #endif
3948 #ifdef ED
3949 /*
3950 TRANS The experienced user will know what is wrong.
3951 TRANS @c This error code is a joke. Its perror text is part of the joke.
3952 TRANS @c Don't change it. */
3953 -_S(ERR_MAP(ED), N_("?"))
3954 +_S(ED, N_("?"))
3955 #endif
3956 #ifdef EPROGUNAVAIL
3957 -_S(ERR_MAP(EPROGUNAVAIL), N_("RPC program not available"))
3958 +_S(EPROGUNAVAIL, N_("RPC program not available"))
3959 #endif
3960 diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
3961 index 0f08079e48..672d8f27ce 100644
3962 --- a/sysdeps/i386/dl-machine.h
3963 +++ b/sysdeps/i386/dl-machine.h
3964 @@ -338,16 +338,22 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
3965 {
3966 # ifndef RTLD_BOOTSTRAP
3967 if (sym_map != map
3968 - && sym_map->l_type != lt_executable
3969 && !sym_map->l_relocated)
3970 {
3971 const char *strtab
3972 = (const char *) D_PTR (map, l_info[DT_STRTAB]);
3973 - _dl_error_printf ("\
3974 + if (sym_map->l_type == lt_executable)
3975 + _dl_fatal_printf ("\
3976 +%s: IFUNC symbol '%s' referenced in '%s' is defined in the executable \
3977 +and creates an unsatisfiable circular dependency.\n",
3978 + RTLD_PROGNAME, strtab + refsym->st_name,
3979 + map->l_name);
3980 + else
3981 + _dl_error_printf ("\
3982 %s: Relink `%s' with `%s' for IFUNC symbol `%s'\n",
3983 - RTLD_PROGNAME, map->l_name,
3984 - sym_map->l_name,
3985 - strtab + refsym->st_name);
3986 + RTLD_PROGNAME, map->l_name,
3987 + sym_map->l_name,
3988 + strtab + refsym->st_name);
3989 }
3990 # endif
3991 value = ((Elf32_Addr (*) (void)) value) ();
3992 diff --git a/sysdeps/powerpc/powerpc64/backtrace.c b/sysdeps/powerpc/powerpc64/backtrace.c
3993 index 8a53a1088f..362a2b713c 100644
3994 --- a/sysdeps/powerpc/powerpc64/backtrace.c
3995 +++ b/sysdeps/powerpc/powerpc64/backtrace.c
3996 @@ -54,11 +54,22 @@ struct signal_frame_64 {
3997 /* We don't care about the rest, since the IP value is at 'uc' field. */
3998 };
3999
4000 +/* Test if the address match to the inside the trampoline code.
4001 + Up to and including kernel 5.8, returning from an interrupt or syscall to a
4002 + signal handler starts execution directly at the handler's entry point, with
4003 + LR set to address of the sigreturn trampoline (the vDSO symbol).
4004 + Newer kernels will branch to signal handler from the trampoline instead, so
4005 + checking the stacktrace against the vDSO entrypoint does not work in such
4006 + case.
4007 + The vDSO branches with a 'bctrl' instruction, so checking either the
4008 + vDSO address itself and the next instruction should cover all kernel
4009 + versions. */
4010 static inline bool
4011 is_sigtramp_address (void *nip)
4012 {
4013 #ifdef HAVE_SIGTRAMP_RT64
4014 - if (nip == GLRO (dl_vdso_sigtramp_rt64))
4015 + if (nip == GLRO (dl_vdso_sigtramp_rt64) ||
4016 + nip == GLRO (dl_vdso_sigtramp_rt64) + 4)
4017 return true;
4018 #endif
4019 return false;
4020 diff --git a/sysdeps/sh/be/sh4/fpu/Implies b/sysdeps/sh/be/sh4/fpu/Implies
4021 new file mode 100644
4022 index 0000000000..71b28ee1a4
4023 --- /dev/null
4024 +++ b/sysdeps/sh/be/sh4/fpu/Implies
4025 @@ -0,0 +1 @@
4026 +sh/sh4/fpu
4027 diff --git a/sysdeps/sh/le/sh4/fpu/Implies b/sysdeps/sh/le/sh4/fpu/Implies
4028 new file mode 100644
4029 index 0000000000..71b28ee1a4
4030 --- /dev/null
4031 +++ b/sysdeps/sh/le/sh4/fpu/Implies
4032 @@ -0,0 +1 @@
4033 +sh/sh4/fpu
4034 diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
4035 index 9b2a253032..34748ffcd1 100644
4036 --- a/sysdeps/unix/sysv/linux/Makefile
4037 +++ b/sysdeps/unix/sysv/linux/Makefile
4038 @@ -100,7 +100,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
4039 tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
4040 test-errno-linux tst-memfd_create tst-mlock2 tst-pkey \
4041 tst-rlimit-infinity tst-ofdlocks tst-gettid tst-gettid-kill \
4042 - tst-tgkill
4043 + tst-tgkill tst-sysvsem-linux tst-sysvmsg-linux tst-sysvshm-linux
4044 tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc
4045
4046 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
4047 diff --git a/sysdeps/unix/sysv/linux/aarch64/cpu-features.h b/sysdeps/unix/sysv/linux/aarch64/cpu-features.h
4048 index fc688450ee..00a4d0c8e7 100644
4049 --- a/sysdeps/unix/sysv/linux/aarch64/cpu-features.h
4050 +++ b/sysdeps/unix/sysv/linux/aarch64/cpu-features.h
4051 @@ -54,6 +54,10 @@
4052 && MIDR_PARTNUM(midr) == 0x000)
4053 #define IS_NEOVERSE_N1(midr) (MIDR_IMPLEMENTOR(midr) == 'A' \
4054 && MIDR_PARTNUM(midr) == 0xd0c)
4055 +#define IS_NEOVERSE_N2(midr) (MIDR_IMPLEMENTOR(midr) == 'A' \
4056 + && MIDR_PARTNUM(midr) == 0xd49)
4057 +#define IS_NEOVERSE_V1(midr) (MIDR_IMPLEMENTOR(midr) == 'A' \
4058 + && MIDR_PARTNUM(midr) == 0xd40)
4059
4060 #define IS_EMAG(midr) (MIDR_IMPLEMENTOR(midr) == 'P' \
4061 && MIDR_PARTNUM(midr) == 0x000)
4062 diff --git a/sysdeps/unix/sysv/linux/msgctl.c b/sysdeps/unix/sysv/linux/msgctl.c
4063 index 0776472d5e..a1f24ab242 100644
4064 --- a/sysdeps/unix/sysv/linux/msgctl.c
4065 +++ b/sysdeps/unix/sysv/linux/msgctl.c
4066 @@ -90,8 +90,15 @@ __msgctl64 (int msqid, int cmd, struct __msqid64_ds *buf)
4067 struct kernel_msqid64_ds ksemid, *arg = NULL;
4068 if (buf != NULL)
4069 {
4070 - msqid64_to_kmsqid64 (buf, &ksemid);
4071 - arg = &ksemid;
4072 + /* This is a Linux extension where kernel returns a 'struct msginfo'
4073 + instead. */
4074 + if (cmd == IPC_INFO || cmd == MSG_INFO)
4075 + arg = (struct kernel_msqid64_ds *) buf;
4076 + else
4077 + {
4078 + msqid64_to_kmsqid64 (buf, &ksemid);
4079 + arg = &ksemid;
4080 + }
4081 }
4082 # ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T
4083 if (cmd == IPC_SET)
4084 @@ -169,8 +176,15 @@ __msgctl (int msqid, int cmd, struct msqid_ds *buf)
4085 struct __msqid64_ds msqid64, *buf64 = NULL;
4086 if (buf != NULL)
4087 {
4088 - msqid_to_msqid64 (&msqid64, buf);
4089 - buf64 = &msqid64;
4090 + /* This is a Linux extension where kernel returns a 'struct msginfo'
4091 + instead. */
4092 + if (cmd == IPC_INFO || cmd == MSG_INFO)
4093 + buf64 = (struct __msqid64_ds *) buf;
4094 + else
4095 + {
4096 + msqid_to_msqid64 (&msqid64, buf);
4097 + buf64 = &msqid64;
4098 + }
4099 }
4100
4101 int ret = __msgctl64 (msqid, cmd, buf64);
4102 diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c
4103 index f131a26fc7..1cdabde8f2 100644
4104 --- a/sysdeps/unix/sysv/linux/semctl.c
4105 +++ b/sysdeps/unix/sysv/linux/semctl.c
4106 @@ -102,6 +102,7 @@ semun64_to_ksemun64 (int cmd, union semun64 semun64,
4107 r.array = semun64.array;
4108 break;
4109 case SEM_STAT:
4110 + case SEM_STAT_ANY:
4111 case IPC_STAT:
4112 case IPC_SET:
4113 r.buf = buf;
4114 @@ -150,6 +151,7 @@ __semctl64 (int semid, int semnum, int cmd, ...)
4115 case IPC_STAT: /* arg.buf */
4116 case IPC_SET:
4117 case SEM_STAT:
4118 + case SEM_STAT_ANY:
4119 case IPC_INFO: /* arg.__buf */
4120 case SEM_INFO:
4121 va_start (ap, cmd);
4122 @@ -238,6 +240,7 @@ semun_to_semun64 (int cmd, union semun semun, struct __semid64_ds *semid64)
4123 r.array = semun.array;
4124 break;
4125 case SEM_STAT:
4126 + case SEM_STAT_ANY:
4127 case IPC_STAT:
4128 case IPC_SET:
4129 r.buf = semid64;
4130 @@ -267,6 +270,7 @@ __semctl (int semid, int semnum, int cmd, ...)
4131 case IPC_STAT: /* arg.buf */
4132 case IPC_SET:
4133 case SEM_STAT:
4134 + case SEM_STAT_ANY:
4135 case IPC_INFO: /* arg.__buf */
4136 case SEM_INFO:
4137 va_start (ap, cmd);
4138 @@ -321,6 +325,7 @@ __semctl_mode16 (int semid, int semnum, int cmd, ...)
4139 case IPC_STAT: /* arg.buf */
4140 case IPC_SET:
4141 case SEM_STAT:
4142 + case SEM_STAT_ANY:
4143 case IPC_INFO: /* arg.__buf */
4144 case SEM_INFO:
4145 va_start (ap, cmd);
4146 @@ -354,6 +359,7 @@ __old_semctl (int semid, int semnum, int cmd, ...)
4147 case IPC_STAT: /* arg.buf */
4148 case IPC_SET:
4149 case SEM_STAT:
4150 + case SEM_STAT_ANY:
4151 case IPC_INFO: /* arg.__buf */
4152 case SEM_INFO:
4153 va_start (ap, cmd);
4154 diff --git a/sysdeps/unix/sysv/linux/sh/be/sh4/fpu/Implies b/sysdeps/unix/sysv/linux/sh/be/sh4/fpu/Implies
4155 new file mode 100644
4156 index 0000000000..7eeaf15a5a
4157 --- /dev/null
4158 +++ b/sysdeps/unix/sysv/linux/sh/be/sh4/fpu/Implies
4159 @@ -0,0 +1 @@
4160 +unix/sysv/linux/sh/sh4/fpu
4161 diff --git a/sysdeps/unix/sysv/linux/sh/le/sh4/fpu/Implies b/sysdeps/unix/sysv/linux/sh/le/sh4/fpu/Implies
4162 new file mode 100644
4163 index 0000000000..7eeaf15a5a
4164 --- /dev/null
4165 +++ b/sysdeps/unix/sysv/linux/sh/le/sh4/fpu/Implies
4166 @@ -0,0 +1 @@
4167 +unix/sysv/linux/sh/sh4/fpu
4168 diff --git a/sysdeps/unix/sysv/linux/shmctl.c b/sysdeps/unix/sysv/linux/shmctl.c
4169 index 76d88441f1..1d19a798b1 100644
4170 --- a/sysdeps/unix/sysv/linux/shmctl.c
4171 +++ b/sysdeps/unix/sysv/linux/shmctl.c
4172 @@ -90,8 +90,15 @@ __shmctl64 (int shmid, int cmd, struct __shmid64_ds *buf)
4173 struct kernel_shmid64_ds kshmid, *arg = NULL;
4174 if (buf != NULL)
4175 {
4176 - shmid64_to_kshmid64 (buf, &kshmid);
4177 - arg = &kshmid;
4178 + /* This is a Linux extension where kernel expects either a
4179 + 'struct shminfo' (IPC_INFO) or 'struct shm_info' (SHM_INFO). */
4180 + if (cmd == IPC_INFO || cmd == SHM_INFO)
4181 + arg = (struct kernel_shmid64_ds *) buf;
4182 + else
4183 + {
4184 + shmid64_to_kshmid64 (buf, &kshmid);
4185 + arg = &kshmid;
4186 + }
4187 }
4188 # ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T
4189 if (cmd == IPC_SET)
4190 @@ -107,7 +114,6 @@ __shmctl64 (int shmid, int cmd, struct __shmid64_ds *buf)
4191
4192 switch (cmd)
4193 {
4194 - case IPC_INFO:
4195 case IPC_STAT:
4196 case SHM_STAT:
4197 case SHM_STAT_ANY:
4198 @@ -168,8 +174,15 @@ __shmctl (int shmid, int cmd, struct shmid_ds *buf)
4199 struct __shmid64_ds shmid64, *buf64 = NULL;
4200 if (buf != NULL)
4201 {
4202 - shmid_to_shmid64 (&shmid64, buf);
4203 - buf64 = &shmid64;
4204 + /* This is a Linux extension where kernel expects either a
4205 + 'struct shminfo' (IPC_INFO) or 'struct shm_info' (SHM_INFO). */
4206 + if (cmd == IPC_INFO || cmd == SHM_INFO)
4207 + buf64 = (struct __shmid64_ds *) buf;
4208 + else
4209 + {
4210 + shmid_to_shmid64 (&shmid64, buf);
4211 + buf64 = &shmid64;
4212 + }
4213 }
4214
4215 int ret = __shmctl64 (shmid, cmd, buf64);
4216 @@ -178,7 +191,6 @@ __shmctl (int shmid, int cmd, struct shmid_ds *buf)
4217
4218 switch (cmd)
4219 {
4220 - case IPC_INFO:
4221 case IPC_STAT:
4222 case SHM_STAT:
4223 case SHM_STAT_ANY:
4224 diff --git a/sysdeps/unix/sysv/linux/tst-sysvmsg-linux.c b/sysdeps/unix/sysv/linux/tst-sysvmsg-linux.c
4225 new file mode 100644
4226 index 0000000000..630f4f792c
4227 --- /dev/null
4228 +++ b/sysdeps/unix/sysv/linux/tst-sysvmsg-linux.c
4229 @@ -0,0 +1,177 @@
4230 +/* Basic tests for Linux SYSV message queue extensions.
4231 + Copyright (C) 2020 Free Software Foundation, Inc.
4232 + This file is part of the GNU C Library.
4233 +
4234 + The GNU C Library is free software; you can redistribute it and/or
4235 + modify it under the terms of the GNU Lesser General Public
4236 + License as published by the Free Software Foundation; either
4237 + version 2.1 of the License, or (at your option) any later version.
4238 +
4239 + The GNU C Library is distributed in the hope that it will be useful,
4240 + but WITHOUT ANY WARRANTY; without even the implied warranty of
4241 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4242 + Lesser General Public License for more details.
4243 +
4244 + You should have received a copy of the GNU Lesser General Public
4245 + License along with the GNU C Library; if not, see
4246 + <https://www.gnu.org/licenses/>. */
4247 +
4248 +#include <sys/ipc.h>
4249 +#include <sys/msg.h>
4250 +#include <errno.h>
4251 +#include <stdlib.h>
4252 +#include <stdbool.h>
4253 +#include <stdio.h>
4254 +
4255 +#include <support/check.h>
4256 +#include <support/temp_file.h>
4257 +
4258 +#define MSGQ_MODE 0644
4259 +
4260 +/* These are for the temporary file we generate. */
4261 +static char *name;
4262 +static int msqid;
4263 +
4264 +static void
4265 +remove_msq (void)
4266 +{
4267 + /* Enforce message queue removal in case of early test failure.
4268 + Ignore error since the msg may already have being removed. */
4269 + msgctl (msqid, IPC_RMID, NULL);
4270 +}
4271 +
4272 +static void
4273 +do_prepare (int argc, char *argv[])
4274 +{
4275 + TEST_VERIFY_EXIT (create_temp_file ("tst-sysvmsg.", &name) != -1);
4276 +}
4277 +
4278 +#define PREPARE do_prepare
4279 +
4280 +struct test_msginfo
4281 +{
4282 + int msgmax;
4283 + int msgmnb;
4284 + int msgmni;
4285 +};
4286 +
4287 +/* It tries to obtain some system-wide SysV messsage queue information from
4288 + /proc to check against IPC_INFO/MSG_INFO. The /proc only returns the
4289 + tunables value of MSGMAX, MSGMNB, and MSGMNI.
4290 +
4291 + The kernel also returns constant value for MSGSSZ, MSGSEG and also MSGMAP,
4292 + MSGPOOL, and MSGTQL (for IPC_INFO). The issue to check them is they might
4293 + change over kernel releases. */
4294 +
4295 +static int
4296 +read_proc_file (const char *file)
4297 +{
4298 + FILE *f = fopen (file, "r");
4299 + if (f == NULL)
4300 + FAIL_UNSUPPORTED ("/proc is not mounted or %s is not available", file);
4301 +
4302 + int v;
4303 + int r = fscanf (f, "%d", & v);
4304 + TEST_VERIFY_EXIT (r == 1);
4305 +
4306 + fclose (f);
4307 + return v;
4308 +}
4309 +
4310 +
4311 +/* Check if the message queue with IDX (index into the kernel's internal
4312 + array) matches the one with KEY. The CMD is either MSG_STAT or
4313 + MSG_STAT_ANY. */
4314 +
4315 +static bool
4316 +check_msginfo (int idx, key_t key, int cmd)
4317 +{
4318 + struct msqid_ds msginfo;
4319 + int mid = msgctl (idx, cmd, &msginfo);
4320 + /* Ignore unused array slot returned by the kernel or information from
4321 + unknown message queue. */
4322 + if ((mid == -1 && errno == EINVAL) || mid != msqid)
4323 + return false;
4324 +
4325 + if (mid == -1)
4326 + FAIL_EXIT1 ("msgctl with %s failed: %m",
4327 + cmd == MSG_STAT ? "MSG_STAT" : "MSG_STAT_ANY");
4328 +
4329 + TEST_COMPARE (msginfo.msg_perm.__key, key);
4330 + TEST_COMPARE (msginfo.msg_perm.mode, MSGQ_MODE);
4331 + TEST_COMPARE (msginfo.msg_qnum, 0);
4332 +
4333 + return true;
4334 +}
4335 +
4336 +static int
4337 +do_test (void)
4338 +{
4339 + atexit (remove_msq);
4340 +
4341 + key_t key = ftok (name, 'G');
4342 + if (key == -1)
4343 + FAIL_EXIT1 ("ftok failed: %m");
4344 +
4345 + msqid = msgget (key, MSGQ_MODE | IPC_CREAT);
4346 + if (msqid == -1)
4347 + FAIL_EXIT1 ("msgget failed: %m");
4348 +
4349 + struct test_msginfo tipcinfo;
4350 + tipcinfo.msgmax = read_proc_file ("/proc/sys/kernel/msgmax");
4351 + tipcinfo.msgmnb = read_proc_file ("/proc/sys/kernel/msgmnb");
4352 + tipcinfo.msgmni = read_proc_file ("/proc/sys/kernel/msgmni");
4353 +
4354 + int msqidx;
4355 +
4356 + {
4357 + struct msginfo ipcinfo;
4358 + msqidx = msgctl (msqid, IPC_INFO, (struct msqid_ds *) &ipcinfo);
4359 + if (msqidx == -1)
4360 + FAIL_EXIT1 ("msgctl with IPC_INFO failed: %m");
4361 +
4362 + TEST_COMPARE (ipcinfo.msgmax, tipcinfo.msgmax);
4363 + TEST_COMPARE (ipcinfo.msgmnb, tipcinfo.msgmnb);
4364 + TEST_COMPARE (ipcinfo.msgmni, tipcinfo.msgmni);
4365 + }
4366 +
4367 + /* Same as before but with MSG_INFO. */
4368 + {
4369 + struct msginfo ipcinfo;
4370 + msqidx = msgctl (msqid, MSG_INFO, (struct msqid_ds *) &ipcinfo);
4371 + if (msqidx == -1)
4372 + FAIL_EXIT1 ("msgctl with IPC_INFO failed: %m");
4373 +
4374 + TEST_COMPARE (ipcinfo.msgmax, tipcinfo.msgmax);
4375 + TEST_COMPARE (ipcinfo.msgmnb, tipcinfo.msgmnb);
4376 + TEST_COMPARE (ipcinfo.msgmni, tipcinfo.msgmni);
4377 + }
4378 +
4379 + /* We check if the created message queue shows in global list. */
4380 + bool found = false;
4381 + for (int i = 0; i <= msqidx; i++)
4382 + {
4383 + /* We can't tell apart if MSG_STAT_ANY is not supported (kernel older
4384 + than 4.17) or if the index used is invalid. So it just check if the
4385 + value returned from a valid call matches the created message
4386 + queue. */
4387 + check_msginfo (i, key, MSG_STAT_ANY);
4388 +
4389 + if (check_msginfo (i, key, MSG_STAT))
4390 + {
4391 + found = true;
4392 + break;
4393 + }
4394 + }
4395 +
4396 + if (!found)
4397 + FAIL_EXIT1 ("msgctl with MSG_STAT/MSG_STAT_ANY could not find the "
4398 + "created message queue");
4399 +
4400 + if (msgctl (msqid, IPC_RMID, NULL) == -1)
4401 + FAIL_EXIT1 ("msgctl failed");
4402 +
4403 + return 0;
4404 +}
4405 +
4406 +#include <support/test-driver.c>
4407 diff --git a/sysdeps/unix/sysv/linux/tst-sysvsem-linux.c b/sysdeps/unix/sysv/linux/tst-sysvsem-linux.c
4408 new file mode 100644
4409 index 0000000000..45f19e2d37
4410 --- /dev/null
4411 +++ b/sysdeps/unix/sysv/linux/tst-sysvsem-linux.c
4412 @@ -0,0 +1,184 @@
4413 +/* Basic tests for Linux SYSV semaphore extensions.
4414 + Copyright (C) 2020 Free Software Foundation, Inc.
4415 + This file is part of the GNU C Library.
4416 +
4417 + The GNU C Library is free software; you can redistribute it and/or
4418 + modify it under the terms of the GNU Lesser General Public
4419 + License as published by the Free Software Foundation; either
4420 + version 2.1 of the License, or (at your option) any later version.
4421 +
4422 + The GNU C Library is distributed in the hope that it will be useful,
4423 + but WITHOUT ANY WARRANTY; without even the implied warranty of
4424 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4425 + Lesser General Public License for more details.
4426 +
4427 + You should have received a copy of the GNU Lesser General Public
4428 + License along with the GNU C Library; if not, see
4429 + <https://www.gnu.org/licenses/>. */
4430 +
4431 +#include <sys/ipc.h>
4432 +#include <sys/sem.h>
4433 +#include <errno.h>
4434 +#include <stdlib.h>
4435 +#include <stdbool.h>
4436 +#include <stdio.h>
4437 +
4438 +#include <support/check.h>
4439 +#include <support/temp_file.h>
4440 +
4441 +/* These are for the temporary file we generate. */
4442 +static char *name;
4443 +static int semid;
4444 +
4445 +static void
4446 +remove_sem (void)
4447 +{
4448 + /* Enforce message queue removal in case of early test failure.
4449 + Ignore error since the sem may already have being removed. */
4450 + semctl (semid, 0, IPC_RMID, 0);
4451 +}
4452 +
4453 +static void
4454 +do_prepare (int argc, char *argv[])
4455 +{
4456 + TEST_VERIFY_EXIT (create_temp_file ("tst-sysvsem.", &name) != -1);
4457 +}
4458 +
4459 +#define PREPARE do_prepare
4460 +
4461 +#define SEM_MODE 0644
4462 +
4463 +union semun
4464 +{
4465 + int val;
4466 + struct semid_ds *buf;
4467 + unsigned short *array;
4468 + struct seminfo *__buf;
4469 +};
4470 +
4471 +struct test_seminfo
4472 +{
4473 + int semmsl;
4474 + int semmns;
4475 + int semopm;
4476 + int semmni;
4477 +};
4478 +
4479 +/* It tries to obtain some system-wide SysV semaphore information from /proc
4480 + to check against IPC_INFO/SEM_INFO. The /proc only returns the tunables
4481 + value of SEMMSL, SEMMNS, SEMOPM, and SEMMNI.
4482 +
4483 + The kernel also returns constant value for SEMVMX, SEMMNU, SEMMAP, SEMUME,
4484 + and also SEMUSZ and SEMAEM (for IPC_INFO). The issue to check them is they
4485 + might change over kernel releases. */
4486 +
4487 +static void
4488 +read_sem_stat (struct test_seminfo *tseminfo)
4489 +{
4490 + FILE *f = fopen ("/proc/sys/kernel/sem", "r");
4491 + if (f == NULL)
4492 + FAIL_UNSUPPORTED ("/proc is not mounted or /proc/sys/kernel/sem is not "
4493 + "available");
4494 +
4495 + int r = fscanf (f, "%d %d %d %d",
4496 + &tseminfo->semmsl, &tseminfo->semmns, &tseminfo->semopm,
4497 + &tseminfo->semmni);
4498 + TEST_VERIFY_EXIT (r == 4);
4499 +
4500 + fclose (f);
4501 +}
4502 +
4503 +
4504 +/* Check if the semaphore with IDX (index into the kernel's internal array)
4505 + matches the one with KEY. The CMD is either SEM_STAT or SEM_STAT_ANY. */
4506 +
4507 +static bool
4508 +check_seminfo (int idx, key_t key, int cmd)
4509 +{
4510 + struct semid_ds seminfo;
4511 + int sid = semctl (idx, 0, cmd, (union semun) { .buf = &seminfo });
4512 + /* Ignore unused array slot returned by the kernel or information from
4513 + unknown semaphores. */
4514 + if ((sid == -1 && errno == EINVAL) || sid != semid)
4515 + return false;
4516 +
4517 + if (sid == -1)
4518 + FAIL_EXIT1 ("semctl with SEM_STAT failed (errno=%d)", errno);
4519 +
4520 + TEST_COMPARE (seminfo.sem_perm.__key, key);
4521 + TEST_COMPARE (seminfo.sem_perm.mode, SEM_MODE);
4522 + TEST_COMPARE (seminfo.sem_nsems, 1);
4523 +
4524 + return true;
4525 +}
4526 +
4527 +static int
4528 +do_test (void)
4529 +{
4530 + atexit (remove_sem);
4531 +
4532 + key_t key = ftok (name, 'G');
4533 + if (key == -1)
4534 + FAIL_EXIT1 ("ftok failed: %m");
4535 +
4536 + semid = semget (key, 1, IPC_CREAT | IPC_EXCL | SEM_MODE);
4537 + if (semid == -1)
4538 + FAIL_EXIT1 ("semget failed: %m");
4539 +
4540 + struct test_seminfo tipcinfo;
4541 + read_sem_stat (&tipcinfo);
4542 +
4543 + int semidx;
4544 +
4545 + {
4546 + struct seminfo ipcinfo;
4547 + semidx = semctl (semid, 0, IPC_INFO, (union semun) { .__buf = &ipcinfo });
4548 + if (semidx == -1)
4549 + FAIL_EXIT1 ("semctl with IPC_INFO failed: %m");
4550 +
4551 + TEST_COMPARE (ipcinfo.semmsl, tipcinfo.semmsl);
4552 + TEST_COMPARE (ipcinfo.semmns, tipcinfo.semmns);
4553 + TEST_COMPARE (ipcinfo.semopm, tipcinfo.semopm);
4554 + TEST_COMPARE (ipcinfo.semmni, tipcinfo.semmni);
4555 + }
4556 +
4557 + /* Same as before but with SEM_INFO. */
4558 + {
4559 + struct seminfo ipcinfo;
4560 + semidx = semctl (semid, 0, SEM_INFO, (union semun) { .__buf = &ipcinfo });
4561 + if (semidx == -1)
4562 + FAIL_EXIT1 ("semctl with IPC_INFO failed: %m");
4563 +
4564 + TEST_COMPARE (ipcinfo.semmsl, tipcinfo.semmsl);
4565 + TEST_COMPARE (ipcinfo.semmns, tipcinfo.semmns);
4566 + TEST_COMPARE (ipcinfo.semopm, tipcinfo.semopm);
4567 + TEST_COMPARE (ipcinfo.semmni, tipcinfo.semmni);
4568 + }
4569 +
4570 + /* We check if the created semaphore shows in the system-wide status. */
4571 + bool found = false;
4572 + for (int i = 0; i <= semidx; i++)
4573 + {
4574 + /* We can't tell apart if SEM_STAT_ANY is not supported (kernel older
4575 + than 4.17) or if the index used is invalid. So it just check if
4576 + value returned from a valid call matches the created semaphore. */
4577 + check_seminfo (i, key, SEM_STAT_ANY);
4578 +
4579 + if (check_seminfo (i, key, SEM_STAT))
4580 + {
4581 + found = true;
4582 + break;
4583 + }
4584 + }
4585 +
4586 + if (!found)
4587 + FAIL_EXIT1 ("semctl with SEM_STAT/SEM_STAT_ANY could not find the "
4588 + "created semaphore");
4589 +
4590 + if (semctl (semid, 0, IPC_RMID, 0) == -1)
4591 + FAIL_EXIT1 ("semctl failed: %m");
4592 +
4593 + return 0;
4594 +}
4595 +
4596 +#include <support/test-driver.c>
4597 diff --git a/sysdeps/unix/sysv/linux/tst-sysvshm-linux.c b/sysdeps/unix/sysv/linux/tst-sysvshm-linux.c
4598 new file mode 100644
4599 index 0000000000..7128ae2e14
4600 --- /dev/null
4601 +++ b/sysdeps/unix/sysv/linux/tst-sysvshm-linux.c
4602 @@ -0,0 +1,185 @@
4603 +/* Basic tests for Linux SYSV shared memory extensions.
4604 + Copyright (C) 2020 Free Software Foundation, Inc.
4605 + This file is part of the GNU C Library.
4606 +
4607 + The GNU C Library is free software; you can redistribute it and/or
4608 + modify it under the terms of the GNU Lesser General Public
4609 + License as published by the Free Software Foundation; either
4610 + version 2.1 of the License, or (at your option) any later version.
4611 +
4612 + The GNU C Library is distributed in the hope that it will be useful,
4613 + but WITHOUT ANY WARRANTY; without even the implied warranty of
4614 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4615 + Lesser General Public License for more details.
4616 +
4617 + You should have received a copy of the GNU Lesser General Public
4618 + License along with the GNU C Library; if not, see
4619 + <https://www.gnu.org/licenses/>. */
4620 +
4621 +#include <sys/ipc.h>
4622 +#include <sys/shm.h>
4623 +#include <errno.h>
4624 +#include <stdlib.h>
4625 +#include <stdbool.h>
4626 +#include <stdio.h>
4627 +#include <unistd.h>
4628 +#include <inttypes.h>
4629 +#include <limits.h>
4630 +
4631 +#include <support/check.h>
4632 +#include <support/temp_file.h>
4633 +
4634 +#define SHM_MODE 0644
4635 +
4636 +/* These are for the temporary file we generate. */
4637 +static char *name;
4638 +static int shmid;
4639 +static long int pgsz;
4640 +
4641 +static void
4642 +remove_shm (void)
4643 +{
4644 + /* Enforce message queue removal in case of early test failure.
4645 + Ignore error since the shm may already have being removed. */
4646 + shmctl (shmid, IPC_RMID, NULL);
4647 +}
4648 +
4649 +static void
4650 +do_prepare (int argc, char *argv[])
4651 +{
4652 + TEST_VERIFY_EXIT (create_temp_file ("tst-sysvshm.", &name) != -1);
4653 +}
4654 +
4655 +#define PREPARE do_prepare
4656 +
4657 +struct test_shminfo
4658 +{
4659 + unsigned long int shmall;
4660 + unsigned long int shmmax;
4661 + unsigned long int shmmni;
4662 +};
4663 +
4664 +/* It tries to obtain some system-wide SysV shared memory information from
4665 + /proc to check against IPC_INFO/SHM_INFO. The /proc only returns the
4666 + tunables value of SHMALL, SHMMAX, and SHMMNI. */
4667 +
4668 +static uint64_t
4669 +read_proc_file (const char *file)
4670 +{
4671 + FILE *f = fopen (file, "r");
4672 + if (f == NULL)
4673 + FAIL_UNSUPPORTED ("/proc is not mounted or %s is not available", file);
4674 +
4675 + /* Handle 32-bit binaries running on 64-bit kernels. */
4676 + uint64_t v;
4677 + int r = fscanf (f, "%" SCNu64, &v);
4678 + TEST_VERIFY_EXIT (r == 1);
4679 +
4680 + fclose (f);
4681 + return v;
4682 +}
4683 +
4684 +
4685 +/* Check if the message queue with IDX (index into the kernel's internal
4686 + array) matches the one with KEY. The CMD is either SHM_STAT or
4687 + SHM_STAT_ANY. */
4688 +
4689 +static bool
4690 +check_shminfo (int idx, key_t key, int cmd)
4691 +{
4692 + struct shmid_ds shminfo;
4693 + int sid = shmctl (idx, cmd, &shminfo);
4694 + /* Ignore unused array slot returned by the kernel or information from
4695 + unknown message queue. */
4696 + if ((sid == -1 && errno == EINVAL) || sid != shmid)
4697 + return false;
4698 +
4699 + if (sid == -1)
4700 + FAIL_EXIT1 ("shmctl with %s failed: %m",
4701 + cmd == SHM_STAT ? "SHM_STAT" : "SHM_STAT_ANY");
4702 +
4703 + TEST_COMPARE (shminfo.shm_perm.__key, key);
4704 + TEST_COMPARE (shminfo.shm_perm.mode, SHM_MODE);
4705 + TEST_COMPARE (shminfo.shm_segsz, pgsz);
4706 +
4707 + return true;
4708 +}
4709 +
4710 +static int
4711 +do_test (void)
4712 +{
4713 + atexit (remove_shm);
4714 +
4715 + pgsz = sysconf (_SC_PAGESIZE);
4716 + if (pgsz == -1)
4717 + FAIL_EXIT1 ("sysconf (_SC_PAGESIZE) failed: %m");
4718 +
4719 + key_t key = ftok (name, 'G');
4720 + if (key == -1)
4721 + FAIL_EXIT1 ("ftok failed: %m");
4722 +
4723 + shmid = shmget (key, pgsz, IPC_CREAT | IPC_EXCL | SHM_MODE);
4724 + if (shmid == -1)
4725 + FAIL_EXIT1 ("shmget failed: %m");
4726 +
4727 + struct test_shminfo tipcinfo;
4728 + {
4729 + uint64_t v = read_proc_file ("/proc/sys/kernel/shmmax");
4730 +#if LONG_MAX == INT_MAX
4731 + /* Kernel explicit clamp the value for shmmax on compat symbol (32-bit
4732 + binaries running on 64-bit kernels). */
4733 + if (v > INT_MAX)
4734 + v = INT_MAX;
4735 +#endif
4736 + tipcinfo.shmmax = v;
4737 + }
4738 + tipcinfo.shmall = read_proc_file ("/proc/sys/kernel/shmall");
4739 + tipcinfo.shmmni = read_proc_file ("/proc/sys/kernel/shmmni");
4740 +
4741 + int shmidx;
4742 +
4743 + /* Note: SHM_INFO does not return a shminfo, but rather a 'struct shm_info'.
4744 + It is tricky to verify its values since the syscall returns system wide
4745 + resources consumed by shared memory. The shmctl implementation handles
4746 + SHM_INFO as IPC_INFO, so the IPC_INFO test should validate SHM_INFO as
4747 + well. */
4748 +
4749 + {
4750 + struct shminfo ipcinfo;
4751 + shmidx = shmctl (shmid, IPC_INFO, (struct shmid_ds *) &ipcinfo);
4752 + if (shmidx == -1)
4753 + FAIL_EXIT1 ("shmctl with IPC_INFO failed: %m");
4754 +
4755 + TEST_COMPARE (ipcinfo.shmall, tipcinfo.shmall);
4756 + TEST_COMPARE (ipcinfo.shmmax, tipcinfo.shmmax);
4757 + TEST_COMPARE (ipcinfo.shmmni, tipcinfo.shmmni);
4758 + }
4759 +
4760 + /* We check if the created shared memory shows in the global list. */
4761 + bool found = false;
4762 + for (int i = 0; i <= shmidx; i++)
4763 + {
4764 + /* We can't tell apart if SHM_STAT_ANY is not supported (kernel older
4765 + than 4.17) or if the index used is invalid. So it just check if
4766 + value returned from a valid call matches the created message
4767 + queue. */
4768 + check_shminfo (i, key, SHM_STAT_ANY);
4769 +
4770 + if (check_shminfo (i, key, SHM_STAT))
4771 + {
4772 + found = true;
4773 + break;
4774 + }
4775 + }
4776 +
4777 + if (!found)
4778 + FAIL_EXIT1 ("shmctl with SHM_STAT/SHM_STAT_ANY could not find the "
4779 + "created shared memory");
4780 +
4781 + if (shmctl (shmid, IPC_RMID, NULL) == -1)
4782 + FAIL_EXIT1 ("shmctl failed");
4783 +
4784 + return 0;
4785 +}
4786 +
4787 +#include <support/test-driver.c>
4788 diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
4789 index a6736aef25..9736a13e7b 100644
4790 --- a/sysdeps/x86/Makefile
4791 +++ b/sysdeps/x86/Makefile
4792 @@ -12,6 +12,12 @@ endif
4793 ifeq ($(subdir),setjmp)
4794 gen-as-const-headers += jmp_buf-ssp.sym
4795 sysdep_routines += __longjmp_cancel
4796 +ifneq ($(enable-cet),no)
4797 +ifneq ($(have-tunables),no)
4798 +tests += tst-setjmp-cet
4799 +tst-setjmp-cet-ENV = GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on
4800 +endif
4801 +endif
4802 endif
4803
4804 ifeq ($(subdir),string)
4805 diff --git a/sysdeps/x86/cacheinfo.c b/sysdeps/x86/cacheinfo.c
4806 index 217c21c34f..3fb4a028d8 100644
4807 --- a/sysdeps/x86/cacheinfo.c
4808 +++ b/sysdeps/x86/cacheinfo.c
4809 @@ -808,7 +808,7 @@ init_cacheinfo (void)
4810 threads = 1 << ((ecx >> 12) & 0x0f);
4811 }
4812
4813 - if (threads == 0)
4814 + if (threads == 0 || cpu_features->basic.family >= 0x17)
4815 {
4816 /* If APIC ID width is not available, use logical
4817 processor count. */
4818 @@ -823,8 +823,22 @@ init_cacheinfo (void)
4819 if (threads > 0)
4820 shared /= threads;
4821
4822 - /* Account for exclusive L2 and L3 caches. */
4823 - shared += core;
4824 + /* Get shared cache per ccx for Zen architectures. */
4825 + if (cpu_features->basic.family >= 0x17)
4826 + {
4827 + unsigned int eax;
4828 +
4829 + /* Get number of threads share the L3 cache in CCX. */
4830 + __cpuid_count (0x8000001D, 0x3, eax, ebx, ecx, edx);
4831 +
4832 + unsigned int threads_per_ccx = ((eax >> 14) & 0xfff) + 1;
4833 + shared *= threads_per_ccx;
4834 + }
4835 + else
4836 + {
4837 + /* Account for exclusive L2 and L3 caches. */
4838 + shared += core;
4839 + }
4840 }
4841 }
4842
4843 @@ -854,14 +868,20 @@ init_cacheinfo (void)
4844 __x86_shared_cache_size = shared;
4845 }
4846
4847 - /* The large memcpy micro benchmark in glibc shows that 6 times of
4848 - shared cache size is the approximate value above which non-temporal
4849 - store becomes faster on a 8-core processor. This is the 3/4 of the
4850 - total shared cache size. */
4851 + /* The default setting for the non_temporal threshold is 3/4 of one
4852 + thread's share of the chip's cache. For most Intel and AMD processors
4853 + with an initial release date between 2017 and 2020, a thread's typical
4854 + share of the cache is from 500 KBytes to 2 MBytes. Using the 3/4
4855 + threshold leaves 125 KBytes to 500 KBytes of the thread's data
4856 + in cache after a maximum temporal copy, which will maintain
4857 + in cache a reasonable portion of the thread's stack and other
4858 + active data. If the threshold is set higher than one thread's
4859 + share of the cache, it has a substantial risk of negatively
4860 + impacting the performance of other threads running on the chip. */
4861 __x86_shared_non_temporal_threshold
4862 = (cpu_features->non_temporal_threshold != 0
4863 ? cpu_features->non_temporal_threshold
4864 - : __x86_shared_cache_size * threads * 3 / 4);
4865 + : __x86_shared_cache_size * 3 / 4);
4866
4867 /* NB: The REP MOVSB threshold must be greater than VEC_SIZE * 8. */
4868 unsigned int minimum_rep_movsb_threshold;
4869 diff --git a/sysdeps/x86/dl-cet.c b/sysdeps/x86/dl-cet.c
4870 index 03572f7af6..3cc54a8d53 100644
4871 --- a/sysdeps/x86/dl-cet.c
4872 +++ b/sysdeps/x86/dl-cet.c
4873 @@ -47,7 +47,10 @@ dl_cet_check (struct link_map *m, const char *program)
4874 /* No legacy object check if both IBT and SHSTK are always on. */
4875 if (enable_ibt_type == cet_always_on
4876 && enable_shstk_type == cet_always_on)
4877 - return;
4878 + {
4879 + THREAD_SETMEM (THREAD_SELF, header.feature_1, GL(dl_x86_feature_1));
4880 + return;
4881 + }
4882
4883 /* Check if IBT is enabled by kernel. */
4884 bool ibt_enabled
4885 diff --git a/sysdeps/x86/dl-prop.h b/sysdeps/x86/dl-prop.h
4886 index 89911e19e2..4eb3b85a7b 100644
4887 --- a/sysdeps/x86/dl-prop.h
4888 +++ b/sysdeps/x86/dl-prop.h
4889 @@ -145,15 +145,15 @@ _dl_process_cet_property_note (struct link_map *l,
4890 }
4891
4892 static inline void __attribute__ ((unused))
4893 -_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph)
4894 +_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph)
4895 {
4896 const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr);
4897 _dl_process_cet_property_note (l, note, ph->p_memsz, ph->p_align);
4898 }
4899
4900 static inline int __attribute__ ((always_inline))
4901 -_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz,
4902 - void *data)
4903 +_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
4904 + uint32_t datasz, void *data)
4905 {
4906 return 0;
4907 }
4908 diff --git a/sysdeps/x86/tst-setjmp-cet.c b/sysdeps/x86/tst-setjmp-cet.c
4909 new file mode 100644
4910 index 0000000000..42c795d2a8
4911 --- /dev/null
4912 +++ b/sysdeps/x86/tst-setjmp-cet.c
4913 @@ -0,0 +1 @@
4914 +#include <setjmp/tst-setjmp.c>
4915 diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
4916 index ca73d8fef9..363a749cb2 100644
4917 --- a/sysdeps/x86_64/dl-machine.h
4918 +++ b/sysdeps/x86_64/dl-machine.h
4919 @@ -315,16 +315,22 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
4920 {
4921 # ifndef RTLD_BOOTSTRAP
4922 if (sym_map != map
4923 - && sym_map->l_type != lt_executable
4924 && !sym_map->l_relocated)
4925 {
4926 const char *strtab
4927 = (const char *) D_PTR (map, l_info[DT_STRTAB]);
4928 - _dl_error_printf ("\
4929 + if (sym_map->l_type == lt_executable)
4930 + _dl_fatal_printf ("\
4931 +%s: IFUNC symbol '%s' referenced in '%s' is defined in the executable \
4932 +and creates an unsatisfiable circular dependency.\n",
4933 + RTLD_PROGNAME, strtab + refsym->st_name,
4934 + map->l_name);
4935 + else
4936 + _dl_error_printf ("\
4937 %s: Relink `%s' with `%s' for IFUNC symbol `%s'\n",
4938 - RTLD_PROGNAME, map->l_name,
4939 - sym_map->l_name,
4940 - strtab + refsym->st_name);
4941 + RTLD_PROGNAME, map->l_name,
4942 + sym_map->l_name,
4943 + strtab + refsym->st_name);
4944 }
4945 # endif
4946 value = ((ElfW(Addr) (*) (void)) value) ();
4947 diff --git a/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h b/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h
4948 index 7659758972..e5fd5ac9cb 100644
4949 --- a/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h
4950 +++ b/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h
4951 @@ -32,7 +32,7 @@ IFUNC_SELECTOR (void)
4952 && CPU_FEATURE_USABLE_P (cpu_features, AVX2))
4953 return OPTIMIZE (fma);
4954
4955 - if (CPU_FEATURE_USABLE_P (cpu_features, FMA))
4956 + if (CPU_FEATURE_USABLE_P (cpu_features, FMA4))
4957 return OPTIMIZE (fma4);
4958
4959 return OPTIMIZE (sse2);
4960 diff --git a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
4961 index bd5dc1a3f3..092f364bb6 100644
4962 --- a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
4963 +++ b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
4964 @@ -56,6 +56,13 @@
4965 # endif
4966 #endif
4967
4968 +/* Avoid short distance rep movsb only with non-SSE vector. */
4969 +#ifndef AVOID_SHORT_DISTANCE_REP_MOVSB
4970 +# define AVOID_SHORT_DISTANCE_REP_MOVSB (VEC_SIZE > 16)
4971 +#else
4972 +# define AVOID_SHORT_DISTANCE_REP_MOVSB 0
4973 +#endif
4974 +
4975 #ifndef PREFETCH
4976 # define PREFETCH(addr) prefetcht0 addr
4977 #endif
4978 @@ -243,7 +250,21 @@ L(movsb):
4979 cmpq %r9, %rdi
4980 /* Avoid slow backward REP MOVSB. */
4981 jb L(more_8x_vec_backward)
4982 +# if AVOID_SHORT_DISTANCE_REP_MOVSB
4983 + movq %rdi, %rcx
4984 + subq %rsi, %rcx
4985 + jmp 2f
4986 +# endif
4987 1:
4988 +# if AVOID_SHORT_DISTANCE_REP_MOVSB
4989 + movq %rsi, %rcx
4990 + subq %rdi, %rcx
4991 +2:
4992 +/* Avoid "rep movsb" if RCX, the distance between source and destination,
4993 + is N*4GB + [1..63] with N >= 0. */
4994 + cmpl $63, %ecx
4995 + jbe L(more_2x_vec) /* Avoid "rep movsb" if ECX <= 63. */
4996 +# endif
4997 mov %RDX_LP, %RCX_LP
4998 rep movsb
4999 L(nop):
5000 diff --git a/sysvipc/test-sysvsem.c b/sysvipc/test-sysvsem.c
5001 index 01dbff343a..b7284e0b48 100644
5002 --- a/sysvipc/test-sysvsem.c
5003 +++ b/sysvipc/test-sysvsem.c
5004 @@ -20,6 +20,7 @@
5005 #include <stdlib.h>
5006 #include <errno.h>
5007 #include <string.h>
5008 +#include <stdbool.h>
5009 #include <sys/types.h>
5010 #include <sys/ipc.h>
5011 #include <sys/sem.h>
5012 diff --git a/version.h b/version.h
5013 index 83cd196798..e6ca7a8857 100644
5014 --- a/version.h
5015 +++ b/version.h
5016 @@ -1,4 +1,4 @@
5017 /* This file just defines the current version number of libc. */
5018
5019 -#define RELEASE "release"
5020 +#define RELEASE "stable"
5021 #define VERSION "2.32"
5022 diff --git a/sysdeps/unix/sysv/linux/x86_64/64/configure b/sysdeps/unix/sysv/linux/x86_64/64/configure
5023 index 9d298faba7..cef1ec842c 100644
5024 --- a/sysdeps/unix/sysv/linux/x86_64/64/configure
5025 +++ b/sysdeps/unix/sysv/linux/x86_64/64/configure
5026 @@ -4,10 +4,10 @@
5027 test -n "$libc_cv_slibdir" ||
5028 case "$prefix" in
5029 /usr | /usr/)
5030 - libc_cv_slibdir='/lib64'
5031 - libc_cv_rtlddir='/lib64'
5032 + libc_cv_slibdir='/lib'
5033 + libc_cv_rtlddir='/lib'
5034 if test "$libdir" = '${exec_prefix}/lib'; then
5035 - libdir='${exec_prefix}/lib64';
5036 + libdir='${exec_prefix}/lib';
5037 # Locale data can be shared between 32-bit and 64-bit libraries.
5038 libc_cv_complocaledir='${exec_prefix}/lib/locale'
5039 fi
5040 diff --git a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
5041 index 062c04689d..7783757726 100644
5042 --- a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
5043 +++ b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
5044 @@ -18,9 +18,9 @@
5045 #include <sysdeps/generic/ldconfig.h>
5046
5047 #define SYSDEP_KNOWN_INTERPRETER_NAMES \
5048 - { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 }, \
5049 + { "/lib32/ld-linux.so.2", FLAG_ELF_LIBC6 }, \
5050 { "/libx32/ld-linux-x32.so.2", FLAG_ELF_LIBC6 }, \
5051 - { "/lib64/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 },
5052 + { "/lib/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 },
5053 #define SYSDEP_KNOWN_LIBRARY_NAMES \
5054 { "libc.so.6", FLAG_ELF_LIBC6 }, \
5055 { "libm.so.6", FLAG_ELF_LIBC6 },