This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/3002] New: iconvconfig misalignes hash table on ARM
- From: "mikpe at it dot uu dot se" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 5 Aug 2006 18:57:48 -0000
- Subject: [Bug libc/3002] New: iconvconfig misalignes hash table on ARM
- Reply-to: sourceware-bugzilla at sourceware dot org
Iconvconfig explicitly aligns the hash table part of its output file
(gconv-modules.cache) to a two-byte boundary. That's not OK for ARM
because the hash table is an array of structures, and those structures
have 4-byte alignment on ARM. When compiling for gcc's default CPU
type (the ARMv3 arm6 processor), gcc uses combinations of 4-byte loads
and shifts to read 2-byte fields from the hash table; this occurs in
__gconv_lookup_cache(). Due the broken code to align the hash table,
there is a very high probability (50%, depends on the size of the
preceeding string table) that each of these loads will cause an alignment
exception and require kernel fixup.
The fix is to use __alignof__ (struct hash_entry) not sizeof (gidx_t)
when aligning the hash table. This has no effect on other architectures
since they make __alignof__ (struct hash_entry) == __alignof__ (gidx_t).
--- glibc-2.3.6/iconv/iconvconfig.c.~1~ 2005-04-05 20:37:52.000000000 -0400
+++ glibc-2.3.6/iconv/iconvconfig.c 2006-07-28 09:59:22.000000000 -0400
@@ -1028,7 +1028,7 @@ write_output (void)
size_t n;
int idx;
struct iovec iov[6];
- static const gidx_t null_word;
+ static const char null_word[__alignof__ (struct hash_entry)];
size_t total;
char finalname[prefix_len + sizeof GCONV_MODULES_CACHE];
char tmpfname[(output_file == NULL ? sizeof finalname : output_file_len + 1)
@@ -1193,11 +1193,11 @@ write_output (void)
total += iov[1].iov_len;
idx = 2;
- if ((string_table_size & (sizeof (gidx_t) - 1)) != 0)
+ if ((string_table_size & (__alignof__ (struct hash_entry) - 1)) != 0)
{
iov[2].iov_base = (void *) &null_word;
- iov[2].iov_len = (sizeof (gidx_t)
- - (string_table_size & (sizeof (gidx_t) - 1)));
+ iov[2].iov_len = (__alignof__ (struct hash_entry)
+ - (string_table_size & (__alignof__ (struct hash_entry)
- 1)));
total += iov[2].iov_len;
++idx;
}
--
Summary: iconvconfig misalignes hash table on ARM
Product: glibc
Version: 2.3.6
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: mikpe at it dot uu dot se
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: armv5b-unknown-linux
GCC host triplet: armv5b-unknown-linux
GCC target triplet: armv5b-unknown-linux
http://sourceware.org/bugzilla/show_bug.cgi?id=3002
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.