Page MenuHomeFreeBSD

D20544.id58496.diff
No OneTemporary

D20544.id58496.diff

Index: contrib/elftoolchain/elfcopy/sections.c
===================================================================
--- contrib/elftoolchain/elfcopy/sections.c
+++ contrib/elftoolchain/elfcopy/sections.c
@@ -1398,7 +1398,23 @@
void
init_shstrtab(struct elfcopy *ecp)
{
+ Elf_Scn *shstrtab;
+ GElf_Shdr shdr;
struct section *s;
+ size_t indx, sizehint;
+
+ if (elf_getshstrndx(ecp->ein, &indx) != 0) {
+ shstrtab = elf_getscn(ecp->ein, indx);
+ if (shstrtab == NULL)
+ errx(EXIT_FAILURE, "elf_getscn failed: %s",
+ elf_errmsg(-1));
+ if (gelf_getshdr(shstrtab, &shdr) != &shdr)
+ errx(EXIT_FAILURE, "gelf_getshdr failed: %s",
+ elf_errmsg(-1));
+ sizehint = shdr.sh_size;
+ } else {
+ sizehint = 0;
+ }
if ((ecp->shstrtab = calloc(1, sizeof(*ecp->shstrtab))) == NULL)
err(EXIT_FAILURE, "calloc failed");
@@ -1410,7 +1426,7 @@
s->loadable = 0;
s->type = SHT_STRTAB;
s->vma = 0;
- s->strtab = elftc_string_table_create(0);
+ s->strtab = elftc_string_table_create(sizehint);
add_to_shstrtab(ecp, "");
add_to_shstrtab(ecp, ".symtab");
Index: contrib/elftoolchain/libelftc/elftc_string_table.c
===================================================================
--- contrib/elftoolchain/libelftc/elftc_string_table.c
+++ contrib/elftoolchain/libelftc/elftc_string_table.c
@@ -66,7 +66,7 @@
struct _Elftc_String_Table {
unsigned int 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[];
@@ -102,7 +102,7 @@
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,7 +126,7 @@
}
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;
@@ -173,7 +173,7 @@
}
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;
Index: contrib/elftoolchain/libelftc/elftc_string_table_create.3
===================================================================
--- contrib/elftoolchain/libelftc/elftc_string_table_create.3
+++ contrib/elftoolchain/libelftc/elftc_string_table_create.3
@@ -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"
Index: contrib/elftoolchain/libelftc/libelftc.h
===================================================================
--- contrib/elftoolchain/libelftc/libelftc.h
+++ contrib/elftoolchain/libelftc/libelftc.h
@@ -77,10 +77,10 @@
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,

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 25, 12:10 AM (14 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32098616
Default Alt Text
D20544.id58496.diff (3 KB)

Event Timeline