bug 225340 : fix unaligned memory access on 64bit machines in nsSaveAsCharset and Gfx. (r=smontagu, sr=rbs, a1.6b = asa)

This commit is contained in:
jshin%mailaps.org 2003-11-23 00:25:52 +00:00
Родитель c24f856310
Коммит c8ce8c2966
6 изменённых файлов: 176 добавлений и 24 удалений

Просмотреть файл

@ -4302,8 +4302,69 @@
0X0E0FFF :
*/
#if defined(IS_LITTLE_ENDIAN)
// Precompiled CCMap for Little Endian(16/32/64bit)
#if (defined(IS_LITTLE_ENDIAN) && ALU_SIZE == 64)
// Precompiled CCMap for Little Endian(64bit)
/* EXTFLG */ 0x0001,0x0000,0x0100,0x0000,
/* 000000 */ 0x0030,0x0080,0x00B0,0x0010,0x0010,0x0010,0x0010,0x0010,
0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x00D0,
/* 000010 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 000020 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000030 */ 0x0040,0x0020,0x0020,0x0050,0x0020,0x0020,0x0060,0x0070,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 000040 */ 0xC1FF,0xFFFF,0x0000,0x0000,0x0000,0x0000,0x0000,0x8000,
0xFFDF,0xFFFF,0x2000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000050 */ 0x0000,0x0000,0x0000,0x0000,0x8000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000060 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x2000,0x0000,0x0000,
/* 000070 */ 0x8000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000080 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0090,
0x00A0,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 000090 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0030,0x0000,0x0000,0x0000,0x0000,
/* 0000a0 */ 0x3800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 0000b0 */ 0x00C0,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 0000c0 */ 0xC800,0x0000,0x7C00,0x0000,0x0000,0x0000,0xFFFF,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 0000d0 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x00E0,0x00F0,
/* 0000e0 */ 0xFFFF,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x8000,
/* 0000f0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0001,0x0000,0x0000,0x0000,0x0000,0x0FFF,
/* 000100 */ 0x0130,0x0000,0x0120,0x0000,0x0120,0x0000,0x0120,0x0000,
0x0120,0x0000,0x0120,0x0000,0x0120,0x0000,0x0120,0x0000,
/* 000110 */ 0x0120,0x0000,0x0120,0x0000,0x0120,0x0000,0x0120,0x0000,
0x0120,0x0000,0x0180,0x0000,0x0120,0x0000,0x0120,0x0000,
/* 000120 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000130 */ 0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,
0x0010,0x0010,0x0010,0x0010,0x0010,0x0030,0x0010,0x0010,
/* 000140 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 000150 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000160 */ 0x0020,0x0040,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 000170 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x07F8,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000180 */ 0x0040,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,
0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,
/* 000190 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 0001a0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 0001b0 */ 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
/* 0001c0 */ 0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,
0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,
#elif defined(IS_LITTLE_ENDIAN)
// Precompiled CCMap for Little Endian(16/32bit)
/* EXTFLG */ 0x0001,0x0100,
/* 000000 */ 0x0030,0x0080,0x00B0,0x0010,0x0010,0x0010,0x0010,0x0010,
0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x00D0,
@ -4487,7 +4548,7 @@
0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,
#elif (ALU_SIZE == 64)
// Precompiled CCMap for Big Endian(64bit)
/* EXTFLG */ 0x0001,0x0100,
/* EXTFLG */ 0x0000,0x0001,0x0000,0x0100,
/* 000000 */ 0x0030,0x0080,0x00B0,0x0010,0x0010,0x0010,0x0010,0x0010,
0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x00D0,
/* 000010 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,

Просмотреть файл

@ -170,9 +170,10 @@ static PRUint16 gIgnorableCCMapExtRaw[] = {
#include "ignorable.x-ccmap"
};
// It's a pre-compiled extended ccmap so that the pointer
// has to point at the 3rd element.
static PRUint16 *gIgnorableCCMapExt = gIgnorableCCMapExtRaw + 2;
// It's a pre-compiled extended ccmap so that the first CCMAP_EXTRA
// (2 on 16/32bit machines, 4 on 64bit machines)
// elements are used to store the ccmap flag and the size of the BMP map.
static PRUint16 *gIgnorableCCMapExt = gIgnorableCCMapExtRaw + CCMAP_EXTRA;
static nsCharsetInfo gCharsetInfo[eCharset_COUNT] =
{

Просмотреть файл

@ -4399,8 +4399,77 @@
0X0E0FFF :
*/
#if defined(IS_LITTLE_ENDIAN)
// Precompiled CCMap for Little Endian(16/32/64bit)
#if (defined(IS_LITTLE_ENDIAN) && ALU_SIZE == 64)
// Precompiled CCMap for Little Endian(64bit)
/* EXTFLG */ 0x0001,0x0000,0x0140,0x0000,
/* 000000 */ 0x0030,0x0090,0x00D0,0x00F0,0x0010,0x0010,0x0010,0x0010,
0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0110,
/* 000010 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 000020 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000030 */ 0x0040,0x0020,0x0020,0x0050,0x0020,0x0060,0x0070,0x0080,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 000040 */ 0xC1FF,0xFFFF,0x0000,0x0000,0x0000,0x0000,0x0000,0x8000,
0xFFDF,0xFFFF,0x2000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000050 */ 0x0000,0x0000,0x0000,0x0000,0x8000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000060 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0xFFFE,0xFFFB,0xBBFF,0x0016,0x0000,0x0000,0x0000,
/* 000070 */ 0x000F,0x003F,0x0000,0x0000,0xF800,0x01FF,0x0000,0x0001,
0x0000,0x0000,0x0000,0x0000,0x0000,0xFFC0,0x3D9F,0x0000,
/* 000080 */ 0x8000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000090 */ 0x0020,0x00A0,0x0020,0x0020,0x0020,0x0020,0x0020,0x00B0,
0x00C0,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 0000a0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x8000,0x0001,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 0000b0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0030,0x0000,0x0000,0x0000,0x0000,
/* 0000c0 */ 0x3800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 0000d0 */ 0x00E0,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 0000e0 */ 0xF800,0x0000,0x7C00,0x0000,0x0000,0x0000,0xFFFF,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 0000f0 */ 0x0020,0x0100,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 000100 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0010,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000110 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0120,0x0130,
/* 000120 */ 0xFFFF,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x8000,
/* 000130 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0001,0x0000,0x0000,0x0000,0x0000,0x0FFF,
/* 000140 */ 0x0170,0x0000,0x0160,0x0000,0x0160,0x0000,0x0160,0x0000,
0x0160,0x0000,0x0160,0x0000,0x0160,0x0000,0x0160,0x0000,
/* 000150 */ 0x0160,0x0000,0x0160,0x0000,0x0160,0x0000,0x0160,0x0000,
0x0160,0x0000,0x01C0,0x0000,0x0160,0x0000,0x0160,0x0000,
/* 000160 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 000170 */ 0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,
0x0010,0x0010,0x0010,0x0010,0x0010,0x0030,0x0010,0x0010,
/* 000180 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 000190 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 0001a0 */ 0x0020,0x0040,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 0001b0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x07F8,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 0001c0 */ 0x0040,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,
0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,
/* 0001d0 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,
/* 0001e0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
/* 0001f0 */ 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
/* 000200 */ 0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,
0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,
#elif defined(IS_LITTLE_ENDIAN)
// Precompiled CCMap for Little Endian(16/32bit)
/* EXTFLG */ 0x0001,0x0140,
/* 000000 */ 0x0030,0x0090,0x00D0,0x00F0,0x0010,0x0010,0x0010,0x0010,
0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0110,
@ -4608,7 +4677,7 @@
0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,
#elif (ALU_SIZE == 64)
// Precompiled CCMap for Big Endian(64bit)
/* EXTFLG */ 0x0001,0x0140,
/* EXTFLG */ 0x0000,0x0001,0x0000,0x0140,
/* 000000 */ 0x0030,0x0090,0x00D0,0x00F0,0x0010,0x0010,0x0010,0x0010,
0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0110,
/* 000010 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,

Просмотреть файл

@ -58,8 +58,9 @@ const static PRUint16 gIgnorableCCMapExtRaw[] =
#include "ignorables_abjadpoints.x-ccmap"
};
// 1st Two elements of ext. ccmap need to have negative indices.
const static PRUint16 *gIgnorableCCMapExt = gIgnorableCCMapExtRaw + 2;
// 1st CCMAP_EXTRA (2 on 32bit, 4 on 64bit machines) elements of ext. ccmap
// need to have negative indices.
const static PRUint16 *gIgnorableCCMapExt = gIgnorableCCMapExtRaw + CCMAP_EXTRA;
//
// nsSaveAsCharset

Просмотреть файл

@ -385,20 +385,37 @@ sub print_ccmap
# BE order) have to be treated differently based on the
# the endianness as well.
# For BMP-only CCMap, 16BE CCMap is identical to LE CCMaps.
my @fmts = $is_ext ? ("LE", "16BE", "32BE", "64BE") : ("LE", "32BE", "64BE") ;
# For BMP-only CCMap, 16BE CCMap is identical to LE CCMaps.
# With non-BMP characters present, to avoid the misalignment on 64bit
# machines, we have to store the ccmap flag (indicating whether the map
# is extended or not)and the BMP map size in two 32bit integers instead of
# two 16bit integers (bug 225340)
my @fmts = $is_ext ? ("64LE", "LE", "16BE", "32BE", "64BE") : ("LE", "32BE", "64BE") ;
foreach my $fmt (@fmts)
{
my($offset) = 0;
for ($fmt) {
/64LE/ and do {
@idxlist = (0, 1, 2, 3);
@int16toint32 = (1, 0, 3, 2);
print OUT "#if (defined(IS_LITTLE_ENDIAN) && ALU_SIZE == 64)\n" .
"// Precompiled CCMap for Little Endian(64bit)\n";
printf OUT "/* EXTFLG */ 0x%04X,0x0000,0x%04X,0x0000,\n",
$ccmap_p->[0], $ccmap_p->[1];
last;
};
/LE/ and do {
@idxlist = (0, 1, 2, 3);
@int16toint32 = (1, 0, 3, 2);
print OUT $is_ext ?
"#if defined(IS_LITTLE_ENDIAN)\n" .
"// Precompiled CCMap for Little Endian(16/32/64bit) \n" :
"#elif defined(IS_LITTLE_ENDIAN)\n" .
"// Precompiled CCMap for Little Endian(16/32bit) \n" :
"#if (defined(IS_LITTLE_ENDIAN) || ALU_SIZE == 16)\n" .
"// Precompiled CCMap for Little Endian(16/32/64bit)\n" .
"// and Big Endian(16bit)\n";
printf OUT "/* EXTFLG */ 0x%04X,0x%04X,\n",
$ccmap_p->[0], $ccmap_p->[1];
last;
};
/16BE/ and do {
@ -406,6 +423,8 @@ sub print_ccmap
@int16toint32 = (0, 1, 2, 3);
print OUT "#elif (ALU_SIZE == 16)\n" .
"// Precompiled CCMap for Big Endian(16bit)\n";
printf OUT "/* EXTFLG */ 0x%04X,0x%04X,\n",
$ccmap_p->[0], $ccmap_p->[1];
last;
};
/32BE/ and do {
@ -413,6 +432,8 @@ sub print_ccmap
@int16toint32 = (0, 1, 2, 3);
print OUT "#elif (ALU_SIZE == 32)\n" .
"// Precompiled CCMap for Big Endian(32bit)\n";
printf OUT "/* EXTFLG */ 0x%04X,0x%04X,\n",
$ccmap_p->[0], $ccmap_p->[1];
last;
};
/64BE/ and do {
@ -420,18 +441,16 @@ sub print_ccmap
@int16toint32 = (0, 1, 2, 3);
print OUT "#elif (ALU_SIZE == 64)\n" .
"// Precompiled CCMap for Big Endian(64bit)\n";
printf OUT "/* EXTFLG */ 0x0000,0x%04X,0x0000,0x%04X,\n",
$ccmap_p->[0], $ccmap_p->[1];
last;
};
}
my($offset) = 0;
if ($is_ext) {
printf OUT "/* EXTFLG */ 0x%04X,0x%04X,\n", $ccmap_p->[0], $ccmap_p->[1];
$offset = 2;
}
$offset = $is_ext ? 2 : 0;
while ($offset < @$ccmap_p) {
printf OUT "/* %06x */ ", $offset - ($is_ext ? 2 : 0);
printf OUT "/* %06x */ ", $offset - ($is_ext ? 2 : 0);
for my $i (0 .. 3) {
for my $j (defined($pg_flags_p->{$offset}) ?
($pg_flags_p->{$offset} > 0 ? @idxlist : @int16toint32) : (0,1,2,3)) {

Просмотреть файл

@ -214,15 +214,16 @@ protected:
// unchanged.
//
// structure of extended charmap:
// ccmap flag 1 PRUint16 , indication if this is extended one or not
// bmp ccmap size 1 PRUint16 , the size of BMP ccmap,
// ccmap flag 1 PRUint16 (PRUint32) , indicates if this is extended or not
// bmp ccmap size 1 PRUint16 (PRUint32) , the size of BMP ccmap,
// BMP ccmap size varies,
// plane index 16 PRUint32, use to index ccmap for non-BMP plane
// empty ccmap 16 PRUint16, a total empty ccmap
// non-BMP ccmaps size varies, other non-empty, non-BMP ccmap
//
// Changes to basic ccmap
// 2 PRUint16 are added in the very beginning. One is used to descript the size
// 2 PRUint16 (PRUint32 on 64bit machines) are added in the very beginning.
// One is used to specify the size
// of the ccmap, the other is used as a flag. But these 2 fields are indexed
// negatively so that all other operation remain unchanged to keep efficiency.
// ccmap memory allocation is moved from nsCompressedCharMap::NewCCMap to