svn commit: r367322 - head/contrib/elftoolchain/libelftc

Dimitry Andric dim at FreeBSD.org
Wed Nov 4 11:02:06 UTC 2020


Author: dim
Date: Wed Nov  4 11:02:05 2020
New Revision: 367322
URL: https://svnweb.freebsd.org/changeset/base/367322

Log:
  Merge elftoolchain r3877 (by jkoshy):
  
    Incorporate fixes from Dimitry Andric:
  
    - Use a BUFFER_GROW() macro to avoid rounding errors in capacity
      calculations.
    - Fix a bug introduced in [r3531].
    - Fix handling of nested template parameters.
  
    Ticket:	#581
  
  This should fix a number of assertions on elftoolchain's cxxfilt, and
  allow it to correctly demangle several names that it could not handle
  before.
  
  Obtained from:	https://sourceforge.net/p/elftoolchain/code/3877/
  PR:		250702
  MFC after:	3 days

Modified:
  head/contrib/elftoolchain/libelftc/_libelftc.h
  head/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c
  head/contrib/elftoolchain/libelftc/libelftc_vstr.c

Modified: head/contrib/elftoolchain/libelftc/_libelftc.h
==============================================================================
--- head/contrib/elftoolchain/libelftc/_libelftc.h	Wed Nov  4 10:38:25 2020	(r367321)
+++ head/contrib/elftoolchain/libelftc/_libelftc.h	Wed Nov  4 11:02:05 2020	(r367322)
@@ -56,6 +56,7 @@ struct vector_str {
 };
 
 #define BUFFER_GROWFACTOR	1.618
+#define BUFFER_GROW(x)		(((x)+0.5)*BUFFER_GROWFACTOR)
 
 #define	ELFTC_FAILURE		0
 #define	ELFTC_ISDIGIT(C) 	(isdigit((C) & 0xFF))

Modified: head/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c
==============================================================================
--- head/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c	Wed Nov  4 10:38:25 2020	(r367321)
+++ head/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c	Wed Nov  4 11:02:05 2020	(r367322)
@@ -2135,10 +2135,10 @@ cpp_demangle_read_sname(struct cpp_demangle_data *ddat
 	if (err == 0)
 		return (0);
 
-	assert(ddata->output.size > 0);
+	assert(ddata->cur_output->size > 0);
 	if (vector_read_cmd_find(&ddata->cmd, READ_TMPL) == NULL)
 		ddata->last_sname =
-		    ddata->output.container[ddata->output.size - 1];
+		    ddata->cur_output->container[ddata->output.size - 1];
 
 	ddata->cur += len;
 
@@ -2421,7 +2421,7 @@ cpp_demangle_read_tmpl_args(struct cpp_demangle_data *
 		return (0);
 
 	limit = 0;
-	v = &ddata->output;
+	v = ddata->cur_output;
 	for (;;) {
 		idx = v->size;
 		if (!cpp_demangle_read_tmpl_arg(ddata))
@@ -3909,7 +3909,7 @@ vector_read_cmd_push(struct vector_read_cmd *v, enum r
 		return (0);
 
 	if (v->size == v->capacity) {
-		tmp_cap = v->capacity * BUFFER_GROWFACTOR;
+		tmp_cap = BUFFER_GROW(v->capacity);
 		if ((tmp_r_ctn = malloc(sizeof(*tmp_r_ctn) * tmp_cap)) == NULL)
 			return (0);
 		for (i = 0; i < v->size; ++i)
@@ -3974,7 +3974,7 @@ vector_type_qualifier_push(struct vector_type_qualifie
 		return (0);
 
 	if (v->size == v->capacity) {
-		tmp_cap = v->capacity * BUFFER_GROWFACTOR;
+		tmp_cap = BUFFER_GROW(v->capacity);
 		if ((tmp_ctn = malloc(sizeof(enum type_qualifier) * tmp_cap))
 		    == NULL)
 			return (0);

Modified: head/contrib/elftoolchain/libelftc/libelftc_vstr.c
==============================================================================
--- head/contrib/elftoolchain/libelftc/libelftc_vstr.c	Wed Nov  4 10:38:25 2020	(r367321)
+++ head/contrib/elftoolchain/libelftc/libelftc_vstr.c	Wed Nov  4 11:02:05 2020	(r367322)
@@ -152,7 +152,7 @@ vector_str_grow(struct vector_str *v)
 
 	assert(v->capacity > 0);
 
-	tmp_cap = v->capacity * BUFFER_GROWFACTOR;
+	tmp_cap = BUFFER_GROW(v->capacity);
 
 	assert(tmp_cap > v->capacity);
 
@@ -253,7 +253,7 @@ vector_str_push_vector_head(struct vector_str *dst, st
 	if (dst == NULL || org == NULL)
 		return (false);
 
-	tmp_cap = (dst->size + org->size) * BUFFER_GROWFACTOR;
+	tmp_cap = BUFFER_GROW(dst->size + org->size);
 
 	if ((tmp_ctn = malloc(sizeof(char *) * tmp_cap)) == NULL)
 		return (false);
@@ -293,7 +293,7 @@ vector_str_push_vector(struct vector_str *dst, struct 
 	if (dst == NULL || org == NULL)
 		return (false);
 
-	tmp_cap = (dst->size + org->size) * BUFFER_GROWFACTOR;
+	tmp_cap = BUFFER_GROW(dst->size + org->size);
 
 	if ((tmp_ctn = malloc(sizeof(char *) * tmp_cap)) == NULL)
 		return (false);


More information about the svn-src-all mailing list