summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2019-07-03 20:54:36 +0000
committerMark Johnston <markj@FreeBSD.org>2019-07-03 20:54:36 +0000
commitaca924dfb90055aa66d021f5191e5b76b4ef3889 (patch)
tree167894c4094f0d489408c48239a59fdda50d9740 /contrib
parentd712d2d8c38ce64215d0c830f600d101177b59fb (diff)
downloadsrc-test2-aca924dfb90055aa66d021f5191e5b76b4ef3889.tar.gz
src-test2-aca924dfb90055aa66d021f5191e5b76b4ef3889.zip
Notes
Diffstat (limited to 'contrib')
-rw-r--r--contrib/elftoolchain/libelftc/elftc_string_table.c35
-rw-r--r--contrib/elftoolchain/libelftc/elftc_string_table_create.36
-rw-r--r--contrib/elftoolchain/libelftc/libelftc.h4
3 files changed, 24 insertions, 21 deletions
diff --git a/contrib/elftoolchain/libelftc/elftc_string_table.c b/contrib/elftoolchain/libelftc/elftc_string_table.c
index c738fc64501e..37fcc36d407b 100644
--- a/contrib/elftoolchain/libelftc/elftc_string_table.c
+++ b/contrib/elftoolchain/libelftc/elftc_string_table.c
@@ -44,7 +44,7 @@ ELFTC_VCSID("$Id: elftc_string_table.c 2869 2013-01-06 13:29:18Z jkoshy $");
#define ELFTC_STRING_TABLE_POOL_SIZE_INCREMENT (4*1024)
struct _Elftc_String_Table_Entry {
- int ste_idx;
+ ssize_t ste_idx;
SLIST_ENTRY(_Elftc_String_Table_Entry) ste_next;
};
@@ -64,9 +64,9 @@ struct _Elftc_String_Table_Entry {
} while (0)
struct _Elftc_String_Table {
- unsigned int st_len; /* length and flags */
+ size_t st_len; /* length and flags */
int st_nbuckets;
- int st_string_pool_size;
+ size_t st_string_pool_size;
char *st_string_pool;
SLIST_HEAD(_Elftc_String_Table_Bucket,
_Elftc_String_Table_Entry) st_buckets[];
@@ -86,7 +86,7 @@ elftc_string_table_find_hash_entry(Elftc_String_Table *st, const char *string,
*rhashindex = hashindex;
SLIST_FOREACH(ste, &st->st_buckets[hashindex], ste_next) {
- s = st->st_string_pool + abs(ste->ste_idx);
+ s = st->st_string_pool + labs(ste->ste_idx);
assert(s > st->st_string_pool &&
s < st->st_string_pool + st->st_string_pool_size);
@@ -102,7 +102,7 @@ static int
elftc_string_table_add_to_pool(Elftc_String_Table *st, const char *string)
{
char *newpool;
- int len, newsize, stlen;
+ size_t len, newsize, stlen;
len = strlen(string) + 1; /* length, including the trailing NUL */
stlen = ELFTC_STRING_TABLE_LENGTH(st);
@@ -126,10 +126,10 @@ elftc_string_table_add_to_pool(Elftc_String_Table *st, const char *string)
}
Elftc_String_Table *
-elftc_string_table_create(int sizehint)
+elftc_string_table_create(size_t sizehint)
{
- int n, nbuckets, tablesize;
struct _Elftc_String_Table *st;
+ int n, nbuckets, tablesize;
if (sizehint < ELFTC_STRING_TABLE_DEFAULT_SIZE)
sizehint = ELFTC_STRING_TABLE_DEFAULT_SIZE;
@@ -173,13 +173,13 @@ elftc_string_table_destroy(Elftc_String_Table *st)
}
Elftc_String_Table *
-elftc_string_table_from_section(Elf_Scn *scn, int sizehint)
+elftc_string_table_from_section(Elf_Scn *scn, size_t sizehint)
{
- int len;
Elf_Data *d;
GElf_Shdr sh;
const char *s, *end;
Elftc_String_Table *st;
+ size_t len;
/* Verify the type of the section passed in. */
if (gelf_getshdr(scn, &sh) == NULL ||
@@ -235,7 +235,8 @@ elftc_string_table_image(Elftc_String_Table *st, size_t *size)
char *r, *s, *end;
struct _Elftc_String_Table_Entry *ste;
struct _Elftc_String_Table_Bucket *head;
- int copied, hashindex, offset, length, newsize;
+ size_t copied, offset, length, newsize;
+ int hashindex;
/*
* For the common case of a string table has not seen
@@ -303,8 +304,9 @@ elftc_string_table_image(Elftc_String_Table *st, size_t *size)
size_t
elftc_string_table_insert(Elftc_String_Table *st, const char *string)
{
- int hashindex, idx;
struct _Elftc_String_Table_Entry *ste;
+ ssize_t idx;
+ int hashindex;
hashindex = 0;
@@ -326,7 +328,7 @@ elftc_string_table_insert(Elftc_String_Table *st, const char *string)
idx = ste->ste_idx;
if (idx < 0) /* Undelete. */
- ste->ste_idx = idx = (- idx);
+ ste->ste_idx = idx = -idx;
return (idx);
}
@@ -334,8 +336,9 @@ elftc_string_table_insert(Elftc_String_Table *st, const char *string)
size_t
elftc_string_table_lookup(Elftc_String_Table *st, const char *string)
{
- int hashindex, idx;
struct _Elftc_String_Table_Entry *ste;
+ ssize_t idx;
+ int hashindex;
ste = elftc_string_table_find_hash_entry(st, string, &hashindex);
@@ -350,17 +353,17 @@ elftc_string_table_lookup(Elftc_String_Table *st, const char *string)
int
elftc_string_table_remove(Elftc_String_Table *st, const char *string)
{
- int idx;
struct _Elftc_String_Table_Entry *ste;
+ ssize_t idx;
ste = elftc_string_table_find_hash_entry(st, string, NULL);
if (ste == NULL || (idx = ste->ste_idx) < 0)
return (ELFTC_FAILURE);
- assert(idx > 0 && idx < (int) ELFTC_STRING_TABLE_LENGTH(st));
+ assert(idx > 0 && (size_t)idx < ELFTC_STRING_TABLE_LENGTH(st));
- ste->ste_idx = (- idx);
+ ste->ste_idx = -idx;
ELFTC_STRING_TABLE_SET_COMPACTION_FLAG(st);
diff --git a/contrib/elftoolchain/libelftc/elftc_string_table_create.3 b/contrib/elftoolchain/libelftc/elftc_string_table_create.3
index 36c7290d9f46..813999a47180 100644
--- a/contrib/elftoolchain/libelftc/elftc_string_table_create.3
+++ b/contrib/elftoolchain/libelftc/elftc_string_table_create.3
@@ -24,7 +24,7 @@
.\"
.\" $Id: elftc_string_table_create.3 3645 2018-10-15 20:17:14Z jkoshy $
.\"
-.Dd January 5, 2013
+.Dd June 19, 2019
.Dt ELFTC_STRING_TABLE_CREATE 3
.Os
.Sh NAME
@@ -40,11 +40,11 @@
.Sh SYNOPSIS
.In libelftc.h
.Ft "Elftc_String_Table *"
-.Fn elftc_string_table_create "int sizehint"
+.Fn elftc_string_table_create "size_t sizehint"
.Ft int
.Fn elftc_string_table_destroy "Elftc_String_Table *table"
.Ft "Elftc_String_Table *"
-.Fn elftc_string_table_from_section "Elf_Scn *scn" "int sizehint"
+.Fn elftc_string_table_from_section "Elf_Scn *scn" "size_t sizehint"
.Ft "const char *"
.Fo elftc_string_table_image
.Fa "Elftc_String_Table *table"
diff --git a/contrib/elftoolchain/libelftc/libelftc.h b/contrib/elftoolchain/libelftc/libelftc.h
index a235097e6910..a404dfe34e9c 100644
--- a/contrib/elftoolchain/libelftc/libelftc.h
+++ b/contrib/elftoolchain/libelftc/libelftc.h
@@ -77,10 +77,10 @@ int elftc_demangle(const char *_mangledname, char *_buffer,
size_t _bufsize, unsigned int _flags);
const char *elftc_reloc_type_str(unsigned int mach, unsigned int type);
int elftc_set_timestamps(const char *_filename, struct stat *_sb);
-Elftc_String_Table *elftc_string_table_create(int _hint);
+Elftc_String_Table *elftc_string_table_create(size_t _sizehint);
void elftc_string_table_destroy(Elftc_String_Table *_table);
Elftc_String_Table *elftc_string_table_from_section(Elf_Scn *_scn,
- int _hint);
+ size_t _sizehint);
const char *elftc_string_table_image(Elftc_String_Table *_table,
size_t *_sz);
size_t elftc_string_table_insert(Elftc_String_Table *_table,