diff options
author | Ian Lance Taylor <iant@google.com> | 2007-10-19 23:33:37 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-10-19 23:33:37 +0000 |
commit | b0fac732e5dbe96fa96800b22cd303d06cbb2470 (patch) | |
tree | 75f2f9f4a3a784df433499d37acce91836bd873a /gold/merge.cc | |
parent | b9985f4041b6c0fdb5ab2b957e06d4babcfb9e73 (diff) | |
download | binutils-redhat-b0fac732e5dbe96fa96800b22cd303d06cbb2470.tar.gz |
Fix handling of wide string merge sections.
Diffstat (limited to 'gold/merge.cc')
-rw-r--r-- | gold/merge.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gold/merge.cc b/gold/merge.cc index b5c836f5f7..80d2d1ae1a 100644 --- a/gold/merge.cc +++ b/gold/merge.cc @@ -259,16 +259,17 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object, "character size")); return false; } - len /= sizeof(Char_type); + // The index I is in bytes, not characters. off_t i = 0; while (i < len) { off_t plen = 0; for (const Char_type* pl = p; *pl != 0; ++pl) { + // The length PLEN is in characters, not bytes. ++plen; - if (i + plen >= len) + if (i + plen * sizeof(Char_type) >= len) { object->error(_("entry in mergeable string section " "not null terminated")); @@ -281,7 +282,7 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object, this->merged_strings_.push_back(Merged_string(object, shndx, i, str)); p += plen + 1; - i += plen + 1; + i += (plen + 1) * sizeof(Char_type); } return true; |