aboutsummaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2012-10-10 03:11:33 +0000
committerDJ Delorie <dj@redhat.com>2012-10-10 03:11:33 +0000
commit995b61fe5b880e79b767160207fd363b125fdaa3 (patch)
tree47dc5239563a2d1ab75ea7790c9ce51baf80a821 /libiberty
parentfd49b9b373ee89cd57fcd4d9cfd791fd4b9ebdc7 (diff)
downloadfsf-binutils-gdb-995b61fe5b880e79b767160207fd363b125fdaa3.zip
fsf-binutils-gdb-995b61fe5b880e79b767160207fd363b125fdaa3.tar.gz
fsf-binutils-gdb-995b61fe5b880e79b767160207fd363b125fdaa3.tar.bz2
merge from gcc
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog23
-rw-r--r--libiberty/Makefile.in25
-rw-r--r--libiberty/config.in3
-rwxr-xr-xlibiberty/configure13
-rw-r--r--libiberty/configure.ac8
-rw-r--r--libiberty/cp-demangle.c26
-rw-r--r--libiberty/functions.texi70
-rw-r--r--libiberty/maint-tool2
-rw-r--r--libiberty/objalloc.c11
-rw-r--r--libiberty/strnlen.c30
10 files changed, 187 insertions, 24 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 9afed43..303dda2 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,26 @@
+2012-10-08 Jason Merrill <jason@redhat.com>
+
+ * cp-demangle.c (d_special_name, d_dump): Handle TH and TW.
+ (d_make_comp, d_print_comp): Likewise.
+
+2012-09-18 Ian Lance Taylor <iant@google.com>
+
+ * strnlen.c: New file.
+ * configure.ac: Check for strnlen, add it to AC_LIBOBJ if it's not
+ present.
+ * Makefile.in: Rebuild dependencies.
+ (CFILES): Add strnlen.c.
+ (CONFIGURED_OFILES): Add ./strnlen.$(objext).
+ * configure, config.in, functions.texi: Rebuild.
+
+ * maint-tool: Accept .def files in the include directory.
+
+2012-09-18 Florian Weimer <fweimer@redhat.com>
+
+ PR other/54411
+ * objalloc.c (_objalloc_alloc): Add overflow check covering
+ alignment and CHUNK_HEADER_SIZE addition.
+
2011-08-28 H.J. Lu <hongjiu.lu@intel.com>
* argv.c (dupargv): Replace malloc with xmalloc. Don't check
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 0a5da31..1ba8cf1 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -151,7 +151,7 @@ CFILES = alloca.c argv.c asprintf.c atexit.c \
spaces.c splay-tree.c stack-limit.c stpcpy.c stpncpy.c \
strcasecmp.c strchr.c strdup.c strerror.c strncasecmp.c \
strncmp.c strrchr.c strsignal.c strstr.c strtod.c strtol.c \
- strtoul.c strndup.c strverscmp.c \
+ strtoul.c strndup.c strnlen.c strverscmp.c \
timeval-utils.c tmpnam.c \
unlink-if-ordinary.c \
vasprintf.c vfork.c vfprintf.c vprintf.c vsnprintf.c vsprintf.c \
@@ -215,9 +215,9 @@ CONFIGURED_OFILES = ./asprintf.$(objext) ./atexit.$(objext) \
./sigsetmask.$(objext) ./snprintf.$(objext) \
./stpcpy.$(objext) ./stpncpy.$(objext) ./strcasecmp.$(objext) \
./strchr.$(objext) ./strdup.$(objext) ./strncasecmp.$(objext) \
- ./strncmp.$(objext) ./strndup.$(objext) ./strrchr.$(objext) \
- ./strstr.$(objext) ./strtod.$(objext) ./strtol.$(objext) \
- ./strtoul.$(objext) ./strverscmp.$(objext) \
+ ./strncmp.$(objext) ./strndup.$(objext) ./strnlen.$(objext) \
+ ./strrchr.$(objext) ./strstr.$(objext) ./strtod.$(objext) \
+ ./strtol.$(objext) ./strtoul.$(objext) ./strverscmp.$(objext) \
./tmpnam.$(objext) \
./vasprintf.$(objext) ./vfork.$(objext) ./vfprintf.$(objext) \
./vprintf.$(objext) ./vsnprintf.$(objext) ./vsprintf.$(objext) \
@@ -622,8 +622,8 @@ $(CONFIGURED_OFILES): stamp-picdir
else true; fi
$(COMPILE.c) $(srcdir)/crc32.c $(OUTPUT_OPTION)
-./dwarfnames.$(objext): $(srcdir)/dwarfnames.c $(INCDIR)/dwarf2.h \
- $(INCDIR)/dwarf2.def
+./dwarfnames.$(objext): $(srcdir)/dwarfnames.c $(INCDIR)/dwarf2.def \
+ $(INCDIR)/dwarf2.h
if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.c) $(PICFLAG) $(srcdir)/dwarfnames.c -o pic/$@; \
else true; fi
@@ -656,7 +656,8 @@ $(CONFIGURED_OFILES): stamp-picdir
else true; fi
$(COMPILE.c) $(srcdir)/fibheap.c $(OUTPUT_OPTION)
-./filename_cmp.$(objext): $(srcdir)/filename_cmp.c config.h $(INCDIR)/filenames.h \
+./filename_cmp.$(objext): $(srcdir)/filename_cmp.c config.h $(INCDIR)/ansidecl.h \
+ $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
$(INCDIR)/safe-ctype.h
if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.c) $(PICFLAG) $(srcdir)/filename_cmp.c -o pic/$@; \
@@ -757,7 +758,7 @@ $(CONFIGURED_OFILES): stamp-picdir
$(COMPILE.c) $(srcdir)/insque.c $(OUTPUT_OPTION)
./lbasename.$(objext): $(srcdir)/lbasename.c config.h $(INCDIR)/ansidecl.h \
- $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \
+ $(INCDIR)/filenames.h $(INCDIR)/hashtab.h $(INCDIR)/libiberty.h \
$(INCDIR)/safe-ctype.h
if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.c) $(PICFLAG) $(srcdir)/lbasename.c -o pic/$@; \
@@ -1043,7 +1044,7 @@ $(CONFIGURED_OFILES): stamp-picdir
else true; fi
$(COMPILE.c) $(srcdir)/splay-tree.c $(OUTPUT_OPTION)
-./stack-limit.$(objext): $(srcdir)/stack-limit.c config.h
+./stack-limit.$(objext): $(srcdir)/stack-limit.c config.h $(INCDIR)/ansidecl.h
if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.c) $(PICFLAG) $(srcdir)/stack-limit.c -o pic/$@; \
else true; fi
@@ -1104,6 +1105,12 @@ $(CONFIGURED_OFILES): stamp-picdir
else true; fi
$(COMPILE.c) $(srcdir)/strndup.c $(OUTPUT_OPTION)
+./strnlen.$(objext): $(srcdir)/strnlen.c config.h
+ if [ x"$(PICFLAG)" != x ]; then \
+ $(COMPILE.c) $(PICFLAG) $(srcdir)/strnlen.c -o pic/$@; \
+ else true; fi
+ $(COMPILE.c) $(srcdir)/strnlen.c $(OUTPUT_OPTION)
+
./strrchr.$(objext): $(srcdir)/strrchr.c $(INCDIR)/ansidecl.h
if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.c) $(PICFLAG) $(srcdir)/strrchr.c -o pic/$@; \
diff --git a/libiberty/config.in b/libiberty/config.in
index 17c4c2e..1cf9c11 100644
--- a/libiberty/config.in
+++ b/libiberty/config.in
@@ -262,6 +262,9 @@
/* Define to 1 if you have the `strndup' function. */
#undef HAVE_STRNDUP
+/* Define to 1 if you have the `strnlen' function. */
+#undef HAVE_STRNLEN
+
/* Define to 1 if you have the `strrchr' function. */
#undef HAVE_STRRCHR
diff --git a/libiberty/configure b/libiberty/configure
index 6e98352..5367027 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -5340,6 +5340,7 @@ funcs="$funcs strchr"
funcs="$funcs strdup"
funcs="$funcs strncasecmp"
funcs="$funcs strndup"
+funcs="$funcs strnlen"
funcs="$funcs strrchr"
funcs="$funcs strstr"
funcs="$funcs strtod"
@@ -5380,8 +5381,8 @@ if test "x" = "y"; then
random realpath rename rindex \
sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \
stpcpy stpncpy strcasecmp strchr strdup \
- strerror strncasecmp strndup strrchr strsignal strstr strtod strtol \
- strtoul strverscmp sysconf sysctl sysmp \
+ strerror strncasecmp strndup strnlen strrchr strsignal strstr strtod \
+ strtol strtoul strverscmp sysconf sysctl sysmp \
table times tmpnam \
vasprintf vfprintf vprintf vsprintf \
wait3 wait4 waitpid
@@ -5663,6 +5664,12 @@ esac
esac
case " $LIBOBJS " in
+ *" strnlen.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS strnlen.$ac_objext"
+ ;;
+esac
+
+ case " $LIBOBJS " in
*" strverscmp.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS strverscmp.$ac_objext"
;;
@@ -5683,7 +5690,7 @@ esac
for f in $funcs; do
case "$f" in
- asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strverscmp | vasprintf | waitpid)
+ asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strnlen | strverscmp | vasprintf | waitpid)
;;
*)
n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index 754b66a..c763894 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -322,6 +322,7 @@ funcs="$funcs strchr"
funcs="$funcs strdup"
funcs="$funcs strncasecmp"
funcs="$funcs strndup"
+funcs="$funcs strnlen"
funcs="$funcs strrchr"
funcs="$funcs strstr"
funcs="$funcs strtod"
@@ -362,8 +363,8 @@ if test "x" = "y"; then
random realpath rename rindex \
sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \
stpcpy stpncpy strcasecmp strchr strdup \
- strerror strncasecmp strndup strrchr strsignal strstr strtod strtol \
- strtoul strverscmp sysconf sysctl sysmp \
+ strerror strncasecmp strndup strnlen strrchr strsignal strstr strtod \
+ strtol strtoul strverscmp sysconf sysctl sysmp \
table times tmpnam \
vasprintf vfprintf vprintf vsprintf \
wait3 wait4 waitpid)
@@ -442,13 +443,14 @@ if test -n "${with_target_subdir}"; then
AC_LIBOBJ([stpcpy])
AC_LIBOBJ([stpncpy])
AC_LIBOBJ([strndup])
+ AC_LIBOBJ([strnlen])
AC_LIBOBJ([strverscmp])
AC_LIBOBJ([vasprintf])
AC_LIBOBJ([waitpid])
for f in $funcs; do
case "$f" in
- asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strverscmp | vasprintf | waitpid)
+ asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strnlen | strverscmp | vasprintf | waitpid)
;;
*)
n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 258aaa7..32df38c 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -696,6 +696,12 @@ d_dump (struct demangle_component *dc, int indent)
case DEMANGLE_COMPONENT_PACK_EXPANSION:
printf ("pack expansion\n");
break;
+ case DEMANGLE_COMPONENT_TLS_INIT:
+ printf ("tls init function\n");
+ break;
+ case DEMANGLE_COMPONENT_TLS_WRAPPER:
+ printf ("tls wrapper function\n");
+ break;
}
d_dump (d_left (dc), indent + 2);
@@ -832,6 +838,8 @@ d_make_comp (struct d_info *di, enum demangle_component_type type,
case DEMANGLE_COMPONENT_COVARIANT_THUNK:
case DEMANGLE_COMPONENT_JAVA_CLASS:
case DEMANGLE_COMPONENT_GUARD:
+ case DEMANGLE_COMPONENT_TLS_INIT:
+ case DEMANGLE_COMPONENT_TLS_WRAPPER:
case DEMANGLE_COMPONENT_REFTEMP:
case DEMANGLE_COMPONENT_HIDDEN_ALIAS:
case DEMANGLE_COMPONENT_TRANSACTION_CLONE:
@@ -1867,6 +1875,14 @@ d_special_name (struct d_info *di)
return d_make_comp (di, DEMANGLE_COMPONENT_JAVA_CLASS,
cplus_demangle_type (di), NULL);
+ case 'H':
+ return d_make_comp (di, DEMANGLE_COMPONENT_TLS_INIT,
+ d_name (di), NULL);
+
+ case 'W':
+ return d_make_comp (di, DEMANGLE_COMPONENT_TLS_WRAPPER,
+ d_name (di), NULL);
+
default:
return NULL;
}
@@ -4072,6 +4088,16 @@ d_print_comp (struct d_print_info *dpi, int options,
d_print_comp (dpi, options, d_left (dc));
return;
+ case DEMANGLE_COMPONENT_TLS_INIT:
+ d_append_string (dpi, "TLS init function for ");
+ d_print_comp (dpi, options, d_left (dc));
+ return;
+
+ case DEMANGLE_COMPONENT_TLS_WRAPPER:
+ d_append_string (dpi, "TLS wrapper function for ");
+ d_print_comp (dpi, options, d_left (dc));
+ return;
+
case DEMANGLE_COMPONENT_REFTEMP:
d_append_string (dpi, "reference temporary #");
d_print_comp (dpi, options, d_right (dc));
diff --git a/libiberty/functions.texi b/libiberty/functions.texi
index c9df186..9323ff9 100644
--- a/libiberty/functions.texi
+++ b/libiberty/functions.texi
@@ -84,7 +84,7 @@ is respectively less than, matching, or greater than the array member.
@end deftypefn
-@c argv.c:142
+@c argv.c:135
@deftypefn Extension char** buildargv (char *@var{sp})
Given a pointer to a string, parse the string extracting fields
@@ -95,7 +95,7 @@ remains unchanged. The last element of the vector is followed by a
@code{NULL} element.
All of the memory for the pointer array and copies of the string
-is obtained from @code{malloc}. All of the memory can be returned to the
+is obtained from @code{xmalloc}. All of the memory can be returned to the
system with the single function call @code{freeargv}, which takes the
returned result of @code{buildargv}, as it's argument.
@@ -166,6 +166,14 @@ pointer encountered. Pointers to empty strings are ignored.
@end deftypefn
+@c argv.c:470
+@deftypefn Extension int countargv (char **@var{argv})
+
+Return the number of elements in @var{argv}.
+Returns zero if @var{argv} is NULL.
+
+@end deftypefn
+
@c crc32.c:141
@deftypefn Extension {unsigned int} crc32 (const unsigned char *@var{buf}, @
int @var{len}, unsigned int @var{init})
@@ -224,7 +232,7 @@ symbolic name or message.
@end deftypefn
-@c argv.c:361
+@c argv.c:341
@deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp})
The @var{argcp} and @code{argvp} arguments are pointers to the usual
@@ -296,7 +304,24 @@ and backward slashes are equal.
@end deftypefn
-@c filename_cmp.c:81
+@c filename_cmp.c:178
+@deftypefn Extension int filename_eq (const void *@var{s1}, const void *@var{s2})
+
+Return non-zero if file names @var{s1} and @var{s2} are equivalent.
+This function is for use with hashtab.c hash tables.
+
+@end deftypefn
+
+@c filename_cmp.c:147
+@deftypefn Extension hashval_t filename_hash (const void *@var{s})
+
+Return the hash value for file name @var{s} that will be compared
+using filename_cmp.
+This function is for use with hashtab.c hash tables.
+
+@end deftypefn
+
+@c filename_cmp.c:89
@deftypefn Extension int filename_ncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n})
Return zero if the two file names @var{s1} and @var{s2} are equivalent
@@ -376,7 +401,7 @@ unchanged.
@end deftypefn
-@c argv.c:97
+@c argv.c:90
@deftypefn Extension void freeargv (char **@var{vector})
Free an argument vector that was built using @code{buildargv}. Simply
@@ -1465,6 +1490,13 @@ deallocate values.
@end deftypefn
+@c stack-limit.c:28
+@deftypefn Extension void stack_limit_increase (unsigned long @var{pref})
+
+Attempt to increase stack size limit to @var{pref} bytes if possible.
+
+@end deftypefn
+
@c stpcpy.c:23
@deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src})
@@ -1574,6 +1606,16 @@ memory was available. The result is always NUL terminated.
@end deftypefn
+@c strnlen.c:6
+@deftypefn Supplemental size_t strnlen (const char *@var{s}, size_t @var{maxlen})
+
+Returns the length of @var{s}, as with @code{strlen}, but never looks
+past the first @var{maxlen} characters in the string. If there is no
+'\0' character in the first @var{maxlen} characters, returns
+@var{maxlen}.
+
+@end deftypefn
+
@c strrchr.c:6
@deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
@@ -1728,6 +1770,22 @@ This function is especially useful when dealing with filename sorting,
because filenames frequently hold indices/version numbers.
@end deftypefun
+@c timeval-utils.c:43
+@deftypefn Extension void timeval_add (struct timeval *@var{a}, @
+ struct timeval *@var{b}, struct timeval *@var{result})
+
+Adds @var{a} to @var{b} and stores the result in @var{result}.
+
+@end deftypefn
+
+@c timeval-utils.c:67
+@deftypefn Extension void timeval_sub (struct timeval *@var{a}, @
+ struct timeval *@var{b}, struct timeval *@var{result})
+
+Subtracts @var{b} from @var{a} and stores the result in @var{result}.
+
+@end deftypefn
+
@c tmpnam.c:3
@deftypefn Supplemental char* tmpnam (char *@var{s})
@@ -1829,7 +1887,7 @@ does the return value. The third argument is unused in @libib{}.
@end deftypefn
-@c argv.c:306
+@c argv.c:286
@deftypefn Extension int writeargv (const char **@var{argv}, FILE *@var{file})
Write each member of ARGV, handling all necessary quoting, to the file
diff --git a/libiberty/maint-tool b/libiberty/maint-tool
index 36b9203..d50f895 100644
--- a/libiberty/maint-tool
+++ b/libiberty/maint-tool
@@ -222,7 +222,7 @@ sub deps {
opendir(INC, $incdir);
while ($f = readdir INC) {
- next unless $f =~ /\.h$/;
+ next unless $f =~ /\.h$/ || $f =~ /\.def$/;
$mine{$f} = "\$(INCDIR)/$f";
$deps{$f} = join(' ', &deps_for("$incdir/$f"));
}
diff --git a/libiberty/objalloc.c b/libiberty/objalloc.c
index 3ddac2c..72e92d2 100644
--- a/libiberty/objalloc.c
+++ b/libiberty/objalloc.c
@@ -1,5 +1,5 @@
/* objalloc.c -- routines to allocate memory for objects
- Copyright 1997 Free Software Foundation, Inc.
+ Copyright 1997-2012 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Solutions.
This program is free software; you can redistribute it and/or modify it
@@ -112,8 +112,10 @@ objalloc_create (void)
/* Allocate space from an objalloc structure. */
PTR
-_objalloc_alloc (struct objalloc *o, unsigned long len)
+_objalloc_alloc (struct objalloc *o, unsigned long original_len)
{
+ unsigned long len = original_len;
+
/* We avoid confusion from zero sized objects by always allocating
at least 1 byte. */
if (len == 0)
@@ -121,6 +123,11 @@ _objalloc_alloc (struct objalloc *o, unsigned long len)
len = (len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1);
+ /* Check for overflow in the alignment operation above and the
+ malloc argument below. */
+ if (len + CHUNK_HEADER_SIZE < original_len)
+ return NULL;
+
if (len <= o->current_space)
{
o->current_ptr += len;
diff --git a/libiberty/strnlen.c b/libiberty/strnlen.c
new file mode 100644
index 0000000..4934973
--- /dev/null
+++ b/libiberty/strnlen.c
@@ -0,0 +1,30 @@
+/* Portable version of strnlen.
+ This function is in the public domain. */
+
+/*
+
+@deftypefn Supplemental size_t strnlen (const char *@var{s}, size_t @var{maxlen})
+
+Returns the length of @var{s}, as with @code{strlen}, but never looks
+past the first @var{maxlen} characters in the string. If there is no
+'\0' character in the first @var{maxlen} characters, returns
+@var{maxlen}.
+
+@end deftypefn
+
+*/
+
+#include "config.h"
+
+#include <stddef.h>
+
+size_t
+strnlen (const char *s, size_t maxlen)
+{
+ size_t i;
+
+ for (i = 0; i < maxlen; ++i)
+ if (s[i] == '\0')
+ break;
+ return i;
+}