aboutsummaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog88
-rw-r--r--libiberty/Makefile.in34
-rw-r--r--libiberty/_doprnt.c2
-rw-r--r--libiberty/acinclude.m42
-rw-r--r--libiberty/argv.c2
-rw-r--r--libiberty/asprintf.c2
-rw-r--r--libiberty/choose-temp.c2
-rw-r--r--libiberty/clock.c2
-rw-r--r--libiberty/concat.c2
-rw-r--r--libiberty/config.in6
-rwxr-xr-xlibiberty/configure18
-rw-r--r--libiberty/configure.ac18
-rw-r--r--libiberty/configure.com2
-rw-r--r--libiberty/copying-lib.texi2
-rw-r--r--libiberty/cp-demangle.c6
-rw-r--r--libiberty/cp-demangle.h2
-rw-r--r--libiberty/cp-demint.c2
-rw-r--r--libiberty/cplus-dem.c4
-rw-r--r--libiberty/crc32.c2
-rw-r--r--libiberty/d-demangle.c2
-rw-r--r--libiberty/dwarfnames.c2
-rw-r--r--libiberty/dyn-string.c2
-rw-r--r--libiberty/fdmatch.c2
-rw-r--r--libiberty/fibheap.c2
-rw-r--r--libiberty/filedescriptor.c2
-rw-r--r--libiberty/filename_cmp.c2
-rw-r--r--libiberty/floatformat.c2
-rw-r--r--libiberty/fnmatch.c2
-rw-r--r--libiberty/fopen_unlocked.c2
-rw-r--r--libiberty/functions.texi14
-rw-r--r--libiberty/gather-docs2
-rw-r--r--libiberty/getopt.c8
-rw-r--r--libiberty/getopt1.c2
-rw-r--r--libiberty/getruntime.c2
-rw-r--r--libiberty/hashtab.c2
-rw-r--r--libiberty/hex.c2
-rw-r--r--libiberty/lbasename.c2
-rw-r--r--libiberty/ldirname.c94
-rw-r--r--libiberty/libiberty.texi4
-rw-r--r--libiberty/lrealpath.c2
-rw-r--r--libiberty/maint-tool2
-rw-r--r--libiberty/make-relative-prefix.c2
-rw-r--r--libiberty/make-temp-file.c2
-rw-r--r--libiberty/makefile.vms2
-rw-r--r--libiberty/md5.c2
-rw-r--r--libiberty/memmem.c2
-rw-r--r--libiberty/mempcpy.c2
-rw-r--r--libiberty/memrchr.c33
-rw-r--r--libiberty/mkstemps.c2
-rw-r--r--libiberty/objalloc.c2
-rw-r--r--libiberty/obstack.c2
-rw-r--r--libiberty/partition.c2
-rw-r--r--libiberty/pex-common.c2
-rw-r--r--libiberty/pex-common.h2
-rw-r--r--libiberty/pex-djgpp.c2
-rw-r--r--libiberty/pex-msdos.c2
-rw-r--r--libiberty/pex-one.c2
-rw-r--r--libiberty/pex-unix.c2
-rw-r--r--libiberty/pex-win32.c2
-rw-r--r--libiberty/pexecute.c2
-rw-r--r--libiberty/physmem.c2
-rw-r--r--libiberty/putenv.c2
-rw-r--r--libiberty/regex.c4
-rw-r--r--libiberty/rust-demangle.c2
-rw-r--r--libiberty/safe-ctype.c2
-rw-r--r--libiberty/setenv.c2
-rw-r--r--libiberty/setproctitle.c2
-rw-r--r--libiberty/sha1.c2
-rw-r--r--libiberty/simple-object-coff.c6
-rw-r--r--libiberty/simple-object-common.h2
-rw-r--r--libiberty/simple-object-elf.c212
-rw-r--r--libiberty/simple-object-mach-o.c2
-rw-r--r--libiberty/simple-object-xcoff.c2
-rw-r--r--libiberty/simple-object.c2
-rw-r--r--libiberty/snprintf.c2
-rw-r--r--libiberty/sort.c2
-rw-r--r--libiberty/spaces.c2
-rw-r--r--libiberty/splay-tree.c2
-rw-r--r--libiberty/stack-limit.c2
-rw-r--r--libiberty/stpcpy.c2
-rw-r--r--libiberty/stpncpy.c2
-rw-r--r--libiberty/strndup.c2
-rw-r--r--libiberty/strtod.c2
-rw-r--r--libiberty/strverscmp.c2
-rw-r--r--libiberty/testsuite/Makefile.in14
-rw-r--r--libiberty/testsuite/demangler-fuzzer.c2
-rw-r--r--libiberty/testsuite/test-demangle.c17
-rw-r--r--libiberty/testsuite/test-doubly-linked-list.c269
-rw-r--r--libiberty/testsuite/test-expandargv.c2
-rw-r--r--libiberty/testsuite/test-pexecute.c2
-rw-r--r--libiberty/testsuite/test-strtol.c2
-rw-r--r--libiberty/timeval-utils.c2
-rw-r--r--libiberty/unlink-if-ordinary.c2
-rw-r--r--libiberty/vasprintf.c2
-rw-r--r--libiberty/vfprintf.c2
-rw-r--r--libiberty/vprintf-support.c2
-rw-r--r--libiberty/vprintf-support.h2
-rw-r--r--libiberty/vsnprintf.c2
-rw-r--r--libiberty/vsprintf.c2
-rw-r--r--libiberty/xasprintf.c2
-rw-r--r--libiberty/xexit.c2
-rw-r--r--libiberty/xmalloc.c2
-rw-r--r--libiberty/xstrndup.c2
-rw-r--r--libiberty/xvasprintf.c2
104 files changed, 817 insertions, 204 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 949fec6..cf90917 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,91 @@
+2025-07-09 Matthieu Longo <matthieu.longo@arm.com>
+
+ * Makefile.in: Add new header.
+ * testsuite/Makefile.in: Add new test.
+ * testsuite/test-doubly-linked-list.c: New test.
+
+2025-05-13 Andreas Schwab <schwab@suse.de>
+
+ * regex.c (regex_compile): Don't write beyond array bounds when
+ collecting range expression.
+
+2025-03-29 Iain Sandoe <iain@sandoe.co.uk>
+
+ PR cobol/119283
+ * Makefile.in: Add memrchr build rules.
+ * config.in: Regenerate.
+ * configure: Regenerate.
+ * configure.ac: Check for memrchr.
+ * functions.texi: Document memrchr.
+ * memrchr.c: New file.
+
+2025-03-25 Iain Sandoe <iain@sandoe.co.uk>
+
+ PR other/119218
+ * config.in: Regenerate.
+ * configure: Regenerate.
+ * configure.ac: Append <libgen.h> to AC_INCLUDES_DEFAULT
+ when checking for the 'basename' decl.
+
+2025-03-18 Jose E. Marchesi <jose.marchesi@oracle.com>
+
+ * ldirname.c: New file.
+ * Makefile.in (CFILES): Add ldirname.c.
+ (REQUIRED_OFILES): Add ldirname.$(objext).
+ (./ldirname.$(objext)): New rule.
+ * makefile.vms (OBJS): Add ldirname.obj.
+ * configure.com (FILES): Add ldirname.
+
+2024-12-11 Matthieu Longo <matthieu.longo@arm.com>
+
+ * configure: Regenerate.
+ * configure.ac: Fix autoupdate warnings.
+
+2024-12-11 Sangamesh Mallayya <swamy.sangamesh@gmail.com>
+
+ * getopt.c: Remove _NO_PROTO block
+
+2024-11-19 Evgeny Karpov <evgeny.karpov@microsoft.com>
+
+ * simple-object-coff.c: Add aarch64.
+
+2024-11-16 Andrew Pinski <quic_apinski@quicinc.com>
+
+ * testsuite/test-demangle.c (get_line): Change K&R style
+ definition into ANSI C90 definitions.
+ (fail): Likewise.
+ (main): Likewise.
+
+2024-10-31 Mark Wielaard <mark@klomp.org>
+
+ * cplus-dem.c: Change preceeded to preceded.
+
+2024-10-10 Simon Martin <simon@nasilyan.com>
+
+ * cp-demangle.c (d_dump): Fix compilation when CP_DEMANGLE_DEBUG
+ is defined.
+
+2024-09-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR lto/116614
+ * simple-object-elf.c (SHN_COMMON): Align comment with neighbouring
+ comments.
+ (SHN_HIRESERVE): Use uppercase hex digits instead of lowercase for
+ consistency.
+ (simple_object_elf_find_sections): Formatting fixes.
+ (simple_object_elf_fetch_attributes): Likewise.
+ (simple_object_elf_attributes_merge): Likewise.
+ (simple_object_elf_start_write): Likewise.
+ (simple_object_elf_write_ehdr): Likewise.
+ (simple_object_elf_write_shdr): Likewise.
+ (simple_object_elf_write_to_file): Likewise.
+ (simple_object_elf_copy_lto_debug_section): Likewise. Don't fail for
+ new_i - 1 >= SHN_LORESERVE, instead arrange in that case to copy
+ over .symtab_shndx sections, though emit those last and compute their
+ section content when processing associated .symtab sections. Handle
+ simple_object_internal_read failure even in the .symtab_shndx reading
+ case.
+
2024-08-05 Andrew Burgess <aburgess@redhat.com>
* argv.c (only_whitespace): Delete.
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 85c4b6b..e4d7d0a 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -1,7 +1,7 @@
# Makefile for the libiberty library.
# Originally written by K. Richard Pixley <rich@cygnus.com>.
#
-# Copyright (C) 1990-2024 Free Software Foundation, Inc.
+# Copyright (C) 1990-2025 Free Software Foundation, Inc.
#
# This file is part of the libiberty library.
# Libiberty is free software; you can redistribute it and/or
@@ -136,10 +136,11 @@ CFILES = alloca.c argv.c asprintf.c atexit.c \
hashtab.c hex.c \
index.c insque.c \
lbasename.c \
+ ldirname.c \
lrealpath.c \
make-relative-prefix.c \
- make-temp-file.c md5.c memchr.c memcmp.c memcpy.c memmem.c \
- memmove.c mempcpy.c memset.c mkstemps.c \
+ make-temp-file.c md5.c memchr.c memrchr.c memcmp.c memcpy.c \
+ memmem.c memmove.c mempcpy.c memset.c mkstemps.c \
objalloc.c obstack.c \
partition.c pexecute.c \
pex-common.c pex-djgpp.c pex-msdos.c pex-one.c \
@@ -179,7 +180,7 @@ REQUIRED_OFILES = \
./fnmatch.$(objext) ./fopen_unlocked.$(objext) \
./getopt.$(objext) ./getopt1.$(objext) ./getpwd.$(objext) \
./getruntime.$(objext) ./hashtab.$(objext) ./hex.$(objext) \
- ./lbasename.$(objext) ./lrealpath.$(objext) \
+ ./lbasename.$(objext) ./ldirname.$(objext) ./lrealpath.$(objext)\
./make-relative-prefix.$(objext) ./make-temp-file.$(objext) \
./objalloc.$(objext) \
./obstack.$(objext) \
@@ -212,8 +213,8 @@ CONFIGURED_OFILES = ./asprintf.$(objext) ./atexit.$(objext) \
./getcwd.$(objext) ./getpagesize.$(objext) \
./gettimeofday.$(objext) \
./index.$(objext) ./insque.$(objext) \
- ./memchr.$(objext) ./memcmp.$(objext) ./memcpy.$(objext) \
- ./memmem.$(objext) ./memmove.$(objext) \
+ ./memchr.$(objext) ./memrchr.$(objext) ./memcmp.$(objext) \
+ ./memcpy.$(objext) ./memmem.$(objext) ./memmove.$(objext) \
./mempcpy.$(objext) ./memset.$(objext) ./mkstemps.$(objext) \
./pex-djgpp.$(objext) ./pex-msdos.$(objext) \
./pex-unix.$(objext) ./pex-win32.$(objext) \
@@ -236,6 +237,7 @@ CONFIGURED_OFILES = ./asprintf.$(objext) ./atexit.$(objext) \
INSTALLED_HEADERS = \
$(INCDIR)/ansidecl.h \
$(INCDIR)/demangle.h \
+ $(INCDIR)/doubly-linked-list.h \
$(INCDIR)/dyn-string.h \
$(INCDIR)/fibheap.h \
$(INCDIR)/floatformat.h \
@@ -965,6 +967,17 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir
else true; fi
$(COMPILE.c) $(srcdir)/lbasename.c $(OUTPUT_OPTION)
+./ldirname.$(objext): $(srcdir)/ldirname.c config.h $(INCDIR)/ansidecl.h \
+ $(INCDIR)/filenames.h $(INCDIR)/hashtab.h $(INCDIR)/libiberty.h \
+ $(INCDIR)/safe-ctype.h
+ if [ x"$(PICFLAG)" != x ]; then \
+ $(COMPILE.c) $(PICFLAG) $(srcdir)/ldirname.c -o pic/$@; \
+ else true; fi
+ if [ x"$(NOASANFLAG)" != x ]; then \
+ $(COMPILE.c) $(PICFLAG) $(NOASANFLAG) $(srcdir)/ldirname.c -o noasan/$@; \
+ else true; fi
+ $(COMPILE.c) $(srcdir)/ldirname.c $(OUTPUT_OPTION)
+
./lrealpath.$(objext): $(srcdir)/lrealpath.c config.h $(INCDIR)/ansidecl.h \
$(INCDIR)/libiberty.h
if [ x"$(PICFLAG)" != x ]; then \
@@ -1013,6 +1026,15 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir
else true; fi
$(COMPILE.c) $(srcdir)/memchr.c $(OUTPUT_OPTION)
+./memrchr.$(objext): $(srcdir)/memrchr.c $(INCDIR)/ansidecl.h
+ if [ x"$(PICFLAG)" != x ]; then \
+ $(COMPILE.c) $(PICFLAG) $(srcdir)/memrchr.c -o pic/$@; \
+ else true; fi
+ if [ x"$(NOASANFLAG)" != x ]; then \
+ $(COMPILE.c) $(PICFLAG) $(NOASANFLAG) $(srcdir)/memrchr.c -o noasan/$@; \
+ else true; fi
+ $(COMPILE.c) $(srcdir)/memrchr.c $(OUTPUT_OPTION)
+
./memcmp.$(objext): $(srcdir)/memcmp.c $(INCDIR)/ansidecl.h
if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.c) $(PICFLAG) $(srcdir)/memcmp.c -o pic/$@; \
diff --git a/libiberty/_doprnt.c b/libiberty/_doprnt.c
index 12c3ac0..46e17f2 100644
--- a/libiberty/_doprnt.c
+++ b/libiberty/_doprnt.c
@@ -1,5 +1,5 @@
/* Provide a version of _doprnt in terms of fprintf.
- Copyright (C) 1998-2024 Free Software Foundation, Inc.
+ Copyright (C) 1998-2025 Free Software Foundation, Inc.
Contributed by Kaveh Ghazi (ghazi@caip.rutgers.edu) 3/29/98
This program is free software; you can redistribute it and/or modify it
diff --git a/libiberty/acinclude.m4 b/libiberty/acinclude.m4
index 9974dcd..1e98d55 100644
--- a/libiberty/acinclude.m4
+++ b/libiberty/acinclude.m4
@@ -1,4 +1,4 @@
-dnl Copyright (C) 2000-2024 Free Software Foundation, Inc.
+dnl Copyright (C) 2000-2025 Free Software Foundation, Inc.
dnl
dnl GCC is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
diff --git a/libiberty/argv.c b/libiberty/argv.c
index f889432..c64db28 100644
--- a/libiberty/argv.c
+++ b/libiberty/argv.c
@@ -1,5 +1,5 @@
/* Create and destroy argument vectors (argv's)
- Copyright (C) 1992-2024 Free Software Foundation, Inc.
+ Copyright (C) 1992-2025 Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support
This file is part of the libiberty library.
diff --git a/libiberty/asprintf.c b/libiberty/asprintf.c
index 48425eb..c542b15 100644
--- a/libiberty/asprintf.c
+++ b/libiberty/asprintf.c
@@ -1,6 +1,6 @@
/* Like sprintf but provides a pointer to malloc'd storage, which must
be freed by the caller.
- Copyright (C) 1997-2024 Free Software Foundation, Inc.
+ Copyright (C) 1997-2025 Free Software Foundation, Inc.
Contributed by Cygnus Solutions.
This file is part of the libiberty library.
diff --git a/libiberty/choose-temp.c b/libiberty/choose-temp.c
index 29a9947..bcc47ad 100644
--- a/libiberty/choose-temp.c
+++ b/libiberty/choose-temp.c
@@ -1,5 +1,5 @@
/* Utility to pick a temporary filename prefix.
- Copyright (C) 1996-2024 Free Software Foundation, Inc.
+ Copyright (C) 1996-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/clock.c b/libiberty/clock.c
index 58d78af..2412045 100644
--- a/libiberty/clock.c
+++ b/libiberty/clock.c
@@ -1,5 +1,5 @@
/* ANSI-compatible clock function.
- Copyright (C) 1994-2024 Free Software Foundation, Inc.
+ Copyright (C) 1994-2025 Free Software Foundation, Inc.
This file is part of the libiberty library. This library is free
software; you can redistribute it and/or modify it under the
diff --git a/libiberty/concat.c b/libiberty/concat.c
index 8686e29..c0aa1f5 100644
--- a/libiberty/concat.c
+++ b/libiberty/concat.c
@@ -1,5 +1,5 @@
/* Concatenate variable number of strings.
- Copyright (C) 1991-2024 Free Software Foundation, Inc.
+ Copyright (C) 1991-2025 Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support
This file is part of the libiberty library.
diff --git a/libiberty/config.in b/libiberty/config.in
index 1b1f2b0..3b87165 100644
--- a/libiberty/config.in
+++ b/libiberty/config.in
@@ -153,6 +153,9 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
+/* Define to 1 if you have the <libgen.h> header file. */
+#undef HAVE_LIBGEN_H
+
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
@@ -183,6 +186,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
diff --git a/libiberty/configure b/libiberty/configure
index 5c69fee..02fbaab 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -4413,7 +4413,6 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
$as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h
-
# Check whether --enable-largefile was given.
if test "${enable_largefile+set}" = set; then :
enableval=$enable_largefile;
@@ -5746,7 +5745,7 @@ host_makefile_frag=${frag}
# It's OK to check for header files. Although the compiler may not be
# able to link anything, it had better be able to at least compile
# something.
-for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h
+for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h libgen.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_preproc "$LINENO" "$ac_header" "$as_ac_Header"
@@ -6211,6 +6210,7 @@ funcs="$funcs gettimeofday"
funcs="$funcs index"
funcs="$funcs insque"
funcs="$funcs memchr"
+funcs="$funcs memrchr"
funcs="$funcs memcmp"
funcs="$funcs memcpy"
funcs="$funcs memmem"
@@ -6277,7 +6277,7 @@ if test "x" = "y"; then
ffs __fsetlocking \
getcwd getpagesize getrlimit getrusage getsysinfo gettimeofday \
index insque \
- memchr memcmp memcpy memmem memmove memset mkstemps \
+ memchr memrchr memcmp memcpy memmem memmove memset mkstemps \
on_exit \
pipe2 posix_spawn posix_spawnp psignal \
pstat_getdynamic pstat_getstatic putenv \
@@ -6692,7 +6692,7 @@ esac
for f in atexit basename bcmp bcopy bsearch bzero calloc clock ffs \
getcwd getpagesize getrusage gettimeofday \
- index insque memchr memcmp memcpy memmove memset psignal \
+ index insque memchr memrchr memcmp memcpy memmove memset psignal \
putenv random rename rindex sbrk setenv stpcpy strcasecmp \
strchr strdup strerror strncasecmp strrchr strstr strtod \
strtol strtoul sysconf times tmpnam vfprintf vprintf \
@@ -7390,7 +7390,12 @@ fi
done
as_ac_Symbol=`$as_echo "ac_cv_have_decl_basename(char *)" | $as_tr_sh`
-ac_fn_c_check_decl "$LINENO" "basename(char *)" "$as_ac_Symbol" "$ac_includes_default"
+ac_fn_c_check_decl "$LINENO" "basename(char *)" "$as_ac_Symbol" "
+$ac_includes_default
+#ifdef HAVE_LIBGEN_H
+# include <libgen.h>
+#endif
+"
if eval test \"x\$"$as_ac_Symbol"\" = x"yes"; then :
ac_have_decl=1
else
@@ -7400,7 +7405,8 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_BASENAME $ac_have_decl
_ACEOF
-ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "$ac_includes_default"
+
+ ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "$ac_includes_default"
if test "x$ac_cv_have_decl_ffs" = xyes; then :
ac_have_decl=1
else
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index 0888e63..3de5eca 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -172,7 +172,7 @@ AC_MSG_NOTICE([target_header_dir = $target_header_dir])
GCC_NO_EXECUTABLES
AC_PROG_CC
-AC_GNU_SOURCE
+AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE
AC_PROG_CPP_WERROR
@@ -205,7 +205,7 @@ dnl AM_PROG_LIBTOOL
dnl When we start using automake:
dnl AM_CONFIG_HEADER(config.h:config.in)
-AC_CONFIG_HEADER(config.h:config.in)
+AC_CONFIG_HEADERS([config.h:config.in])
dnl When we start using automake:
dnl AM_MAINTAINER_MODE
@@ -291,7 +291,7 @@ AC_SUBST_FILE(host_makefile_frag)
# It's OK to check for header files. Although the compiler may not be
# able to link anything, it had better be able to at least compile
# something.
-AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h)
+AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h libgen.h)
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
@@ -370,6 +370,7 @@ funcs="$funcs gettimeofday"
funcs="$funcs index"
funcs="$funcs insque"
funcs="$funcs memchr"
+funcs="$funcs memrchr"
funcs="$funcs memcmp"
funcs="$funcs memcpy"
funcs="$funcs memmem"
@@ -436,7 +437,7 @@ if test "x" = "y"; then
ffs __fsetlocking \
getcwd getpagesize getrlimit getrusage getsysinfo gettimeofday \
index insque \
- memchr memcmp memcpy memmem memmove memset mkstemps \
+ memchr memrchr memcmp memcpy memmem memmove memset mkstemps \
on_exit \
pipe2 posix_spawn posix_spawnp psignal \
pstat_getdynamic pstat_getstatic putenv \
@@ -555,7 +556,7 @@ if test -n "${with_target_subdir}"; then
for f in atexit basename bcmp bcopy bsearch bzero calloc clock ffs \
getcwd getpagesize getrusage gettimeofday \
- index insque memchr memcmp memcpy memmove memset psignal \
+ index insque memchr memrchr memcmp memcpy memmove memset psignal \
putenv random rename rindex sbrk setenv stpcpy strcasecmp \
strchr strdup strerror strncasecmp strrchr strstr strtod \
strtol strtoul sysconf times tmpnam vfprintf vprintf \
@@ -723,7 +724,12 @@ if test -z "${setobjs}"; then
[AC_MSG_RESULT([no])])
AC_CHECK_FUNCS($checkfuncs)
- AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf])
+ AC_CHECK_DECLS([basename(char *)], [], [], [
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_LIBGEN_H
+# include <libgen.h>
+#endif])
+ AC_CHECK_DECLS([ffs, asprintf, vasprintf, snprintf, vsnprintf])
AC_CHECK_DECLS([calloc, getenv, getopt, malloc, realloc])
case "${host}" in
*-*-darwin*) ;; # Darwin's sbrk implementation is deprecated.
diff --git a/libiberty/configure.com b/libiberty/configure.com
index 0301829..55aee2f 100644
--- a/libiberty/configure.com
+++ b/libiberty/configure.com
@@ -17,7 +17,7 @@ $DECK
$ FILES="getopt,obstack,xexit,xmalloc,hex,getopt1,cplus-dem,cp-demangle,"+-
"cp-demint,asprintf,vasprintf,mkstemps,concat,getruntime,getpagesize,"+-
"getpwd,xstrerror,xmemdup,xstrdup,xatexit,choose-temp,fnmatch,objalloc,"+-
- "safe-ctype,hashtab,lbasename,argv,lrealpath,make-temp-file,"+-
+ "safe-ctype,hashtab,lbasename,ldirname,argv,lrealpath,make-temp-file,"+-
"stpcpy,unlink-if-ordinary"
$ OPT="/noopt/debug/warnings=disable=(missingreturn)"
$ CFLAGS=OPT + "/include=([],[-.include])/name=(as_is,shortened)" +-
diff --git a/libiberty/copying-lib.texi b/libiberty/copying-lib.texi
index 66b24b1..eb4a2b6 100644
--- a/libiberty/copying-lib.texi
+++ b/libiberty/copying-lib.texi
@@ -5,7 +5,7 @@
@center Version 2.1, February 1999
@display
-Copyright @copyright{} 1991-2024 Free Software Foundation, Inc.
+Copyright @copyright{} 1991-2025 Free Software Foundation, Inc.
51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index fc2cf64..1922046 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -1,5 +1,5 @@
/* Demangler for g++ V3 ABI.
- Copyright (C) 2003-2024 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@wasabisystems.com>.
This file is part of the libiberty library, which is part of GCC.
@@ -655,9 +655,9 @@ d_dump (struct demangle_component *dc, int indent)
return;
case DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE:
{
- char suffix[2] = { dc->u.s_extended_builtin.type->suffix, 0 };
+ char suffix[2] = { dc->u.s_extended_builtin.suffix, 0 };
printf ("builtin type %s%d%s\n", dc->u.s_extended_builtin.type->name,
- dc->u.s_extended_builtin.type->arg, suffix);
+ dc->u.s_extended_builtin.arg, suffix);
}
return;
case DEMANGLE_COMPONENT_OPERATOR:
diff --git a/libiberty/cp-demangle.h b/libiberty/cp-demangle.h
index 7640a4f..4525c9a 100644
--- a/libiberty/cp-demangle.h
+++ b/libiberty/cp-demangle.h
@@ -1,5 +1,5 @@
/* Internal demangler interface for g++ V3 ABI.
- Copyright (C) 2003-2024 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@wasabisystems.com>.
This file is part of the libiberty library, which is part of GCC.
diff --git a/libiberty/cp-demint.c b/libiberty/cp-demint.c
index e172ae6..f0c8e52 100644
--- a/libiberty/cp-demint.c
+++ b/libiberty/cp-demint.c
@@ -1,5 +1,5 @@
/* Demangler component interface functions.
- Copyright (C) 2004-2024 Free Software Foundation, Inc.
+ Copyright (C) 2004-2025 Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@wasabisystems.com>.
This file is part of the libiberty library, which is part of GCC.
diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c
index ee9e84f..c40658c 100644
--- a/libiberty/cplus-dem.c
+++ b/libiberty/cplus-dem.c
@@ -1,5 +1,5 @@
/* Demangler for GNU C++
- Copyright (C) 1989-2024 Free Software Foundation, Inc.
+ Copyright (C) 1989-2025 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.uucp)
Rewritten by Fred Fish (fnf@cygnus.com) for ARM and Lucid demangling
Modified by Satish Pai (pai@apollo.hp.com) for HP demangling
@@ -215,7 +215,7 @@ ada_demangle (const char *mangled, int option ATTRIBUTE_UNUSED)
goto unknown;
/* Most of the demangling will trivially remove chars. Operator names
- may add one char but because they are always preceeded by '__' which is
+ may add one char but because they are always preceded by '__' which is
replaced by '.', they eventually never expand the size.
A few special names such as '___elabs' add a few chars (at most 7), but
they occur only once. */
diff --git a/libiberty/crc32.c b/libiberty/crc32.c
index 1063674..e404436 100644
--- a/libiberty/crc32.c
+++ b/libiberty/crc32.c
@@ -1,5 +1,5 @@
/* crc32.c
- Copyright (C) 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2009-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 2989d85..81c1209 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -1,5 +1,5 @@
/* Demangler for the D programming language
- Copyright (C) 2014-2024 Free Software Foundation, Inc.
+ Copyright (C) 2014-2025 Free Software Foundation, Inc.
Written by Iain Buclaw (ibuclaw@gdcproject.org)
This file is part of the libiberty library.
diff --git a/libiberty/dwarfnames.c b/libiberty/dwarfnames.c
index 1458861..cf0780c 100644
--- a/libiberty/dwarfnames.c
+++ b/libiberty/dwarfnames.c
@@ -1,5 +1,5 @@
/* Names of various DWARF tags.
- Copyright (C) 2012-2024 Free Software Foundation, Inc.
+ Copyright (C) 2012-2025 Free Software Foundation, Inc.
This file is part of GNU CC.
diff --git a/libiberty/dyn-string.c b/libiberty/dyn-string.c
index 5805c0b..4ad88b6 100644
--- a/libiberty/dyn-string.c
+++ b/libiberty/dyn-string.c
@@ -1,5 +1,5 @@
/* An abstract string datatype.
- Copyright (C) 1998-2024 Free Software Foundation, Inc.
+ Copyright (C) 1998-2025 Free Software Foundation, Inc.
Contributed by Mark Mitchell (mark@markmitchell.com).
This file is part of GNU CC.
diff --git a/libiberty/fdmatch.c b/libiberty/fdmatch.c
index 1aecf46..3eca15a 100644
--- a/libiberty/fdmatch.c
+++ b/libiberty/fdmatch.c
@@ -1,5 +1,5 @@
/* Compare two open file descriptors to see if they refer to the same file.
- Copyright (C) 1991-2024 Free Software Foundation, Inc.
+ Copyright (C) 1991-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/fibheap.c b/libiberty/fibheap.c
index 24e0e99..e755911d 100644
--- a/libiberty/fibheap.c
+++ b/libiberty/fibheap.c
@@ -1,5 +1,5 @@
/* A Fibonacci heap datatype.
- Copyright (C) 1998-2024 Free Software Foundation, Inc.
+ Copyright (C) 1998-2025 Free Software Foundation, Inc.
Contributed by Daniel Berlin (dan@cgsoftware.com).
This file is part of GNU CC.
diff --git a/libiberty/filedescriptor.c b/libiberty/filedescriptor.c
index 8722398..d7b19f4 100644
--- a/libiberty/filedescriptor.c
+++ b/libiberty/filedescriptor.c
@@ -1,6 +1,6 @@
/* File descriptor related functions.
- Copyright (C) 2019-2024 Free Software Foundation, Inc.
+ Copyright (C) 2019-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
diff --git a/libiberty/filename_cmp.c b/libiberty/filename_cmp.c
index 84808bf..9055b20 100644
--- a/libiberty/filename_cmp.c
+++ b/libiberty/filename_cmp.c
@@ -1,6 +1,6 @@
/* File name comparison routine.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
index dd2f971..fe82e01 100644
--- a/libiberty/floatformat.c
+++ b/libiberty/floatformat.c
@@ -1,5 +1,5 @@
/* IEEE floating point support routines, for GDB, the GNU Debugger.
- Copyright (C) 1991-2024 Free Software Foundation, Inc.
+ Copyright (C) 1991-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/libiberty/fnmatch.c b/libiberty/fnmatch.c
index b9d9470..dd81122 100644
--- a/libiberty/fnmatch.c
+++ b/libiberty/fnmatch.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2025 Free Software Foundation, Inc.
NOTE: This source is derived from an old version taken from the GNU C
Library (glibc).
diff --git a/libiberty/fopen_unlocked.c b/libiberty/fopen_unlocked.c
index 36db096..23f53f7 100644
--- a/libiberty/fopen_unlocked.c
+++ b/libiberty/fopen_unlocked.c
@@ -1,5 +1,5 @@
/* Implement fopen_unlocked and related functions.
- Copyright (C) 2005-2024 Free Software Foundation, Inc.
+ Copyright (C) 2005-2025 Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library.
diff --git a/libiberty/functions.texi b/libiberty/functions.texi
index b56b02e..7c7da1b 100644
--- a/libiberty/functions.texi
+++ b/libiberty/functions.texi
@@ -749,6 +749,20 @@ returned.
@end deftypefn
+@c memrchr.c:3
+@deftypefn Supplemental void* memrchr (const void *@var{s}, int @var{c}, @
+ size_t @var{n})
+
+This function searches memory for the character @var{c} in reverse order,
+starting at @code{*@var{s}+@var{n}-1} . The search only ends with
+the first occurrence of @var{c}, or when the start us reached; in particular,
+a null character does not terminate the search. If the character @var{c} is
+found within @var{length} characters of @code{*@var{s}}, a pointer
+to the character is returned. If @var{c} is not found, then @code{NULL} is
+returned.
+
+@end deftypefn
+
@c memcmp.c:6
@deftypefn Supplemental int memcmp (const void *@var{x}, const void *@var{y}, @
size_t @var{count})
diff --git a/libiberty/gather-docs b/libiberty/gather-docs
index 4659ca2..3fa8f60 100644
--- a/libiberty/gather-docs
+++ b/libiberty/gather-docs
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# -*- perl -*-
-# Copyright (C) 2001-2024 Free Software Foundation, Inc.
+# Copyright (C) 2001-2025 Free Software Foundation, Inc.
#
# This file is part of the libiberty library.
# Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/getopt.c b/libiberty/getopt.c
index 2f7086c..0f64a8f 100644
--- a/libiberty/getopt.c
+++ b/libiberty/getopt.c
@@ -3,7 +3,7 @@
"Keep this file name-space clean" means, talk to drepper@gnu.org
before changing it!
- Copyright (C) 1987-2024 Free Software Foundation, Inc.
+ Copyright (C) 1987-2025 Free Software Foundation, Inc.
NOTE: This source is derived from an old version taken from the GNU C
Library (glibc).
@@ -23,12 +23,6 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
USA. */
-/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
- Ditto for AIX 3.2 and <stdlib.h>. */
-#ifndef _NO_PROTO
-# define _NO_PROTO
-#endif
-
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/libiberty/getopt1.c b/libiberty/getopt1.c
index 7db3d16..6a3f901 100644
--- a/libiberty/getopt1.c
+++ b/libiberty/getopt1.c
@@ -1,5 +1,5 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
- Copyright (C) 1987-2024 Free Software Foundation, Inc.
+ Copyright (C) 1987-2025 Free Software Foundation, Inc.
NOTE: This source is derived from an old version taken from the GNU C
Library (glibc).
diff --git a/libiberty/getruntime.c b/libiberty/getruntime.c
index 0ad4244..0f226f8 100644
--- a/libiberty/getruntime.c
+++ b/libiberty/getruntime.c
@@ -1,5 +1,5 @@
/* Return time used so far, in microseconds.
- Copyright (C) 1994-2024 Free Software Foundation, Inc.
+ Copyright (C) 1994-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c
index e3a0725..705a59c 100644
--- a/libiberty/hashtab.c
+++ b/libiberty/hashtab.c
@@ -1,5 +1,5 @@
/* An expandable hash tables datatype.
- Copyright (C) 1999-2024 Free Software Foundation, Inc.
+ Copyright (C) 1999-2025 Free Software Foundation, Inc.
Contributed by Vladimir Makarov (vmakarov@cygnus.com).
This file is part of the libiberty library.
diff --git a/libiberty/hex.c b/libiberty/hex.c
index 5de5f9d..4be701d 100644
--- a/libiberty/hex.c
+++ b/libiberty/hex.c
@@ -1,5 +1,5 @@
/* Hex character manipulation support.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/lbasename.c b/libiberty/lbasename.c
index 0da028c..61af0c3 100644
--- a/libiberty/lbasename.c
+++ b/libiberty/lbasename.c
@@ -1,6 +1,6 @@
/* Libiberty basename. Like basename, but is not overridden by the
system C library.
- Copyright (C) 2001-2024 Free Software Foundation, Inc.
+ Copyright (C) 2001-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/ldirname.c b/libiberty/ldirname.c
new file mode 100644
index 0000000..e3cd5c8
--- /dev/null
+++ b/libiberty/ldirname.c
@@ -0,0 +1,94 @@
+/* Libiberty dirname. Like dirname, but is not overridden by the
+ system C library.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+Boston, MA 02110-1301, USA. */
+
+/*
+
+@deftypefn Replacement {char*} ldirname (const char *@var{name})
+
+Given a pointer to a string containing a typical pathname
+(@samp{/usr/src/cmd/ls/ls.c} for example), returns a string containing the
+passed string up to, but not including, the final directory separator.
+
+If the given pathname doesn't contain a directory separator then this funtion
+returns the empty string; this includes an empty given pathname. @code{NULL}
+is returned on memory allocation error.
+
+@end deftypefn
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "ansidecl.h"
+#include "libiberty.h"
+#include "safe-ctype.h"
+#include "filenames.h"
+
+/* For malloc. */
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+/* For memcpy. */
+# if HAVE_STRING_H
+# include <string.h>
+# else
+# if HAVE_STRINGS_H
+# include <strings.h>
+# endif
+# endif
+
+#define LDIRNAME(FPREFIX,DIRSEP) \
+ char *FPREFIX##_ldirname (const char *name) \
+ { \
+ /* Note that lbasename guarantees that the returned */ \
+ /* pointer lies within the passed string. */ \
+ const char *basename = FPREFIX##_lbasename (name); \
+ size_t size = basename - name; \
+ char *res = NULL; \
+ \
+ res = (char*) malloc (size + 1); \
+ if (res != NULL) \
+ { \
+ if (size > 0) \
+ { \
+ if (IS_DIR_SEPARATOR_1 ((DIRSEP),name[size - 1])) \
+ size -= 1; \
+ memcpy (res, name, size); \
+ } \
+ res[size] = '\0'; \
+ } \
+ \
+ return res; \
+ }
+
+LDIRNAME(dos,1)
+LDIRNAME(unix,0)
+
+char *
+ldirname (const char *name)
+{
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ return dos_ldirname (name);
+#else
+ return unix_ldirname (name);
+#endif
+}
diff --git a/libiberty/libiberty.texi b/libiberty/libiberty.texi
index 84ab5a4..6809834 100644
--- a/libiberty/libiberty.texi
+++ b/libiberty/libiberty.texi
@@ -24,7 +24,7 @@
@ifinfo
This manual describes the GNU @libib library of utility subroutines.
-Copyright @copyright{} 2001-2024 Free Software Foundation, Inc.
+Copyright @copyright{} 2001-2025 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
@@ -50,7 +50,7 @@ notice identical to this one except for the removal of this paragraph
@vskip 0pt plus 1filll
-Copyright @copyright{} 2001-2024 Free Software Foundation, Inc.
+Copyright @copyright{} 2001-2025 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
diff --git a/libiberty/lrealpath.c b/libiberty/lrealpath.c
index c683837..03e3b5b 100644
--- a/libiberty/lrealpath.c
+++ b/libiberty/lrealpath.c
@@ -1,7 +1,7 @@
/* Libiberty realpath. Like realpath, but more consistent behavior.
Based on gdb_realpath from GDB.
- Copyright (C) 2003-2024 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
diff --git a/libiberty/maint-tool b/libiberty/maint-tool
index cade9d4..d544577 100644
--- a/libiberty/maint-tool
+++ b/libiberty/maint-tool
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# -*- perl -*-
-# Copyright (C) 2001-2024 Free Software Foundation, Inc.
+# Copyright (C) 2001-2025 Free Software Foundation, Inc.
#
# This file is part of the libiberty library.
# Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/make-relative-prefix.c b/libiberty/make-relative-prefix.c
index 23920a8..642eaee 100644
--- a/libiberty/make-relative-prefix.c
+++ b/libiberty/make-relative-prefix.c
@@ -1,5 +1,5 @@
/* Relative (relocatable) prefix support.
- Copyright (C) 1987-2024 Free Software Foundation, Inc.
+ Copyright (C) 1987-2025 Free Software Foundation, Inc.
This file is part of libiberty.
diff --git a/libiberty/make-temp-file.c b/libiberty/make-temp-file.c
index 23b4670..01aa8cc 100644
--- a/libiberty/make-temp-file.c
+++ b/libiberty/make-temp-file.c
@@ -1,5 +1,5 @@
/* Utility to pick a temporary filename prefix.
- Copyright (C) 1996-2024 Free Software Foundation, Inc.
+ Copyright (C) 1996-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/makefile.vms b/libiberty/makefile.vms
index 15a7d0a..4cfcc98 100644
--- a/libiberty/makefile.vms
+++ b/libiberty/makefile.vms
@@ -12,7 +12,7 @@ OBJS=getopt.obj,obstack.obj,xexit.obj,xmalloc.obj,hex.obj,\
asprintf.obj vasprintf.obj,mkstemps.obj,filename_cmp.obj,\
concat.obj,getruntime.obj,getpagesize.obj,getpwd.obj,xstrerror.obj,\
xmemdup.obj,xstrdup.obj,xatexit.obj,choose-temp.obj,fnmatch.obj,\
- objalloc.obj,safe-ctype.obj,hashtab.obj,lbasename.obj,argv.obj,\
+ objalloc.obj,safe-ctype.obj,hashtab.obj,lbasename.obj,ldirname.obj,argv.obj,\
lrealpath.obj,make-temp-file.obj,stpcpy.obj,unlink-if-ordinary.obj,\
dwarfnames.obj
diff --git a/libiberty/md5.c b/libiberty/md5.c
index 602d716..92264be 100644
--- a/libiberty/md5.c
+++ b/libiberty/md5.c
@@ -1,6 +1,6 @@
/* md5.c - Functions to compute MD5 message digest of files or memory blocks
according to the definition of MD5 in RFC 1321 from April 1992.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
NOTE: This source is derived from an old version taken from the GNU C
Library (glibc).
diff --git a/libiberty/memmem.c b/libiberty/memmem.c
index 0b35f73..fdb77ee 100644
--- a/libiberty/memmem.c
+++ b/libiberty/memmem.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2025 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
diff --git a/libiberty/mempcpy.c b/libiberty/mempcpy.c
index b9e3d37..9fa710a 100644
--- a/libiberty/mempcpy.c
+++ b/libiberty/mempcpy.c
@@ -1,5 +1,5 @@
/* Implement the mempcpy function.
- Copyright (C) 2003-2024 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library.
diff --git a/libiberty/memrchr.c b/libiberty/memrchr.c
new file mode 100644
index 0000000..fe7713e
--- /dev/null
+++ b/libiberty/memrchr.c
@@ -0,0 +1,33 @@
+/*
+
+@deftypefn Supplemental void* memrchr (const void *@var{s}, int @var{c}, @
+ size_t @var{n})
+
+This function searches memory for the character @var{c} in reverse order,
+starting at @code{*@var{s}+@var{n}-1} . The search only ends with
+the first occurrence of @var{c}, or when the start us reached; in particular,
+a null character does not terminate the search. If the character @var{c} is
+found within @var{length} characters of @code{*@var{s}}, a pointer
+to the character is returned. If @var{c} is not found, then @code{NULL} is
+returned.
+
+@end deftypefn
+
+*/
+
+#include <ansidecl.h>
+#include <stddef.h>
+
+void *
+memrchr (const void *src_void, int c, size_t length)
+{
+ if (length == 0)
+ return NULL;
+
+ const unsigned char *p = (const unsigned char*)src_void;
+ p += length;
+ while (*--p != (unsigned char)c)
+ if (src_void == p)
+ return NULL;
+ return (void *)p;
+}
diff --git a/libiberty/mkstemps.c b/libiberty/mkstemps.c
index a78f3f0..916d06e 100644
--- a/libiberty/mkstemps.c
+++ b/libiberty/mkstemps.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2025 Free Software Foundation, Inc.
This file is derived from mkstemp.c from the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/libiberty/objalloc.c b/libiberty/objalloc.c
index b651aab..218a557 100644
--- a/libiberty/objalloc.c
+++ b/libiberty/objalloc.c
@@ -1,5 +1,5 @@
/* objalloc.c -- routines to allocate memory for objects
- Copyright (C) 1997-2024 Free Software Foundation, Inc.
+ Copyright (C) 1997-2025 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Solutions.
This program is free software; you can redistribute it and/or modify it
diff --git a/libiberty/obstack.c b/libiberty/obstack.c
index f6d4eb7..4e4f416 100644
--- a/libiberty/obstack.c
+++ b/libiberty/obstack.c
@@ -1,5 +1,5 @@
/* obstack.c - subroutines used implicitly by object stack macros
- Copyright (C) 1988-2024 Free Software Foundation, Inc.
+ Copyright (C) 1988-2025 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/libiberty/partition.c b/libiberty/partition.c
index 007f851..984a26c 100644
--- a/libiberty/partition.c
+++ b/libiberty/partition.c
@@ -1,5 +1,5 @@
/* List implementation of a partition of consecutive integers.
- Copyright (C) 2000-2024 Free Software Foundation, Inc.
+ Copyright (C) 2000-2025 Free Software Foundation, Inc.
Contributed by CodeSourcery, LLC.
This file is part of GNU CC.
diff --git a/libiberty/pex-common.c b/libiberty/pex-common.c
index f249fee..5157940 100644
--- a/libiberty/pex-common.c
+++ b/libiberty/pex-common.c
@@ -1,5 +1,5 @@
/* Common code for executing a program in a sub-process.
- Copyright (C) 2005-2024 Free Software Foundation, Inc.
+ Copyright (C) 2005-2025 Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@airs.com>.
This file is part of the libiberty library.
diff --git a/libiberty/pex-common.h b/libiberty/pex-common.h
index 98b7194..84f3749 100644
--- a/libiberty/pex-common.h
+++ b/libiberty/pex-common.h
@@ -1,6 +1,6 @@
/* Utilities to execute a program in a subprocess (possibly linked by pipes
with other subprocesses), and wait for it. Shared logic.
- Copyright (C) 1996-2024 Free Software Foundation, Inc.
+ Copyright (C) 1996-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/pex-djgpp.c b/libiberty/pex-djgpp.c
index 6fd1136..af3e840 100644
--- a/libiberty/pex-djgpp.c
+++ b/libiberty/pex-djgpp.c
@@ -1,6 +1,6 @@
/* Utilities to execute a program in a subprocess (possibly linked by pipes
with other subprocesses), and wait for it. DJGPP specialization.
- Copyright (C) 1996-2024 Free Software Foundation, Inc.
+ Copyright (C) 1996-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/pex-msdos.c b/libiberty/pex-msdos.c
index 1ff4581..dfdcc4f 100644
--- a/libiberty/pex-msdos.c
+++ b/libiberty/pex-msdos.c
@@ -1,6 +1,6 @@
/* Utilities to execute a program in a subprocess (possibly linked by pipes
with other subprocesses), and wait for it. Generic MSDOS specialization.
- Copyright (C) 1996-2024 Free Software Foundation, Inc.
+ Copyright (C) 1996-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/pex-one.c b/libiberty/pex-one.c
index fae7099..8736aca 100644
--- a/libiberty/pex-one.c
+++ b/libiberty/pex-one.c
@@ -1,5 +1,5 @@
/* Execute a program and wait for a result.
- Copyright (C) 2005-2024 Free Software Foundation, Inc.
+ Copyright (C) 2005-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/pex-unix.c b/libiberty/pex-unix.c
index f3a1cc9..90c6b99 100644
--- a/libiberty/pex-unix.c
+++ b/libiberty/pex-unix.c
@@ -1,7 +1,7 @@
/* Utilities to execute a program in a subprocess (possibly linked by pipes
with other subprocesses), and wait for it. Generic Unix version
(also used for UWIN and VMS).
- Copyright (C) 1996-2024 Free Software Foundation, Inc.
+ Copyright (C) 1996-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c
index 3780f1d..3a12fd8 100644
--- a/libiberty/pex-win32.c
+++ b/libiberty/pex-win32.c
@@ -1,6 +1,6 @@
/* Utilities to execute a program in a subprocess (possibly linked by pipes
with other subprocesses), and wait for it. Generic Win32 specialization.
- Copyright (C) 1996-2024 Free Software Foundation, Inc.
+ Copyright (C) 1996-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/pexecute.c b/libiberty/pexecute.c
index d7655f6..e86b66e 100644
--- a/libiberty/pexecute.c
+++ b/libiberty/pexecute.c
@@ -1,6 +1,6 @@
/* Utilities to execute a program in a subprocess (possibly linked by pipes
with other subprocesses), and wait for it.
- Copyright (C) 2004-2024 Free Software Foundation, Inc.
+ Copyright (C) 2004-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/physmem.c b/libiberty/physmem.c
index 845272f..62253e1 100644
--- a/libiberty/physmem.c
+++ b/libiberty/physmem.c
@@ -1,5 +1,5 @@
/* Calculate the size of physical memory.
- Copyright (C) 2000-2024 Free Software Foundation, Inc.
+ Copyright (C) 2000-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/libiberty/putenv.c b/libiberty/putenv.c
index 847af5a..734236c 100644
--- a/libiberty/putenv.c
+++ b/libiberty/putenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2025 Free Software Foundation, Inc.
This file based on putenv.c in the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/libiberty/regex.c b/libiberty/regex.c
index 67747e6..8337dea 100644
--- a/libiberty/regex.c
+++ b/libiberty/regex.c
@@ -3,7 +3,7 @@
(Implements POSIX draft P1003.2/D11.2, except for some of the
internationalization features.)
- Copyright (C) 1993-2024 Free Software Foundation, Inc.
+ Copyright (C) 1993-2025 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -3468,7 +3468,7 @@ PREFIX(regex_compile) (const char *ARG_PREFIX(pattern),
PATFETCH (c);
if ((c == '.' && *p == ']') || p == pend)
break;
- if (c1 < sizeof (str))
+ if (c1 < sizeof (str) - 1)
str[c1++] = c;
else
/* This is in any case an invalid class name. */
diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
index ae6be4f..30e1ea9 100644
--- a/libiberty/rust-demangle.c
+++ b/libiberty/rust-demangle.c
@@ -1,5 +1,5 @@
/* Demangler for the Rust programming language
- Copyright (C) 2016-2024 Free Software Foundation, Inc.
+ Copyright (C) 2016-2025 Free Software Foundation, Inc.
Written by David Tolnay (dtolnay@gmail.com).
Rewritten by Eduard-Mihai Burtescu (eddyb@lyken.rs) for v0 support.
diff --git a/libiberty/safe-ctype.c b/libiberty/safe-ctype.c
index 0f44e94..95d3f6d 100644
--- a/libiberty/safe-ctype.c
+++ b/libiberty/safe-ctype.c
@@ -1,6 +1,6 @@
/* <ctype.h> replacement macros.
- Copyright (C) 2000-2024 Free Software Foundation, Inc.
+ Copyright (C) 2000-2025 Free Software Foundation, Inc.
Contributed by Zack Weinberg <zackw@stanford.edu>.
This file is part of the libiberty library.
diff --git a/libiberty/setenv.c b/libiberty/setenv.c
index 232b2d6..c2c006e 100644
--- a/libiberty/setenv.c
+++ b/libiberty/setenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2025 Free Software Foundation, Inc.
This file based on setenv.c in the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/libiberty/setproctitle.c b/libiberty/setproctitle.c
index 8e85a7e..3e0cabb 100644
--- a/libiberty/setproctitle.c
+++ b/libiberty/setproctitle.c
@@ -1,5 +1,5 @@
/* Set the title of a process.
- Copyright (C) 2010-2024 Free Software Foundation, Inc.
+ Copyright (C) 2010-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/sha1.c b/libiberty/sha1.c
index 49e8e0b..27ceccc 100644
--- a/libiberty/sha1.c
+++ b/libiberty/sha1.c
@@ -1,7 +1,7 @@
/* sha1.c - Functions to compute SHA1 message digest of files or
memory blocks according to the NIST specification FIPS-180-1.
- Copyright (C) 2000-2024 Free Software Foundation, Inc.
+ Copyright (C) 2000-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/libiberty/simple-object-coff.c b/libiberty/simple-object-coff.c
index e748205..922477f 100644
--- a/libiberty/simple-object-coff.c
+++ b/libiberty/simple-object-coff.c
@@ -1,5 +1,5 @@
/* simple-object-coff.c -- routines to manipulate COFF object files.
- Copyright (C) 2010-2024 Free Software Foundation, Inc.
+ Copyright (C) 2010-2025 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google.
This program is free software; you can redistribute it and/or modify it
@@ -219,7 +219,9 @@ static const struct coff_magic_struct coff_magic[] =
/* i386. */
{ 0x14c, 0, F_EXEC | IMAGE_FILE_SYSTEM | IMAGE_FILE_DLL },
/* x86_64. */
- { 0x8664, 0, F_EXEC | IMAGE_FILE_SYSTEM | IMAGE_FILE_DLL }
+ { 0x8664, 0, F_EXEC | IMAGE_FILE_SYSTEM | IMAGE_FILE_DLL },
+ /* AArch64. */
+ { 0xaa64, 0, F_EXEC | IMAGE_FILE_SYSTEM | IMAGE_FILE_DLL }
};
/* See if we have a COFF file. */
diff --git a/libiberty/simple-object-common.h b/libiberty/simple-object-common.h
index 37a0ff0..462db9c 100644
--- a/libiberty/simple-object-common.h
+++ b/libiberty/simple-object-common.h
@@ -1,5 +1,5 @@
/* simple-object-common.h -- common structs for object file manipulation.
- Copyright (C) 2010-2024 Free Software Foundation, Inc.
+ Copyright (C) 2010-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c
index c09c216..3a00970 100644
--- a/libiberty/simple-object-elf.c
+++ b/libiberty/simple-object-elf.c
@@ -1,5 +1,5 @@
/* simple-object-elf.c -- routines to manipulate ELF object files.
- Copyright (C) 2010-2024 Free Software Foundation, Inc.
+ Copyright (C) 2010-2025 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google.
This program is free software; you can redistribute it and/or modify it
@@ -128,9 +128,9 @@ typedef struct {
#define SHN_UNDEF 0 /* Undefined section */
#define SHN_LORESERVE 0xFF00 /* Begin range of reserved indices */
-#define SHN_COMMON 0xFFF2 /* Associated symbol is in common */
+#define SHN_COMMON 0xFFF2 /* Associated symbol is in common */
#define SHN_XINDEX 0xFFFF /* Section index is held elsewhere */
-#define SHN_HIRESERVE 0xffff /* End of reserved indices */
+#define SHN_HIRESERVE 0xFFFF /* End of reserved indices */
/* 32-bit ELF program header. */
@@ -569,8 +569,8 @@ simple_object_elf_find_sections (simple_object_read *sobj,
void *data,
int *err)
{
- struct simple_object_elf_read *eor =
- (struct simple_object_elf_read *) sobj->data;
+ struct simple_object_elf_read *eor
+ = (struct simple_object_elf_read *) sobj->data;
const struct elf_type_functions *type_functions = eor->type_functions;
unsigned char ei_class = eor->ei_class;
size_t shdr_size;
@@ -662,8 +662,8 @@ simple_object_elf_fetch_attributes (simple_object_read *sobj,
const char **errmsg ATTRIBUTE_UNUSED,
int *err ATTRIBUTE_UNUSED)
{
- struct simple_object_elf_read *eor =
- (struct simple_object_elf_read *) sobj->data;
+ struct simple_object_elf_read *eor
+ = (struct simple_object_elf_read *) sobj->data;
struct simple_object_elf_attributes *ret;
ret = XNEW (struct simple_object_elf_attributes);
@@ -689,10 +689,10 @@ simple_object_elf_release_read (void *data)
static const char *
simple_object_elf_attributes_merge (void *todata, void *fromdata, int *err)
{
- struct simple_object_elf_attributes *to =
- (struct simple_object_elf_attributes *) todata;
- struct simple_object_elf_attributes *from =
- (struct simple_object_elf_attributes *) fromdata;
+ struct simple_object_elf_attributes *to
+ = (struct simple_object_elf_attributes *) todata;
+ struct simple_object_elf_attributes *from
+ = (struct simple_object_elf_attributes *) fromdata;
if (to->ei_data != from->ei_data || to->ei_class != from->ei_class)
{
@@ -751,8 +751,8 @@ simple_object_elf_start_write (void *attributes_data,
const char **errmsg ATTRIBUTE_UNUSED,
int *err ATTRIBUTE_UNUSED)
{
- struct simple_object_elf_attributes *attrs =
- (struct simple_object_elf_attributes *) attributes_data;
+ struct simple_object_elf_attributes *attrs
+ = (struct simple_object_elf_attributes *) attributes_data;
struct simple_object_elf_write *ret;
/* We're just going to record the attributes, but we need to make a
@@ -769,8 +769,8 @@ static int
simple_object_elf_write_ehdr (simple_object_write *sobj, int descriptor,
const char **errmsg, int *err)
{
- struct simple_object_elf_attributes *attrs =
- (struct simple_object_elf_attributes *) sobj->data;
+ struct simple_object_elf_attributes *attrs
+ = (struct simple_object_elf_attributes *) sobj->data;
const struct elf_type_functions* fns;
unsigned char cl;
size_t ehdr_size;
@@ -852,8 +852,8 @@ simple_object_elf_write_shdr (simple_object_write *sobj, int descriptor,
size_t sh_entsize,
const char **errmsg, int *err)
{
- struct simple_object_elf_attributes *attrs =
- (struct simple_object_elf_attributes *) sobj->data;
+ struct simple_object_elf_attributes *attrs
+ = (struct simple_object_elf_attributes *) sobj->data;
const struct elf_type_functions* fns;
unsigned char cl;
size_t shdr_size;
@@ -894,8 +894,8 @@ static const char *
simple_object_elf_write_to_file (simple_object_write *sobj, int descriptor,
int *err)
{
- struct simple_object_elf_write *eow =
- (struct simple_object_elf_write *) sobj->data;
+ struct simple_object_elf_write *eow
+ = (struct simple_object_elf_write *) sobj->data;
struct simple_object_elf_attributes *attrs = &eow->attrs;
unsigned char cl;
size_t ehdr_size;
@@ -1088,11 +1088,11 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
char *(*pfn) (const char *),
int *err)
{
- struct simple_object_elf_read *eor =
- (struct simple_object_elf_read *) sobj->data;
+ struct simple_object_elf_read *eor
+ = (struct simple_object_elf_read *) sobj->data;
const struct elf_type_functions *type_functions = eor->type_functions;
- struct simple_object_elf_write *eow =
- (struct simple_object_elf_write *) dobj->data;
+ struct simple_object_elf_write *eow
+ = (struct simple_object_elf_write *) dobj->data;
unsigned char ei_class = eor->ei_class;
size_t shdr_size;
unsigned int shnum;
@@ -1106,10 +1106,13 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
int changed;
int *pfnret;
const char **pfnname;
- unsigned new_i;
+ unsigned new_i, new_count;
unsigned *sh_map;
unsigned first_shndx = 0;
unsigned int *symtab_indices_shndx;
+ int pass_symtab_indices_shndx;
+ unsigned int first_symtab_indices_shndx;
+ unsigned char **symtab_indices_shndx_buf;
shdr_size = (ei_class == ELFCLASS32
? sizeof (Elf32_External_Shdr)
@@ -1179,8 +1182,7 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
ret = (*pfn) (name);
pfnret[i - 1] = ret == NULL ? -1 : 0;
pfnname[i - 1] = ret == NULL ? name : ret;
- if (first_shndx == 0
- && pfnret[i - 1] == 0)
+ if (first_shndx == 0 && pfnret[i - 1] == 0)
first_shndx = i;
/* Remember the indexes of existing SHT_SYMTAB_SHNDX sections. */
@@ -1191,11 +1193,12 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
unsigned int sh_link;
sh_link = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
shdr, sh_link, Elf_Word);
- symtab_indices_shndx[sh_link - 1] = i - 1;
- /* Always discard the extended index sections, after
- copying it will not be needed. This way we don't need to
- update it and deal with the ordering constraints of
- processing the existing symtab and changing the index. */
+ symtab_indices_shndx[sh_link - 1] = i;
+ /* Discard the extended index sections, after copying it will not
+ be needed, unless we need more than SHN_LORESERVE - 1 sections
+ in the output. This way we don't need to update it and deal with
+ the ordering constraints of processing the existing symtab and
+ changing the index. */
pfnret[i - 1] = -1;
}
}
@@ -1291,16 +1294,25 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
else
sh_map[i] = new_i++;
}
+ first_symtab_indices_shndx = new_i;
+ symtab_indices_shndx_buf = NULL;
if (new_i - 1 >= SHN_LORESERVE)
- {
- *err = ENOTSUP;
- return "Too many copied sections";
- }
- eow->shdrs = XNEWVEC (unsigned char, shdr_size * (new_i - 1));
+ for (i = 1; i < shnum; ++i)
+ if (pfnret[i - 1] == 0 && symtab_indices_shndx[i - 1] != 0)
+ {
+ pfnret[symtab_indices_shndx[i - 1] - 1] = 0;
+ sh_map[symtab_indices_shndx[i - 1]] = new_i++;
+ }
+ new_count = new_i;
+ if (new_count != first_symtab_indices_shndx)
+ symtab_indices_shndx_buf
+ = XNEWVEC (unsigned char *, new_count - first_symtab_indices_shndx);
+ eow->shdrs = XNEWVEC (unsigned char, shdr_size * (new_count - 1));
/* Then perform the actual copying. */
new_i = 0;
- for (i = 1; i < shnum; ++i)
+ pass_symtab_indices_shndx = 0;
+ for (i = 1; i <= shnum; ++i)
{
unsigned char *shdr;
unsigned int sh_name, sh_type;
@@ -1311,11 +1323,30 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
off_t flags;
unsigned char *buf;
+ if (i == shnum)
+ {
+ if (new_count - 1 < SHN_LORESERVE || pass_symtab_indices_shndx)
+ break;
+ i = 0;
+ pass_symtab_indices_shndx = 1;
+ continue;
+ }
+
if (pfnret[i - 1])
continue;
- new_i++;
shdr = shdrs + (i - 1) * shdr_size;
+ sh_type = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
+ shdr, sh_type, Elf_Word);
+ if (sh_type == SHT_SYMTAB_SHNDX)
+ {
+ if (!pass_symtab_indices_shndx)
+ continue;
+ }
+ else if (pass_symtab_indices_shndx)
+ continue;
+
+ new_i++;
sh_name = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
shdr, sh_name, Elf_Word);
if (sh_name >= name_size)
@@ -1324,6 +1355,7 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
XDELETEVEC (names);
XDELETEVEC (shdrs);
XDELETEVEC (symtab_indices_shndx);
+ XDELETEVEC (symtab_indices_shndx_buf);
return "ELF section name out of range";
}
@@ -1332,16 +1364,14 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
shdr, sh_offset, Elf_Addr);
length = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
shdr, sh_size, Elf_Addr);
- sh_type = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
- shdr, sh_type, Elf_Word);
- dest = simple_object_write_create_section (dobj, pfnname[i - 1],
- 0, &errmsg, err);
+ dest = simple_object_write_create_section (dobj, name, 0, &errmsg, err);
if (dest == NULL)
{
XDELETEVEC (names);
XDELETEVEC (shdrs);
XDELETEVEC (symtab_indices_shndx);
+ XDELETEVEC (symtab_indices_shndx_buf);
return errmsg;
}
@@ -1363,6 +1393,7 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
XDELETEVEC (names);
XDELETEVEC (shdrs);
XDELETEVEC (symtab_indices_shndx);
+ XDELETEVEC (symtab_indices_shndx_buf);
return errmsg;
}
@@ -1378,7 +1409,8 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
/* Read the section index table if present. */
if (symtab_indices_shndx[i - 1] != 0)
{
- unsigned char *sidxhdr = shdrs + symtab_indices_shndx[i - 1] * shdr_size;
+ unsigned char *sidxhdr
+ = shdrs + (symtab_indices_shndx[i - 1] - 1) * shdr_size;
off_t sidxoff = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
sidxhdr, sh_offset, Elf_Addr);
size_t sidxsz = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
@@ -1388,11 +1420,20 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
sidxhdr, sh_type, Elf_Word);
if (shndx_type != SHT_SYMTAB_SHNDX)
return "Wrong section type of a SYMTAB SECTION INDICES section";
- shndx_table = (unsigned *)XNEWVEC (char, sidxsz);
- simple_object_internal_read (sobj->descriptor,
- sobj->offset + sidxoff,
- (unsigned char *)shndx_table,
- sidxsz, &errmsg, err);
+ shndx_table = (unsigned *) XNEWVEC (char, sidxsz);
+ if (!simple_object_internal_read (sobj->descriptor,
+ sobj->offset + sidxoff,
+ (unsigned char *) shndx_table,
+ sidxsz, &errmsg, err))
+ {
+ XDELETEVEC (buf);
+ XDELETEVEC (names);
+ XDELETEVEC (shdrs);
+ XDELETEVEC (symtab_indices_shndx);
+ XDELETEVEC (shndx_table);
+ XDELETEVEC (symtab_indices_shndx_buf);
+ return errmsg;
+ }
}
/* Find a WEAK HIDDEN symbol which name we will use for removed
@@ -1407,17 +1448,20 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
unsigned char *st_other;
if (ei_class == ELFCLASS32)
{
- st_info = &((Elf32_External_Sym *)ent)->st_info;
- st_other = &((Elf32_External_Sym *)ent)->st_other;
+ st_info = &((Elf32_External_Sym *) ent)->st_info;
+ st_other = &((Elf32_External_Sym *) ent)->st_other;
}
else
{
- st_info = &((Elf64_External_Sym *)ent)->st_info;
- st_other = &((Elf64_External_Sym *)ent)->st_other;
+ st_info = &((Elf64_External_Sym *) ent)->st_info;
+ st_other = &((Elf64_External_Sym *) ent)->st_other;
}
if (st_shndx == SHN_XINDEX)
- st_shndx = type_functions->fetch_Elf_Word
- ((unsigned char *)(shndx_table + (ent - buf) / entsize));
+ {
+ unsigned char *ndx_ptr
+ = (unsigned char *) (shndx_table + (ent - buf) / entsize);
+ st_shndx = type_functions->fetch_Elf_Word (ndx_ptr);
+ }
if (st_shndx != SHN_COMMON
&& !(st_shndx != SHN_UNDEF
@@ -1442,19 +1486,26 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
unsigned char *st_info;
unsigned char *st_other;
int discard = 0;
+ unsigned char *ndx_ptr = NULL;
if (ei_class == ELFCLASS32)
{
- st_info = &((Elf32_External_Sym *)ent)->st_info;
- st_other = &((Elf32_External_Sym *)ent)->st_other;
+ st_info = &((Elf32_External_Sym *) ent)->st_info;
+ st_other = &((Elf32_External_Sym *) ent)->st_other;
}
else
{
- st_info = &((Elf64_External_Sym *)ent)->st_info;
- st_other = &((Elf64_External_Sym *)ent)->st_other;
+ st_info = &((Elf64_External_Sym *) ent)->st_info;
+ st_other = &((Elf64_External_Sym *) ent)->st_other;
}
+ if (shndx_table)
+ ndx_ptr
+ = (unsigned char *) (shndx_table + (ent - buf) / entsize);
+
if (st_shndx == SHN_XINDEX)
- st_shndx = type_functions->fetch_Elf_Word
- ((unsigned char *)(shndx_table + (ent - buf) / entsize));
+ {
+ st_shndx = type_functions->fetch_Elf_Word (ndx_ptr);
+ type_functions->set_Elf_Word (ndx_ptr, SHN_UNDEF);
+ }
/* Eliminate all COMMONs - this includes __gnu_lto_slim
which otherwise cause endless LTO plugin invocation.
FIXME: remove the condition once we remove emission
@@ -1488,9 +1539,14 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
defined in the first prevailing section. */
ELF_SET_FIELD (type_functions, ei_class, Sym,
ent, st_name, Elf_Word, 0);
+ st_shndx = sh_map[first_shndx];
+ if (st_shndx >= SHN_LORESERVE)
+ {
+ type_functions->set_Elf_Word (ndx_ptr, st_shndx);
+ st_shndx = SHN_XINDEX;
+ }
ELF_SET_FIELD (type_functions, ei_class, Sym,
- ent, st_shndx, Elf_Half,
- sh_map[first_shndx]);
+ ent, st_shndx, Elf_Half, st_shndx);
}
else
{
@@ -1514,11 +1570,24 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
}
else if (raw_st_shndx < SHN_LORESERVE
|| raw_st_shndx == SHN_XINDEX)
- /* Remap the section reference. */
- ELF_SET_FIELD (type_functions, ei_class, Sym,
- ent, st_shndx, Elf_Half, sh_map[st_shndx]);
+ {
+ /* Remap the section reference. */
+ st_shndx = sh_map[st_shndx];
+ if (st_shndx >= SHN_LORESERVE)
+ {
+ type_functions->set_Elf_Word (ndx_ptr, st_shndx);
+ st_shndx = SHN_XINDEX;
+ }
+ ELF_SET_FIELD (type_functions, ei_class, Sym,
+ ent, st_shndx, Elf_Half, st_shndx);
+ }
}
- XDELETEVEC (shndx_table);
+ if (symtab_indices_shndx_buf)
+ symtab_indices_shndx_buf[sh_map[symtab_indices_shndx[i - 1]]
+ - first_symtab_indices_shndx]
+ = (unsigned char *) shndx_table;
+ else
+ XDELETEVEC (shndx_table);
}
else if (sh_type == SHT_GROUP)
{
@@ -1538,15 +1607,21 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
/* Adjust the length. */
length = dst - buf;
}
+ else if (sh_type == SHT_SYMTAB_SHNDX)
+ {
+ XDELETEVEC (buf);
+ buf = symtab_indices_shndx_buf[new_i - first_symtab_indices_shndx];
+ symtab_indices_shndx_buf[new_i - first_symtab_indices_shndx] = NULL;
+ }
- errmsg = simple_object_write_add_data (dobj, dest,
- buf, length, 1, err);
+ errmsg = simple_object_write_add_data (dobj, dest, buf, length, 1, err);
XDELETEVEC (buf);
if (errmsg)
{
XDELETEVEC (names);
XDELETEVEC (shdrs);
XDELETEVEC (symtab_indices_shndx);
+ XDELETEVEC (symtab_indices_shndx_buf);
return errmsg;
}
@@ -1586,6 +1661,7 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
XDELETEVEC (pfnname);
XDELETEVEC (symtab_indices_shndx);
XDELETEVEC (sh_map);
+ XDELETEVEC (symtab_indices_shndx_buf);
return NULL;
}
diff --git a/libiberty/simple-object-mach-o.c b/libiberty/simple-object-mach-o.c
index 3aa4e50..e70e98e 100644
--- a/libiberty/simple-object-mach-o.c
+++ b/libiberty/simple-object-mach-o.c
@@ -1,5 +1,5 @@
/* simple-object-mach-o.c -- routines to manipulate Mach-O object files.
- Copyright (C) 2010-2024 Free Software Foundation, Inc.
+ Copyright (C) 2010-2025 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google.
This program is free software; you can redistribute it and/or modify it
diff --git a/libiberty/simple-object-xcoff.c b/libiberty/simple-object-xcoff.c
index dacf44b..5bfd4b9 100644
--- a/libiberty/simple-object-xcoff.c
+++ b/libiberty/simple-object-xcoff.c
@@ -1,5 +1,5 @@
/* simple-object-coff.c -- routines to manipulate XCOFF object files.
- Copyright (C) 2013-2024 Free Software Foundation, Inc.
+ Copyright (C) 2013-2025 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google and David Edelsohn, IBM.
This program is free software; you can redistribute it and/or modify it
diff --git a/libiberty/simple-object.c b/libiberty/simple-object.c
index 3abdeb4..07c9ad8 100644
--- a/libiberty/simple-object.c
+++ b/libiberty/simple-object.c
@@ -1,5 +1,5 @@
/* simple-object.c -- simple routines to read and write object files.
- Copyright (C) 2010-2024 Free Software Foundation, Inc.
+ Copyright (C) 2010-2025 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google.
This program is free software; you can redistribute it and/or modify it
diff --git a/libiberty/snprintf.c b/libiberty/snprintf.c
index 3d731aa..9a2bc01 100644
--- a/libiberty/snprintf.c
+++ b/libiberty/snprintf.c
@@ -1,5 +1,5 @@
/* Implement the snprintf function.
- Copyright (C) 2003-2024 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library. This library is free
diff --git a/libiberty/sort.c b/libiberty/sort.c
index cfdde38..c14533a 100644
--- a/libiberty/sort.c
+++ b/libiberty/sort.c
@@ -1,5 +1,5 @@
/* Sorting algorithms.
- Copyright (C) 2000-2024 Free Software Foundation, Inc.
+ Copyright (C) 2000-2025 Free Software Foundation, Inc.
Contributed by Mark Mitchell <mark@codesourcery.com>.
This file is part of GNU CC.
diff --git a/libiberty/spaces.c b/libiberty/spaces.c
index c9752e8..5e6f7f5 100644
--- a/libiberty/spaces.c
+++ b/libiberty/spaces.c
@@ -1,5 +1,5 @@
/* Allocate memory region filled with spaces.
- Copyright (C) 1991-2024 Free Software Foundation, Inc.
+ Copyright (C) 1991-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/splay-tree.c b/libiberty/splay-tree.c
index c787f44..755a101 100644
--- a/libiberty/splay-tree.c
+++ b/libiberty/splay-tree.c
@@ -1,5 +1,5 @@
/* A splay-tree datatype.
- Copyright (C) 1998-2024 Free Software Foundation, Inc.
+ Copyright (C) 1998-2025 Free Software Foundation, Inc.
Contributed by Mark Mitchell (mark@markmitchell.com).
This file is part of GNU CC.
diff --git a/libiberty/stack-limit.c b/libiberty/stack-limit.c
index e2dfab3..e1b8f80 100644
--- a/libiberty/stack-limit.c
+++ b/libiberty/stack-limit.c
@@ -1,5 +1,5 @@
/* Increase stack size limit if possible.
- Copyright (C) 2011-2024 Free Software Foundation, Inc.
+ Copyright (C) 2011-2025 Free Software Foundation, Inc.
This file is part of the libiberty library. This library is free
software; you can redistribute it and/or modify it under the
diff --git a/libiberty/stpcpy.c b/libiberty/stpcpy.c
index 572d063..a1784e3 100644
--- a/libiberty/stpcpy.c
+++ b/libiberty/stpcpy.c
@@ -1,5 +1,5 @@
/* Implement the stpcpy function.
- Copyright (C) 2003-2024 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library.
diff --git a/libiberty/stpncpy.c b/libiberty/stpncpy.c
index 53a867d..568fc0e 100644
--- a/libiberty/stpncpy.c
+++ b/libiberty/stpncpy.c
@@ -1,5 +1,5 @@
/* Implement the stpncpy function.
- Copyright (C) 2003-2024 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library.
diff --git a/libiberty/strndup.c b/libiberty/strndup.c
index 283e5d7..fe57158 100644
--- a/libiberty/strndup.c
+++ b/libiberty/strndup.c
@@ -1,5 +1,5 @@
/* Implement the strndup function.
- Copyright (C) 2005-2024 Free Software Foundation, Inc.
+ Copyright (C) 2005-2025 Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library.
diff --git a/libiberty/strtod.c b/libiberty/strtod.c
index 86cedd3b..b4c8706 100644
--- a/libiberty/strtod.c
+++ b/libiberty/strtod.c
@@ -1,5 +1,5 @@
/* Implementation of strtod for systems with atof.
- Copyright (C) 1991-2024 Free Software Foundation, Inc.
+ Copyright (C) 1991-2025 Free Software Foundation, Inc.
This file is part of the libiberty library. This library is free
software; you can redistribute it and/or modify it under the
diff --git a/libiberty/strverscmp.c b/libiberty/strverscmp.c
index fb28dc79..56f0184 100644
--- a/libiberty/strverscmp.c
+++ b/libiberty/strverscmp.c
@@ -1,5 +1,5 @@
/* Compare strings while treating digits characters numerically.
- Copyright (C) 1997-2024 Free Software Foundation, Inc.
+ Copyright (C) 1997-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Contributed by Jean-François Bignolles <bignolle@ecoledoc.ibp.fr>, 1997.
diff --git a/libiberty/testsuite/Makefile.in b/libiberty/testsuite/Makefile.in
index eb9bc19..ef549ca 100644
--- a/libiberty/testsuite/Makefile.in
+++ b/libiberty/testsuite/Makefile.in
@@ -1,6 +1,6 @@
#
# Makefile
-# Copyright (C) 1999-2024 Free Software Foundation, Inc.
+# Copyright (C) 1999-2025 Free Software Foundation, Inc.
#
# This file is part of the libiberty library.
# Libiberty is free software; you can redistribute it and/or
@@ -45,7 +45,8 @@ all:
check: @CHECK@
really-check: check-cplus-dem check-d-demangle check-rust-demangle \
- check-pexecute check-expandargv check-strtol
+ check-pexecute check-expandargv check-strtol \
+ check-doubly-linked-list
# Run some tests of the demangler.
check-cplus-dem: test-demangle $(srcdir)/demangle-expected
@@ -69,6 +70,10 @@ check-expandargv: test-expandargv
check-strtol: test-strtol
./test-strtol
+# Check the linked list functionality
+check-doubly-linked-list: test-doubly-linked-list
+ ./test-doubly-linked-list
+
# Run the demangler fuzzer
fuzz-demangler: demangler-fuzzer
./demangler-fuzzer
@@ -90,6 +95,10 @@ test-strtol: $(srcdir)/test-strtol.c ../libiberty.a
$(TEST_COMPILE) -DHAVE_CONFIG_H -I.. -o test-strtol \
$(srcdir)/test-strtol.c ../libiberty.a
+test-doubly-linked-list: $(srcdir)/test-doubly-linked-list.c
+ $(TEST_COMPILE) -DHAVE_CONFIG_H -I.. -o test-doubly-linked-list \
+ $(srcdir)/test-doubly-linked-list.c
+
demangler-fuzzer: $(srcdir)/demangler-fuzzer.c ../libiberty.a
$(TEST_COMPILE) -o demangler-fuzzer \
$(srcdir)/demangler-fuzzer.c ../libiberty.a
@@ -104,6 +113,7 @@ mostlyclean:
rm -f test-pexecute
rm -f test-expandargv
rm -f test-strtol
+ rm -f test-doubly-linked-list
rm -f demangler-fuzzer
rm -f core
clean: mostlyclean
diff --git a/libiberty/testsuite/demangler-fuzzer.c b/libiberty/testsuite/demangler-fuzzer.c
index f0c6559..2b54f0c 100644
--- a/libiberty/testsuite/demangler-fuzzer.c
+++ b/libiberty/testsuite/demangler-fuzzer.c
@@ -1,6 +1,6 @@
/* Demangler fuzzer.
- Copyright (C) 2014-2024 Free Software Foundation, Inc.
+ Copyright (C) 2014-2025 Free Software Foundation, Inc.
This file is part of GNU libiberty.
diff --git a/libiberty/testsuite/test-demangle.c b/libiberty/testsuite/test-demangle.c
index abe9015..c6f37d9 100644
--- a/libiberty/testsuite/test-demangle.c
+++ b/libiberty/testsuite/test-demangle.c
@@ -1,5 +1,5 @@
/* Demangler test program,
- Copyright (C) 2002-2024 Free Software Foundation, Inc.
+ Copyright (C) 2002-2025 Free Software Foundation, Inc.
Written by Zack Weinberg <zack@codesourcery.com
This file is part of GNU libiberty.
@@ -49,8 +49,7 @@ static unsigned int lineno;
#define LINELEN 80
static void
-get_line(buf)
- struct line *buf;
+get_line(struct line *buf)
{
char *data = buf->data;
size_t alloc = buf->alloced;
@@ -134,12 +133,8 @@ protect_end (const char * s)
}
static void
-fail (lineno, opts, in, out, exp)
- int lineno;
- const char *opts;
- const char *in;
- const char *out;
- const char *exp;
+fail (int lineno, const char *opts, const char *in,
+ const char *out, const char *exp)
{
printf ("\
FAIL at line %d, options %s:\n\
@@ -170,9 +165,7 @@ exp: %s\n",
*/
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char **argv)
{
enum demangling_styles style = auto_demangling;
int no_params;
diff --git a/libiberty/testsuite/test-doubly-linked-list.c b/libiberty/testsuite/test-doubly-linked-list.c
new file mode 100644
index 0000000..1e1fc63
--- /dev/null
+++ b/libiberty/testsuite/test-doubly-linked-list.c
@@ -0,0 +1,269 @@
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "doubly-linked-list.h"
+
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+
+/* Implementation */
+
+typedef int T;
+
+typedef struct ListNodeType
+{
+ T value;
+ struct ListNodeType *next;
+ struct ListNodeType *prev;
+} ListNodeType;
+
+ListNodeType * l_new_node (T value)
+{
+ ListNodeType *n = malloc (sizeof (ListNodeType));
+ n->next = NULL;
+ n->prev = NULL;
+ n->value = value;
+ return n;
+}
+
+typedef struct LinkedListWrapperType
+{
+ ListNodeType *first;
+ ListNodeType *last;
+ size_t size;
+} LinkedListWrapperType;
+
+int compare_nodes (const ListNodeType *n1, const ListNodeType *n2)
+{
+ if (n1->value == n2->value)
+ return 0;
+ else if (n1->value < n2->value)
+ return -1;
+ else
+ return 1;
+}
+
+LINKED_LIST_MUTATIVE_OPS_PROTOTYPE (LinkedListWrapperType, ListNodeType, static);
+LINKED_LIST_MERGE_SORT_PROTOTYPE (LinkedListWrapperType, ListNodeType, static);
+
+LINKED_LIST_MUTATIVE_OPS_DECL (LinkedListWrapperType, ListNodeType, static)
+LINKED_LIST_MERGE_SORT_DECL (LinkedListWrapperType, ListNodeType, static)
+
+ListNodeType * find_last_node (ListNodeType *head)
+{
+ if (head == NULL)
+ return NULL;
+
+ ListNodeType *n = head;
+ while (n->next != NULL)
+ n = n->next;
+
+ return n;
+}
+
+void l_print (ListNodeType *node)
+{
+ for (ListNodeType *l = node; l != NULL; l = l->next)
+ printf ("%d ", l->value);
+ printf ("\n");
+}
+
+void l_reverse_print (ListNodeType *last_node)
+{
+ for (ListNodeType *l = last_node; l != NULL; l = l->prev)
+ printf ("%d ", l->value);
+ printf ("\n");
+}
+
+struct test_data_t
+{
+ T const *content;
+ size_t size;
+};
+
+bool run_test (const struct test_data_t *expect,
+ LinkedListWrapperType *current,
+ bool reversed)
+{
+ ListNodeType *node = (reversed) ? current->last : current->first;
+ bool passed = true;
+ for (int i=0; i<expect->size && node != NULL; ++i)
+ {
+ if (reversed)
+ {
+ if (expect->content[expect->size - 1 - i] != node->value)
+ {
+ printf ("FAIL: mismatching expected (%d) VS current (%d).\n",
+ expect->content[expect->size - 1 - i], node->value);
+ passed = false;
+ }
+ if (node->prev == NULL && current->first != node)
+ {
+ printf ("FAIL: first is not matching the first node.\n");
+ passed = false;
+ }
+ }
+ else
+ {
+ if (expect->content[i] != node->value)
+ {
+ printf ("FAIL: mismatching expected (%d) VS current (%d).\n",
+ expect->content[i], node->value);
+ passed = false;
+ }
+ if (node->next == NULL && current->last != node)
+ {
+ printf ("FAIL: last_ is not matching the last node.\n");
+ passed = false;
+ }
+ }
+
+ if (!passed)
+ return false;
+
+ if (reversed)
+ node = node->prev;
+ else
+ node = node->next;
+ }
+
+ if (node != NULL)
+ {
+ printf ("FAIL: the list is longer than expected.\n");
+ passed = false;
+ }
+ if (expect->size != current->size)
+ {
+ printf ("FAIL: size (%ld) is not matching the real size of the list (%ld).\n",
+ current->size, expect->size);
+ passed = false;
+ }
+
+ return passed;
+}
+
+bool check(const char *op,
+ const struct test_data_t *expect,
+ LinkedListWrapperType *wrapper)
+{
+ bool success = true;
+ bool res;
+
+ l_print (wrapper->first);
+ res = run_test (expect, wrapper, false);
+ printf ("%s: test-linked-list::%s: check forward conformity\n",
+ res ? "PASS": "FAIL", op);
+ success &= res;
+
+ l_reverse_print (wrapper->last);
+ res = run_test (expect, wrapper, true);
+ printf ("%s: test-linked-list::%s: check backward conformity\n",
+ res ? "PASS": "FAIL", op);
+ success &= res;
+
+ printf("\n");
+
+ return success;
+}
+
+const int EXPECT_0 [] = { 10, 4, 3, 1, 9, 2 };
+const int EXPECT_1 [] = { 1, 2, 3, 4, 9, 10 };
+const int EXPECT_2 [] = { 11, 1, 2, 3, 4, 9, 10 };
+const int EXPECT_3 [] = { 11, 1, 2, 3, 4, 9, 8, 10 };
+const int EXPECT_4 [] = { 11, 2, 3, 4, 9, 8, 10 };
+const int EXPECT_5 [] = { 10, 2, 3, 4, 9, 8, 11 };
+const int EXPECT_6 [] = { 10, 3, 2, 4, 9, 8, 11 };
+const int EXPECT_7 [] = { 10, 9, 2, 4, 3, 8, 11 };
+const int EXPECT_8 [] = { 2, 3, 4, 8, 9, 10, 11 };
+const int EXPECT_9 [] = { 3, 4, 8, 9, 10, 11 };
+const int EXPECT_10 [] = { 3, 4, 8, 9, 10 };
+const struct test_data_t test_data[] = {
+ { .content = EXPECT_0, .size = sizeof(EXPECT_0) / sizeof(EXPECT_0[0]) },
+ { .content = EXPECT_1, .size = sizeof(EXPECT_1) / sizeof(EXPECT_1[0]) },
+ { .content = EXPECT_2, .size = sizeof(EXPECT_2) / sizeof(EXPECT_2[0]) },
+ { .content = EXPECT_3, .size = sizeof(EXPECT_3) / sizeof(EXPECT_3[0]) },
+ { .content = EXPECT_4, .size = sizeof(EXPECT_4) / sizeof(EXPECT_4[0]) },
+ { .content = EXPECT_5, .size = sizeof(EXPECT_5) / sizeof(EXPECT_5[0]) },
+ { .content = EXPECT_6, .size = sizeof(EXPECT_6) / sizeof(EXPECT_6[0]) },
+ { .content = EXPECT_7, .size = sizeof(EXPECT_7) / sizeof(EXPECT_7[0]) },
+ { .content = EXPECT_8, .size = sizeof(EXPECT_8) / sizeof(EXPECT_8[0]) },
+ { .content = EXPECT_9, .size = sizeof(EXPECT_9) / sizeof(EXPECT_9[0]) },
+ { .content = EXPECT_10, .size = sizeof(EXPECT_10) / sizeof(EXPECT_10[0]) },
+};
+
+int main (void)
+{
+ int failures = 0;
+
+ LinkedListWrapperType wrapper = {
+ .first = NULL,
+ .last = NULL,
+ .size = 0,
+ };
+
+ /* Append nodes. */
+ LINKED_LIST_APPEND(ListNodeType) (&wrapper, l_new_node (10));
+ LINKED_LIST_APPEND(ListNodeType) (&wrapper, l_new_node (4));
+ LINKED_LIST_APPEND(ListNodeType) (&wrapper, l_new_node (3));
+ LINKED_LIST_APPEND(ListNodeType) (&wrapper, l_new_node (1));
+ LINKED_LIST_APPEND(ListNodeType) (&wrapper, l_new_node (9));
+ LINKED_LIST_APPEND(ListNodeType) (&wrapper, l_new_node (2));
+
+ failures += ! check ("append", &test_data[0], &wrapper);
+
+ /* Sort nodes (without updating wrapper). */
+ wrapper.first =
+ LINKED_LIST_MERGE_SORT_(ListNodeType) (wrapper.first, compare_nodes);
+ wrapper.last = find_last_node (wrapper.first);
+
+ failures += ! check ("sort", &test_data[1], &wrapper);
+
+ /* Save a reference to this node for later. */
+ ListNodeType *n_to_remove = wrapper.first;
+
+ /* Prepend node. */
+ LINKED_LIST_PREPEND(ListNodeType) (&wrapper, l_new_node (11));
+ failures += ! check ("prepend", &test_data[2], &wrapper);
+
+ /* Insert node. */
+ LINKED_LIST_INSERT_BEFORE(ListNodeType) (&wrapper, l_new_node (8), wrapper.last);
+ failures += ! check ("insert_before", &test_data[3], &wrapper);
+
+ /* Remove a node. */
+ LINKED_LIST_REMOVE(ListNodeType) (&wrapper, n_to_remove);
+ failures += ! check ("remove", &test_data[4], &wrapper);
+
+ /* Swap first and last. */
+ LINKED_LIST_SWAP(ListNodeType) (&wrapper, wrapper.first, wrapper.last);
+ failures += ! check ("swap first and last", &test_data[5], &wrapper);
+
+ /* Swap adjacent nodes. */
+ LINKED_LIST_SWAP(ListNodeType) (&wrapper, wrapper.first->next,
+ wrapper.first->next->next);
+ failures += ! check ("swap adjacent nodes", &test_data[6], &wrapper);
+
+ /* Swap non-adjacent nodes, but neither first nor last. */
+ LINKED_LIST_SWAP(ListNodeType) (&wrapper, wrapper.first->next,
+ wrapper.first->next->next->next->next);
+ failures += ! check ("swap non-adjacent nodes", &test_data[7], &wrapper);
+
+ /* Sort nodes. */
+ LINKED_LIST_MERGE_SORT(ListNodeType) (&wrapper, compare_nodes);
+ failures += ! check ("sort", &test_data[8], &wrapper);
+
+ /* Pop front. */
+ LINKED_LIST_POP_FRONT(ListNodeType) (&wrapper);
+ failures += ! check ("pop_front", &test_data[9], &wrapper);
+
+ /* Pop back. */
+ LINKED_LIST_POP_BACK(ListNodeType) (&wrapper);
+ failures += ! check ("pop_back", &test_data[10], &wrapper);
+
+ exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
+}
diff --git a/libiberty/testsuite/test-expandargv.c b/libiberty/testsuite/test-expandargv.c
index ca7031e..b6cdaa3 100644
--- a/libiberty/testsuite/test-expandargv.c
+++ b/libiberty/testsuite/test-expandargv.c
@@ -1,5 +1,5 @@
/* expandargv test program,
- Copyright (C) 2006-2024 Free Software Foundation, Inc.
+ Copyright (C) 2006-2025 Free Software Foundation, Inc.
Written by Carlos O'Donell <carlos@codesourcery.com>
This file is part of the libiberty library, which is part of GCC.
diff --git a/libiberty/testsuite/test-pexecute.c b/libiberty/testsuite/test-pexecute.c
index a5171d5..f900e58 100644
--- a/libiberty/testsuite/test-pexecute.c
+++ b/libiberty/testsuite/test-pexecute.c
@@ -1,5 +1,5 @@
/* Pexecute test program,
- Copyright (C) 2005-2024 Free Software Foundation, Inc.
+ Copyright (C) 2005-2025 Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@airs.com>.
This file is part of GNU libiberty.
diff --git a/libiberty/testsuite/test-strtol.c b/libiberty/testsuite/test-strtol.c
index 0fcdb4b..5613afe 100644
--- a/libiberty/testsuite/test-strtol.c
+++ b/libiberty/testsuite/test-strtol.c
@@ -1,5 +1,5 @@
/* Test program for strtol family of funtions,
- Copyright (C) 2014-2024 Free Software Foundation, Inc.
+ Copyright (C) 2014-2025 Free Software Foundation, Inc.
Written by Yury Gribov <y.gribov@samsung.com>
This file is part of the libiberty library, which is part of GCC.
diff --git a/libiberty/timeval-utils.c b/libiberty/timeval-utils.c
index d041b72..fc679bd 100644
--- a/libiberty/timeval-utils.c
+++ b/libiberty/timeval-utils.c
@@ -1,5 +1,5 @@
/* Basic struct timeval utilities.
- Copyright (C) 2011-2024 Free Software Foundation, Inc.
+ Copyright (C) 2011-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/unlink-if-ordinary.c b/libiberty/unlink-if-ordinary.c
index 0816ceb..f6ecd90 100644
--- a/libiberty/unlink-if-ordinary.c
+++ b/libiberty/unlink-if-ordinary.c
@@ -1,5 +1,5 @@
/* unlink-if-ordinary.c - remove link to a file unless it is special
- Copyright (C) 2004-2024 Free Software Foundation, Inc.
+ Copyright (C) 2004-2025 Free Software Foundation, Inc.
This file is part of the libiberty library. This library is free
software; you can redistribute it and/or modify it under the
diff --git a/libiberty/vasprintf.c b/libiberty/vasprintf.c
index 1296f53..768f413 100644
--- a/libiberty/vasprintf.c
+++ b/libiberty/vasprintf.c
@@ -1,6 +1,6 @@
/* Like vsprintf but provides a pointer to malloc'd storage, which must
be freed by the caller.
- Copyright (C) 1994-2024 Free Software Foundation, Inc.
+ Copyright (C) 1994-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/vfprintf.c b/libiberty/vfprintf.c
index 4d2ed1d..9fe7282 100644
--- a/libiberty/vfprintf.c
+++ b/libiberty/vfprintf.c
@@ -1,6 +1,6 @@
/* Provide a version vfprintf in terms of _doprnt.
By Kaveh Ghazi (ghazi@caip.rutgers.edu) 3/29/98
- Copyright (C) 1998-2024 Free Software Foundation, Inc.
+ Copyright (C) 1998-2025 Free Software Foundation, Inc.
*/
#include "ansidecl.h"
diff --git a/libiberty/vprintf-support.c b/libiberty/vprintf-support.c
index 0543ec0..6aa07d0 100644
--- a/libiberty/vprintf-support.c
+++ b/libiberty/vprintf-support.c
@@ -1,6 +1,6 @@
/* Estimate the length of the string generated by a vprintf-like
function. Used by vasprintf and xvasprintf.
- Copyright (C) 1994-2024 Free Software Foundation, Inc.
+ Copyright (C) 1994-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/vprintf-support.h b/libiberty/vprintf-support.h
index e849d35..f81f038 100644
--- a/libiberty/vprintf-support.h
+++ b/libiberty/vprintf-support.h
@@ -1,6 +1,6 @@
/* Estimate the length of the string generated by a vprintf-like
function. Use by vasprintf and xvasprintf.
- Copyright (C) 1994-2024 Free Software Foundation, Inc.
+ Copyright (C) 1994-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/vsnprintf.c b/libiberty/vsnprintf.c
index 6736dd4..77538ad 100644
--- a/libiberty/vsnprintf.c
+++ b/libiberty/vsnprintf.c
@@ -1,5 +1,5 @@
/* Implement the vsnprintf function.
- Copyright (C) 2003-2024 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library. This library is free
diff --git a/libiberty/vsprintf.c b/libiberty/vsprintf.c
index 3524ed3..2cd1fc0 100644
--- a/libiberty/vsprintf.c
+++ b/libiberty/vsprintf.c
@@ -3,7 +3,7 @@
implementations of stdio; newer ones should already have vsprintf.
Written by Per Bothner of Cygnus Support.
Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu).
- Copyright (C) 1991-2024 Free Software Foundation, Inc.
+ Copyright (C) 1991-2025 Free Software Foundation, Inc.
This file is part of the libiberty library. This library is free
software; you can redistribute it and/or modify it under the
diff --git a/libiberty/xasprintf.c b/libiberty/xasprintf.c
index 12fb41a..139b838 100644
--- a/libiberty/xasprintf.c
+++ b/libiberty/xasprintf.c
@@ -1,5 +1,5 @@
/* Implement the xasprintf function.
- Copyright (C) 2014-2024 Free Software Foundation, Inc.
+ Copyright (C) 2014-2025 Free Software Foundation, Inc.
Contributed by Manuel Lopez-Ibanez.
This file is part of the libiberty library.
diff --git a/libiberty/xexit.c b/libiberty/xexit.c
index c334fbd..40611d6 100644
--- a/libiberty/xexit.c
+++ b/libiberty/xexit.c
@@ -1,5 +1,5 @@
/* xexit.c -- Run any exit handlers, then exit.
- Copyright (C) 1994-2024 Free Software Foundation, Inc.
+ Copyright (C) 1994-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/xmalloc.c b/libiberty/xmalloc.c
index 652ffd3..87b4952 100644
--- a/libiberty/xmalloc.c
+++ b/libiberty/xmalloc.c
@@ -1,5 +1,5 @@
/* memory allocation routines with error checking.
- Copyright (C) 1989-2024 Free Software Foundation, Inc.
+ Copyright (C) 1989-2025 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/xstrndup.c b/libiberty/xstrndup.c
index 0d9d6af9..12bcf4d 100644
--- a/libiberty/xstrndup.c
+++ b/libiberty/xstrndup.c
@@ -1,5 +1,5 @@
/* Implement the xstrndup function.
- Copyright (C) 2005-2024 Free Software Foundation, Inc.
+ Copyright (C) 2005-2025 Free Software Foundation, Inc.
Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
This file is part of the libiberty library.
diff --git a/libiberty/xvasprintf.c b/libiberty/xvasprintf.c
index 4107695..77c558a 100644
--- a/libiberty/xvasprintf.c
+++ b/libiberty/xvasprintf.c
@@ -1,5 +1,5 @@
/* Implement the xvasprintf function.
- Copyright (C) 2014-2024 Free Software Foundation, Inc.
+ Copyright (C) 2014-2025 Free Software Foundation, Inc.
Contributed by Manuel Lopez-Ibanez.
This file is part of the libiberty library.