]> Cypherpunks repositories - gostls13.git/commitdiff
gofmt on crypto, debug
authorRuss Cox <rsc@golang.org>
Tue, 6 Oct 2009 21:55:06 +0000 (14:55 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 6 Oct 2009 21:55:06 +0000 (14:55 -0700)
R=gri
DELTA=2560  (127 added, 177 deleted, 2256 changed)
OCL=35388
CL=35395

50 files changed:
src/pkg/crypto/aes/aes_test.go
src/pkg/crypto/aes/cipher.go
src/pkg/crypto/aes/const.go
src/pkg/crypto/block/cbc.go
src/pkg/crypto/block/cbc_aes_test.go
src/pkg/crypto/block/cfb.go
src/pkg/crypto/block/cfb_aes_test.go
src/pkg/crypto/block/cipher.go
src/pkg/crypto/block/cmac.go
src/pkg/crypto/block/cmac_aes_test.go
src/pkg/crypto/block/ctr.go
src/pkg/crypto/block/ctr_aes_test.go
src/pkg/crypto/block/eax.go
src/pkg/crypto/block/eax_aes_test.go
src/pkg/crypto/block/ecb.go
src/pkg/crypto/block/ecb_aes_test.go
src/pkg/crypto/block/ofb.go
src/pkg/crypto/block/ofb_aes_test.go
src/pkg/crypto/block/xor.go
src/pkg/crypto/block/xor_test.go
src/pkg/crypto/hmac/hmac.go
src/pkg/crypto/hmac/hmac_test.go
src/pkg/crypto/md5/md5.go
src/pkg/crypto/md5/md5_test.go
src/pkg/crypto/md5/md5block.go
src/pkg/crypto/sha1/sha1.go
src/pkg/crypto/sha1/sha1_test.go
src/pkg/crypto/sha1/sha1block.go
src/pkg/debug/binary/binary_test.go
src/pkg/debug/dwarf/buf.go
src/pkg/debug/dwarf/const.go
src/pkg/debug/dwarf/entry.go
src/pkg/debug/dwarf/open.go
src/pkg/debug/dwarf/type.go
src/pkg/debug/dwarf/type_test.go
src/pkg/debug/dwarf/unit.go
src/pkg/debug/elf/elf.go
src/pkg/debug/elf/elf_test.go
src/pkg/debug/elf/file.go
src/pkg/debug/elf/file_test.go
src/pkg/debug/gosym/pclntab.go
src/pkg/debug/gosym/pclntab_test.go
src/pkg/debug/macho/file_test.go
src/pkg/debug/macho/macho.go
src/pkg/debug/proc/proc.go
src/pkg/debug/proc/proc_linux.go
src/pkg/debug/proc/proc_nacl.go
src/pkg/debug/proc/regs_darwin_386.go
src/pkg/debug/proc/regs_linux_386.go
src/pkg/debug/proc/regs_nacl_386.go

index b2e0c7bb56364180018981c5c63cafcf6cbb8421..6488d54ba4f1dec3059e2c868a223dcfe66f22e9 100644 (file)
@@ -19,7 +19,7 @@ func TestPowx(t *testing.T) {
                        t.Errorf("powx[%d] = %#x, want %#x", i, powx[i], p);
                }
                p <<= 1;
-               if p & 0x100 != 0 {
+               if p&0x100 != 0 {
                        p ^= poly;
                }
        }
@@ -33,7 +33,7 @@ func mul(b, c uint32) uint32 {
        for k := uint32(1); k < 0x100 && j != 0; k <<= 1 {
                // Invariant: k == 1<<n, i == b * xⁿ
 
-               if j & k != 0 {
+               if j&k != 0 {
                        // s += i in GF(2); xor in binary
                        s ^= i;
                        j ^= k; // turn off bit to end loop early
@@ -41,7 +41,7 @@ func mul(b, c uint32) uint32 {
 
                // i *= x in GF(2) modulo the polynomial
                i <<= 1;
-               if i & 0x100 != 0 {
+               if i&0x100 != 0 {
                        i ^= poly;
                }
        }
@@ -56,7 +56,7 @@ func TestMul(t *testing.T) {
                        s := uint8(0);
                        for k := uint(0); k < 8; k++ {
                                for l := uint(0); l < 8; l++ {
-                                       if i & (1<<k) != 0 && j & (1<<l) != 0 {
+                                       if i&(1<<k) != 0 && j&(1<<l) != 0 {
                                                s ^= powx[k+l];
                                        }
                                }
@@ -124,18 +124,16 @@ func TestTd(t *testing.T) {
 
 // Appendix A of FIPS 197: Key expansion examples
 type KeyTest struct {
-       key []byte;
-       enc []uint32;
-       dec []uint32;   // decryption expansion; not in FIPS 197, computed from C implementation.
+       key     []byte;
+       enc     []uint32;
+       dec     []uint32;       // decryption expansion; not in FIPS 197, computed from C implementation.
 }
 
-var keyTests = []KeyTest {
-       KeyTest {
+var keyTests = []KeyTest{
+       KeyTest{
                // A.1.  Expansion of a 128-bit Cipher Key
-               []byte {
-                       0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
-               },
-               []uint32 {
+               []byte{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c},
+               []uint32{
                        0x2b7e1516, 0x28aed2a6, 0xabf71588, 0x09cf4f3c,
                        0xa0fafe17, 0x88542cb1, 0x23a33939, 0x2a6c7605,
                        0xf2c295f2, 0x7a96b943, 0x5935807a, 0x7359f67f,
@@ -148,7 +146,7 @@ var keyTests = []KeyTest {
                        0xac7766f3, 0x19fadc21, 0x28d12941, 0x575c006e,
                        0xd014f9a8, 0xc9ee2589, 0xe13f0cc8, 0xb6630ca6,
                },
-               []uint32 {
+               []uint32{
                        0xd014f9a8, 0xc9ee2589, 0xe13f0cc8, 0xb6630ca6,
                        0xc7b5a63, 0x1319eafe, 0xb0398890, 0x664cfbb4,
                        0xdf7d925a, 0x1f62b09d, 0xa320626e, 0xd6757324,
@@ -162,13 +160,13 @@ var keyTests = []KeyTest {
                        0x2b7e1516, 0x28aed2a6, 0xabf71588, 0x9cf4f3c,
                },
        },
-       KeyTest {
+       KeyTest{
                // A.2.  Expansion of a 192-bit Cipher Key
-               []byte {
+               []byte{
                        0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
                        0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b,
                },
-               []uint32 {
+               []uint32{
                        0x8e73b0f7, 0xda0e6452, 0xc810f32b, 0x809079e5,
                        0x62f8ead2, 0x522c6b7b, 0xfe0c91f7, 0x2402f5a5,
                        0xec12068e, 0x6c827f6b, 0x0e7a95b9, 0x5c56fec2,
@@ -185,13 +183,13 @@ var keyTests = []KeyTest {
                },
                nil,
        },
-       KeyTest {
+       KeyTest{
                // A.3.  Expansion of a 256-bit Cipher Key
-               []byte {
+               []byte{
                        0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
                        0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4,
                },
-               []uint32 {
+               []uint32{
                        0x603deb10, 0x15ca71be, 0x2b73aef0, 0x857d7781,
                        0x1f352c07, 0x3b6108d7, 0x2d9810a3, 0x0914dff4,
                        0x9ba35411, 0x8e6925af, 0xa51a8b5f, 0x2067fcde,
@@ -241,37 +239,39 @@ L:
 
 // Appendix B, C of FIPS 197: Cipher examples, Example vectors.
 type CryptTest struct {
-       key []byte;
-       in []byte;
-       out []byte;
+       key     []byte;
+       in      []byte;
+       out     []byte;
 }
 
-var encryptTests = []CryptTest {
-       CryptTest {
+var encryptTests = []CryptTest{
+       CryptTest{
                // Appendix B.
-               []byte { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, },
-               []byte { 0x32, 0x43, 0xf6, 0xa8, 0x88, 0x5a, 0x30, 0x8d, 0x31, 0x31, 0x98, 0xa2, 0xe0, 0x37, 0x07, 0x34, },
-               []byte { 0x39, 0x25, 0x84, 0x1d, 0x02, 0xdc, 0x09, 0xfb, 0xdc, 0x11, 0x85, 0x97, 0x19, 0x6a, 0x0b, 0x32, },
+               []byte{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c},
+               []byte{0x32, 0x43, 0xf6, 0xa8, 0x88, 0x5a, 0x30, 0x8d, 0x31, 0x31, 0x98, 0xa2, 0xe0, 0x37, 0x07, 0x34},
+               []byte{0x39, 0x25, 0x84, 0x1d, 0x02, 0xdc, 0x09, 0xfb, 0xdc, 0x11, 0x85, 0x97, 0x19, 0x6a, 0x0b, 0x32},
        },
-       CryptTest {
+       CryptTest{
                // Appendix C.1.  AES-128
-               []byte { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, },
-               []byte { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, },
-               []byte { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a, },
+               []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
+               []byte{0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff},
+               []byte{0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a},
        },
-       CryptTest {
+       CryptTest{
                // Appendix C.2.  AES-192
-               []byte { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
-                       0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, },
-               []byte { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, },
-               []byte { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0, 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91, },
+               []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                       0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+               },
+               []byte{0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff},
+               []byte{0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0, 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91},
        },
-       CryptTest {
+       CryptTest{
                // Appendix C.3.  AES-256
-               []byte { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
-                       0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, },
-               []byte { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, },
-               []byte { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89, },
+               []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                       0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+               },
+               []byte{0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff},
+               []byte{0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89},
        },
 }
 
@@ -348,4 +348,3 @@ func TestCipherDecrypt(t *testing.T) {
                }
        }
 }
-
index e73335feb887d1c65b3ca27af66cc5fb3672db83..db9b59cd0e77d14caad95442e3f05450e9f3ca6e 100644 (file)
@@ -10,15 +10,16 @@ import (
 )
 
 // The AES block size in bytes.
-const BlockSize = 16;
+const BlockSize = 16
 
 // A Cipher is an instance of AES encryption using a particular key.
 type Cipher struct {
-       enc []uint32;
-       dec []uint32;
+       enc     []uint32;
+       dec     []uint32;
 }
 
 type KeySizeError int
+
 func (k KeySizeError) String() string {
        return "crypto/aes: invalid key size " + strconv.Itoa(int(k));
 }
@@ -36,7 +37,7 @@ func NewCipher(key []byte) (*Cipher, os.Error) {
                break;
        }
 
-       n := k + 28;
+       n := k+28;
        c := &Cipher{make([]uint32, n), make([]uint32, n)};
        expandKey(key, c.enc, c.dec);
        return c, nil;
@@ -74,4 +75,3 @@ func (c *Cipher) Reset() {
                c.dec[i] = 0;
        }
 }
-
index 9167d602dd132953046b9cd513739d461092c2cf..862be087be47ca651d4281f8c1d7f96481820247 100644 (file)
@@ -15,7 +15,7 @@ package aes
 // Addition of these binary polynomials corresponds to binary xor.
 // Reducing mod poly corresponds to binary xor with poly every
 // time a 0x100 bit appears.
-const poly = 1<<8 | 1<<4 | 1<<3 | 1<<1 | 1<<0;  // x⁸ + x⁴ + x² + x + 1
+const poly = 1<<8 | 1<<4 | 1<<3 | 1<<1 | 1<<0  // x⁸ + x⁴ + x² + x + 1
 
 // Powers of x mod poly in GF(2).
 var powx = [16]byte{
@@ -38,7 +38,7 @@ var powx = [16]byte{
 }
 
 // FIPS-197 Figure 7. S-box substitution values in hexadecimal format.
-var sbox0 = [256]byte {
+var sbox0 = [256]byte{
        0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
        0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
        0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
@@ -58,7 +58,7 @@ var sbox0 = [256]byte {
 }
 
 // FIPS-197 Figure 14.  Inverse S-box substitution values in hexadecimal format.
-var sbox1 = [256]byte {
+var sbox1 = [256]byte{
        0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
        0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
        0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
@@ -80,8 +80,8 @@ var sbox1 = [256]byte {
 // Lookup tables for encryption.
 // These can be recomputed by adapting the tests in aes_test.go.
 
-var te = [4][256]uint32 {
-       [256]uint32 {
+var te = [4][256]uint32{
+       [256]uint32{
                0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554,
                0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a,
                0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b,
@@ -115,7 +115,7 @@ var te = [4][256]uint32 {
                0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8,
                0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a,
        },
-       [256]uint32 {
+       [256]uint32{
                0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5,
                0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676,
                0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0,
@@ -149,7 +149,7 @@ var te = [4][256]uint32 {
                0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d, 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868,
                0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616,
        },
-       [256]uint32 {
+       [256]uint32{
                0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5,
                0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76,
                0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0,
@@ -183,7 +183,7 @@ var te = [4][256]uint32 {
                0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d, 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068,
                0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16,
        },
-       [256]uint32 {
+       [256]uint32{
                0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491,
                0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec,
                0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb,
@@ -222,8 +222,8 @@ var te = [4][256]uint32 {
 // Lookup tables for decryption.
 // These can be recomputed by adapting the tests in aes_test.go.
 
-var td = [4][256]uint32 {
-       [256]uint32 {
+var td = [4][256]uint32{
+       [256]uint32{
                0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393,
                0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f,
                0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6,
@@ -257,7 +257,7 @@ var td = [4][256]uint32 {
                0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541,
                0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742,
        },
-       [256]uint32 {
+       [256]uint32{
                0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303,
                0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3,
                0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9,
@@ -291,7 +291,7 @@ var td = [4][256]uint32 {
                0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340, 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95,
                0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857,
        },
-       [256]uint32 {
+       [256]uint32{
                0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3,
                0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562,
                0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3,
@@ -325,7 +325,7 @@ var td = [4][256]uint32 {
                0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3, 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d,
                0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8,
        },
-       [256]uint32 {
+       [256]uint32{
                0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b,
                0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5,
                0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b,
@@ -360,4 +360,3 @@ var td = [4][256]uint32 {
                0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0,
        },
 }
-
index 3aea0c1822f95a3c24ed903957127aadd0f69b0a..7bdf7d3049b9850f0f9685a7808ae2d831f30c85 100644 (file)
@@ -16,10 +16,10 @@ import (
 )
 
 type cbcCipher struct {
-       c Cipher;
-       blockSize int;
-       iv []byte;
-       tmp []byte;
+       c               Cipher;
+       blockSize       int;
+       iv              []byte;
+       tmp             []byte;
 }
 
 func newCBC(c Cipher, iv []byte) *cbcCipher {
@@ -71,4 +71,3 @@ func NewCBCDecrypter(c Cipher, iv []byte, r io.Reader) io.Reader {
 func NewCBCEncrypter(c Cipher, iv []byte, w io.Writer) io.Writer {
        return NewECBEncrypter(newCBC(c, iv), w);
 }
-
index 23cf21a5f685c7d2cb7e367c4c806b375c2abf1c..e2e0446fdc983600b555656f2972de7fd9ba5f8c 100644 (file)
@@ -18,45 +18,45 @@ import (
 )
 
 type cbcTest struct {
-       name string;
-       key []byte;
-       iv []byte;
-       in []byte;
-       out []byte;
+       name    string;
+       key     []byte;
+       iv      []byte;
+       in      []byte;
+       out     []byte;
 }
 
-var cbcAESTests = []cbcTest {
+var cbcAESTests = []cbcTest{
        // NIST SP 800-38A pp 27-29
-       cbcTest {
+       cbcTest{
                "CBC-AES128",
                commonKey128,
                commonIV,
                commonInput,
-               []byte {
+               []byte{
                        0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46, 0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d,
                        0x50, 0x86, 0xcb, 0x9b, 0x50, 0x72, 0x19, 0xee, 0x95, 0xdb, 0x11, 0x3a, 0x91, 0x76, 0x78, 0xb2,
                        0x73, 0xbe, 0xd6, 0xb8, 0xe3, 0xc1, 0x74, 0x3b, 0x71, 0x16, 0xe6, 0x9e, 0x22, 0x22, 0x95, 0x16,
                        0x3f, 0xf1, 0xca, 0xa1, 0x68, 0x1f, 0xac, 0x09, 0x12, 0x0e, 0xca, 0x30, 0x75, 0x86, 0xe1, 0xa7,
                },
        },
-       cbcTest {
+       cbcTest{
                "CBC-AES192",
                commonKey192,
                commonIV,
                commonInput,
-               []byte {
+               []byte{
                        0x4f, 0x02, 0x1d, 0xb2, 0x43, 0xbc, 0x63, 0x3d, 0x71, 0x78, 0x18, 0x3a, 0x9f, 0xa0, 0x71, 0xe8,
                        0xb4, 0xd9, 0xad, 0xa9, 0xad, 0x7d, 0xed, 0xf4, 0xe5, 0xe7, 0x38, 0x76, 0x3f, 0x69, 0x14, 0x5a,
                        0x57, 0x1b, 0x24, 0x20, 0x12, 0xfb, 0x7a, 0xe0, 0x7f, 0xa9, 0xba, 0xac, 0x3d, 0xf1, 0x02, 0xe0,
                        0x08, 0xb0, 0xe2, 0x79, 0x88, 0x59, 0x88, 0x81, 0xd9, 0x20, 0xa9, 0xe6, 0x4f, 0x56, 0x15, 0xcd,
                },
        },
-       cbcTest {
+       cbcTest{
                "CBC-AES256",
                commonKey256,
                commonIV,
                commonInput,
-               []byte {
+               []byte{
                        0xf5, 0x8c, 0x4c, 0x04, 0xd6, 0xe5, 0xf1, 0xba, 0x77, 0x9e, 0xab, 0xfb, 0x5f, 0x7b, 0xfb, 0xd6,
                        0x9c, 0xfc, 0x4e, 0x96, 0x7e, 0xdb, 0x80, 0x8d, 0x67, 0x9f, 0x77, 0x7b, 0xc6, 0x70, 0x2c, 0x7d,
                        0x39, 0xf2, 0x33, 0x69, 0xa9, 0xd9, 0xba, 0xcf, 0xa5, 0x30, 0xe2, 0x63, 0x04, 0x23, 0x14, 0x61,
index 0d73827b4c98aca0b770e99912e88ce5822b3572..412381605fdd41fb760e6010793735e0e867b44d 100644 (file)
@@ -17,15 +17,15 @@ import (
 )
 
 type cfbCipher struct {
-       c Cipher;
-       blockSize int;  // our block size (s/8)
-       cipherSize int; // underlying cipher block size
-       iv []byte;
-       tmp []byte;
+       c               Cipher;
+       blockSize       int;    // our block size (s/8)
+       cipherSize      int;    // underlying cipher block size
+       iv              []byte;
+       tmp             []byte;
 }
 
 func newCFB(c Cipher, s int, iv []byte) *cfbCipher {
-       if s == 0 || s % 8 != 0 {
+       if s == 0 || s%8 != 0 {
                panicln("crypto/block: invalid CFB mode", s);
        }
        b := c.BlockSize();
@@ -55,7 +55,7 @@ func (x *cfbCipher) Encrypt(src, dst []byte) {
        }
        off := x.cipherSize - x.blockSize;
        for i := off; i < x.cipherSize; i++ {
-               x.iv[i] = dst[i - off];
+               x.iv[i] = dst[i-off];
        }
 }
 
@@ -74,7 +74,7 @@ func (x *cfbCipher) Decrypt(src, dst []byte) {
        for i := off; i < x.cipherSize; i++ {
                // Reconstruct src = dst ^ x.tmp
                // in case we overwrote src (src == dst).
-               x.iv[i] = dst[i - off] ^ x.tmp[i - off];
+               x.iv[i] = dst[i-off] ^ x.tmp[i-off];
        }
 }
 
@@ -96,4 +96,3 @@ func NewCFBDecrypter(c Cipher, s int, iv []byte, r io.Reader) io.Reader {
 func NewCFBEncrypter(c Cipher, s int, iv []byte, w io.Writer) io.Writer {
        return NewECBEncrypter(newCFB(c, s, iv), w);
 }
-
index 6e948d33de10302646ce80c37c7954a25fe5bbd9..46747efc102c9b8069a29c310c059fdb9a025c1d 100644 (file)
@@ -18,16 +18,16 @@ import (
 )
 
 type cfbTest struct {
-       name string;
-       s int;
-       key []byte;
-       iv []byte;
-       in []byte;
-       out []byte;
+       name    string;
+       s       int;
+       key     []byte;
+       iv      []byte;
+       in      []byte;
+       out     []byte;
 }
 
-var cfbAESTests = []cfbTest {
-       cfbTest {
+var cfbAESTests = []cfbTest{
+       cfbTest{
                "CFB1-AES128",
                1,
                commonKey128,
@@ -41,7 +41,7 @@ var cfbAESTests = []cfbTest {
                        1<<7 | 0<<6 | 1<<5 | 1<<4 | 0<<3 | 0<<2 | 1<<1,
                },
        },
-       cfbTest {
+       cfbTest{
                "CFB1-AES192",
                1,
                commonKey192,
@@ -55,7 +55,7 @@ var cfbAESTests = []cfbTest {
                        0<<7 | 1<<6 | 0<<5 | 1<<4 | 1<<3 | 0<<2 | 0<<1,
                },
        },
-       cfbTest {
+       cfbTest{
                "CFB1-AES256",
                1,
                commonKey256,
@@ -70,7 +70,7 @@ var cfbAESTests = []cfbTest {
                },
        },
 
-       cfbTest {
+       cfbTest{
                "CFB8-AES128",
                8,
                commonKey128,
@@ -117,7 +117,7 @@ var cfbAESTests = []cfbTest {
                },
        },
 
-       cfbTest {
+       cfbTest{
                "CFB8-AES192",
                8,
                commonKey192,
@@ -164,7 +164,7 @@ var cfbAESTests = []cfbTest {
                },
        },
 
-       cfbTest {
+       cfbTest{
                "CFB8-AES256",
                8,
                commonKey256,
@@ -211,7 +211,7 @@ var cfbAESTests = []cfbTest {
                },
        },
 
-       cfbTest {
+       cfbTest{
                "CFB128-AES128",
                128,
                commonKey128,
@@ -230,7 +230,7 @@ var cfbAESTests = []cfbTest {
                },
        },
 
-       cfbTest {
+       cfbTest{
                "CFB128-AES192",
                128,
                commonKey192,
@@ -249,7 +249,7 @@ var cfbAESTests = []cfbTest {
                },
        },
 
-       cfbTest {
+       cfbTest{
                "CFB128-AES256",
                128,
                commonKey256,
index 7ea035db9a6203621eea429701fb989fc4c7a1a6..ed6db02f7b1cc11539e62a78b20d6b11a276e595 100644 (file)
@@ -8,7 +8,7 @@
 // and NIST Special Publication 800-38A.
 package block
 
-import "io";
+import "io"
 
 // A Cipher represents an implementation of block cipher
 // using a given key.  It provides the capability to encrypt
@@ -40,7 +40,6 @@ type Digest interface {
 }
 
 
-
 // Utility routines
 
 func shift1(src, dst []byte) byte {
index 112dcc23846b49ac8abd966716600201cef9e733..ff8d0b0fbe2adf1d10178ecf19523c716272d641 100644 (file)
@@ -11,14 +11,14 @@ import "os"
 
 const (
        // minimal irreducible polynomial of degree b
-       r64 = 0x1b;
-       r128 = 0x87;
+       r64     = 0x1b;
+       r128    = 0x87;
 )
 
 type cmac struct {
-       k1, k2, ci, digest []byte;
-       p int;  // position in ci
-       c Cipher;
+       k1, k2, ci, digest      []byte;
+       p                       int;    // position in ci
+       c                       Cipher;
 }
 
 // TODO(rsc): Should this return an error instead of panic?
@@ -98,4 +98,3 @@ func (d *cmac) Sum() []byte {
        d.c.Encrypt(d.digest, d.digest);
        return d.digest;
 }
-
index 3b2602c51ec734ba99edf55df1bb0e04a48cd67f..8e727ed9cf0855bae99e1b427612f4887f70c98d 100644 (file)
@@ -12,129 +12,99 @@ import (
 )
 
 type cmacAESTest struct {
-       key []byte;
-       in []byte;
-       digest []byte;
+       key     []byte;
+       in      []byte;
+       digest  []byte;
 }
 
-var cmacAESTests = []cmacAESTest {
-       cmacAESTest {
+var cmacAESTests = []cmacAESTest{
+       cmacAESTest{
                commonKey128,
                nil,
-               []byte {
-                       0xbb, 0x1d, 0x69, 0x29, 0xe9, 0x59, 0x37, 0x28, 0x7f, 0xa3, 0x7d, 0x12, 0x9b, 0x75, 0x67, 0x46,
-               }
-       },
-       cmacAESTest {
-               commonKey128,
-               []byte {
-                       0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
-               },
-               []byte {
-                       0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44, 0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c,
-               }
+               []byte{0xbb, 0x1d, 0x69, 0x29, 0xe9, 0x59, 0x37, 0x28, 0x7f, 0xa3, 0x7d, 0x12, 0x9b, 0x75, 0x67, 0x46},
        },
-       cmacAESTest {
+       cmacAESTest{
                commonKey128,
-               []byte {
+               []byte{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a},
+               []byte{0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44, 0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c},
+       },
+       cmacAESTest{
+               commonKey128,
+               []byte{
                        0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
                        0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
                        0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
                },
-               []byte {
-                       0xdf, 0xa6, 0x67, 0x47, 0xde, 0x9a, 0xe6, 0x30, 0x30, 0xca, 0x32, 0x61, 0x14, 0x97, 0xc8, 0x27,
-               }
+               []byte{0xdf, 0xa6, 0x67, 0x47, 0xde, 0x9a, 0xe6, 0x30, 0x30, 0xca, 0x32, 0x61, 0x14, 0x97, 0xc8, 0x27},
        },
-       cmacAESTest {
+       cmacAESTest{
                commonKey128,
-               []byte {
+               []byte{
                        0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
                        0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
                        0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
                        0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10,
                },
-               []byte {
-                       0x51, 0xf0, 0xbe, 0xbf, 0x7e, 0x3b, 0x9d, 0x92, 0xfc, 0x49, 0x74, 0x17, 0x79, 0x36, 0x3c, 0xfe,
-               }
+               []byte{0x51, 0xf0, 0xbe, 0xbf, 0x7e, 0x3b, 0x9d, 0x92, 0xfc, 0x49, 0x74, 0x17, 0x79, 0x36, 0x3c, 0xfe},
        },
-       cmacAESTest {
+       cmacAESTest{
                commonKey192,
                nil,
-               []byte {
-                       0xd1, 0x7d, 0xdf, 0x46, 0xad, 0xaa, 0xcd, 0xe5, 0x31, 0xca, 0xc4, 0x83, 0xde, 0x7a, 0x93, 0x67,
-               }
-       },
-       cmacAESTest {
-               commonKey192,
-               []byte {
-                       0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
-               },
-               []byte {
-                       0x9e, 0x99, 0xa7, 0xbf, 0x31, 0xe7, 0x10, 0x90, 0x06, 0x62, 0xf6, 0x5e, 0x61, 0x7c, 0x51, 0x84,
-               }
-       },
-       cmacAESTest {
-               commonKey192,
-               []byte {
+               []byte{0xd1, 0x7d, 0xdf, 0x46, 0xad, 0xaa, 0xcd, 0xe5, 0x31, 0xca, 0xc4, 0x83, 0xde, 0x7a, 0x93, 0x67},
+       },
+       cmacAESTest{
+               commonKey192,
+               []byte{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a},
+               []byte{0x9e, 0x99, 0xa7, 0xbf, 0x31, 0xe7, 0x10, 0x90, 0x06, 0x62, 0xf6, 0x5e, 0x61, 0x7c, 0x51, 0x84},
+       },
+       cmacAESTest{
+               commonKey192,
+               []byte{
                        0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
                        0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
                        0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
                },
-               []byte {
-                       0x8a, 0x1d, 0xe5, 0xbe, 0x2e, 0xb3, 0x1a, 0xad, 0x08, 0x9a, 0x82, 0xe6, 0xee, 0x90, 0x8b, 0x0e,
-               }
+               []byte{0x8a, 0x1d, 0xe5, 0xbe, 0x2e, 0xb3, 0x1a, 0xad, 0x08, 0x9a, 0x82, 0xe6, 0xee, 0x90, 0x8b, 0x0e},
        },
-       cmacAESTest {
+       cmacAESTest{
                commonKey192,
-               []byte {
+               []byte{
                        0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
                        0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
                        0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
                        0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10,
                },
-               []byte {
-                       0xa1, 0xd5, 0xdf, 0x0e, 0xed, 0x79, 0x0f, 0x79, 0x4d, 0x77, 0x58, 0x96, 0x59, 0xf3, 0x9a, 0x11,
-               }
+               []byte{0xa1, 0xd5, 0xdf, 0x0e, 0xed, 0x79, 0x0f, 0x79, 0x4d, 0x77, 0x58, 0x96, 0x59, 0xf3, 0x9a, 0x11},
        },
-       cmacAESTest {
+       cmacAESTest{
                commonKey256,
                nil,
-               []byte {
-                       0x02, 0x89, 0x62, 0xf6, 0x1b, 0x7b, 0xf8, 0x9e, 0xfc, 0x6b, 0x55, 0x1f, 0x46, 0x67, 0xd9, 0x83,
-               }
-       },
-       cmacAESTest {
-               commonKey256,
-               []byte {
-                       0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
-               },
-               []byte {
-                       0x28, 0xa7, 0x02, 0x3f, 0x45, 0x2e, 0x8f, 0x82, 0xbd, 0x4b, 0xf2, 0x8d, 0x8c, 0x37, 0xc3, 0x5c,
-               }
-       },
-       cmacAESTest {
-               commonKey256,
-               []byte {
+               []byte{0x02, 0x89, 0x62, 0xf6, 0x1b, 0x7b, 0xf8, 0x9e, 0xfc, 0x6b, 0x55, 0x1f, 0x46, 0x67, 0xd9, 0x83},
+       },
+       cmacAESTest{
+               commonKey256,
+               []byte{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a},
+               []byte{0x28, 0xa7, 0x02, 0x3f, 0x45, 0x2e, 0x8f, 0x82, 0xbd, 0x4b, 0xf2, 0x8d, 0x8c, 0x37, 0xc3, 0x5c},
+       },
+       cmacAESTest{
+               commonKey256,
+               []byte{
                        0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
                        0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
                        0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
                },
-               []byte {
-                       0xaa, 0xf3, 0xd8, 0xf1, 0xde, 0x56, 0x40, 0xc2, 0x32, 0xf5, 0xb1, 0x69, 0xb9, 0xc9, 0x11, 0xe6,
-               }
-       },
-       cmacAESTest {
-               commonKey256,
-               []byte {
+               []byte{0xaa, 0xf3, 0xd8, 0xf1, 0xde, 0x56, 0x40, 0xc2, 0x32, 0xf5, 0xb1, 0x69, 0xb9, 0xc9, 0x11, 0xe6},
+       },
+       cmacAESTest{
+               commonKey256,
+               []byte{
                        0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
                        0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
                        0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
                        0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10,
                },
-               []byte {
-                       0xe1, 0x99, 0x21, 0x90, 0x54, 0x9f, 0x6e, 0xd5, 0x69, 0x6a, 0x2c, 0x05, 0x6c, 0x31, 0x54, 0x10,
-               }
-       }
+               []byte{0xe1, 0x99, 0x21, 0x90, 0x54, 0x9f, 0x6e, 0xd5, 0x69, 0x6a, 0x2c, 0x05, 0x6c, 0x31, 0x54, 0x10},
+       },
 }
 
 func TestCMAC_AES(t *testing.T) {
index 38700c1855c081b6f4384d98931a59fbf578731f..235e3b974a87a05e654511b55254e2368e48e4f2 100644 (file)
@@ -17,9 +17,9 @@ import (
 )
 
 type ctrStream struct {
-       c Cipher;
-       ctr []byte;
-       out []byte;
+       c       Cipher;
+       ctr     []byte;
+       out     []byte;
 }
 
 func newCTRStream(c Cipher, ctr []byte) *ctrStream {
@@ -65,4 +65,3 @@ func NewCTRReader(c Cipher, iv []byte, r io.Reader) io.Reader {
 func NewCTRWriter(c Cipher, iv []byte, w io.Writer) io.Writer {
        return newXorWriter(newCTRStream(c, iv), w);
 }
-
index 2e800fe163740863d5c30699b4cce96f758e4230..f34fadc7449ebceb9d07dadf4c3beb9df48250a2 100644 (file)
@@ -18,54 +18,52 @@ import (
 )
 
 type ctrTest struct {
-       name string;
-       key []byte;
-       iv []byte;
-       in []byte;
-       out []byte;
+       name    string;
+       key     []byte;
+       iv      []byte;
+       in      []byte;
+       out     []byte;
 }
 
-var commonCounter = []byte {
-       0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
-}
+var commonCounter = []byte{0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff}
 
-var ctrAESTests = []ctrTest {
+var ctrAESTests = []ctrTest{
        // NIST SP 800-38A pp 55-58
-       ctrTest {
+       ctrTest{
                "CTR-AES128",
                commonKey128,
                commonCounter,
                commonInput,
-               []byte {
+               []byte{
                        0x87, 0x4d, 0x61, 0x91, 0xb6, 0x20, 0xe3, 0x26, 0x1b, 0xef, 0x68, 0x64, 0x99, 0x0d, 0xb6, 0xce,
                        0x98, 0x06, 0xf6, 0x6b, 0x79, 0x70, 0xfd, 0xff, 0x86, 0x17, 0x18, 0x7b, 0xb9, 0xff, 0xfd, 0xff,
                        0x5a, 0xe4, 0xdf, 0x3e, 0xdb, 0xd5, 0xd3, 0x5e, 0x5b, 0x4f, 0x09, 0x02, 0x0d, 0xb0, 0x3e, 0xab,
                        0x1e, 0x03, 0x1d, 0xda, 0x2f, 0xbe, 0x03, 0xd1, 0x79, 0x21, 0x70, 0xa0, 0xf3, 0x00, 0x9c, 0xee,
                },
        },
-       ctrTest {
+       ctrTest{
                "CTR-AES192",
                commonKey192,
                commonCounter,
                commonInput,
-               []byte {
+               []byte{
                        0x1a, 0xbc, 0x93, 0x24, 0x17, 0x52, 0x1c, 0xa2, 0x4f, 0x2b, 0x04, 0x59, 0xfe, 0x7e, 0x6e, 0x0b,
                        0x09, 0x03, 0x39, 0xec, 0x0a, 0xa6, 0xfa, 0xef, 0xd5, 0xcc, 0xc2, 0xc6, 0xf4, 0xce, 0x8e, 0x94,
                        0x1e, 0x36, 0xb2, 0x6b, 0xd1, 0xeb, 0xc6, 0x70, 0xd1, 0xbd, 0x1d, 0x66, 0x56, 0x20, 0xab, 0xf7,
                        0x4f, 0x78, 0xa7, 0xf6, 0xd2, 0x98, 0x09, 0x58, 0x5a, 0x97, 0xda, 0xec, 0x58, 0xc6, 0xb0, 0x50,
                },
        },
-       ctrTest {
+       ctrTest{
                "CTR-AES256",
                commonKey256,
                commonCounter,
                commonInput,
-               []byte {
+               []byte{
                        0x60, 0x1e, 0xc3, 0x13, 0x77, 0x57, 0x89, 0xa5, 0xb7, 0xa7, 0xf5, 0x04, 0xbb, 0xf3, 0xd2, 0x28,
                        0xf4, 0x43, 0xe3, 0xca, 0x4d, 0x62, 0xb5, 0x9a, 0xca, 0x84, 0xe9, 0x90, 0xca, 0xca, 0xf5, 0xc5,
                        0x2b, 0x09, 0x30, 0xda, 0xa2, 0x3d, 0xe9, 0x4c, 0xe8, 0x70, 0x17, 0xba, 0x2d, 0x84, 0x98, 0x8d,
                        0xdf, 0xc9, 0xc5, 0x8d, 0xb6, 0x7a, 0xad, 0xa6, 0x13, 0xc2, 0xdd, 0x08, 0x45, 0x79, 0x41, 0xa6,
-               }
+               },
        },
 }
 
@@ -81,7 +79,7 @@ func TestCTR_AES(t *testing.T) {
 
                for j := 0; j <= 5; j += 5 {
                        var crypt bytes.Buffer;
-                       in := tt.in[0:len(tt.in) - j];
+                       in := tt.in[0 : len(tt.in) - j];
                        w := NewCTRWriter(c, tt.iv, &crypt);
                        var r io.Reader = bytes.NewBuffer(in);
                        n, err := io.Copy(r, w);
@@ -94,7 +92,7 @@ func TestCTR_AES(t *testing.T) {
 
                for j := 0; j <= 7; j += 7 {
                        var plain bytes.Buffer;
-                       out := tt.out[0:len(tt.out) - j];
+                       out := tt.out[0 : len(tt.out) - j];
                        r := NewCTRReader(c, tt.iv, bytes.NewBuffer(out));
                        w := &plain;
                        n, err := io.Copy(r, w);
index bac721dbf02e581f4c7c494ede8881091d7f9373..e6dc39195c149f0f808a64889c5f26f9c91eaa4f 100644 (file)
@@ -24,8 +24,8 @@ import (
 // because the tag at the end of the message stream (Read) does not match
 // the tag computed from the message itself (Computed).
 type EAXTagError struct {
-       Read []byte;
-       Computed []byte;
+       Read            []byte;
+       Computed        []byte;
 }
 
 func (e *EAXTagError) String() string {
@@ -57,7 +57,7 @@ func setupEAX(c Cipher, iv, hdr []byte, tagBytes int) (ctrIV, tag []byte, cmac D
        }
 
        cmac.Reset();
-       buf[n-1] = 2;           // 2
+       buf[n-1] = 2;   // 2
        cmac.Write(buf);
 
        return;
@@ -74,8 +74,8 @@ func finishEAX(tag []byte, cmac Digest) {
 // Writer adapter.  Tees writes into both w and cmac.
 // Knows that cmac never returns write errors.
 type cmacWriter struct {
-       w io.Writer;
-       cmac Digest;
+       w       io.Writer;
+       cmac    Digest;
 }
 
 func (cw *cmacWriter) Write(p []byte) (n int, err os.Error) {
@@ -86,9 +86,9 @@ func (cw *cmacWriter) Write(p []byte) (n int, err os.Error) {
 
 // An eaxEncrypter implements the EAX encryption mode.
 type eaxEncrypter struct {
-       ctr io.Writer;  // CTR encrypter
-       cw cmacWriter;  // CTR's output stream
-       tag []byte;
+       ctr     io.Writer;      // CTR encrypter
+       cw      cmacWriter;     // CTR's output stream
+       tag     []byte;
 }
 
 // NewEAXEncrypter creates and returns a new EAX encrypter
@@ -132,10 +132,10 @@ func (x *eaxEncrypter) Close() os.Error {
 // and the "tee into digest" functionality could be separated,
 // but the latter half is trivial.
 type cmacReader struct {
-       r io.Reader;
-       cmac Digest;
-       tag []byte;
-       tmp []byte;
+       r       io.Reader;
+       cmac    Digest;
+       tag     []byte;
+       tmp     []byte;
 }
 
 func (cr *cmacReader) Read(p []byte) (n int, err os.Error) {
@@ -150,7 +150,7 @@ func (cr *cmacReader) Read(p []byte) (n int, err os.Error) {
        if len(tag) < cap(tag) {
                nt := len(tag);
                nn, err1 := io.ReadFull(cr.r, tag[nt:cap(tag)]);
-               tag = tag[0:nt+nn];
+               tag = tag[0 : nt+nn];
                cr.tag = tag;
                if err1 != nil {
                        return 0, err1;
@@ -183,12 +183,12 @@ func (cr *cmacReader) Read(p []byte) (n int, err os.Error) {
 
        // copy tag+p into p+tmp and then swap tmp, tag
        tmp := cr.tmp;
-       for i := n + tagBytes - 1; i >= 0; i-- {
+       for i := n+tagBytes-1; i >= 0; i-- {
                var c byte;
                if i < tagBytes {
                        c = tag[i];
                } else {
-                       c = p[i - tagBytes];
+                       c = p[i-tagBytes];
                }
                if i < n {
                        p[i] = c;
@@ -204,9 +204,9 @@ out:
 }
 
 type eaxDecrypter struct {
-       ctr io.Reader;
-       cr cmacReader;
-       tag []byte;
+       ctr     io.Reader;
+       cr      cmacReader;
+       tag     []byte;
 }
 
 // NewEAXDecrypter creates and returns a new EAX decrypter
@@ -250,4 +250,3 @@ func (x *eaxDecrypter) Read(p []byte) (n int, err os.Error) {
        }
        return n, err;
 }
-
index 2105c5accf8cb01ae193945d8dc5ca94af6ca23c..36578b8117d6199049ac930151769cd2dbeb4427 100644 (file)
@@ -15,182 +15,83 @@ import (
 // Test vectors from http://www.cs.ucdavis.edu/~rogaway/papers/eax.pdf
 
 type eaxAESTest struct {
-       msg []byte;
-       key []byte;
-       nonce []byte;
-       header []byte;
-       cipher []byte;
+       msg     []byte;
+       key     []byte;
+       nonce   []byte;
+       header  []byte;
+       cipher  []byte;
 }
 
-var eaxAESTests = []eaxAESTest {
-       eaxAESTest {
-               []byte {
-               },
-               []byte {
-                       0x23, 0x39, 0x52, 0xDE, 0xE4, 0xD5, 0xED, 0x5F, 0x9B, 0x9C, 0x6D, 0x6F, 0xF8, 0x0F, 0xF4, 0x78,
-               },
-               []byte {
-                       0x62, 0xEC, 0x67, 0xF9, 0xC3, 0xA4, 0xA4, 0x07, 0xFC, 0xB2, 0xA8, 0xC4, 0x90, 0x31, 0xA8, 0xB3,
-               },
-               []byte {
-                       0x6B, 0xFB, 0x91, 0x4F, 0xD0, 0x7E, 0xAE, 0x6B,
-               },
-               []byte {
-                       0xE0, 0x37, 0x83, 0x0E, 0x83, 0x89, 0xF2, 0x7B, 0x02, 0x5A, 0x2D, 0x65, 0x27, 0xE7, 0x9D, 0x01,
-               },
+var eaxAESTests = []eaxAESTest{
+       eaxAESTest{
+               []byte{},
+               []byte{0x23, 0x39, 0x52, 0xDE, 0xE4, 0xD5, 0xED, 0x5F, 0x9B, 0x9C, 0x6D, 0x6F, 0xF8, 0x0F, 0xF4, 0x78},
+               []byte{0x62, 0xEC, 0x67, 0xF9, 0xC3, 0xA4, 0xA4, 0x07, 0xFC, 0xB2, 0xA8, 0xC4, 0x90, 0x31, 0xA8, 0xB3},
+               []byte{0x6B, 0xFB, 0x91, 0x4F, 0xD0, 0x7E, 0xAE, 0x6B},
+               []byte{0xE0, 0x37, 0x83, 0x0E, 0x83, 0x89, 0xF2, 0x7B, 0x02, 0x5A, 0x2D, 0x65, 0x27, 0xE7, 0x9D, 0x01},
        },
-       eaxAESTest {
-               []byte {
-                       0xF7, 0xFB,
-               },
-               []byte {
-                       0x91, 0x94, 0x5D, 0x3F, 0x4D, 0xCB, 0xEE, 0x0B, 0xF4, 0x5E, 0xF5, 0x22, 0x55, 0xF0, 0x95, 0xA4,
-               },
-               []byte {
-                       0xBE, 0xCA, 0xF0, 0x43, 0xB0, 0xA2, 0x3D, 0x84, 0x31, 0x94, 0xBA, 0x97, 0x2C, 0x66, 0xDE, 0xBD,
-               },
-               []byte {
-                       0xFA, 0x3B, 0xFD, 0x48, 0x06, 0xEB, 0x53, 0xFA,
-               },
-               []byte {
-                       0x19, 0xDD, 0x5C, 0x4C, 0x93, 0x31, 0x04, 0x9D, 0x0B, 0xDA, 0xB0, 0x27, 0x74, 0x08, 0xF6, 0x79, 0x67, 0xE5,
-               },
+       eaxAESTest{
+               []byte{0xF7, 0xFB},
+               []byte{0x91, 0x94, 0x5D, 0x3F, 0x4D, 0xCB, 0xEE, 0x0B, 0xF4, 0x5E, 0xF5, 0x22, 0x55, 0xF0, 0x95, 0xA4},
+               []byte{0xBE, 0xCA, 0xF0, 0x43, 0xB0, 0xA2, 0x3D, 0x84, 0x31, 0x94, 0xBA, 0x97, 0x2C, 0x66, 0xDE, 0xBD},
+               []byte{0xFA, 0x3B, 0xFD, 0x48, 0x06, 0xEB, 0x53, 0xFA},
+               []byte{0x19, 0xDD, 0x5C, 0x4C, 0x93, 0x31, 0x04, 0x9D, 0x0B, 0xDA, 0xB0, 0x27, 0x74, 0x08, 0xF6, 0x79, 0x67, 0xE5},
        },
-       eaxAESTest {
-               []byte {
-                       0x1A, 0x47, 0xCB, 0x49, 0x33,
-               },
-               []byte {
-                       0x01, 0xF7, 0x4A, 0xD6, 0x40, 0x77, 0xF2, 0xE7, 0x04, 0xC0, 0xF6, 0x0A, 0xDA, 0x3D, 0xD5, 0x23,
-               },
-               []byte {
-                       0x70, 0xC3, 0xDB, 0x4F, 0x0D, 0x26, 0x36, 0x84, 0x00, 0xA1, 0x0E, 0xD0, 0x5D, 0x2B, 0xFF, 0x5E,
-               },
-               []byte {
-                       0x23, 0x4A, 0x34, 0x63, 0xC1, 0x26, 0x4A, 0xC6,
-               },
-               []byte {
-                       0xD8, 0x51, 0xD5, 0xBA, 0xE0, 0x3A, 0x59, 0xF2, 0x38, 0xA2, 0x3E, 0x39, 0x19, 0x9D, 0xC9, 0x26, 0x66, 0x26, 0xC4, 0x0F, 0x80,
-               },
+       eaxAESTest{
+               []byte{0x1A, 0x47, 0xCB, 0x49, 0x33},
+               []byte{0x01, 0xF7, 0x4A, 0xD6, 0x40, 0x77, 0xF2, 0xE7, 0x04, 0xC0, 0xF6, 0x0A, 0xDA, 0x3D, 0xD5, 0x23},
+               []byte{0x70, 0xC3, 0xDB, 0x4F, 0x0D, 0x26, 0x36, 0x84, 0x00, 0xA1, 0x0E, 0xD0, 0x5D, 0x2B, 0xFF, 0x5E},
+               []byte{0x23, 0x4A, 0x34, 0x63, 0xC1, 0x26, 0x4A, 0xC6},
+               []byte{0xD8, 0x51, 0xD5, 0xBA, 0xE0, 0x3A, 0x59, 0xF2, 0x38, 0xA2, 0x3E, 0x39, 0x19, 0x9D, 0xC9, 0x26, 0x66, 0x26, 0xC4, 0x0F, 0x80},
        },
-       eaxAESTest {
-               []byte {
-                       0x48, 0x1C, 0x9E, 0x39, 0xB1,
-               },
-               []byte {
-                       0xD0, 0x7C, 0xF6, 0xCB, 0xB7, 0xF3, 0x13, 0xBD, 0xDE, 0x66, 0xB7, 0x27, 0xAF, 0xD3, 0xC5, 0xE8,
-               },
-               []byte {
-                       0x84, 0x08, 0xDF, 0xFF, 0x3C, 0x1A, 0x2B, 0x12, 0x92, 0xDC, 0x19, 0x9E, 0x46, 0xB7, 0xD6, 0x17,
-               },
-               []byte {
-                       0x33, 0xCC, 0xE2, 0xEA, 0xBF, 0xF5, 0xA7, 0x9D,
-               },
-               []byte {
-                       0x63, 0x2A, 0x9D, 0x13, 0x1A, 0xD4, 0xC1, 0x68, 0xA4, 0x22, 0x5D, 0x8E, 0x1F, 0xF7, 0x55, 0x93, 0x99, 0x74, 0xA7, 0xBE, 0xDE,
-               },
+       eaxAESTest{
+               []byte{0x48, 0x1C, 0x9E, 0x39, 0xB1},
+               []byte{0xD0, 0x7C, 0xF6, 0xCB, 0xB7, 0xF3, 0x13, 0xBD, 0xDE, 0x66, 0xB7, 0x27, 0xAF, 0xD3, 0xC5, 0xE8},
+               []byte{0x84, 0x08, 0xDF, 0xFF, 0x3C, 0x1A, 0x2B, 0x12, 0x92, 0xDC, 0x19, 0x9E, 0x46, 0xB7, 0xD6, 0x17},
+               []byte{0x33, 0xCC, 0xE2, 0xEA, 0xBF, 0xF5, 0xA7, 0x9D},
+               []byte{0x63, 0x2A, 0x9D, 0x13, 0x1A, 0xD4, 0xC1, 0x68, 0xA4, 0x22, 0x5D, 0x8E, 0x1F, 0xF7, 0x55, 0x93, 0x99, 0x74, 0xA7, 0xBE, 0xDE},
        },
-       eaxAESTest {
-               []byte {
-                       0x40, 0xD0, 0xC0, 0x7D, 0xA5, 0xE4,
-               },
-               []byte {
-                       0x35, 0xB6, 0xD0, 0x58, 0x00, 0x05, 0xBB, 0xC1, 0x2B, 0x05, 0x87, 0x12, 0x45, 0x57, 0xD2, 0xC2,
-               },
-               []byte {
-                       0xFD, 0xB6, 0xB0, 0x66, 0x76, 0xEE, 0xDC, 0x5C, 0x61, 0xD7, 0x42, 0x76, 0xE1, 0xF8, 0xE8, 0x16,
-               },
-               []byte {
-                       0xAE, 0xB9, 0x6E, 0xAE, 0xBE, 0x29, 0x70, 0xE9,
-               },
-               []byte {
-                       0x07, 0x1D, 0xFE, 0x16, 0xC6, 0x75, 0xCB, 0x06, 0x77, 0xE5, 0x36, 0xF7, 0x3A, 0xFE, 0x6A, 0x14, 0xB7, 0x4E, 0xE4, 0x98, 0x44, 0xDD,
-               },
+       eaxAESTest{
+               []byte{0x40, 0xD0, 0xC0, 0x7D, 0xA5, 0xE4},
+               []byte{0x35, 0xB6, 0xD0, 0x58, 0x00, 0x05, 0xBB, 0xC1, 0x2B, 0x05, 0x87, 0x12, 0x45, 0x57, 0xD2, 0xC2},
+               []byte{0xFD, 0xB6, 0xB0, 0x66, 0x76, 0xEE, 0xDC, 0x5C, 0x61, 0xD7, 0x42, 0x76, 0xE1, 0xF8, 0xE8, 0x16},
+               []byte{0xAE, 0xB9, 0x6E, 0xAE, 0xBE, 0x29, 0x70, 0xE9},
+               []byte{0x07, 0x1D, 0xFE, 0x16, 0xC6, 0x75, 0xCB, 0x06, 0x77, 0xE5, 0x36, 0xF7, 0x3A, 0xFE, 0x6A, 0x14, 0xB7, 0x4E, 0xE4, 0x98, 0x44, 0xDD},
        },
-       eaxAESTest {
-               []byte {
-                       0x4D, 0xE3, 0xB3, 0x5C, 0x3F, 0xC0, 0x39, 0x24, 0x5B, 0xD1, 0xFB, 0x7D,
-               },
-               []byte {
-                       0xBD, 0x8E, 0x6E, 0x11, 0x47, 0x5E, 0x60, 0xB2, 0x68, 0x78, 0x4C, 0x38, 0xC6, 0x2F, 0xEB, 0x22,
-               },
-               []byte {
-                       0x6E, 0xAC, 0x5C, 0x93, 0x07, 0x2D, 0x8E, 0x85, 0x13, 0xF7, 0x50, 0x93, 0x5E, 0x46, 0xDA, 0x1B,
-               },
-               []byte {
-                       0xD4, 0x48, 0x2D, 0x1C, 0xA7, 0x8D, 0xCE, 0x0F,
-               },
-               []byte {
-                       0x83, 0x5B, 0xB4, 0xF1, 0x5D, 0x74, 0x3E, 0x35, 0x0E, 0x72, 0x84, 0x14, 0xAB, 0xB8, 0x64, 0x4F, 0xD6, 0xCC, 0xB8, 0x69, 0x47, 0xC5, 0xE1, 0x05, 0x90, 0x21, 0x0A, 0x4F,
-               },
+       eaxAESTest{
+               []byte{0x4D, 0xE3, 0xB3, 0x5C, 0x3F, 0xC0, 0x39, 0x24, 0x5B, 0xD1, 0xFB, 0x7D},
+               []byte{0xBD, 0x8E, 0x6E, 0x11, 0x47, 0x5E, 0x60, 0xB2, 0x68, 0x78, 0x4C, 0x38, 0xC6, 0x2F, 0xEB, 0x22},
+               []byte{0x6E, 0xAC, 0x5C, 0x93, 0x07, 0x2D, 0x8E, 0x85, 0x13, 0xF7, 0x50, 0x93, 0x5E, 0x46, 0xDA, 0x1B},
+               []byte{0xD4, 0x48, 0x2D, 0x1C, 0xA7, 0x8D, 0xCE, 0x0F},
+               []byte{0x83, 0x5B, 0xB4, 0xF1, 0x5D, 0x74, 0x3E, 0x35, 0x0E, 0x72, 0x84, 0x14, 0xAB, 0xB8, 0x64, 0x4F, 0xD6, 0xCC, 0xB8, 0x69, 0x47, 0xC5, 0xE1, 0x05, 0x90, 0x21, 0x0A, 0x4F},
        },
-       eaxAESTest {
-               []byte {
-                       0x8B, 0x0A, 0x79, 0x30, 0x6C, 0x9C, 0xE7, 0xED, 0x99, 0xDA, 0xE4, 0xF8, 0x7F, 0x8D, 0xD6, 0x16, 0x36,
-               },
-               []byte {
-                       0x7C, 0x77, 0xD6, 0xE8, 0x13, 0xBE, 0xD5, 0xAC, 0x98, 0xBA, 0xA4, 0x17, 0x47, 0x7A, 0x2E, 0x7D,
-               },
-               []byte {
-                       0x1A, 0x8C, 0x98, 0xDC, 0xD7, 0x3D, 0x38, 0x39, 0x3B, 0x2B, 0xF1, 0x56, 0x9D, 0xEE, 0xFC, 0x19,
-               },
-               []byte {
-                       0x65, 0xD2, 0x01, 0x79, 0x90, 0xD6, 0x25, 0x28,
-               },
-               []byte {
-                       0x02, 0x08, 0x3E, 0x39, 0x79, 0xDA, 0x01, 0x48, 0x12, 0xF5, 0x9F, 0x11, 0xD5, 0x26, 0x30, 0xDA, 0x30, 0x13, 0x73, 0x27, 0xD1, 0x06, 0x49, 0xB0, 0xAA, 0x6E, 0x1C, 0x18, 0x1D, 0xB6, 0x17, 0xD7, 0xF2,
-               },
+       eaxAESTest{
+               []byte{0x8B, 0x0A, 0x79, 0x30, 0x6C, 0x9C, 0xE7, 0xED, 0x99, 0xDA, 0xE4, 0xF8, 0x7F, 0x8D, 0xD6, 0x16, 0x36},
+               []byte{0x7C, 0x77, 0xD6, 0xE8, 0x13, 0xBE, 0xD5, 0xAC, 0x98, 0xBA, 0xA4, 0x17, 0x47, 0x7A, 0x2E, 0x7D},
+               []byte{0x1A, 0x8C, 0x98, 0xDC, 0xD7, 0x3D, 0x38, 0x39, 0x3B, 0x2B, 0xF1, 0x56, 0x9D, 0xEE, 0xFC, 0x19},
+               []byte{0x65, 0xD2, 0x01, 0x79, 0x90, 0xD6, 0x25, 0x28},
+               []byte{0x02, 0x08, 0x3E, 0x39, 0x79, 0xDA, 0x01, 0x48, 0x12, 0xF5, 0x9F, 0x11, 0xD5, 0x26, 0x30, 0xDA, 0x30, 0x13, 0x73, 0x27, 0xD1, 0x06, 0x49, 0xB0, 0xAA, 0x6E, 0x1C, 0x18, 0x1D, 0xB6, 0x17, 0xD7, 0xF2},
        },
-       eaxAESTest {
-               []byte {
-                       0x1B, 0xDA, 0x12, 0x2B, 0xCE, 0x8A, 0x8D, 0xBA, 0xF1, 0x87, 0x7D, 0x96, 0x2B, 0x85, 0x92, 0xDD, 0x2D, 0x56,
-               },
-               []byte {
-                       0x5F, 0xFF, 0x20, 0xCA, 0xFA, 0xB1, 0x19, 0xCA, 0x2F, 0xC7, 0x35, 0x49, 0xE2, 0x0F, 0x5B, 0x0D,
-               },
-               []byte {
-                       0xDD, 0xE5, 0x9B, 0x97, 0xD7, 0x22, 0x15, 0x6D, 0x4D, 0x9A, 0xFF, 0x2B, 0xC7, 0x55, 0x98, 0x26,
-               },
-               []byte {
-                       0x54, 0xB9, 0xF0, 0x4E, 0x6A, 0x09, 0x18, 0x9A,
-               },
-               []byte {
-                       0x2E, 0xC4, 0x7B, 0x2C, 0x49, 0x54, 0xA4, 0x89, 0xAF, 0xC7, 0xBA, 0x48, 0x97, 0xED, 0xCD, 0xAE, 0x8C, 0xC3, 0x3B, 0x60, 0x45, 0x05, 0x99, 0xBD, 0x02, 0xC9, 0x63, 0x82, 0x90, 0x2A, 0xEF, 0x7F, 0x83, 0x2A,
-               },
+       eaxAESTest{
+               []byte{0x1B, 0xDA, 0x12, 0x2B, 0xCE, 0x8A, 0x8D, 0xBA, 0xF1, 0x87, 0x7D, 0x96, 0x2B, 0x85, 0x92, 0xDD, 0x2D, 0x56},
+               []byte{0x5F, 0xFF, 0x20, 0xCA, 0xFA, 0xB1, 0x19, 0xCA, 0x2F, 0xC7, 0x35, 0x49, 0xE2, 0x0F, 0x5B, 0x0D},
+               []byte{0xDD, 0xE5, 0x9B, 0x97, 0xD7, 0x22, 0x15, 0x6D, 0x4D, 0x9A, 0xFF, 0x2B, 0xC7, 0x55, 0x98, 0x26},
+               []byte{0x54, 0xB9, 0xF0, 0x4E, 0x6A, 0x09, 0x18, 0x9A},
+               []byte{0x2E, 0xC4, 0x7B, 0x2C, 0x49, 0x54, 0xA4, 0x89, 0xAF, 0xC7, 0xBA, 0x48, 0x97, 0xED, 0xCD, 0xAE, 0x8C, 0xC3, 0x3B, 0x60, 0x45, 0x05, 0x99, 0xBD, 0x02, 0xC9, 0x63, 0x82, 0x90, 0x2A, 0xEF, 0x7F, 0x83, 0x2A},
        },
-       eaxAESTest {
-               []byte {
-                       0x6C, 0xF3, 0x67, 0x20, 0x87, 0x2B, 0x85, 0x13, 0xF6, 0xEA, 0xB1, 0xA8, 0xA4, 0x44, 0x38, 0xD5, 0xEF, 0x11,
-               },
-               []byte {
-                       0xA4, 0xA4, 0x78, 0x2B, 0xCF, 0xFD, 0x3E, 0xC5, 0xE7, 0xEF, 0x6D, 0x8C, 0x34, 0xA5, 0x61, 0x23,
-               },
-               []byte {
-                       0xB7, 0x81, 0xFC, 0xF2, 0xF7, 0x5F, 0xA5, 0xA8, 0xDE, 0x97, 0xA9, 0xCA, 0x48, 0xE5, 0x22, 0xEC,
-               },
-               []byte {
-                       0x89, 0x9A, 0x17, 0x58, 0x97, 0x56, 0x1D, 0x7E,
-               },
-               []byte {
-                       0x0D, 0xE1, 0x8F, 0xD0, 0xFD, 0xD9, 0x1E, 0x7A, 0xF1, 0x9F, 0x1D, 0x8E, 0xE8, 0x73, 0x39, 0x38, 0xB1, 0xE8, 0xE7, 0xF6, 0xD2, 0x23, 0x16, 0x18, 0x10, 0x2F, 0xDB, 0x7F, 0xE5, 0x5F, 0xF1, 0x99, 0x17, 0x00,
-               },
+       eaxAESTest{
+               []byte{0x6C, 0xF3, 0x67, 0x20, 0x87, 0x2B, 0x85, 0x13, 0xF6, 0xEA, 0xB1, 0xA8, 0xA4, 0x44, 0x38, 0xD5, 0xEF, 0x11},
+               []byte{0xA4, 0xA4, 0x78, 0x2B, 0xCF, 0xFD, 0x3E, 0xC5, 0xE7, 0xEF, 0x6D, 0x8C, 0x34, 0xA5, 0x61, 0x23},
+               []byte{0xB7, 0x81, 0xFC, 0xF2, 0xF7, 0x5F, 0xA5, 0xA8, 0xDE, 0x97, 0xA9, 0xCA, 0x48, 0xE5, 0x22, 0xEC},
+               []byte{0x89, 0x9A, 0x17, 0x58, 0x97, 0x56, 0x1D, 0x7E},
+               []byte{0x0D, 0xE1, 0x8F, 0xD0, 0xFD, 0xD9, 0x1E, 0x7A, 0xF1, 0x9F, 0x1D, 0x8E, 0xE8, 0x73, 0x39, 0x38, 0xB1, 0xE8, 0xE7, 0xF6, 0xD2, 0x23, 0x16, 0x18, 0x10, 0x2F, 0xDB, 0x7F, 0xE5, 0x5F, 0xF1, 0x99, 0x17, 0x00},
        },
-       eaxAESTest {
-               []byte {
-                       0xCA, 0x40, 0xD7, 0x44, 0x6E, 0x54, 0x5F, 0xFA, 0xED, 0x3B, 0xD1, 0x2A, 0x74, 0x0A, 0x65, 0x9F, 0xFB, 0xBB, 0x3C, 0xEA, 0xB7,
-               },
-               []byte {
-                       0x83, 0x95, 0xFC, 0xF1, 0xE9, 0x5B, 0xEB, 0xD6, 0x97, 0xBD, 0x01, 0x0B, 0xC7, 0x66, 0xAA, 0xC3,
-               },
-               []byte {
-                       0x22, 0xE7, 0xAD, 0xD9, 0x3C, 0xFC, 0x63, 0x93, 0xC5, 0x7E, 0xC0, 0xB3, 0xC1, 0x7D, 0x6B, 0x44,
-               },
-               []byte {
-                       0x12, 0x67, 0x35, 0xFC, 0xC3, 0x20, 0xD2, 0x5A,
-               },
-               []byte {
-                       0xCB, 0x89, 0x20, 0xF8, 0x7A, 0x6C, 0x75, 0xCF, 0xF3, 0x96, 0x27, 0xB5, 0x6E, 0x3E, 0xD1, 0x97, 0xC5, 0x52, 0xD2, 0x95, 0xA7, 0xCF, 0xC4, 0x6A, 0xFC, 0x25, 0x3B, 0x46, 0x52, 0xB1, 0xAF, 0x37, 0x95, 0xB1, 0x24, 0xAB, 0x6E,
-               },
+       eaxAESTest{
+               []byte{0xCA, 0x40, 0xD7, 0x44, 0x6E, 0x54, 0x5F, 0xFA, 0xED, 0x3B, 0xD1, 0x2A, 0x74, 0x0A, 0x65, 0x9F, 0xFB, 0xBB, 0x3C, 0xEA, 0xB7},
+               []byte{0x83, 0x95, 0xFC, 0xF1, 0xE9, 0x5B, 0xEB, 0xD6, 0x97, 0xBD, 0x01, 0x0B, 0xC7, 0x66, 0xAA, 0xC3},
+               []byte{0x22, 0xE7, 0xAD, 0xD9, 0x3C, 0xFC, 0x63, 0x93, 0xC5, 0x7E, 0xC0, 0xB3, 0xC1, 0x7D, 0x6B, 0x44},
+               []byte{0x12, 0x67, 0x35, 0xFC, 0xC3, 0x20, 0xD2, 0x5A},
+               []byte{0xCB, 0x89, 0x20, 0xF8, 0x7A, 0x6C, 0x75, 0xCF, 0xF3, 0x96, 0x27, 0xB5, 0x6E, 0x3E, 0xD1, 0x97, 0xC5, 0x52, 0xD2, 0x95, 0xA7, 0xCF, 0xC4, 0x6A, 0xFC, 0x25, 0x3B, 0x46, 0x52, 0xB1, 0xAF, 0x37, 0x95, 0xB1, 0x24, 0xAB, 0x6E},
        },
 }
 
index e20c73a14c54c46d30539136229fa1845d2a780c..af8f26cc6eae632472a9ec6028fc86bf1d6952d7 100644 (file)
@@ -20,16 +20,16 @@ import (
 )
 
 type ecbDecrypter struct {
-       c Cipher;
-       r io.Reader;
-       blockSize int;          // block size
+       c               Cipher;
+       r               io.Reader;
+       blockSize       int;    // block size
 
        // Buffered data.
        // The buffer buf is used as storage for both
        // plain or crypt; at least one of those is nil at any given time.
-       buf []byte;
-       plain []byte;   // plain text waiting to be read
-       crypt []byte;   // ciphertext waiting to be decrypted
+       buf     []byte;
+       plain   []byte; // plain text waiting to be read
+       crypt   []byte; // ciphertext waiting to be decrypted
 }
 
 // Read into x.crypt until it has a full block or EOF or an error happens.
@@ -38,8 +38,8 @@ func (x *ecbDecrypter) fillCrypt() os.Error {
        for len(x.crypt) < x.blockSize {
                off := len(x.crypt);
                var m int;
-               m, err = x.r.Read(x.crypt[off:x.blockSize]);
-               x.crypt = x.crypt[0:off+m];
+               m, err = x.r.Read(x.crypt[off : x.blockSize]);
+               x.crypt = x.crypt[0 : off+m];
                if m == 0 {
                        break;
                }
@@ -66,7 +66,7 @@ func (x *ecbDecrypter) readPlain(p []byte) int {
                p[i] = x.plain[i];
        }
        if n < len(x.plain) {
-               x.plain = x.plain[n:len(x.plain)];
+               x.plain = x.plain[n : len(x.plain)];
        } else {
                x.plain = nil;
        }
@@ -74,6 +74,7 @@ func (x *ecbDecrypter) readPlain(p []byte) int {
 }
 
 type ecbFragmentError int
+
 func (n ecbFragmentError) String() string {
        return "crypto/block: " + strconv.Itoa(int(n)) + "-byte fragment at EOF";
 }
@@ -117,8 +118,8 @@ func (x *ecbDecrypter) Read(p []byte) (n int, err os.Error) {
                return;
        }
        var i int;
-       for i = 0; i+x.blockSize <= n; i += x.blockSize {
-               a := p[i:i+x.blockSize];
+       for i = 0; i + x.blockSize <= n; i += x.blockSize {
+               a := p[i : i + x.blockSize];
                x.c.Decrypt(a, a);
        }
 
@@ -151,17 +152,17 @@ func NewECBDecrypter(c Cipher, r io.Reader) io.Reader {
 }
 
 type ecbEncrypter struct {
-       c Cipher;
-       w io.Writer;
-       blockSize int;
+       c               Cipher;
+       w               io.Writer;
+       blockSize       int;
 
        // Buffered data.
        // The buffer buf is used as storage for both
        // plain or crypt.  If both are non-nil, plain
        // follows crypt in buf.
-       buf []byte;
-       plain []byte;   // plain text waiting to be encrypted
-       crypt []byte;   // encrypted text waiting to be written
+       buf     []byte;
+       plain   []byte; // plain text waiting to be encrypted
+       crypt   []byte; // encrypted text waiting to be written
 }
 
 // Flush the x.crypt buffer to x.w.
@@ -171,7 +172,7 @@ func (x *ecbEncrypter) flushCrypt() os.Error {
        }
        n, err := x.w.Write(x.crypt);
        if n < len(x.crypt) {
-               x.crypt = x.crypt[n:len(x.crypt)];
+               x.crypt = x.crypt[n : len(x.crypt)];
                if err == nil {
                        err = io.ErrShortWrite;
                }
@@ -195,7 +196,7 @@ func (x *ecbEncrypter) slidePlain() {
                for i := 0; i < len(x.plain); i++ {
                        x.buf[i] = x.plain[i];
                }
-               x.plain = x.buf[0:len(x.plain)];
+               x.plain = x.buf[0 : len(x.plain)];
        }
 }
 
@@ -207,9 +208,9 @@ func (x *ecbEncrypter) fillPlain(p []byte) int {
        if max := cap(x.plain) - off; n > max {
                n = max;
        }
-       x.plain = x.plain[0:off+n];
+       x.plain = x.plain[0 : off+n];
        for i := 0; i < n; i++ {
-               x.plain[off + i] = p[i];
+               x.plain[off+i] = p[i];
        }
        return n;
 }
@@ -218,8 +219,8 @@ func (x *ecbEncrypter) fillPlain(p []byte) int {
 func (x *ecbEncrypter) encrypt() {
        var i int;
        n := len(x.plain);
-       for i = 0; i+x.blockSize <= n; i += x.blockSize {
-               a := x.plain[i:i+x.blockSize];
+       for i = 0; i + x.blockSize <= n; i += x.blockSize {
+               a := x.plain[i : i + x.blockSize];
                x.c.Encrypt(a, a);
        }
        x.crypt = x.plain[0:i];
@@ -270,7 +271,6 @@ func NewECBEncrypter(c Cipher, w io.Writer) io.Writer {
        x.blockSize = c.BlockSize();
 
        // Create a buffer that is an integral number of blocks.
-       x.buf = make([]byte, 8192/x.blockSize * x.blockSize);
+       x.buf = make([]byte, 8192 / x.blockSize * x.blockSize);
        return x;
 }
-
index f823d2fe2b09e12b40068594acbd7fed974c4e94..40c1371d8282ac9c8453bc19bc19ae14f9fd0130 100644 (file)
@@ -18,84 +18,76 @@ import (
 )
 
 type ecbTest struct {
-       name string;
-       key []byte;
-       in []byte;
-       out []byte;
+       name    string;
+       key     []byte;
+       in      []byte;
+       out     []byte;
 }
 
-var commonInput = []byte {
+var commonInput = []byte{
        0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
        0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
        0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
        0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10,
 }
 
-var commonKey128 = []byte {
-       0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c,
-}
+var commonKey128 = []byte{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}
 
-var commonKey192 = []byte {
+var commonKey192 = []byte{
        0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
        0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b,
 }
 
-var commonKey256 = []byte {
+var commonKey256 = []byte{
        0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
        0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4,
 }
 
-var commonIV = []byte {
-       0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
-}
+var commonIV = []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}
 
-var ecbAESTests = []ecbTest {
+var ecbAESTests = []ecbTest{
        // FIPS 197, Appendix B, C
-       ecbTest {
+       ecbTest{
                "FIPS-197 Appendix B",
                commonKey128,
-               []byte {
-                       0x32, 0x43, 0xf6, 0xa8, 0x88, 0x5a, 0x30, 0x8d, 0x31, 0x31, 0x98, 0xa2, 0xe0, 0x37, 0x07, 0x34,
-               },
-               []byte {
-                       0x39, 0x25, 0x84, 0x1d, 0x02, 0xdc, 0x09, 0xfb, 0xdc, 0x11, 0x85, 0x97, 0x19, 0x6a, 0x0b, 0x32,
-               }
+               []byte{0x32, 0x43, 0xf6, 0xa8, 0x88, 0x5a, 0x30, 0x8d, 0x31, 0x31, 0x98, 0xa2, 0xe0, 0x37, 0x07, 0x34},
+               []byte{0x39, 0x25, 0x84, 0x1d, 0x02, 0xdc, 0x09, 0xfb, 0xdc, 0x11, 0x85, 0x97, 0x19, 0x6a, 0x0b, 0x32},
        },
 
        // NIST SP 800-38A pp 24-27
-       ecbTest {
+       ecbTest{
                "ECB-AES128",
                commonKey128,
                commonInput,
-               []byte {
+               []byte{
                        0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60, 0xa8, 0x9e, 0xca, 0xf3, 0x24, 0x66, 0xef, 0x97,
                        0xf5, 0xd3, 0xd5, 0x85, 0x03, 0xb9, 0x69, 0x9d, 0xe7, 0x85, 0x89, 0x5a, 0x96, 0xfd, 0xba, 0xaf,
                        0x43, 0xb1, 0xcd, 0x7f, 0x59, 0x8e, 0xce, 0x23, 0x88, 0x1b, 0x00, 0xe3, 0xed, 0x03, 0x06, 0x88,
                        0x7b, 0x0c, 0x78, 0x5e, 0x27, 0xe8, 0xad, 0x3f, 0x82, 0x23, 0x20, 0x71, 0x04, 0x72, 0x5d, 0xd4,
-               }
+               },
        },
-       ecbTest {
+       ecbTest{
                "ECB-AES192",
                commonKey192,
                commonInput,
-               []byte {
+               []byte{
                        0xbd, 0x33, 0x4f, 0x1d, 0x6e, 0x45, 0xf2, 0x5f, 0xf7, 0x12, 0xa2, 0x14, 0x57, 0x1f, 0xa5, 0xcc,
                        0x97, 0x41, 0x04, 0x84, 0x6d, 0x0a, 0xd3, 0xad, 0x77, 0x34, 0xec, 0xb3, 0xec, 0xee, 0x4e, 0xef,
                        0xef, 0x7a, 0xfd, 0x22, 0x70, 0xe2, 0xe6, 0x0a, 0xdc, 0xe0, 0xba, 0x2f, 0xac, 0xe6, 0x44, 0x4e,
                        0x9a, 0x4b, 0x41, 0xba, 0x73, 0x8d, 0x6c, 0x72, 0xfb, 0x16, 0x69, 0x16, 0x03, 0xc1, 0x8e, 0x0e,
-               }
+               },
        },
-       ecbTest {
+       ecbTest{
                "ECB-AES256",
                commonKey256,
                commonInput,
-               []byte {
+               []byte{
                        0xf3, 0xee, 0xd1, 0xbd, 0xb5, 0xd2, 0xa0, 0x3c, 0x06, 0x4b, 0x5a, 0x7e, 0x3d, 0xb1, 0x81, 0xf8,
                        0x59, 0x1c, 0xcb, 0x10, 0xd4, 0x10, 0xed, 0x26, 0xdc, 0x5b, 0xa7, 0x4a, 0x31, 0x36, 0x28, 0x70,
                        0xb6, 0xed, 0x21, 0xb9, 0x9c, 0xa6, 0xf4, 0xf9, 0xf1, 0x53, 0xe7, 0xb1, 0xbe, 0xaf, 0xed, 0x1d,
                        0x23, 0x30, 0x4b, 0x7a, 0x39, 0xf9, 0xf3, 0xff, 0x06, 0x7d, 0x8d, 0x8f, 0x9e, 0x24, 0xec, 0xc7,
-               }
-       }
+               },
+       },
 }
 
 func TestECB_AES(t *testing.T) {
index f6d5f98ad02115b42c5f356711c489aaa9053279..86647abc2f5505cb6f2f0cc3a877945e661835dc 100644 (file)
@@ -17,8 +17,8 @@ import (
 )
 
 type ofbStream struct {
-       c Cipher;
-       iv []byte;
+       c       Cipher;
+       iv      []byte;
 }
 
 func newOFBStream(c Cipher, iv []byte) *ofbStream {
@@ -57,4 +57,3 @@ func NewOFBReader(c Cipher, iv []byte, r io.Reader) io.Reader {
 func NewOFBWriter(c Cipher, iv []byte, w io.Writer) io.Writer {
        return newXorWriter(newOFBStream(c, iv), w);
 }
-
index 85d32bd724532acc865b4a7b36fdb4dadcea4664..e54a9ce67730b9de6f562909e232246d854e53b1 100644 (file)
@@ -18,50 +18,50 @@ import (
 )
 
 type ofbTest struct {
-       name string;
-       key []byte;
-       iv []byte;
-       in []byte;
-       out []byte;
+       name    string;
+       key     []byte;
+       iv      []byte;
+       in      []byte;
+       out     []byte;
 }
 
-var ofbAESTests = []ofbTest {
+var ofbAESTests = []ofbTest{
        // NIST SP 800-38A pp 52-55
-       ofbTest {
+       ofbTest{
                "OFB-AES128",
                commonKey128,
                commonIV,
                commonInput,
-               []byte {
+               []byte{
                        0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20, 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a,
                        0x77, 0x89, 0x50, 0x8d, 0x16, 0x91, 0x8f, 0x03, 0xf5, 0x3c, 0x52, 0xda, 0xc5, 0x4e, 0xd8, 0x25,
                        0x97, 0x40, 0x05, 0x1e, 0x9c, 0x5f, 0xec, 0xf6, 0x43, 0x44, 0xf7, 0xa8, 0x22, 0x60, 0xed, 0xcc,
                        0x30, 0x4c, 0x65, 0x28, 0xf6, 0x59, 0xc7, 0x78, 0x66, 0xa5, 0x10, 0xd9, 0xc1, 0xd6, 0xae, 0x5e,
                },
        },
-       ofbTest {
+       ofbTest{
                "OFB-AES192",
                commonKey192,
                commonIV,
                commonInput,
-               []byte {
+               []byte{
                        0xcd, 0xc8, 0x0d, 0x6f, 0xdd, 0xf1, 0x8c, 0xab, 0x34, 0xc2, 0x59, 0x09, 0xc9, 0x9a, 0x41, 0x74,
                        0xfc, 0xc2, 0x8b, 0x8d, 0x4c, 0x63, 0x83, 0x7c, 0x09, 0xe8, 0x17, 0x00, 0xc1, 0x10, 0x04, 0x01,
                        0x8d, 0x9a, 0x9a, 0xea, 0xc0, 0xf6, 0x59, 0x6f, 0x55, 0x9c, 0x6d, 0x4d, 0xaf, 0x59, 0xa5, 0xf2,
                        0x6d, 0x9f, 0x20, 0x08, 0x57, 0xca, 0x6c, 0x3e, 0x9c, 0xac, 0x52, 0x4b, 0xd9, 0xac, 0xc9, 0x2a,
                },
        },
-       ofbTest {
+       ofbTest{
                "OFB-AES256",
                commonKey256,
                commonIV,
                commonInput,
-               []byte {
+               []byte{
                        0xdc, 0x7e, 0x84, 0xbf, 0xda, 0x79, 0x16, 0x4b, 0x7e, 0xcd, 0x84, 0x86, 0x98, 0x5d, 0x38, 0x60,
                        0x4f, 0xeb, 0xdc, 0x67, 0x40, 0xd2, 0x0b, 0x3a, 0xc8, 0x8f, 0x6a, 0xd8, 0x2a, 0x4f, 0xb0, 0x8d,
                        0x71, 0xab, 0x47, 0xa0, 0x86, 0xe8, 0x6e, 0xed, 0xf3, 0x9d, 0x1c, 0x5b, 0xba, 0x97, 0xc4, 0x08,
                        0x01, 0x26, 0x14, 0x1d, 0x67, 0xf3, 0x7b, 0xe8, 0x53, 0x8f, 0x5a, 0x8b, 0xe7, 0x40, 0xe4, 0x84,
-               }
+               },
        },
 }
 
@@ -77,7 +77,7 @@ func TestOFB_AES(t *testing.T) {
 
                for j := 0; j <= 5; j += 5 {
                        var crypt bytes.Buffer;
-                       in := tt.in[0:len(tt.in) - j];
+                       in := tt.in[0 : len(tt.in) - j];
                        w := NewOFBWriter(c, tt.iv, &crypt);
                        var r io.Reader = bytes.NewBuffer(in);
                        n, err := io.Copy(r, w);
@@ -90,7 +90,7 @@ func TestOFB_AES(t *testing.T) {
 
                for j := 0; j <= 7; j += 7 {
                        var plain bytes.Buffer;
-                       out := tt.out[0:len(tt.out) - j];
+                       out := tt.out[0 : len(tt.out) - j];
                        r := NewOFBReader(c, tt.iv, bytes.NewBuffer(out));
                        w := &plain;
                        n, err := io.Copy(r, w);
index 675dcb77a7043609483cc22c849445c16de34873..c92d2d3ffb3b0eba2fc356a89f001f5df48f4a39 100644 (file)
@@ -16,13 +16,13 @@ import (
 // Calls to Next() return sequential blocks of data from the stream.
 // Each call must return at least one byte: there is no EOF.
 type dataStream interface {
-       Next() []byte
+       Next() []byte;
 }
 
 type xorReader struct {
-       r io.Reader;
-       rand dataStream;        // pseudo-random
-       buf []byte;             // data available from last call to rand
+       r       io.Reader;
+       rand    dataStream;     // pseudo-random
+       buf     []byte;         // data available from last call to rand
 }
 
 func newXorReader(rand dataStream, r io.Reader) io.Reader {
@@ -51,11 +51,11 @@ func (x *xorReader) Read(p []byte) (n int, err os.Error) {
 }
 
 type xorWriter struct {
-       w io.Writer;
-       rand dataStream;        // pseudo-random
-       buf []byte;     // last buffer returned by rand
-       extra []byte;   // extra random data (use before buf)
-       work []byte;    // work space
+       w       io.Writer;
+       rand    dataStream;     // pseudo-random
+       buf     []byte;         // last buffer returned by rand
+       extra   []byte;         // extra random data (use before buf)
+       work    []byte;         // work space
 }
 
 func newXorWriter(rand dataStream, w io.Writer) io.Writer {
@@ -93,7 +93,7 @@ func (x *xorWriter) Write(p []byte) (n int, err os.Error) {
                                        buf = x.rand.Next();
                                        bp = 0;
                                }
-                               x.work[i] = buf[bp] ^ p[i];
+                               x.work[i] = buf[bp]^p[i];
                                bp++;
                        }
                        x.buf = buf[bp:len(buf)];
@@ -122,4 +122,3 @@ func (x *xorWriter) Write(p []byte) (n int, err os.Error) {
        }
        return;
 }
-
index 571ef4eb9d63e26ab81d0615ea40be77b7385c3c..2bee99cc9885e4366243b7462d92620d4f485d2b 100644 (file)
@@ -14,8 +14,8 @@ import (
 
 // Simple "pseudo-random" stream for testing.
 type incStream struct {
-       buf []byte;
-       n byte;
+       buf     []byte;
+       n       byte;
 }
 
 func newIncStream(blockSize int) *incStream {
@@ -43,10 +43,10 @@ func testXorWriter(t *testing.T, maxio int) {
                // compute encrypted version
                n := byte(0);
                for i := 0; i < len(crypt); i++ {
-                       if i % block == 0 {
+                       if i%block == 0 {
                                n++;
                        }
-                       crypt[i] = plain[i] ^ n;
+                       crypt[i] = plain[i]^n;
                        n++;
                }
 
@@ -74,7 +74,7 @@ func testXorWriter(t *testing.T, maxio int) {
                        }
 
                        // check output
-                       crypt := crypt[0:len(crypt) - frag];
+                       crypt := crypt[0 : len(crypt)-frag];
                        data := b.Bytes();
                        if len(data) != len(crypt) {
                                t.Errorf("%s: want %d bytes, got %d", test, len(crypt), len(data));
@@ -97,24 +97,26 @@ func TestXorWriter(t *testing.T) {
 }
 
 func testXorReader(t *testing.T, maxio int) {
-       var readers = []func(io.Reader) io.Reader {
-               func (r io.Reader) io.Reader { return r },
+       var readers = []func(io.Reader) io.Reader{
+               func(r io.Reader) io.Reader {
+                       return r;
+               },
                iotest.OneByteReader,
                iotest.HalfReader,
        };
        var plain, crypt [256]byte;
        for i := 0; i < len(plain); i++ {
-               plain[i] = byte(255 - i);
+               plain[i] = byte(255-i);
        }
        b := new(bytes.Buffer);
        for block := 1; block <= 64 && block <= maxio; block *= 2 {
                // compute encrypted version
                n := byte(0);
                for i := 0; i < len(crypt); i++ {
-                       if i % block == 0 {
+                       if i%block == 0 {
                                n++;
                        }
-                       crypt[i] = plain[i] ^ n;
+                       crypt[i] = plain[i]^n;
                        n++;
                }
 
@@ -143,8 +145,8 @@ func testXorReader(t *testing.T, maxio int) {
 
                                // check output
                                data := b.Bytes();
-                               crypt := crypt[0:maxio - frag];
-                               plain := plain[0:maxio - frag];
+                               crypt := crypt[0 : maxio-frag];
+                               plain := plain[0 : maxio-frag];
                                if len(data) != len(plain) {
                                        t.Errorf("%s: want %d bytes, got %d", test, len(plain), len(data));
                                        continue;
@@ -166,4 +168,3 @@ func TestXorReader(t *testing.T) {
 }
 
 // TODO(rsc): Test handling of writes after write errors.
-
index a3f47ccc9f01fe3428122ed297baa3ccd6cf14c2..4ed5686d703335ae6885f964f4860688c20cf811 100644 (file)
@@ -34,15 +34,15 @@ const (
 )
 
 type hmac struct {
-       size int;
-       key []byte;
-       tmp []byte;
-       inner hash.Hash;
+       size    int;
+       key     []byte;
+       tmp     []byte;
+       inner   hash.Hash;
 }
 
 func (h *hmac) tmpPad(xor byte) {
        for i, k := range h.key {
-               h.tmp[i] = xor ^ k;
+               h.tmp[i] = xor^k;
        }
        for i := len(h.key); i < padSize; i++ {
                h.tmp[i] = xor;
@@ -53,7 +53,7 @@ func (h *hmac) Sum() []byte {
        h.tmpPad(0x5c);
        sum := h.inner.Sum();
        for i, b := range sum {
-               h.tmp[padSize + i] = b;
+               h.tmp[padSize+i] = b;
        }
        h.inner.Reset();
        h.inner.Write(h.tmp);
index d0de00dce683c924c843cd2df9c99e9f7614827c..82ed3ab821ed0187205a4d11caf3f2f65dcc0a7b 100644 (file)
@@ -14,18 +14,18 @@ import (
 )
 
 type hmacTest struct {
-       hash func([]byte) hash.Hash;
-       key []byte;
-       in []byte;
-       out string;
+       hash    func([]byte) hash.Hash;
+       key     []byte;
+       in      []byte;
+       out     string;
 }
 
 // Tests from US FIPS 198
 // http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf
-var hmacTests = []hmacTest {
-       hmacTest {
+var hmacTests = []hmacTest{
+       hmacTest{
                NewSHA1,
-               []byte {
+               []byte{
                        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
                        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
@@ -38,9 +38,9 @@ var hmacTests = []hmacTest {
                strings.Bytes("Sample #1"),
                "4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a",
        },
-       hmacTest {
+       hmacTest{
                NewSHA1,
-               []byte {
+               []byte{
                        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
                        0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
                        0x40, 0x41, 0x42, 0x43,
@@ -48,9 +48,9 @@ var hmacTests = []hmacTest {
                strings.Bytes("Sample #2"),
                "0922d3405faa3d194f82a45830737d5cc6c75d24",
        },
-       hmacTest {
+       hmacTest{
                NewSHA1,
-               []byte {
+               []byte{
                        0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
                        0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
                        0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
@@ -70,12 +70,12 @@ var hmacTests = []hmacTest {
        },
 
        // Test from Plan 9.
-       hmacTest {
+       hmacTest{
                NewMD5,
                strings.Bytes("Jefe"),
                strings.Bytes("what do ya want for nothing?"),
                "750c783e6ab0b503eaa86e310a5db738",
-       }
+       },
 }
 
 func TestHMAC(t *testing.T) {
index a47d913415ec0ed868063d7b9b88862e732485bd..77b3319c01828b013cd1bbd127599a9645abdb13 100644 (file)
@@ -11,23 +11,22 @@ import (
 )
 
 // The size of an MD5 checksum in bytes.
-const Size = 16;
+const Size = 16
 
 const (
-       _Chunk = 64;
-
-       _Init0 = 0x67452301;
-       _Init1 = 0xEFCDAB89;
-       _Init2 = 0x98BADCFE;
-       _Init3 = 0x10325476;
+       _Chunk  = 64;
+       _Init0  = 0x67452301;
+       _Init1  = 0xEFCDAB89;
+       _Init2  = 0x98BADCFE;
+       _Init3  = 0x10325476;
 )
 
 // digest represents the partial evaluation of a checksum.
 type digest struct {
-       s [4]uint32;
-       x [_Chunk]byte;
-       nx int;
-       len uint64;
+       s       [4]uint32;
+       x       [_Chunk]byte;
+       nx      int;
+       len     uint64;
 }
 
 func (d *digest) Reset() {
@@ -55,11 +54,11 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
        d.len += uint64(nn);
        if d.nx > 0 {
                n := len(p);
-               if n > _Chunk-d.nx {
-                       n = _Chunk-d.nx;
+               if n > _Chunk - d.nx {
+                       n = _Chunk - d.nx;
                }
                for i := 0; i < n; i++ {
-                       d.x[d.nx+i] = p[i];
+                       d.x[d.nx + i] = p[i];
                }
                d.nx += n;
                if d.nx == _Chunk {
@@ -85,9 +84,9 @@ func (d *digest) Sum() []byte {
        var tmp [64]byte;
        tmp[0] = 0x80;
        if len%64 < 56 {
-               d.Write(tmp[0:56-len%64]);
+               d.Write(tmp[0 : 56 - len%64]);
        } else {
-               d.Write(tmp[0:64+56-len%64]);
+               d.Write(tmp[0 : 64 + 56 - len%64]);
        }
 
        // Length in bits.
@@ -105,11 +104,14 @@ func (d *digest) Sum() []byte {
        j := 0;
        for i := 0; i < 4; i++ {
                s := d.s[i];
-               p[j] = byte(s); j++;
-               p[j] = byte(s>>8); j++;
-               p[j] = byte(s>>16); j++;
-               p[j] = byte(s>>24); j++;
+               p[j] = byte(s);
+               j++;
+               p[j] = byte(s>>8);
+               j++;
+               p[j] = byte(s>>16);
+               j++;
+               p[j] = byte(s>>24);
+               j++;
        }
        return p;
 }
-
index c6319c7d87f7f6b5eead8db35402016d0252adb7..51fd5a53af4db41bd199744fcaf5c9bb48673757 100644 (file)
@@ -11,42 +11,42 @@ import (
 )
 
 type md5Test struct {
-       out string;
-       in string;
+       out     string;
+       in      string;
 }
 
-var golden = []md5Test {
-       md5Test{ "d41d8cd98f00b204e9800998ecf8427e", "" },
-       md5Test{ "0cc175b9c0f1b6a831c399e269772661", "a" },
-       md5Test{ "187ef4436122d1cc2f40dc2b92f0eba0", "ab" },
-       md5Test{ "900150983cd24fb0d6963f7d28e17f72", "abc" },
-       md5Test{ "e2fc714c4727ee9395f324cd2e7f331f", "abcd" },
-       md5Test{ "ab56b4d92b40713acc5af89985d4b786", "abcde" },
-       md5Test{ "e80b5017098950fc58aad83c8c14978e", "abcdef" },
-       md5Test{ "7ac66c0f148de9519b8bd264312c4d64", "abcdefg" },
-       md5Test{ "e8dc4081b13434b45189a720b77b6818", "abcdefgh" },
-       md5Test{ "8aa99b1f439ff71293e95357bac6fd94", "abcdefghi" },
-       md5Test{ "a925576942e94b2ef57a066101b48876", "abcdefghij" },
-       md5Test{ "d747fc1719c7eacb84058196cfe56d57", "Discard medicine more than two years old." },
-       md5Test{ "bff2dcb37ef3a44ba43ab144768ca837", "He who has a shady past knows that nice guys finish last." },
-       md5Test{ "0441015ecb54a7342d017ed1bcfdbea5", "I wouldn't marry him with a ten foot pole." },
-       md5Test{ "9e3cac8e9e9757a60c3ea391130d3689", "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave" },
-       md5Test{ "a0f04459b031f916a59a35cc482dc039", "The days of the digital watch are numbered.  -Tom Stoppard" },
-       md5Test{ "e7a48e0fe884faf31475d2a04b1362cc", "Nepal premier won't resign." },
-       md5Test{ "637d2fe925c07c113800509964fb0e06", "For every action there is an equal and opposite government program." },
-       md5Test{ "834a8d18d5c6562119cf4c7f5086cb71", "His money is twice tainted: 'taint yours and 'taint mine." },
-       md5Test{ "de3a4d2fd6c73ec2db2abad23b444281", "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977" },
-       md5Test{ "acf203f997e2cf74ea3aff86985aefaf", "It's a tiny change to the code and not completely disgusting. - Bob Manchek" },
-       md5Test{ "e1c1384cb4d2221dfdd7c795a4222c9a", "size:  a.out:  bad magic" },
-       md5Test{ "c90f3ddecc54f34228c063d7525bf644", "The major problem is with sendmail.  -Mark Horton" },
-       md5Test{ "cdf7ab6c1fd49bd9933c43f3ea5af185", "Give me a rock, paper and scissors and I will move the world.  CCFestoon" },
-       md5Test{ "83bc85234942fc883c063cbd7f0ad5d0", "If the enemy is within range, then so are you." },
-       md5Test{ "277cbe255686b48dd7e8f389394d9299", "It's well we cannot hear the screams/That we create in others' dreams." },
-       md5Test{ "fd3fb0a7ffb8af16603f3d3af98f8e1f", "You remind me of a TV show, but that's all right: I watch it anyway." },
-       md5Test{ "469b13a78ebf297ecda64d4723655154", "C is as portable as Stonehedge!!" },
-       md5Test{ "63eb3a2f466410104731c4b037600110", "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley" },
-       md5Test{ "72c2ed7592debca1c90fc0100f931a2f", "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction.  Lewis-Randall Rule" },
-       md5Test{ "132f7619d33b523b1d9e5bd8e0928355", "How can you write a big system without C++?  -Paul Glick" },
+var golden = []md5Test{
+       md5Test{"d41d8cd98f00b204e9800998ecf8427e", ""},
+       md5Test{"0cc175b9c0f1b6a831c399e269772661", "a"},
+       md5Test{"187ef4436122d1cc2f40dc2b92f0eba0", "ab"},
+       md5Test{"900150983cd24fb0d6963f7d28e17f72", "abc"},
+       md5Test{"e2fc714c4727ee9395f324cd2e7f331f", "abcd"},
+       md5Test{"ab56b4d92b40713acc5af89985d4b786", "abcde"},
+       md5Test{"e80b5017098950fc58aad83c8c14978e", "abcdef"},
+       md5Test{"7ac66c0f148de9519b8bd264312c4d64", "abcdefg"},
+       md5Test{"e8dc4081b13434b45189a720b77b6818", "abcdefgh"},
+       md5Test{"8aa99b1f439ff71293e95357bac6fd94", "abcdefghi"},
+       md5Test{"a925576942e94b2ef57a066101b48876", "abcdefghij"},
+       md5Test{"d747fc1719c7eacb84058196cfe56d57", "Discard medicine more than two years old."},
+       md5Test{"bff2dcb37ef3a44ba43ab144768ca837", "He who has a shady past knows that nice guys finish last."},
+       md5Test{"0441015ecb54a7342d017ed1bcfdbea5", "I wouldn't marry him with a ten foot pole."},
+       md5Test{"9e3cac8e9e9757a60c3ea391130d3689", "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave"},
+       md5Test{"a0f04459b031f916a59a35cc482dc039", "The days of the digital watch are numbered.  -Tom Stoppard"},
+       md5Test{"e7a48e0fe884faf31475d2a04b1362cc", "Nepal premier won't resign."},
+       md5Test{"637d2fe925c07c113800509964fb0e06", "For every action there is an equal and opposite government program."},
+       md5Test{"834a8d18d5c6562119cf4c7f5086cb71", "His money is twice tainted: 'taint yours and 'taint mine."},
+       md5Test{"de3a4d2fd6c73ec2db2abad23b444281", "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977"},
+       md5Test{"acf203f997e2cf74ea3aff86985aefaf", "It's a tiny change to the code and not completely disgusting. - Bob Manchek"},
+       md5Test{"e1c1384cb4d2221dfdd7c795a4222c9a", "size:  a.out:  bad magic"},
+       md5Test{"c90f3ddecc54f34228c063d7525bf644", "The major problem is with sendmail.  -Mark Horton"},
+       md5Test{"cdf7ab6c1fd49bd9933c43f3ea5af185", "Give me a rock, paper and scissors and I will move the world.  CCFestoon"},
+       md5Test{"83bc85234942fc883c063cbd7f0ad5d0", "If the enemy is within range, then so are you."},
+       md5Test{"277cbe255686b48dd7e8f389394d9299", "It's well we cannot hear the screams/That we create in others' dreams."},
+       md5Test{"fd3fb0a7ffb8af16603f3d3af98f8e1f", "You remind me of a TV show, but that's all right: I watch it anyway."},
+       md5Test{"469b13a78ebf297ecda64d4723655154", "C is as portable as Stonehedge!!"},
+       md5Test{"63eb3a2f466410104731c4b037600110", "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley"},
+       md5Test{"72c2ed7592debca1c90fc0100f931a2f", "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction.  Lewis-Randall Rule"},
+       md5Test{"132f7619d33b523b1d9e5bd8e0928355", "How can you write a big system without C++?  -Paul Glick"},
 }
 
 func TestGolden(t *testing.T) {
@@ -64,4 +64,3 @@ func TestGolden(t *testing.T) {
                }
        }
 }
-
index 6ca9d58e096c6000dcfc60718477f299d2752312..8b633c77b7524a0e81cccc818fa53bbff3893c17 100644 (file)
@@ -9,7 +9,7 @@
 package md5
 
 // table[i] = int((1<<32) * abs(sin(i+1 radians))).
-var table = []uint32 {
+var table = []uint32{
        // round 1
        0xd76aa478,
        0xe8c7b756,
@@ -83,10 +83,10 @@ var table = []uint32 {
        0xeb86d391,
 }
 
-var shift1 = []uint { 7, 12, 17, 22 };
-var shift2 = []uint { 5, 9, 14, 20 };
-var shift3 = []uint { 4, 11, 16, 23 };
-var shift4 = []uint { 6, 10, 15, 21 };
+var shift1 = []uint{7, 12, 17, 22}
+var shift2 = []uint{5, 9, 14, 20}
+var shift3 = []uint{4, 11, 16, 23}
+var shift4 = []uint{6, 10, 15, 21}
 
 func _Block(dig *digest, p []byte) int {
        a := dig.s[0];
@@ -116,8 +116,8 @@ func _Block(dig *digest, p []byte) int {
                        x := i;
                        t := i;
                        s := shift1[i%4];
-                       f := ((c ^ d) & b) ^ d;
-                       a += f + X[x] + table[t];
+                       f := ((c^d)&b)^d;
+                       a += f+X[x]+table[t];
                        a = a<<s | a>>(32-s);
                        a += b;
                        a, b, c, d = d, a, b, c;
@@ -125,11 +125,11 @@ func _Block(dig *digest, p []byte) int {
 
                // Round 2.
                for i := 0; i < 16; i++ {
-                       x := (1+5*i)%16;
+                       x := (1 + 5*i)%16;
                        t := 16+i;
                        s := shift2[i%4];
-                       g := ((b ^ c) & d) ^ c;
-                       a += g + X[x] + table[t];
+                       g := ((b^c)&d)^c;
+                       a += g+X[x]+table[t];
                        a = a<<s | a>>(32-s);
                        a += b;
                        a, b, c, d = d, a, b, c;
@@ -137,11 +137,11 @@ func _Block(dig *digest, p []byte) int {
 
                // Round 3.
                for i := 0; i < 16; i++ {
-                       x := (5+3*i)%16;
+                       x := (5 + 3*i)%16;
                        t := 32+i;
                        s := shift3[i%4];
-                       h := b ^ c ^ d;
-                       a += h + X[x] + table[t];
+                       h := b^c^d;
+                       a += h+X[x]+table[t];
                        a = a<<s | a>>(32-s);
                        a += b;
                        a, b, c, d = d, a, b, c;
@@ -152,8 +152,8 @@ func _Block(dig *digest, p []byte) int {
                        x := (7*i)%16;
                        s := shift4[i%4];
                        t := 48+i;
-                       ii := c ^ (b | ^d);
-                       a += ii + X[x] + table[t];
+                       ii := c^(b | ^d);
+                       a += ii+X[x]+table[t];
                        a = a<<s | a>>(32-s);
                        a += b;
                        a, b, c, d = d, a, b, c;
index fd553895cd21460bff860fd51726884dcea61452..a278f04ebea3e75e81eef280dac1ee5e1d093416 100644 (file)
@@ -11,24 +11,23 @@ import (
 )
 
 // The size of a SHA1 checksum in bytes.
-const Size = 20;
+const Size = 20
 
 const (
-       _Chunk = 64;
-
-       _Init0 = 0x67452301;
-       _Init1 = 0xEFCDAB89;
-       _Init2 = 0x98BADCFE;
-       _Init3 = 0x10325476;
-       _Init4 = 0xC3D2E1F0;
+       _Chunk  = 64;
+       _Init0  = 0x67452301;
+       _Init1  = 0xEFCDAB89;
+       _Init2  = 0x98BADCFE;
+       _Init3  = 0x10325476;
+       _Init4  = 0xC3D2E1F0;
 )
 
 // digest represents the partial evaluation of a checksum.
 type digest struct {
-       h [5]uint32;
-       x [_Chunk]byte;
-       nx int;
-       len uint64;
+       h       [5]uint32;
+       x       [_Chunk]byte;
+       nx      int;
+       len     uint64;
 }
 
 func (d *digest) Reset() {
@@ -57,11 +56,11 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
        d.len += uint64(nn);
        if d.nx > 0 {
                n := len(p);
-               if n > _Chunk-d.nx {
-                       n = _Chunk-d.nx;
+               if n > _Chunk - d.nx {
+                       n = _Chunk - d.nx;
                }
                for i := 0; i < n; i++ {
-                       d.x[d.nx+i] = p[i];
+                       d.x[d.nx + i] = p[i];
                }
                d.nx += n;
                if d.nx == _Chunk {
@@ -87,15 +86,15 @@ func (d *digest) Sum() []byte {
        var tmp [64]byte;
        tmp[0] = 0x80;
        if len%64 < 56 {
-               d.Write(tmp[0:56-len%64]);
+               d.Write(tmp[0 : 56 - len%64]);
        } else {
-               d.Write(tmp[0:64+56-len%64]);
+               d.Write(tmp[0 : 64 + 56 - len%64]);
        }
 
        // Length in bits.
        len <<= 3;
        for i := uint(0); i < 8; i++ {
-               tmp[i] = byte(len>>(56-8*i));
+               tmp[i] = byte(len>>(56 - 8*i));
        }
        d.Write(tmp[0:8]);
 
@@ -107,11 +106,14 @@ func (d *digest) Sum() []byte {
        j := 0;
        for i := 0; i < 5; i++ {
                s := d.h[i];
-               p[j] = byte(s>>24); j++;
-               p[j] = byte(s>>16); j++;
-               p[j] = byte(s>>8); j++;
-               p[j] = byte(s); j++;
+               p[j] = byte(s>>24);
+               j++;
+               p[j] = byte(s>>16);
+               j++;
+               p[j] = byte(s>>8);
+               j++;
+               p[j] = byte(s);
+               j++;
        }
        return p;
 }
-
index d2f3788a42c357b04b6d3ee301fd278889a2b475..7536300c2975e551d15eb9d2c8800d91f87d67c5 100644 (file)
@@ -13,42 +13,42 @@ import (
 )
 
 type sha1Test struct {
-       out string;
-       in string;
+       out     string;
+       in      string;
 }
 
-var golden = []sha1Test {
-       sha1Test{ "da39a3ee5e6b4b0d3255bfef95601890afd80709", "" },
-       sha1Test{ "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8", "a" },
-       sha1Test{ "da23614e02469a0d7c7bd1bdab5c9c474b1904dc", "ab" },
-       sha1Test{ "a9993e364706816aba3e25717850c26c9cd0d89d", "abc" },
-       sha1Test{ "81fe8bfe87576c3ecb22426f8e57847382917acf", "abcd" },
-       sha1Test{ "03de6c570bfe24bfc328ccd7ca46b76eadaf4334", "abcde" },
-       sha1Test{ "1f8ac10f23c5b5bc1167bda84b833e5c057a77d2", "abcdef" },
-       sha1Test{ "2fb5e13419fc89246865e7a324f476ec624e8740", "abcdefg" },
-       sha1Test{ "425af12a0743502b322e93a015bcf868e324d56a", "abcdefgh" },
-       sha1Test{ "c63b19f1e4c8b5f76b25c49b8b87f57d8e4872a1", "abcdefghi" },
-       sha1Test{ "d68c19a0a345b7eab78d5e11e991c026ec60db63", "abcdefghij" },
-       sha1Test{ "ebf81ddcbe5bf13aaabdc4d65354fdf2044f38a7", "Discard medicine more than two years old." },
-       sha1Test{ "e5dea09392dd886ca63531aaa00571dc07554bb6", "He who has a shady past knows that nice guys finish last." },
-       sha1Test{ "45988f7234467b94e3e9494434c96ee3609d8f8f", "I wouldn't marry him with a ten foot pole." },
-       sha1Test{ "55dee037eb7460d5a692d1ce11330b260e40c988", "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave" },
-       sha1Test{ "b7bc5fb91080c7de6b582ea281f8a396d7c0aee8", "The days of the digital watch are numbered.  -Tom Stoppard" },
-       sha1Test{ "c3aed9358f7c77f523afe86135f06b95b3999797", "Nepal premier won't resign." },
-       sha1Test{ "6e29d302bf6e3a5e4305ff318d983197d6906bb9", "For every action there is an equal and opposite government program." },
-       sha1Test{ "597f6a540010f94c15d71806a99a2c8710e747bd", "His money is twice tainted: 'taint yours and 'taint mine." },
-       sha1Test{ "6859733b2590a8a091cecf50086febc5ceef1e80", "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977" },
-       sha1Test{ "514b2630ec089b8aee18795fc0cf1f4860cdacad", "It's a tiny change to the code and not completely disgusting. - Bob Manchek" },
-       sha1Test{ "c5ca0d4a7b6676fc7aa72caa41cc3d5df567ed69", "size:  a.out:  bad magic" },
-       sha1Test{ "74c51fa9a04eadc8c1bbeaa7fc442f834b90a00a", "The major problem is with sendmail.  -Mark Horton" },
-       sha1Test{ "0b4c4ce5f52c3ad2821852a8dc00217fa18b8b66", "Give me a rock, paper and scissors and I will move the world.  CCFestoon" },
-       sha1Test{ "3ae7937dd790315beb0f48330e8642237c61550a", "If the enemy is within range, then so are you." },
-       sha1Test{ "410a2b296df92b9a47412b13281df8f830a9f44b", "It's well we cannot hear the screams/That we create in others' dreams." },
-       sha1Test{ "841e7c85ca1adcddbdd0187f1289acb5c642f7f5", "You remind me of a TV show, but that's all right: I watch it anyway." },
-       sha1Test{ "163173b825d03b952601376b25212df66763e1db", "C is as portable as Stonehedge!!" },
-       sha1Test{ "32b0377f2687eb88e22106f133c586ab314d5279", "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley" },
-       sha1Test{ "0885aaf99b569542fd165fa44e322718f4a984e0", "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction.  Lewis-Randall Rule" },
-       sha1Test{ "6627d6904d71420b0bf3886ab629623538689f45", "How can you write a big system without C++?  -Paul Glick" },
+var golden = []sha1Test{
+       sha1Test{"da39a3ee5e6b4b0d3255bfef95601890afd80709", ""},
+       sha1Test{"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8", "a"},
+       sha1Test{"da23614e02469a0d7c7bd1bdab5c9c474b1904dc", "ab"},
+       sha1Test{"a9993e364706816aba3e25717850c26c9cd0d89d", "abc"},
+       sha1Test{"81fe8bfe87576c3ecb22426f8e57847382917acf", "abcd"},
+       sha1Test{"03de6c570bfe24bfc328ccd7ca46b76eadaf4334", "abcde"},
+       sha1Test{"1f8ac10f23c5b5bc1167bda84b833e5c057a77d2", "abcdef"},
+       sha1Test{"2fb5e13419fc89246865e7a324f476ec624e8740", "abcdefg"},
+       sha1Test{"425af12a0743502b322e93a015bcf868e324d56a", "abcdefgh"},
+       sha1Test{"c63b19f1e4c8b5f76b25c49b8b87f57d8e4872a1", "abcdefghi"},
+       sha1Test{"d68c19a0a345b7eab78d5e11e991c026ec60db63", "abcdefghij"},
+       sha1Test{"ebf81ddcbe5bf13aaabdc4d65354fdf2044f38a7", "Discard medicine more than two years old."},
+       sha1Test{"e5dea09392dd886ca63531aaa00571dc07554bb6", "He who has a shady past knows that nice guys finish last."},
+       sha1Test{"45988f7234467b94e3e9494434c96ee3609d8f8f", "I wouldn't marry him with a ten foot pole."},
+       sha1Test{"55dee037eb7460d5a692d1ce11330b260e40c988", "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave"},
+       sha1Test{"b7bc5fb91080c7de6b582ea281f8a396d7c0aee8", "The days of the digital watch are numbered.  -Tom Stoppard"},
+       sha1Test{"c3aed9358f7c77f523afe86135f06b95b3999797", "Nepal premier won't resign."},
+       sha1Test{"6e29d302bf6e3a5e4305ff318d983197d6906bb9", "For every action there is an equal and opposite government program."},
+       sha1Test{"597f6a540010f94c15d71806a99a2c8710e747bd", "His money is twice tainted: 'taint yours and 'taint mine."},
+       sha1Test{"6859733b2590a8a091cecf50086febc5ceef1e80", "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977"},
+       sha1Test{"514b2630ec089b8aee18795fc0cf1f4860cdacad", "It's a tiny change to the code and not completely disgusting. - Bob Manchek"},
+       sha1Test{"c5ca0d4a7b6676fc7aa72caa41cc3d5df567ed69", "size:  a.out:  bad magic"},
+       sha1Test{"74c51fa9a04eadc8c1bbeaa7fc442f834b90a00a", "The major problem is with sendmail.  -Mark Horton"},
+       sha1Test{"0b4c4ce5f52c3ad2821852a8dc00217fa18b8b66", "Give me a rock, paper and scissors and I will move the world.  CCFestoon"},
+       sha1Test{"3ae7937dd790315beb0f48330e8642237c61550a", "If the enemy is within range, then so are you."},
+       sha1Test{"410a2b296df92b9a47412b13281df8f830a9f44b", "It's well we cannot hear the screams/That we create in others' dreams."},
+       sha1Test{"841e7c85ca1adcddbdd0187f1289acb5c642f7f5", "You remind me of a TV show, but that's all right: I watch it anyway."},
+       sha1Test{"163173b825d03b952601376b25212df66763e1db", "C is as portable as Stonehedge!!"},
+       sha1Test{"32b0377f2687eb88e22106f133c586ab314d5279", "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley"},
+       sha1Test{"0885aaf99b569542fd165fa44e322718f4a984e0", "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction.  Lewis-Randall Rule"},
+       sha1Test{"6627d6904d71420b0bf3886ab629623538689f45", "How can you write a big system without C++?  -Paul Glick"},
 }
 
 func TestGolden(t *testing.T) {
@@ -66,4 +66,3 @@ func TestGolden(t *testing.T) {
                }
        }
 }
-
index 023703b8f91424d77af969dacf6895a9b44c7569..356b7625b0bd8be40a2b84e21631b01e6afc0ffb 100644 (file)
@@ -9,10 +9,10 @@
 package sha1
 
 const (
-       _K0 = 0x5A827999;
-       _K1 = 0x6ED9EBA1;
-       _K2 = 0x8F1BBCDC;
-       _K3 = 0xCA62C1D6;
+       _K0     = 0x5A827999;
+       _K1     = 0x6ED9EBA1;
+       _K2     = 0x8F1BBCDC;
+       _K3     = 0xCA62C1D6;
 )
 
 func _Block(dig *digest, p []byte) int {
@@ -25,13 +25,10 @@ func _Block(dig *digest, p []byte) int {
                // rounds below if needed for speed.
                for i := 0; i < 16; i++ {
                        j := i*4;
-                       w[i] = uint32(p[j])<<24 |
-                               uint32(p[j+1])<<16 |
-                               uint32(p[j+2])<<8 |
-                               uint32(p[j+3]);
+                       w[i] = uint32(p[j])<<24 | uint32(p[j+1])<<16 | uint32(p[j+2])<<8 | uint32(p[j+3]);
                }
                for i := 16; i < 80; i++ {
-                       tmp := w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16];
+                       tmp := w[i-3]^w[i-8]^w[i-14]^w[i-16];
                        w[i] = tmp<<1 | tmp>>(32-1);
                }
 
@@ -44,28 +41,28 @@ func _Block(dig *digest, p []byte) int {
                        f := b&c | (^b)&d;
                        a5 := a<<5 | a>>(32-5);
                        b30 := b<<30 | b>>(32-30);
-                       t := a5 + f + e + w[i] + _K0;
+                       t := a5+f+e+w[i]+_K0;
                        a, b, c, d, e = t, a, b30, c, d;
                }
                for i := 20; i < 40; i++ {
-                       f := b ^ c ^ d;
+                       f := b^c^d;
                        a5 := a<<5 | a>>(32-5);
                        b30 := b<<30 | b>>(32-30);
-                       t := a5 + f + e + w[i] + _K1;
+                       t := a5+f+e+w[i]+_K1;
                        a, b, c, d, e = t, a, b30, c, d;
                }
                for i := 40; i < 60; i++ {
                        f := b&c | b&d | c&d;
                        a5 := a<<5 | a>>(32-5);
                        b30 := b<<30 | b>>(32-30);
-                       t := a5 + f + e + w[i] + _K2;
+                       t := a5+f+e+w[i]+_K2;
                        a, b, c, d, e = t, a, b30, c, d;
                }
                for i := 60; i < 80; i++ {
-                       f := b ^ c ^ d;
+                       f := b^c^d;
                        a5 := a<<5 | a>>(32-5);
                        b30 := b<<30 | b>>(32-30);
-                       t := a5 + f + e + w[i] + _K3;
+                       t := a5+f+e+w[i]+_K3;
                        a, b, c, d, e = t, a, b30, c, d;
                }
 
index 7f0c226ce7dfb1a4ca239e7a3e5d53deb39728f8..a04684b72bf8cfa9700a10f4979ff8ab467f1790 100644 (file)
@@ -12,19 +12,19 @@ import (
 )
 
 type Struct struct {
-       Int8 int8;
-       Int16 int16;
-       Int32 int32;
-       Int64 int64;
-       Uint8 uint8;
-       Uint16 uint16;
-       Uint32 uint32;
-       Uint64 uint64;
-       Float64 float64;
-       Array [4]uint8;
+       Int8    int8;
+       Int16   int16;
+       Int32   int32;
+       Int64   int64;
+       Uint8   uint8;
+       Uint16  uint16;
+       Uint32  uint32;
+       Uint64  uint64;
+       Float64 float64;
+       Array   [4]uint8;
 }
 
-var s = Struct {
+var s = Struct{
        0x01,
        0x0203,
        0x04050607,
@@ -34,7 +34,7 @@ var s = Struct {
        0x13141516,
        0x1718191a1b1c1d1e,
        math.Float64frombits(0x1f20212223242526),
-       [4]uint8 { 0x27, 0x28, 0x29, 0x2a },
+       [4]uint8{0x27, 0x28, 0x29, 0x2a},
 }
 
 var big = []byte{
@@ -84,4 +84,3 @@ little:
                t.Errorf("Read big-endian:\n\thave %+v\n\twant %+v", sl, s);
        }
 }
-
index 3089180ac0e831f6b95f69443fc081be103e06aa..e4cb28e5ddb8e18c7062a4f8acacf6de46b44723 100644 (file)
@@ -14,17 +14,17 @@ import (
 
 // Data buffer being decoded.
 type buf struct {
-       dwarf *Data;
-       order binary.ByteOrder;
-       name string;
-       off Offset;
-       data []byte;
-       addrsize int;
-       err os.Error;
+       dwarf           *Data;
+       order           binary.ByteOrder;
+       name            string;
+       off             Offset;
+       data            []byte;
+       addrsize        int;
+       err             os.Error;
 }
 
 func makeBuf(d *Data, name string, off Offset, data []byte, addrsize int) buf {
-       return buf{d, d.order, name, off, data, addrsize, nil}
+       return buf{d, d.order, name, off, data, addrsize, nil};
 }
 
 func (b *buf) uint8() uint8 {
@@ -33,7 +33,7 @@ func (b *buf) uint8() uint8 {
                return 0;
        }
        val := b.data[0];
-       b.data = b.data[1:len(b.data)];
+       b.data = b.data[1 : len(b.data)];
        b.off++;
        return val;
 }
@@ -44,7 +44,7 @@ func (b *buf) bytes(n int) []byte {
                return nil;
        }
        data := b.data[0:n];
-       b.data = b.data[n:len(b.data)];
+       b.data = b.data[n : len(b.data)];
        b.off += Offset(n);
        return data;
 }
@@ -57,7 +57,7 @@ func (b *buf) string() string {
        for i := 0; i < len(b.data); i++ {
                if b.data[i] == 0 {
                        s := string(b.data[0:i]);
-                       b.data = b.data[i+1:len(b.data)];
+                       b.data = b.data[i+1 : len(b.data)];
                        b.off += Offset(i+1);
                        return s;
                }
@@ -66,7 +66,7 @@ func (b *buf) string() string {
        return "";
 }
 
-func (b *buf) uint16() uint16{
+func (b *buf) uint16() uint16 {
        a := b.bytes(2);
        if a == nil {
                return 0;
@@ -99,7 +99,7 @@ func (b *buf) varint() (c uint64, bits uint) {
                bits += 7;
                if byte&0x80 == 0 {
                        b.off += Offset(i+1);
-                       b.data = b.data[i+1:len(b.data)];
+                       b.data = b.data[i+1 : len(b.data)];
                        return c, bits;
                }
        }
@@ -116,8 +116,8 @@ func (b *buf) uint() uint64 {
 func (b *buf) int() int64 {
        ux, bits := b.varint();
        x := int64(ux);
-       if x & (1<<(bits-1)) != 0 {
-               x |= -1<<bits;
+       if x&(1<<(bits-1)) != 0 {
+               x |= -1 << bits;
        }
        return x;
 }
@@ -141,17 +141,16 @@ func (b *buf) addr() uint64 {
 func (b *buf) error(s string) {
        if b.err == nil {
                b.data = nil;
-               b.err = DecodeError{b.name, b.off, s}
+               b.err = DecodeError{b.name, b.off, s};
        }
 }
 
 type DecodeError struct {
-       Name string;
-       Offset Offset;
-       Error string;
+       Name    string;
+       Offset  Offset;
+       Error   string;
 }
 
 func (e DecodeError) String() string {
        return "decoding dwarf section " + e.Name + " at offset 0x" + strconv.Itob64(int64(e.Offset), 16) + ": " + e.Error;
 }
-
index c2878bd6f5224a1dead4816d945c4eec512b6f19..b476b29b6c50c0298e6d6f30377e8390a7a434e1 100644 (file)
@@ -12,81 +12,81 @@ import "strconv"
 type Attr uint32
 
 const (
-       AttrSibling Attr = 0x01;
-       AttrLocation Attr = 0x02;
-       AttrName Attr = 0x03;
-       AttrOrdering Attr = 0x09;
-       AttrByteSize Attr = 0x0B;
-       AttrBitOffset Attr = 0x0C;
-       AttrBitSize Attr = 0x0D;
-       AttrStmtList Attr = 0x10;
-       AttrLowpc Attr = 0x11;
-       AttrHighpc Attr = 0x12;
-       AttrLanguage Attr = 0x13;
-       AttrDiscr Attr = 0x15;
-       AttrDiscrValue Attr = 0x16;
-       AttrVisibility Attr = 0x17;
-       AttrImport Attr = 0x18;
-       AttrStringLength Attr = 0x19;
-       AttrCommonRef Attr = 0x1A;
-       AttrCompDir Attr = 0x1B;
-       AttrConstValue Attr = 0x1C;
-       AttrContainingType Attr = 0x1D;
-       AttrDefaultValue Attr = 0x1E;
-       AttrInline Attr = 0x20;
-       AttrIsOptional Attr = 0x21;
-       AttrLowerBound Attr = 0x22;
-       AttrProducer Attr = 0x25;
-       AttrPrototyped Attr = 0x27;
-       AttrReturnAddr Attr = 0x2A;
-       AttrStartScope Attr = 0x2C;
-       AttrStrideSize Attr = 0x2E;
-       AttrUpperBound Attr = 0x2F;
-       AttrAbstractOrigin Attr = 0x31;
-       AttrAccessibility Attr = 0x32;
-       AttrAddrClass Attr = 0x33;
-       AttrArtificial Attr = 0x34;
-       AttrBaseTypes Attr = 0x35;
-       AttrCalling Attr = 0x36;
-       AttrCount Attr = 0x37;
-       AttrDataMemberLoc Attr = 0x38;
-       AttrDeclColumn Attr = 0x39;
-       AttrDeclFile Attr = 0x3A;
-       AttrDeclLine Attr = 0x3B;
-       AttrDeclaration Attr = 0x3C;
-       AttrDiscrList Attr = 0x3D;
-       AttrEncoding Attr = 0x3E;
-       AttrExternal Attr = 0x3F;
-       AttrFrameBase Attr = 0x40;
-       AttrFriend Attr = 0x41;
-       AttrIdentifierCase Attr = 0x42;
-       AttrMacroInfo Attr = 0x43;
-       AttrNamelistItem Attr = 0x44;
-       AttrPriority Attr = 0x45;
-       AttrSegment Attr = 0x46;
-       AttrSpecification Attr = 0x47;
-       AttrStaticLink Attr = 0x48;
-       AttrType Attr = 0x49;
-       AttrUseLocation Attr = 0x4A;
-       AttrVarParam Attr = 0x4B;
-       AttrVirtuality Attr = 0x4C;
-       AttrVtableElemLoc Attr = 0x4D;
-       AttrAllocated Attr = 0x4E;
-       AttrAssociated Attr = 0x4F;
-       AttrDataLocation Attr = 0x50;
-       AttrStride Attr = 0x51;
-       AttrEntrypc Attr = 0x52;
-       AttrUseUTF8 Attr = 0x53;
-       AttrExtension Attr = 0x54;
-       AttrRanges Attr = 0x55;
-       AttrTrampoline Attr = 0x56;
-       AttrCallColumn Attr = 0x57;
-       AttrCallFile Attr = 0x58;
-       AttrCallLine Attr = 0x59;
-       AttrDescription Attr = 0x5A;
+       AttrSibling             Attr    = 0x01;
+       AttrLocation            Attr    = 0x02;
+       AttrName                Attr    = 0x03;
+       AttrOrdering            Attr    = 0x09;
+       AttrByteSize            Attr    = 0x0B;
+       AttrBitOffset           Attr    = 0x0C;
+       AttrBitSize             Attr    = 0x0D;
+       AttrStmtList            Attr    = 0x10;
+       AttrLowpc               Attr    = 0x11;
+       AttrHighpc              Attr    = 0x12;
+       AttrLanguage            Attr    = 0x13;
+       AttrDiscr               Attr    = 0x15;
+       AttrDiscrValue          Attr    = 0x16;
+       AttrVisibility          Attr    = 0x17;
+       AttrImport              Attr    = 0x18;
+       AttrStringLength        Attr    = 0x19;
+       AttrCommonRef           Attr    = 0x1A;
+       AttrCompDir             Attr    = 0x1B;
+       AttrConstValue          Attr    = 0x1C;
+       AttrContainingType      Attr    = 0x1D;
+       AttrDefaultValue        Attr    = 0x1E;
+       AttrInline              Attr    = 0x20;
+       AttrIsOptional          Attr    = 0x21;
+       AttrLowerBound          Attr    = 0x22;
+       AttrProducer            Attr    = 0x25;
+       AttrPrototyped          Attr    = 0x27;
+       AttrReturnAddr          Attr    = 0x2A;
+       AttrStartScope          Attr    = 0x2C;
+       AttrStrideSize          Attr    = 0x2E;
+       AttrUpperBound          Attr    = 0x2F;
+       AttrAbstractOrigin      Attr    = 0x31;
+       AttrAccessibility       Attr    = 0x32;
+       AttrAddrClass           Attr    = 0x33;
+       AttrArtificial          Attr    = 0x34;
+       AttrBaseTypes           Attr    = 0x35;
+       AttrCalling             Attr    = 0x36;
+       AttrCount               Attr    = 0x37;
+       AttrDataMemberLoc       Attr    = 0x38;
+       AttrDeclColumn          Attr    = 0x39;
+       AttrDeclFile            Attr    = 0x3A;
+       AttrDeclLine            Attr    = 0x3B;
+       AttrDeclaration         Attr    = 0x3C;
+       AttrDiscrList           Attr    = 0x3D;
+       AttrEncoding            Attr    = 0x3E;
+       AttrExternal            Attr    = 0x3F;
+       AttrFrameBase           Attr    = 0x40;
+       AttrFriend              Attr    = 0x41;
+       AttrIdentifierCase      Attr    = 0x42;
+       AttrMacroInfo           Attr    = 0x43;
+       AttrNamelistItem        Attr    = 0x44;
+       AttrPriority            Attr    = 0x45;
+       AttrSegment             Attr    = 0x46;
+       AttrSpecification       Attr    = 0x47;
+       AttrStaticLink          Attr    = 0x48;
+       AttrType                Attr    = 0x49;
+       AttrUseLocation         Attr    = 0x4A;
+       AttrVarParam            Attr    = 0x4B;
+       AttrVirtuality          Attr    = 0x4C;
+       AttrVtableElemLoc       Attr    = 0x4D;
+       AttrAllocated           Attr    = 0x4E;
+       AttrAssociated          Attr    = 0x4F;
+       AttrDataLocation        Attr    = 0x50;
+       AttrStride              Attr    = 0x51;
+       AttrEntrypc             Attr    = 0x52;
+       AttrUseUTF8             Attr    = 0x53;
+       AttrExtension           Attr    = 0x54;
+       AttrRanges              Attr    = 0x55;
+       AttrTrampoline          Attr    = 0x56;
+       AttrCallColumn          Attr    = 0x57;
+       AttrCallFile            Attr    = 0x58;
+       AttrCallLine            Attr    = 0x59;
+       AttrDescription         Attr    = 0x5A;
 )
 
-var attrNames = [...]string {
+var attrNames = [...]string{
        AttrSibling: "Sibling",
        AttrLocation: "Location",
        AttrName: "Name",
@@ -186,92 +186,92 @@ type format uint32
 
 const (
        // value formats
-       formAddr format = 0x01;
-       formDwarfBlock2 format = 0x03;
-       formDwarfBlock4 format = 0x04;
-       formData2 format = 0x05;
-       formData4 format = 0x06;
-       formData8 format = 0x07;
-       formString format = 0x08;
-       formDwarfBlock format = 0x09;
-       formDwarfBlock1 format = 0x0A;
-       formData1 format = 0x0B;
-       formFlag format = 0x0C;
-       formSdata format = 0x0D;
-       formStrp format = 0x0E;
-       formUdata format = 0x0F;
-       formRefAddr format = 0x10;
-       formRef1 format = 0x11;
-       formRef2 format = 0x12;
-       formRef4 format = 0x13;
-       formRef8 format = 0x14;
-       formRefUdata format = 0x15;
-       formIndirect format = 0x16;
+       formAddr        format  = 0x01;
+       formDwarfBlock2 format  = 0x03;
+       formDwarfBlock4 format  = 0x04;
+       formData2       format  = 0x05;
+       formData4       format  = 0x06;
+       formData8       format  = 0x07;
+       formString      format  = 0x08;
+       formDwarfBlock  format  = 0x09;
+       formDwarfBlock1 format  = 0x0A;
+       formData1       format  = 0x0B;
+       formFlag        format  = 0x0C;
+       formSdata       format  = 0x0D;
+       formStrp        format  = 0x0E;
+       formUdata       format  = 0x0F;
+       formRefAddr     format  = 0x10;
+       formRef1        format  = 0x11;
+       formRef2        format  = 0x12;
+       formRef4        format  = 0x13;
+       formRef8        format  = 0x14;
+       formRefUdata    format  = 0x15;
+       formIndirect    format  = 0x16;
 )
 
 // A Tag is the classification (the type) of an Entry.
 type Tag uint32
 
 const (
-       TagArrayType Tag = 0x01;
-       TagClassType Tag = 0x02;
-       TagEntryPoint Tag = 0x03;
-       TagEnumerationType Tag = 0x04;
-       TagFormalParameter Tag = 0x05;
-       TagImportedDeclaration Tag = 0x08;
-       TagLabel Tag = 0x0A;
-       TagLexDwarfBlock Tag = 0x0B;
-       TagMember Tag = 0x0D;
-       TagPointerType Tag = 0x0F;
-       TagReferenceType Tag = 0x10;
-       TagCompileUnit Tag = 0x11;
-       TagStringType Tag = 0x12;
-       TagStructType Tag = 0x13;
-       TagSubroutineType Tag = 0x15;
-       TagTypedef Tag = 0x16;
-       TagUnionType Tag = 0x17;
-       TagUnspecifiedParameters Tag = 0x18;
-       TagVariant Tag = 0x19;
-       TagCommonDwarfBlock Tag = 0x1A;
-       TagCommonInclusion Tag = 0x1B;
-       TagInheritance Tag = 0x1C;
-       TagInlinedSubroutine Tag = 0x1D;
-       TagModule Tag = 0x1E;
-       TagPtrToMemberType Tag = 0x1F;
-       TagSetType Tag = 0x20;
-       TagSubrangeType Tag = 0x21;
-       TagWithStmt Tag = 0x22;
-       TagAccessDeclaration Tag = 0x23;
-       TagBaseType Tag = 0x24;
-       TagCatchDwarfBlock Tag = 0x25;
-       TagConstType Tag = 0x26;
-       TagConstant Tag = 0x27;
-       TagEnumerator Tag = 0x28;
-       TagFileType Tag = 0x29;
-       TagFriend Tag = 0x2A;
-       TagNamelist Tag = 0x2B;
-       TagNamelistItem Tag = 0x2C;
-       TagPackedType Tag = 0x2D;
-       TagSubprogram Tag = 0x2E;
-       TagTemplateTypeParameter Tag = 0x2F;
-       TagTemplateValueParameter Tag = 0x30;
-       TagThrownType Tag = 0x31;
-       TagTryDwarfBlock Tag = 0x32;
-       TagVariantPart Tag = 0x33;
-       TagVariable Tag = 0x34;
-       TagVolatileType Tag = 0x35;
-       TagDwarfProcedure Tag = 0x36;
-       TagRestrictType Tag = 0x37;
-       TagInterfaceType Tag = 0x38;
-       TagNamespace Tag = 0x39;
-       TagImportedModule Tag = 0x3A;
-       TagUnspecifiedType Tag = 0x3B;
-       TagPartialUnit Tag = 0x3C;
-       TagImportedUnit Tag = 0x3D;
-       TagMutableType Tag = 0x3E;
+       TagArrayType                    Tag     = 0x01;
+       TagClassType                    Tag     = 0x02;
+       TagEntryPoint                   Tag     = 0x03;
+       TagEnumerationType              Tag     = 0x04;
+       TagFormalParameter              Tag     = 0x05;
+       TagImportedDeclaration          Tag     = 0x08;
+       TagLabel                        Tag     = 0x0A;
+       TagLexDwarfBlock                Tag     = 0x0B;
+       TagMember                       Tag     = 0x0D;
+       TagPointerType                  Tag     = 0x0F;
+       TagReferenceType                Tag     = 0x10;
+       TagCompileUnit                  Tag     = 0x11;
+       TagStringType                   Tag     = 0x12;
+       TagStructType                   Tag     = 0x13;
+       TagSubroutineType               Tag     = 0x15;
+       TagTypedef                      Tag     = 0x16;
+       TagUnionType                    Tag     = 0x17;
+       TagUnspecifiedParameters        Tag     = 0x18;
+       TagVariant                      Tag     = 0x19;
+       TagCommonDwarfBlock             Tag     = 0x1A;
+       TagCommonInclusion              Tag     = 0x1B;
+       TagInheritance                  Tag     = 0x1C;
+       TagInlinedSubroutine            Tag     = 0x1D;
+       TagModule                       Tag     = 0x1E;
+       TagPtrToMemberType              Tag     = 0x1F;
+       TagSetType                      Tag     = 0x20;
+       TagSubrangeType                 Tag     = 0x21;
+       TagWithStmt                     Tag     = 0x22;
+       TagAccessDeclaration            Tag     = 0x23;
+       TagBaseType                     Tag     = 0x24;
+       TagCatchDwarfBlock              Tag     = 0x25;
+       TagConstType                    Tag     = 0x26;
+       TagConstant                     Tag     = 0x27;
+       TagEnumerator                   Tag     = 0x28;
+       TagFileType                     Tag     = 0x29;
+       TagFriend                       Tag     = 0x2A;
+       TagNamelist                     Tag     = 0x2B;
+       TagNamelistItem                 Tag     = 0x2C;
+       TagPackedType                   Tag     = 0x2D;
+       TagSubprogram                   Tag     = 0x2E;
+       TagTemplateTypeParameter        Tag     = 0x2F;
+       TagTemplateValueParameter       Tag     = 0x30;
+       TagThrownType                   Tag     = 0x31;
+       TagTryDwarfBlock                Tag     = 0x32;
+       TagVariantPart                  Tag     = 0x33;
+       TagVariable                     Tag     = 0x34;
+       TagVolatileType                 Tag     = 0x35;
+       TagDwarfProcedure               Tag     = 0x36;
+       TagRestrictType                 Tag     = 0x37;
+       TagInterfaceType                Tag     = 0x38;
+       TagNamespace                    Tag     = 0x39;
+       TagImportedModule               Tag     = 0x3A;
+       TagUnspecifiedType              Tag     = 0x3B;
+       TagPartialUnit                  Tag     = 0x3C;
+       TagImportedUnit                 Tag     = 0x3D;
+       TagMutableType                  Tag     = 0x3E;
 )
 
-var tagNames = [...]string {
+var tagNames = [...]string{
        TagArrayType: "ArrayType",
        TagClassType: "ClassType",
        TagEntryPoint: "EntryPoint",
@@ -356,78 +356,78 @@ func (t Tag) GoString() string {
 // This package does not implement full expressions;
 // the opPlusUconst operator is expected by the type parser.
 const (
-       opAddr = 0x03;  /* 1 op, const addr */
-       opDeref = 0x06;
-       opConst1u = 0x08;       /* 1 op, 1 byte const */
-       opConst1s = 0x09;       /*      " signed */
-       opConst2u = 0x0A;       /* 1 op, 2 byte const  */
-       opConst2s = 0x0B;       /*      " signed */
-       opConst4u = 0x0C;       /* 1 op, 4 byte const */
-       opConst4s = 0x0D;       /*      " signed */
-       opConst8u = 0x0E;       /* 1 op, 8 byte const */
-       opConst8s = 0x0F;       /*      " signed */
-       opConstu = 0x10;        /* 1 op, LEB128 const */
-       opConsts = 0x11;        /*      " signed */
-       opDup = 0x12;
-       opDrop = 0x13;
-       opOver = 0x14;
-       opPick = 0x15;          /* 1 op, 1 byte stack index */
-       opSwap = 0x16;
-       opRot = 0x17;
-       opXderef = 0x18;
-       opAbs = 0x19;
-       opAnd = 0x1A;
-       opDiv = 0x1B;
-       opMinus = 0x1C;
-       opMod = 0x1D;
-       opMul = 0x1E;
-       opNeg = 0x1F;
-       opNot = 0x20;
-       opOr = 0x21;
-       opPlus = 0x22;
-       opPlusUconst = 0x23;    /* 1 op, ULEB128 addend */
-       opShl = 0x24;
-       opShr = 0x25;
-       opShra = 0x26;
-       opXor = 0x27;
-       opSkip = 0x2F;          /* 1 op, signed 2-byte constant */
-       opBra = 0x28;           /* 1 op, signed 2-byte constant */
-       opEq = 0x29;
-       opGe = 0x2A;
-       opGt = 0x2B;
-       opLe = 0x2C;
-       opLt = 0x2D;
-       opNe = 0x2E;
-       opLit0 = 0x30;
-               /* OpLitN = OpLit0 + N for N = 0..31 */
-       opReg0 = 0x50;
-               /* OpRegN = OpReg0 + N for N = 0..31 */
-       opBreg0 = 0x70; /* 1 op, signed LEB128 constant */
-               /* OpBregN = OpBreg0 + N for N = 0..31 */
-       opRegx = 0x90;  /* 1 op, ULEB128 register */
-       opFbreg = 0x91; /* 1 op, SLEB128 offset */
-       opBregx = 0x92; /* 2 op, ULEB128 reg; SLEB128 off */
-       opPiece = 0x93; /* 1 op, ULEB128 size of piece */
-       opDerefSize = 0x94;     /* 1-byte size of data retrieved */
-       opXderefSize = 0x95;    /* 1-byte size of data retrieved */
-       opNop = 0x96;
+       opAddr          = 0x03; /* 1 op, const addr */
+       opDeref         = 0x06;
+       opConst1u       = 0x08; /* 1 op, 1 byte const */
+       opConst1s       = 0x09; /*      " signed */
+       opConst2u       = 0x0A; /* 1 op, 2 byte const  */
+       opConst2s       = 0x0B; /*      " signed */
+       opConst4u       = 0x0C; /* 1 op, 4 byte const */
+       opConst4s       = 0x0D; /*      " signed */
+       opConst8u       = 0x0E; /* 1 op, 8 byte const */
+       opConst8s       = 0x0F; /*      " signed */
+       opConstu        = 0x10; /* 1 op, LEB128 const */
+       opConsts        = 0x11; /*      " signed */
+       opDup           = 0x12;
+       opDrop          = 0x13;
+       opOver          = 0x14;
+       opPick          = 0x15; /* 1 op, 1 byte stack index */
+       opSwap          = 0x16;
+       opRot           = 0x17;
+       opXderef        = 0x18;
+       opAbs           = 0x19;
+       opAnd           = 0x1A;
+       opDiv           = 0x1B;
+       opMinus         = 0x1C;
+       opMod           = 0x1D;
+       opMul           = 0x1E;
+       opNeg           = 0x1F;
+       opNot           = 0x20;
+       opOr            = 0x21;
+       opPlus          = 0x22;
+       opPlusUconst    = 0x23; /* 1 op, ULEB128 addend */
+       opShl           = 0x24;
+       opShr           = 0x25;
+       opShra          = 0x26;
+       opXor           = 0x27;
+       opSkip          = 0x2F; /* 1 op, signed 2-byte constant */
+       opBra           = 0x28; /* 1 op, signed 2-byte constant */
+       opEq            = 0x29;
+       opGe            = 0x2A;
+       opGt            = 0x2B;
+       opLe            = 0x2C;
+       opLt            = 0x2D;
+       opNe            = 0x2E;
+       opLit0          = 0x30;
+       /* OpLitN = OpLit0 + N for N = 0..31 */
+       opReg0  = 0x50;
+       /* OpRegN = OpReg0 + N for N = 0..31 */
+       opBreg0 = 0x70; /* 1 op, signed LEB128 constant */
+       /* OpBregN = OpBreg0 + N for N = 0..31 */
+       opRegx          = 0x90; /* 1 op, ULEB128 register */
+       opFbreg         = 0x91; /* 1 op, SLEB128 offset */
+       opBregx         = 0x92; /* 2 op, ULEB128 reg; SLEB128 off */
+       opPiece         = 0x93; /* 1 op, ULEB128 size of piece */
+       opDerefSize     = 0x94; /* 1-byte size of data retrieved */
+       opXderefSize    = 0x95; /* 1-byte size of data retrieved */
+       opNop           = 0x96;
        /* next four new in Dwarf v3 */
-       opPushObjAddr = 0x97;
-       opCall2 = 0x98; /* 2-byte offset of DIE */
-       opCall4 = 0x99; /* 4-byte offset of DIE */
-       opCallRef = 0x9A        /* 4- or 8- byte offset of DIE */
-       /* 0xE0-0xFF reserved for user-specific */
+       opPushObjAddr   = 0x97;
+       opCall2         = 0x98; /* 2-byte offset of DIE */
+       opCall4         = 0x99; /* 4-byte offset of DIE */
+       opCallRef       = 0x9A; /* 4- or 8- byte offset of DIE */
+/* 0xE0-0xFF reserved for user-specific */
 )
 
 // Basic type encodings -- the value for AttrEncoding in a TagBaseType Entry.
 const (
-       encAddress = 0x01;
-       encBoolean = 0x02;
-       encComplexFloat = 0x03;
-       encFloat = 0x04;
-       encSigned = 0x05;
-       encSignedChar = 0x06;
-       encUnsigned = 0x07;
-       encUnsignedChar = 0x08;
-       encImaginaryFloat = 0x09;
+       encAddress              = 0x01;
+       encBoolean              = 0x02;
+       encComplexFloat         = 0x03;
+       encFloat                = 0x04;
+       encSigned               = 0x05;
+       encSignedChar           = 0x06;
+       encUnsigned             = 0x07;
+       encUnsignedChar         = 0x08;
+       encImaginaryFloat       = 0x09;
 )
index 986e098a80343b40ad518534b33cb376395d469f..0554a249bf34e81acd4fd3841a5757203fb9a7ea 100644 (file)
@@ -14,14 +14,14 @@ import "os"
 
 // a single entry's description: a sequence of attributes
 type abbrev struct {
-       tag Tag;
-       children bool;
-       field []afield;
+       tag             Tag;
+       children        bool;
+       field           []afield;
 }
 
 type afield struct {
-       attr Attr;
-       fmt format;
+       attr    Attr;
+       fmt     format;
 }
 
 // a map from entry format ids to their descriptions
@@ -92,16 +92,16 @@ func (d *Data) parseAbbrev(off uint32) (abbrevTable, os.Error) {
 
 // An entry is a sequence of attribute/value pairs.
 type Entry struct {
-       Offset Offset;  // offset of Entry in DWARF info
-       Tag Tag;        // tag (kind of Entry)
-       Children bool;  // whether Entry is followed by children
-       Field []Field;
+       Offset          Offset; // offset of Entry in DWARF info
+       Tag             Tag;    // tag (kind of Entry)
+       Children        bool;   // whether Entry is followed by children
+       Field           []Field;
 }
 
 // A Field is a single attribute/value pair in an Entry.
 type Field struct {
-       Attr Attr;
-       Val interface{};
+       Attr    Attr;
+       Val     interface{};
 }
 
 // Val returns the value associated with attribute Attr in Entry,
@@ -141,7 +141,7 @@ func (b *buf) entry(atab abbrevTable, ubase Offset) *Entry {
                Offset: off,
                Tag: a.tag,
                Children: a.children,
-               Field: make([]Field, len(a.field))
+               Field: make([]Field, len(a.field)),
        };
        for i := range e.Field {
                e.Field[i].Attr = a.field[i].attr;
@@ -149,7 +149,7 @@ func (b *buf) entry(atab abbrevTable, ubase Offset) *Entry {
                if fmt == formIndirect {
                        fmt = format(b.uint());
                }
-               var val interface{};
+               var val interface{}
                switch fmt {
                default:
                        b.error("unknown entry attr format");
@@ -230,12 +230,12 @@ func (b *buf) entry(atab abbrevTable, ubase Offset) *Entry {
 // If an entry has children, its Children field will be true, and the children
 // follow, terminated by an Entry with Tag 0.
 type Reader struct {
-       b buf;
-       d *Data;
-       err os.Error;
-       unit int;
-       lastChildren bool;      // .Children of last entry returned by Next
-       lastSibling Offset;     // .Val(AttrSibling) of last entry returned by Next
+       b               buf;
+       d               *Data;
+       err             os.Error;
+       unit            int;
+       lastChildren    bool;   // .Children of last entry returned by Next
+       lastSibling     Offset; // .Val(AttrSibling) of last entry returned by Next
 }
 
 // Reader returns a new Reader for Data.
@@ -267,9 +267,9 @@ func (r *Reader) Seek(off Offset) {
        var u *unit;
        for i = range d.unit {
                u = &d.unit[i];
-               if u.off <= off && off < u.off+Offset(len(u.data)) {
+               if u.off <= off && off < u.off + Offset(len(u.data)) {
                        r.unit = i;
-                       r.b = makeBuf(r.d, "info", off, u.data[off-u.off:len(u.data)], u.addrsize);
+                       r.b = makeBuf(r.d, "info", off, u.data[off - u.off : len(u.data)], u.addrsize);
                        return;
                }
        }
@@ -278,7 +278,7 @@ func (r *Reader) Seek(off Offset) {
 
 // maybeNextUnit advances to the next unit if this one is finished.
 func (r *Reader) maybeNextUnit() {
-       for len(r.b.data) == 0 && r.unit+1 < len(r.d.unit) {
+       for len(r.b.data) == 0 && r.unit + 1 < len(r.d.unit) {
                r.unit++;
                u := &r.d.unit[r.unit];
                r.b = makeBuf(r.d, "info", u.off, u.data, u.addrsize);
@@ -318,7 +318,7 @@ func (r *Reader) Next() (*Entry, os.Error) {
 // the last Entry returned by Next.  If that Entry did not have
 // children or Next has not been called, SkipChildren is a no-op.
 func (r *Reader) SkipChildren() {
-       if r.err != nil || !r.lastChildren{
+       if r.err != nil || !r.lastChildren {
                return;
        }
 
@@ -341,4 +341,3 @@ func (r *Reader) SkipChildren() {
                }
        }
 }
-
index 15d0b6ea6b2860dbe5d8465beeca4be5d75dccb5..f2cfa4c930fa8e5a60b0cb3df0830911fe1973e9 100644 (file)
@@ -16,21 +16,21 @@ import (
 // loaded from an executable file (for example, an ELF or Mach-O executable).
 type Data struct {
        // raw data
-       abbrev []byte;
-       aranges []byte;
-       frame []byte;
-       info []byte;
-       line []byte;
-       pubnames []byte;
-       ranges []byte;
-       str []byte;
+       abbrev          []byte;
+       aranges         []byte;
+       frame           []byte;
+       info            []byte;
+       line            []byte;
+       pubnames        []byte;
+       ranges          []byte;
+       str             []byte;
 
        // parsed data
-       abbrevCache map[uint32] abbrevTable;
-       addrsize int;
-       order binary.ByteOrder;
-       typeCache map[Offset] Type;
-       unit []unit;
+       abbrevCache     map[uint32]abbrevTable;
+       addrsize        int;
+       order           binary.ByteOrder;
+       typeCache       map[Offset]Type;
+       unit            []unit;
 }
 
 // New returns a new Data object initialized from the given parameters.
index 63b63db04edfec5494b3569747639baec423efed..91334bdf29ae7f2476e0229de9f870687cb2f035 100644 (file)
@@ -25,8 +25,8 @@ type Type interface {
 // If a field is not known or not applicable for a given type,
 // the zero value is used.
 type CommonType struct {
-       ByteSize int64;         // size of value of this type, in bytes
-       Name string;            // name that can be used to refer to type
+       ByteSize        int64;  // size of value of this type, in bytes
+       Name            string; // name that can be used to refer to type
 }
 
 func (c *CommonType) Common() *CommonType {
@@ -42,8 +42,8 @@ func (c *CommonType) Size() int64 {
 // A BasicType holds fields common to all basic types.
 type BasicType struct {
        CommonType;
-       BitSize int64;
-       BitOffset int64;
+       BitSize         int64;
+       BitOffset       int64;
 }
 
 func (b *BasicType) Basic() *BasicType {
@@ -54,7 +54,7 @@ func (t *BasicType) String() string {
        if t.Name != "" {
                return t.Name;
        }
-       return "?"
+       return "?";
 }
 
 // A CharType represents a signed character type.
@@ -102,8 +102,8 @@ type AddrType struct {
 // A QualType represents a type that has the C/C++ "const", "restrict", or "volatile" qualifier.
 type QualType struct {
        CommonType;
-       Qual string;
-       Type Type;
+       Qual    string;
+       Type    Type;
 }
 
 func (t *QualType) String() string {
@@ -117,9 +117,9 @@ func (t *QualType) Size() int64 {
 // An ArrayType represents a fixed size array type.
 type ArrayType struct {
        CommonType;
-       Type Type;
-       StrideBitSize int64;    // if > 0, number of bits to hold each element
-       Count int64;    // if == -1, an incomplete array, like char x[].
+       Type            Type;
+       StrideBitSize   int64;  // if > 0, number of bits to hold each element
+       Count           int64;  // if == -1, an incomplete array, like char x[].
 }
 
 func (t *ArrayType) String() string {
@@ -142,7 +142,7 @@ func (t *VoidType) String() string {
 // A PtrType represents a pointer type.
 type PtrType struct {
        CommonType;
-       Type Type;
+       Type    Type;
 }
 
 func (t *PtrType) String() string {
@@ -152,20 +152,20 @@ func (t *PtrType) String() string {
 // A StructType represents a struct, union, or C++ class type.
 type StructType struct {
        CommonType;
-       StructName string;
-       Kind string;    // "struct", "union", or "class".
-       Field []*StructField;
-       Incomplete bool;        // if true, struct, union, class is declared but not defined
+       StructName      string;
+       Kind            string; // "struct", "union", or "class".
+       Field           []*StructField;
+       Incomplete      bool;   // if true, struct, union, class is declared but not defined
 }
 
 // A StructField represents a field in a struct, union, or C++ class type.
 type StructField struct {
-       Name string;
-       Type Type;
-       ByteOffset int64;
-       ByteSize int64;
-       BitOffset int64;        // within the ByteSize bytes at ByteOffset
-       BitSize int64;  // zero if not a bit field
+       Name            string;
+       Type            Type;
+       ByteOffset      int64;
+       ByteSize        int64;
+       BitOffset       int64;  // within the ByteSize bytes at ByteOffset
+       BitSize         int64;  // zero if not a bit field
 }
 
 func (t *StructType) String() string {
@@ -205,14 +205,14 @@ func (t *StructType) Defn() string {
 // (inside CommonType).
 type EnumType struct {
        CommonType;
-       EnumName string;
-       Val []*EnumValue;
+       EnumName        string;
+       Val             []*EnumValue;
 }
 
 // An EnumValue represents a single enumeration value.
 type EnumValue struct {
-       Name string;
-       Val int64;
+       Name    string;
+       Val     int64;
 }
 
 func (t *EnumType) String() string {
@@ -234,8 +234,8 @@ func (t *EnumType) String() string {
 // A FuncType represents a function type.
 type FuncType struct {
        CommonType;
-       ReturnType Type;
-       ParamType []Type;
+       ReturnType      Type;
+       ParamType       []Type;
 }
 
 func (t *FuncType) String() string {
@@ -265,7 +265,7 @@ func (t *DotDotDotType) String() string {
 // A TypedefType represents a named type.
 type TypedefType struct {
        CommonType;
-       Type Type;
+       Type    Type;
 }
 
 func (t *TypedefType) String() string {
@@ -358,7 +358,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
                        case TagSubrangeType:
                                max, ok := kid.Val(AttrUpperBound).(int64);
                                if !ok {
-                                       max = -2;        // Count == -1, as in x[].
+                                       max = -2;       // Count == -1, as in x[].
                                }
                                if ndim == 0 {
                                        t.Count = max+1;
@@ -415,7 +415,9 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
                        typ = new(UcharType);
                }
                d.typeCache[off] = typ;
-               t := typ.(interface{Basic() *BasicType}).Basic();
+               t := typ.(interface {
+                       Basic() *BasicType;
+               }).Basic();
                t.Name = name;
                t.BitSize, _ = e.Val(AttrBitSize).(int64);
                t.BitOffset, _ = e.Val(AttrBitOffset).(int64);
@@ -479,7 +481,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
                                        }
                                        t.Field = fld;
                                }
-                               t.Field = t.Field[0:n+1];
+                               t.Field = t.Field[0 : n+1];
                                t.Field[n] = f;
                        }
                }
@@ -530,7 +532,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
                                        }
                                        t.Val = val;
                                }
-                               t.Val = t.Val[0:n+1];
+                               t.Val = t.Val[0 : n+1];
                                t.Val[n] = f;
                        }
                }
@@ -586,7 +588,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
                                }
                                t.ParamType = param;
                        }
-                       t.ParamType = t.ParamType[0:n+1];
+                       t.ParamType = t.ParamType[0 : n+1];
                        t.ParamType[n] = tkid;
                }
 
index d3aa6aa632b953fa1b14e36d18b28ff5df1f9fa7..22a00c21c53252aa29b166502697032500f592ab 100644 (file)
@@ -5,13 +5,13 @@
 package dwarf_test
 
 import (
-       . "debug/dwarf";
-       "debug/elf";
-       "debug/macho";
-       "testing";
+       .       "debug/dwarf";
+               "debug/elf";
+               "debug/macho";
+               "testing";
 )
 
-var typedefTests = map[string]string {
+var typedefTests = map[string]string{
        "t_ptr_volatile_int": "*volatile int",
        "t_ptr_const_char": "*const char",
        "t_long": "long int",
@@ -26,8 +26,8 @@ var typedefTests = map[string]string {
        "t_my_union": "union my_union {vi volatile int@0; x char@0 : 1@7; y int@0 : 4@28; array [40]long long int@0}",
        "t_my_enum": "enum my_enum {e1=1; e2=2; e3=-5; e4=1000000000000000}",
        "t_my_list": "struct list {val short int@0; next *t_my_list@8}",
-       "t_my_tree": "struct tree {left *struct tree@0; right *struct tree@8; val long long unsigned int@16}"
-};
+       "t_my_tree": "struct tree {left *struct tree@0; right *struct tree@8; val long long unsigned int@16}",
+}
 
 func elfData(t *testing.T, name string) *Data {
        f, err := elf.Open(name);
index 040151f39d7107f91fa6b000a44d9da2936c434c..d4bcf5889d8dec6e4cfd7e8e8c825cf52f0bac07 100644 (file)
@@ -13,11 +13,11 @@ import (
 // Each unit has its own abbreviation table and address size.
 
 type unit struct {
-       base Offset;    // byte offset of header within the aggregate info
-       off Offset;     // byte offset of data within the aggregate info
-       data []byte;
-       atable abbrevTable;
-       addrsize int;
+       base            Offset; // byte offset of header within the aggregate info
+       off             Offset; // byte offset of data within the aggregate info
+       data            []byte;
+       atable          abbrevTable;
+       addrsize        int;
 }
 
 func (d *Data) parseUnits() ([]unit, os.Error) {
@@ -53,11 +53,10 @@ func (d *Data) parseUnits() ([]unit, os.Error) {
                u.atable = atable;
                u.addrsize = int(b.uint8());
                u.off = b.off;
-               u.data = b.bytes(int(n - (2+4+1)));
+               u.data = b.bytes(int(n-(2+4+1)));
        }
        if b.err != nil {
                return nil, b.err;
        }
        return units, nil;
 }
-
index e2adf6bbe227bb20897496eb3243df469475d13f..9a8d2d3491dcaa6361d7cca36eca3367f24d2b01 100644 (file)
@@ -48,667 +48,718 @@ import "strconv"
 
 // Indexes into the Header.Ident array.
 const (
-       EI_CLASS =      4;      /* Class of machine. */
-       EI_DATA =               5;      /* Data format. */
-       EI_VERSION =    6;      /* ELF format version. */
-       EI_OSABI =      7;      /* Operating system / ABI identification */
-       EI_ABIVERSION = 8;      /* ABI version */
-       EI_PAD =                9;      /* Start of padding (per SVR4 ABI). */
-       EI_NIDENT =     16;     /* Size of e_ident array. */
+       EI_CLASS        = 4;    /* Class of machine. */
+       EI_DATA         = 5;    /* Data format. */
+       EI_VERSION      = 6;    /* ELF format version. */
+       EI_OSABI        = 7;    /* Operating system / ABI identification */
+       EI_ABIVERSION   = 8;    /* ABI version */
+       EI_PAD          = 9;    /* Start of padding (per SVR4 ABI). */
+       EI_NIDENT       = 16;   /* Size of e_ident array. */
 )
 
 // Initial magic number for ELF files.
-const ELFMAG =         "\177ELF"
+const ELFMAG = "\177ELF"
 
 // Version is found in Header.Ident[EI_VERSION] and Header.Version.
 type Version byte
+
 const (
-       EV_NONE Version =               0;
-       EV_CURRENT Version =    1;
+       EV_NONE         Version = 0;
+       EV_CURRENT      Version = 1;
 )
-var versionStrings = []intName {
-       intName{ 0, "EV_NONE" },
-       intName{ 1, "EV_CURRENT" },
+
+var versionStrings = []intName{
+       intName{0, "EV_NONE"},
+       intName{1, "EV_CURRENT"},
 }
+
 func (i Version) String() string {
-       return stringName(uint32(i), versionStrings, false)
+       return stringName(uint32(i), versionStrings, false);
 }
 func (i Version) GoString() string {
-       return stringName(uint32(i), versionStrings, true)
+       return stringName(uint32(i), versionStrings, true);
 }
 
 // Class is found in Header.Ident[EI_CLASS] and Header.Class.
 type Class byte
+
 const (
-       ELFCLASSNONE Class =    0;      /* Unknown class. */
-       ELFCLASS32 Class =      1;      /* 32-bit architecture. */
-       ELFCLASS64 Class =      2;      /* 64-bit architecture. */
+       ELFCLASSNONE    Class   = 0;    /* Unknown class. */
+       ELFCLASS32      Class   = 1;    /* 32-bit architecture. */
+       ELFCLASS64      Class   = 2;    /* 64-bit architecture. */
 )
-var classStrings = []intName {
-       intName{ 0, "ELFCLASSNONE" },
-       intName{ 1, "ELFCLASS32" },
-       intName{ 2, "ELFCLASS64" },
+
+var classStrings = []intName{
+       intName{0, "ELFCLASSNONE"},
+       intName{1, "ELFCLASS32"},
+       intName{2, "ELFCLASS64"},
 }
+
 func (i Class) String() string {
-       return stringName(uint32(i), classStrings, false)
+       return stringName(uint32(i), classStrings, false);
 }
 func (i Class) GoString() string {
-       return stringName(uint32(i), classStrings, true)
+       return stringName(uint32(i), classStrings, true);
 }
 
 // Data is found in Header.Ident[EI_DATA] and Header.Data.
 type Data byte
+
 const (
-       ELFDATANONE Data =      0;      /* Unknown data format. */
-       ELFDATA2LSB Data =      1;      /* 2's complement little-endian. */
-       ELFDATA2MSB Data =      2;      /* 2's complement big-endian. */
+       ELFDATANONE     Data    = 0;    /* Unknown data format. */
+       ELFDATA2LSB     Data    = 1;    /* 2's complement little-endian. */
+       ELFDATA2MSB     Data    = 2;    /* 2's complement big-endian. */
 )
-var dataStrings = []intName {
-       intName{ 0, "ELFDATANONE" },
-       intName{ 1, "ELFDATA2LSB" },
-       intName{ 2, "ELFDATA2MSB" },
+
+var dataStrings = []intName{
+       intName{0, "ELFDATANONE"},
+       intName{1, "ELFDATA2LSB"},
+       intName{2, "ELFDATA2MSB"},
 }
+
 func (i Data) String() string {
-       return stringName(uint32(i), dataStrings, false)
+       return stringName(uint32(i), dataStrings, false);
 }
 func (i Data) GoString() string {
-       return stringName(uint32(i), dataStrings, true)
+       return stringName(uint32(i), dataStrings, true);
 }
 
 // OSABI is found in Header.Ident[EI_OSABI] and Header.OSABI.
 type OSABI byte
+
 const (
-       ELFOSABI_NONE OSABI =           0;      /* UNIX System V ABI */
-       ELFOSABI_HPUX OSABI =           1;      /* HP-UX operating system */
-       ELFOSABI_NETBSD OSABI =         2;      /* NetBSD */
-       ELFOSABI_LINUX OSABI =          3;      /* GNU/Linux */
-       ELFOSABI_HURD OSABI =           4;      /* GNU/Hurd */
-       ELFOSABI_86OPEN OSABI =         5;      /* 86Open common IA32 ABI */
-       ELFOSABI_SOLARIS OSABI =        6;      /* Solaris */
-       ELFOSABI_AIX OSABI =            7;      /* AIX */
-       ELFOSABI_IRIX OSABI =           8;      /* IRIX */
-       ELFOSABI_FREEBSD OSABI =        9;      /* FreeBSD */
-       ELFOSABI_TRU64 OSABI =          10;     /* TRU64 UNIX */
-       ELFOSABI_MODESTO OSABI =        11;     /* Novell Modesto */
-       ELFOSABI_OPENBSD OSABI =        12;     /* OpenBSD */
-       ELFOSABI_OPENVMS OSABI =        13;     /* Open VMS */
-       ELFOSABI_NSK OSABI =            14;     /* HP Non-Stop Kernel */
-       ELFOSABI_ARM OSABI =            97;     /* ARM */
-       ELFOSABI_STANDALONE OSABI =     255;    /* Standalone (embedded) application */
+       ELFOSABI_NONE           OSABI   = 0;    /* UNIX System V ABI */
+       ELFOSABI_HPUX           OSABI   = 1;    /* HP-UX operating system */
+       ELFOSABI_NETBSD         OSABI   = 2;    /* NetBSD */
+       ELFOSABI_LINUX          OSABI   = 3;    /* GNU/Linux */
+       ELFOSABI_HURD           OSABI   = 4;    /* GNU/Hurd */
+       ELFOSABI_86OPEN         OSABI   = 5;    /* 86Open common IA32 ABI */
+       ELFOSABI_SOLARIS        OSABI   = 6;    /* Solaris */
+       ELFOSABI_AIX            OSABI   = 7;    /* AIX */
+       ELFOSABI_IRIX           OSABI   = 8;    /* IRIX */
+       ELFOSABI_FREEBSD        OSABI   = 9;    /* FreeBSD */
+       ELFOSABI_TRU64          OSABI   = 10;   /* TRU64 UNIX */
+       ELFOSABI_MODESTO        OSABI   = 11;   /* Novell Modesto */
+       ELFOSABI_OPENBSD        OSABI   = 12;   /* OpenBSD */
+       ELFOSABI_OPENVMS        OSABI   = 13;   /* Open VMS */
+       ELFOSABI_NSK            OSABI   = 14;   /* HP Non-Stop Kernel */
+       ELFOSABI_ARM            OSABI   = 97;   /* ARM */
+       ELFOSABI_STANDALONE     OSABI   = 255;  /* Standalone (embedded) application */
 )
-var osabiStrings = []intName {
-       intName{ 0, "ELFOSABI_NONE" },
-       intName{ 1, "ELFOSABI_HPUX" },
-       intName{ 2, "ELFOSABI_NETBSD" },
-       intName{ 3, "ELFOSABI_LINUX" },
-       intName{ 4, "ELFOSABI_HURD" },
-       intName{ 5, "ELFOSABI_86OPEN" },
-       intName{ 6, "ELFOSABI_SOLARIS" },
-       intName{ 7, "ELFOSABI_AIX" },
-       intName{ 8, "ELFOSABI_IRIX" },
-       intName{ 9, "ELFOSABI_FREEBSD" },
-       intName{ 10, "ELFOSABI_TRU64" },
-       intName{ 11, "ELFOSABI_MODESTO" },
-       intName{ 12, "ELFOSABI_OPENBSD" },
-       intName{ 13, "ELFOSABI_OPENVMS" },
-       intName{ 14, "ELFOSABI_NSK" },
-       intName{ 97, "ELFOSABI_ARM" },
-       intName{ 255, "ELFOSABI_STANDALONE" },
+
+var osabiStrings = []intName{
+       intName{0, "ELFOSABI_NONE"},
+       intName{1, "ELFOSABI_HPUX"},
+       intName{2, "ELFOSABI_NETBSD"},
+       intName{3, "ELFOSABI_LINUX"},
+       intName{4, "ELFOSABI_HURD"},
+       intName{5, "ELFOSABI_86OPEN"},
+       intName{6, "ELFOSABI_SOLARIS"},
+       intName{7, "ELFOSABI_AIX"},
+       intName{8, "ELFOSABI_IRIX"},
+       intName{9, "ELFOSABI_FREEBSD"},
+       intName{10, "ELFOSABI_TRU64"},
+       intName{11, "ELFOSABI_MODESTO"},
+       intName{12, "ELFOSABI_OPENBSD"},
+       intName{13, "ELFOSABI_OPENVMS"},
+       intName{14, "ELFOSABI_NSK"},
+       intName{97, "ELFOSABI_ARM"},
+       intName{255, "ELFOSABI_STANDALONE"},
 }
+
 func (i OSABI) String() string {
-       return stringName(uint32(i), osabiStrings, false)
+       return stringName(uint32(i), osabiStrings, false);
 }
 func (i OSABI) GoString() string {
-       return stringName(uint32(i), osabiStrings, true)
+       return stringName(uint32(i), osabiStrings, true);
 }
 
 // Type is found in Header.Type.
 type Type uint16
+
 const (
-       ET_NONE Type =          0;      /* Unknown type. */
-       ET_REL Type =           1;      /* Relocatable. */
-       ET_EXEC Type =          2;      /* Executable. */
-       ET_DYN Type =           3;      /* Shared object. */
-       ET_CORE Type =          4;      /* Core file. */
-       ET_LOOS Type =          0xfe00; /* First operating system specific. */
-       ET_HIOS Type =          0xfeff; /* Last operating system-specific. */
-       ET_LOPROC Type =        0xff00; /* First processor-specific. */
-       ET_HIPROC Type =        0xffff; /* Last processor-specific. */
+       ET_NONE         Type    = 0;            /* Unknown type. */
+       ET_REL          Type    = 1;            /* Relocatable. */
+       ET_EXEC         Type    = 2;            /* Executable. */
+       ET_DYN          Type    = 3;            /* Shared object. */
+       ET_CORE         Type    = 4;            /* Core file. */
+       ET_LOOS         Type    = 0xfe00;       /* First operating system specific. */
+       ET_HIOS         Type    = 0xfeff;       /* Last operating system-specific. */
+       ET_LOPROC       Type    = 0xff00;       /* First processor-specific. */
+       ET_HIPROC       Type    = 0xffff;       /* Last processor-specific. */
 )
+
 var typeStrings = []intName{
-       intName{ 0, "ET_NONE" },
-       intName{ 1, "ET_REL" },
-       intName{ 2, "ET_EXEC" },
-       intName{ 3, "ET_DYN" },
-       intName{ 4, "ET_CORE" },
-       intName{ 0xfe00, "ET_LOOS" },
-       intName{ 0xfeff, "ET_HIOS" },
-       intName{ 0xff00, "ET_LOPROC" },
-       intName{ 0xffff, "ET_HIPROC" },
+       intName{0, "ET_NONE"},
+       intName{1, "ET_REL"},
+       intName{2, "ET_EXEC"},
+       intName{3, "ET_DYN"},
+       intName{4, "ET_CORE"},
+       intName{0xfe00, "ET_LOOS"},
+       intName{0xfeff, "ET_HIOS"},
+       intName{0xff00, "ET_LOPROC"},
+       intName{0xffff, "ET_HIPROC"},
 }
+
 func (i Type) String() string {
-       return stringName(uint32(i), typeStrings, false)
+       return stringName(uint32(i), typeStrings, false);
 }
 func (i Type) GoString() string {
-       return stringName(uint32(i), typeStrings, true)
+       return stringName(uint32(i), typeStrings, true);
 }
 
 // Machine is found in Header.Machine.
 type Machine uint16
+
 const (
-       EM_NONE Machine =               0;      /* Unknown machine. */
-       EM_M32 Machine =                1;      /* AT&T WE32100. */
-       EM_SPARC Machine =      2;      /* Sun SPARC. */
-       EM_386 Machine =                3;      /* Intel i386. */
-       EM_68K Machine =                4;      /* Motorola 68000. */
-       EM_88K Machine =                5;      /* Motorola 88000. */
-       EM_860 Machine =                7;      /* Intel i860. */
-       EM_MIPS Machine =               8;      /* MIPS R3000 Big-Endian only. */
-       EM_S370 Machine =               9;      /* IBM System/370. */
-       EM_MIPS_RS3_LE Machine =        10;     /* MIPS R3000 Little-Endian. */
-       EM_PARISC Machine =     15;     /* HP PA-RISC. */
-       EM_VPP500 Machine =     17;     /* Fujitsu VPP500. */
-       EM_SPARC32PLUS Machine =        18;     /* SPARC v8plus. */
-       EM_960 Machine =                19;     /* Intel 80960. */
-       EM_PPC Machine =                20;     /* PowerPC 32-bit. */
-       EM_PPC64 Machine =      21;     /* PowerPC 64-bit. */
-       EM_S390 Machine =               22;     /* IBM System/390. */
-       EM_V800 Machine =               36;     /* NEC V800. */
-       EM_FR20 Machine =               37;     /* Fujitsu FR20. */
-       EM_RH32 Machine =               38;     /* TRW RH-32. */
-       EM_RCE Machine =                39;     /* Motorola RCE. */
-       EM_ARM Machine =                40;     /* ARM. */
-       EM_SH Machine =         42;     /* Hitachi SH. */
-       EM_SPARCV9 Machine =    43;     /* SPARC v9 64-bit. */
-       EM_TRICORE Machine =    44;     /* Siemens TriCore embedded processor. */
-       EM_ARC Machine =                45;     /* Argonaut RISC Core. */
-       EM_H8_300 Machine =     46;     /* Hitachi H8/300. */
-       EM_H8_300H Machine =    47;     /* Hitachi H8/300H. */
-       EM_H8S Machine =                48;     /* Hitachi H8S. */
-       EM_H8_500 Machine =     49;     /* Hitachi H8/500. */
-       EM_IA_64 Machine =      50;     /* Intel IA-64 Processor. */
-       EM_MIPS_X Machine =     51;     /* Stanford MIPS-X. */
-       EM_COLDFIRE Machine =   52;     /* Motorola ColdFire. */
-       EM_68HC12 Machine =     53;     /* Motorola M68HC12. */
-       EM_MMA Machine =                54;     /* Fujitsu MMA. */
-       EM_PCP Machine =                55;     /* Siemens PCP. */
-       EM_NCPU Machine =               56;     /* Sony nCPU. */
-       EM_NDR1 Machine =               57;     /* Denso NDR1 microprocessor. */
-       EM_STARCORE Machine =   58;     /* Motorola Star*Core processor. */
-       EM_ME16 Machine =               59;     /* Toyota ME16 processor. */
-       EM_ST100 Machine =      60;     /* STMicroelectronics ST100 processor. */
-       EM_TINYJ Machine =      61;     /* Advanced Logic Corp. TinyJ processor. */
-       EM_X86_64 Machine =     62;     /* Advanced Micro Devices x86-64 */
+       EM_NONE         Machine = 0;    /* Unknown machine. */
+       EM_M32          Machine = 1;    /* AT&T WE32100. */
+       EM_SPARC        Machine = 2;    /* Sun SPARC. */
+       EM_386          Machine = 3;    /* Intel i386. */
+       EM_68K          Machine = 4;    /* Motorola 68000. */
+       EM_88K          Machine = 5;    /* Motorola 88000. */
+       EM_860          Machine = 7;    /* Intel i860. */
+       EM_MIPS         Machine = 8;    /* MIPS R3000 Big-Endian only. */
+       EM_S370         Machine = 9;    /* IBM System/370. */
+       EM_MIPS_RS3_LE  Machine = 10;   /* MIPS R3000 Little-Endian. */
+       EM_PARISC       Machine = 15;   /* HP PA-RISC. */
+       EM_VPP500       Machine = 17;   /* Fujitsu VPP500. */
+       EM_SPARC32PLUS  Machine = 18;   /* SPARC v8plus. */
+       EM_960          Machine = 19;   /* Intel 80960. */
+       EM_PPC          Machine = 20;   /* PowerPC 32-bit. */
+       EM_PPC64        Machine = 21;   /* PowerPC 64-bit. */
+       EM_S390         Machine = 22;   /* IBM System/390. */
+       EM_V800         Machine = 36;   /* NEC V800. */
+       EM_FR20         Machine = 37;   /* Fujitsu FR20. */
+       EM_RH32         Machine = 38;   /* TRW RH-32. */
+       EM_RCE          Machine = 39;   /* Motorola RCE. */
+       EM_ARM          Machine = 40;   /* ARM. */
+       EM_SH           Machine = 42;   /* Hitachi SH. */
+       EM_SPARCV9      Machine = 43;   /* SPARC v9 64-bit. */
+       EM_TRICORE      Machine = 44;   /* Siemens TriCore embedded processor. */
+       EM_ARC          Machine = 45;   /* Argonaut RISC Core. */
+       EM_H8_300       Machine = 46;   /* Hitachi H8/300. */
+       EM_H8_300H      Machine = 47;   /* Hitachi H8/300H. */
+       EM_H8S          Machine = 48;   /* Hitachi H8S. */
+       EM_H8_500       Machine = 49;   /* Hitachi H8/500. */
+       EM_IA_64        Machine = 50;   /* Intel IA-64 Processor. */
+       EM_MIPS_X       Machine = 51;   /* Stanford MIPS-X. */
+       EM_COLDFIRE     Machine = 52;   /* Motorola ColdFire. */
+       EM_68HC12       Machine = 53;   /* Motorola M68HC12. */
+       EM_MMA          Machine = 54;   /* Fujitsu MMA. */
+       EM_PCP          Machine = 55;   /* Siemens PCP. */
+       EM_NCPU         Machine = 56;   /* Sony nCPU. */
+       EM_NDR1         Machine = 57;   /* Denso NDR1 microprocessor. */
+       EM_STARCORE     Machine = 58;   /* Motorola Star*Core processor. */
+       EM_ME16         Machine = 59;   /* Toyota ME16 processor. */
+       EM_ST100        Machine = 60;   /* STMicroelectronics ST100 processor. */
+       EM_TINYJ        Machine = 61;   /* Advanced Logic Corp. TinyJ processor. */
+       EM_X86_64       Machine = 62;   /* Advanced Micro Devices x86-64 */
 
        /* Non-standard or deprecated. */
-       EM_486 Machine =                6;      /* Intel i486. */
-       EM_MIPS_RS4_BE Machine =        10;     /* MIPS R4000 Big-Endian */
-       EM_ALPHA_STD Machine =  41;     /* Digital Alpha (standard value). */
-       EM_ALPHA Machine =      0x9026; /* Alpha (written in the absence of an ABI) */
+       EM_486          Machine = 6;            /* Intel i486. */
+       EM_MIPS_RS4_BE  Machine = 10;           /* MIPS R4000 Big-Endian */
+       EM_ALPHA_STD    Machine = 41;           /* Digital Alpha (standard value). */
+       EM_ALPHA        Machine = 0x9026;       /* Alpha (written in the absence of an ABI) */
 )
-var machineStrings = []intName {
-       intName{ 0, "EM_NONE" },
-       intName{ 1, "EM_M32" },
-       intName{ 2, "EM_SPARC" },
-       intName{ 3, "EM_386" },
-       intName{ 4, "EM_68K" },
-       intName{ 5, "EM_88K" },
-       intName{ 7, "EM_860" },
-       intName{ 8, "EM_MIPS" },
-       intName{ 9, "EM_S370" },
-       intName{ 10, "EM_MIPS_RS3_LE" },
-       intName{ 15, "EM_PARISC" },
-       intName{ 17, "EM_VPP500" },
-       intName{ 18, "EM_SPARC32PLUS" },
-       intName{ 19, "EM_960" },
-       intName{ 20, "EM_PPC" },
-       intName{ 21, "EM_PPC64" },
-       intName{ 22, "EM_S390" },
-       intName{ 36, "EM_V800" },
-       intName{ 37, "EM_FR20" },
-       intName{ 38, "EM_RH32" },
-       intName{ 39, "EM_RCE" },
-       intName{ 40, "EM_ARM" },
-       intName{ 42, "EM_SH" },
-       intName{ 43, "EM_SPARCV9" },
-       intName{ 44, "EM_TRICORE" },
-       intName{ 45, "EM_ARC" },
-       intName{ 46, "EM_H8_300" },
-       intName{ 47, "EM_H8_300H" },
-       intName{ 48, "EM_H8S" },
-       intName{ 49, "EM_H8_500" },
-       intName{ 50, "EM_IA_64" },
-       intName{ 51, "EM_MIPS_X" },
-       intName{ 52, "EM_COLDFIRE" },
-       intName{ 53, "EM_68HC12" },
-       intName{ 54, "EM_MMA" },
-       intName{ 55, "EM_PCP" },
-       intName{ 56, "EM_NCPU" },
-       intName{ 57, "EM_NDR1" },
-       intName{ 58, "EM_STARCORE" },
-       intName{ 59, "EM_ME16" },
-       intName{ 60, "EM_ST100" },
-       intName{ 61, "EM_TINYJ" },
-       intName{ 62, "EM_X86_64" },
+
+var machineStrings = []intName{
+       intName{0, "EM_NONE"},
+       intName{1, "EM_M32"},
+       intName{2, "EM_SPARC"},
+       intName{3, "EM_386"},
+       intName{4, "EM_68K"},
+       intName{5, "EM_88K"},
+       intName{7, "EM_860"},
+       intName{8, "EM_MIPS"},
+       intName{9, "EM_S370"},
+       intName{10, "EM_MIPS_RS3_LE"},
+       intName{15, "EM_PARISC"},
+       intName{17, "EM_VPP500"},
+       intName{18, "EM_SPARC32PLUS"},
+       intName{19, "EM_960"},
+       intName{20, "EM_PPC"},
+       intName{21, "EM_PPC64"},
+       intName{22, "EM_S390"},
+       intName{36, "EM_V800"},
+       intName{37, "EM_FR20"},
+       intName{38, "EM_RH32"},
+       intName{39, "EM_RCE"},
+       intName{40, "EM_ARM"},
+       intName{42, "EM_SH"},
+       intName{43, "EM_SPARCV9"},
+       intName{44, "EM_TRICORE"},
+       intName{45, "EM_ARC"},
+       intName{46, "EM_H8_300"},
+       intName{47, "EM_H8_300H"},
+       intName{48, "EM_H8S"},
+       intName{49, "EM_H8_500"},
+       intName{50, "EM_IA_64"},
+       intName{51, "EM_MIPS_X"},
+       intName{52, "EM_COLDFIRE"},
+       intName{53, "EM_68HC12"},
+       intName{54, "EM_MMA"},
+       intName{55, "EM_PCP"},
+       intName{56, "EM_NCPU"},
+       intName{57, "EM_NDR1"},
+       intName{58, "EM_STARCORE"},
+       intName{59, "EM_ME16"},
+       intName{60, "EM_ST100"},
+       intName{61, "EM_TINYJ"},
+       intName{62, "EM_X86_64"},
 
        /* Non-standard or deprecated. */
-       intName{ 6, "EM_486" },
-       intName{ 10, "EM_MIPS_RS4_BE" },
-       intName{ 41, "EM_ALPHA_STD" },
-       intName{ 0x9026, "EM_ALPHA" },
+       intName{6, "EM_486"},
+       intName{10, "EM_MIPS_RS4_BE"},
+       intName{41, "EM_ALPHA_STD"},
+       intName{0x9026, "EM_ALPHA"},
 }
+
 func (i Machine) String() string {
-       return stringName(uint32(i), machineStrings, false)
+       return stringName(uint32(i), machineStrings, false);
 }
 func (i Machine) GoString() string {
-       return stringName(uint32(i), machineStrings, true)
+       return stringName(uint32(i), machineStrings, true);
 }
 
 // Special section indices.
 type SectionIndex int
+
 const (
-       SHN_UNDEF SectionIndex =             0;         /* Undefined, missing, irrelevant. */
-       SHN_LORESERVE SectionIndex =    0xff00;         /* First of reserved range. */
-       SHN_LOPROC SectionIndex =       0xff00;         /* First processor-specific. */
-       SHN_HIPROC SectionIndex =       0xff1f;         /* Last processor-specific. */
-       SHN_LOOS SectionIndex = 0xff20;         /* First operating system-specific. */
-       SHN_HIOS SectionIndex = 0xff3f;         /* Last operating system-specific. */
-       SHN_ABS SectionIndex =          0xfff1;         /* Absolute values. */
-       SHN_COMMON SectionIndex =       0xfff2;         /* Common data. */
-       SHN_XINDEX SectionIndex =       0xffff;         /* Escape -- index stored elsewhere. */
-       SHN_HIRESERVE SectionIndex =    0xffff;         /* Last of reserved range. */
+       SHN_UNDEF       SectionIndex    = 0;            /* Undefined, missing, irrelevant. */
+       SHN_LORESERVE   SectionIndex    = 0xff00;       /* First of reserved range. */
+       SHN_LOPROC      SectionIndex    = 0xff00;       /* First processor-specific. */
+       SHN_HIPROC      SectionIndex    = 0xff1f;       /* Last processor-specific. */
+       SHN_LOOS        SectionIndex    = 0xff20;       /* First operating system-specific. */
+       SHN_HIOS        SectionIndex    = 0xff3f;       /* Last operating system-specific. */
+       SHN_ABS         SectionIndex    = 0xfff1;       /* Absolute values. */
+       SHN_COMMON      SectionIndex    = 0xfff2;       /* Common data. */
+       SHN_XINDEX      SectionIndex    = 0xffff;       /* Escape -- index stored elsewhere. */
+       SHN_HIRESERVE   SectionIndex    = 0xffff;       /* Last of reserved range. */
 )
-var shnStrings = []intName {
-       intName{ 0, "SHN_UNDEF" },
-       intName{ 0xff00, "SHN_LOPROC" },
-       intName{ 0xff20, "SHN_LOOS" },
-       intName{ 0xfff1, "SHN_ABS" },
-       intName{ 0xfff2, "SHN_COMMON" },
-       intName{ 0xffff, "SHN_XINDEX" },
+
+var shnStrings = []intName{
+       intName{0, "SHN_UNDEF"},
+       intName{0xff00, "SHN_LOPROC"},
+       intName{0xff20, "SHN_LOOS"},
+       intName{0xfff1, "SHN_ABS"},
+       intName{0xfff2, "SHN_COMMON"},
+       intName{0xffff, "SHN_XINDEX"},
 }
+
 func (i SectionIndex) String() string {
-       return stringName(uint32(i), shnStrings, false)
+       return stringName(uint32(i), shnStrings, false);
 }
 func (i SectionIndex) GoString() string {
-       return stringName(uint32(i), shnStrings, true)
+       return stringName(uint32(i), shnStrings, true);
 }
 
 // Section type.
 type SectionType uint32
+
 const (
-       SHT_NULL SectionType =          0;      /* inactive */
-       SHT_PROGBITS SectionType =              1;      /* program defined information */
-       SHT_SYMTAB SectionType =                2;      /* symbol table section */
-       SHT_STRTAB SectionType =                3;      /* string table section */
-       SHT_RELA SectionType =          4;      /* relocation section with addends */
-       SHT_HASH SectionType =          5;      /* symbol hash table section */
-       SHT_DYNAMIC SectionType =               6;      /* dynamic section */
-       SHT_NOTE SectionType =          7;      /* note section */
-       SHT_NOBITS SectionType =                8;      /* no space section */
-       SHT_REL SectionType =                   9;      /* relocation section - no addends */
-       SHT_SHLIB SectionType =         10;     /* reserved - purpose unknown */
-       SHT_DYNSYM SectionType =                11;     /* dynamic symbol table section */
-       SHT_INIT_ARRAY SectionType =            14;     /* Initialization function pointers. */
-       SHT_FINI_ARRAY SectionType =            15;     /* Termination function pointers. */
-       SHT_PREINIT_ARRAY SectionType = 16;     /* Pre-initialization function ptrs. */
-       SHT_GROUP SectionType =         17;     /* Section group. */
-       SHT_SYMTAB_SHNDX SectionType =  18;     /* Section indexes (see SHN_XINDEX). */
-       SHT_LOOS SectionType =  0x60000000;     /* First of OS specific semantics */
-       SHT_HIOS SectionType =  0x6fffffff;     /* Last of OS specific semantics */
-       SHT_LOPROC SectionType =        0x70000000;     /* reserved range for processor */
-       SHT_HIPROC SectionType =        0x7fffffff;     /* specific section header types */
-       SHT_LOUSER SectionType =        0x80000000;     /* reserved range for application */
-       SHT_HIUSER SectionType =        0xffffffff;     /* specific indexes */
+       SHT_NULL                SectionType     = 0;            /* inactive */
+       SHT_PROGBITS            SectionType     = 1;            /* program defined information */
+       SHT_SYMTAB              SectionType     = 2;            /* symbol table section */
+       SHT_STRTAB              SectionType     = 3;            /* string table section */
+       SHT_RELA                SectionType     = 4;            /* relocation section with addends */
+       SHT_HASH                SectionType     = 5;            /* symbol hash table section */
+       SHT_DYNAMIC             SectionType     = 6;            /* dynamic section */
+       SHT_NOTE                SectionType     = 7;            /* note section */
+       SHT_NOBITS              SectionType     = 8;            /* no space section */
+       SHT_REL                 SectionType     = 9;            /* relocation section - no addends */
+       SHT_SHLIB               SectionType     = 10;           /* reserved - purpose unknown */
+       SHT_DYNSYM              SectionType     = 11;           /* dynamic symbol table section */
+       SHT_INIT_ARRAY          SectionType     = 14;           /* Initialization function pointers. */
+       SHT_FINI_ARRAY          SectionType     = 15;           /* Termination function pointers. */
+       SHT_PREINIT_ARRAY       SectionType     = 16;           /* Pre-initialization function ptrs. */
+       SHT_GROUP               SectionType     = 17;           /* Section group. */
+       SHT_SYMTAB_SHNDX        SectionType     = 18;           /* Section indexes (see SHN_XINDEX). */
+       SHT_LOOS                SectionType     = 0x60000000;   /* First of OS specific semantics */
+       SHT_HIOS                SectionType     = 0x6fffffff;   /* Last of OS specific semantics */
+       SHT_LOPROC              SectionType     = 0x70000000;   /* reserved range for processor */
+       SHT_HIPROC              SectionType     = 0x7fffffff;   /* specific section header types */
+       SHT_LOUSER              SectionType     = 0x80000000;   /* reserved range for application */
+       SHT_HIUSER              SectionType     = 0xffffffff;   /* specific indexes */
 )
-var shtStrings = []intName {
-       intName{ 0, "SHT_NULL" },
-       intName{ 1, "SHT_PROGBITS" },
-       intName{ 2, "SHT_SYMTAB" },
-       intName{ 3, "SHT_STRTAB" },
-       intName{ 4, "SHT_RELA" },
-       intName{ 5, "SHT_HASH" },
-       intName{ 6, "SHT_DYNAMIC" },
-       intName{ 7, "SHT_NOTE" },
-       intName{ 8, "SHT_NOBITS" },
-       intName{ 9, "SHT_REL" },
-       intName{ 10, "SHT_SHLIB" },
-       intName{ 11, "SHT_DYNSYM" },
-       intName{ 14, "SHT_INIT_ARRAY" },
-       intName{ 15, "SHT_FINI_ARRAY" },
-       intName{ 16, "SHT_PREINIT_ARRAY" },
-       intName{ 17, "SHT_GROUP" },
-       intName{ 18, "SHT_SYMTAB_SHNDX" },
-       intName{ 0x60000000, "SHT_LOOS" },
-       intName{ 0x6fffffff, "SHT_HIOS" },
-       intName{ 0x70000000, "SHT_LOPROC" },
-       intName{ 0x7fffffff, "SHT_HIPROC" },
-       intName{ 0x80000000, "SHT_LOUSER" },
-       intName{ 0xffffffff, "SHT_HIUSER" },
+
+var shtStrings = []intName{
+       intName{0, "SHT_NULL"},
+       intName{1, "SHT_PROGBITS"},
+       intName{2, "SHT_SYMTAB"},
+       intName{3, "SHT_STRTAB"},
+       intName{4, "SHT_RELA"},
+       intName{5, "SHT_HASH"},
+       intName{6, "SHT_DYNAMIC"},
+       intName{7, "SHT_NOTE"},
+       intName{8, "SHT_NOBITS"},
+       intName{9, "SHT_REL"},
+       intName{10, "SHT_SHLIB"},
+       intName{11, "SHT_DYNSYM"},
+       intName{14, "SHT_INIT_ARRAY"},
+       intName{15, "SHT_FINI_ARRAY"},
+       intName{16, "SHT_PREINIT_ARRAY"},
+       intName{17, "SHT_GROUP"},
+       intName{18, "SHT_SYMTAB_SHNDX"},
+       intName{0x60000000, "SHT_LOOS"},
+       intName{0x6fffffff, "SHT_HIOS"},
+       intName{0x70000000, "SHT_LOPROC"},
+       intName{0x7fffffff, "SHT_HIPROC"},
+       intName{0x80000000, "SHT_LOUSER"},
+       intName{0xffffffff, "SHT_HIUSER"},
 }
+
 func (i SectionType) String() string {
-       return stringName(uint32(i), shtStrings, false)
+       return stringName(uint32(i), shtStrings, false);
 }
 func (i SectionType) GoString() string {
-       return stringName(uint32(i), shtStrings, true)
+       return stringName(uint32(i), shtStrings, true);
 }
 
 // Section flags.
 type SectionFlag uint32
+
 const (
-       SHF_WRITE SectionFlag =         0x1;    /* Section contains writable data. */
-       SHF_ALLOC SectionFlag =         0x2;    /* Section occupies memory. */
-       SHF_EXECINSTR SectionFlag =             0x4;    /* Section contains instructions. */
-       SHF_MERGE SectionFlag =         0x10;   /* Section may be merged. */
-       SHF_STRINGS SectionFlag =               0x20;   /* Section contains strings. */
-       SHF_INFO_LINK SectionFlag =             0x40;   /* sh_info holds section index. */
-       SHF_LINK_ORDER SectionFlag =            0x80;   /* Special ordering requirements. */
-       SHF_OS_NONCONFORMING SectionFlag =      0x100;  /* OS-specific processing required. */
-       SHF_GROUP SectionFlag =         0x200;  /* Member of section group. */
-       SHF_TLS SectionFlag =                   0x400;  /* Section contains TLS data. */
-       SHF_MASKOS SectionFlag =        0x0ff00000;     /* OS-specific semantics. */
-       SHF_MASKPROC SectionFlag =      0xf0000000;     /* Processor-specific semantics. */
+       SHF_WRITE               SectionFlag     = 0x1;          /* Section contains writable data. */
+       SHF_ALLOC               SectionFlag     = 0x2;          /* Section occupies memory. */
+       SHF_EXECINSTR           SectionFlag     = 0x4;          /* Section contains instructions. */
+       SHF_MERGE               SectionFlag     = 0x10;         /* Section may be merged. */
+       SHF_STRINGS             SectionFlag     = 0x20;         /* Section contains strings. */
+       SHF_INFO_LINK           SectionFlag     = 0x40;         /* sh_info holds section index. */
+       SHF_LINK_ORDER          SectionFlag     = 0x80;         /* Special ordering requirements. */
+       SHF_OS_NONCONFORMING    SectionFlag     = 0x100;        /* OS-specific processing required. */
+       SHF_GROUP               SectionFlag     = 0x200;        /* Member of section group. */
+       SHF_TLS                 SectionFlag     = 0x400;        /* Section contains TLS data. */
+       SHF_MASKOS              SectionFlag     = 0x0ff00000;   /* OS-specific semantics. */
+       SHF_MASKPROC            SectionFlag     = 0xf0000000;   /* Processor-specific semantics. */
 )
-var shfStrings = []intName {
-       intName{ 0x1, "SHF_WRITE" },
-       intName{ 0x2, "SHF_ALLOC" },
-       intName{ 0x4, "SHF_EXECINSTR" },
-       intName{ 0x10, "SHF_MERGE" },
-       intName{ 0x20, "SHF_STRINGS" },
-       intName{ 0x40, "SHF_INFO_LINK" },
-       intName{ 0x80, "SHF_LINK_ORDER" },
-       intName{ 0x100, "SHF_OS_NONCONFORMING" },
-       intName{ 0x200, "SHF_GROUP" },
-       intName{ 0x400, "SHF_TLS" },
+
+var shfStrings = []intName{
+       intName{0x1, "SHF_WRITE"},
+       intName{0x2, "SHF_ALLOC"},
+       intName{0x4, "SHF_EXECINSTR"},
+       intName{0x10, "SHF_MERGE"},
+       intName{0x20, "SHF_STRINGS"},
+       intName{0x40, "SHF_INFO_LINK"},
+       intName{0x80, "SHF_LINK_ORDER"},
+       intName{0x100, "SHF_OS_NONCONFORMING"},
+       intName{0x200, "SHF_GROUP"},
+       intName{0x400, "SHF_TLS"},
 }
+
 func (i SectionFlag) String() string {
-       return flagName(uint32(i), shfStrings, false)
+       return flagName(uint32(i), shfStrings, false);
 }
 func (i SectionFlag) GoString() string {
-       return flagName(uint32(i), shfStrings, true)
+       return flagName(uint32(i), shfStrings, true);
 }
 
 // Prog.Type
 type ProgType int
+
 const (
-       PT_NULL ProgType =              0;      /* Unused entry. */
-       PT_LOAD ProgType =              1;      /* Loadable segment. */
-       PT_DYNAMIC ProgType =   2;      /* Dynamic linking information segment. */
-       PT_INTERP ProgType =    3;      /* Pathname of interpreter. */
-       PT_NOTE ProgType =              4;      /* Auxiliary information. */
-       PT_SHLIB ProgType =     5;      /* Reserved (not used). */
-       PT_PHDR ProgType =              6;      /* Location of program header itself. */
-       PT_TLS ProgType =               7;      /* Thread local storage segment */
-       PT_LOOS ProgType =              0x60000000;     /* First OS-specific. */
-       PT_HIOS ProgType =              0x6fffffff;     /* Last OS-specific. */
-       PT_LOPROC ProgType =    0x70000000;     /* First processor-specific type. */
-       PT_HIPROC ProgType =    0x7fffffff;     /* Last processor-specific type. */
+       PT_NULL         ProgType        = 0;            /* Unused entry. */
+       PT_LOAD         ProgType        = 1;            /* Loadable segment. */
+       PT_DYNAMIC      ProgType        = 2;            /* Dynamic linking information segment. */
+       PT_INTERP       ProgType        = 3;            /* Pathname of interpreter. */
+       PT_NOTE         ProgType        = 4;            /* Auxiliary information. */
+       PT_SHLIB        ProgType        = 5;            /* Reserved (not used). */
+       PT_PHDR         ProgType        = 6;            /* Location of program header itself. */
+       PT_TLS          ProgType        = 7;            /* Thread local storage segment */
+       PT_LOOS         ProgType        = 0x60000000;   /* First OS-specific. */
+       PT_HIOS         ProgType        = 0x6fffffff;   /* Last OS-specific. */
+       PT_LOPROC       ProgType        = 0x70000000;   /* First processor-specific type. */
+       PT_HIPROC       ProgType        = 0x7fffffff;   /* Last processor-specific type. */
 )
-var ptStrings = []intName {
-       intName{ 0, "PT_NULL" },
-       intName{ 1, "PT_LOAD" },
-       intName{ 2, "PT_DYNAMIC" },
-       intName{ 3, "PT_INTERP" },
-       intName{ 4, "PT_NOTE" },
-       intName{ 5, "PT_SHLIB" },
-       intName{ 6, "PT_PHDR" },
-       intName{ 7, "PT_TLS" },
-       intName{ 0x60000000, "PT_LOOS" },
-       intName{ 0x6fffffff, "PT_HIOS" },
-       intName{ 0x70000000, "PT_LOPROC" },
-       intName{ 0x7fffffff, "PT_HIPROC" },
+
+var ptStrings = []intName{
+       intName{0, "PT_NULL"},
+       intName{1, "PT_LOAD"},
+       intName{2, "PT_DYNAMIC"},
+       intName{3, "PT_INTERP"},
+       intName{4, "PT_NOTE"},
+       intName{5, "PT_SHLIB"},
+       intName{6, "PT_PHDR"},
+       intName{7, "PT_TLS"},
+       intName{0x60000000, "PT_LOOS"},
+       intName{0x6fffffff, "PT_HIOS"},
+       intName{0x70000000, "PT_LOPROC"},
+       intName{0x7fffffff, "PT_HIPROC"},
 }
+
 func (i ProgType) String() string {
-       return stringName(uint32(i), ptStrings, false)
+       return stringName(uint32(i), ptStrings, false);
 }
 func (i ProgType) GoString() string {
-       return stringName(uint32(i), ptStrings, true)
+       return stringName(uint32(i), ptStrings, true);
 }
 
 // Prog.Flag
 type ProgFlag uint32
+
 const (
-       PF_X ProgFlag =         0x1;            /* Executable. */
-       PF_W ProgFlag =         0x2;            /* Writable. */
-       PF_R ProgFlag =         0x4;            /* Readable. */
-       PF_MASKOS ProgFlag =    0x0ff00000;     /* Operating system-specific. */
-       PF_MASKPROC ProgFlag =  0xf0000000;     /* Processor-specific. */
+       PF_X            ProgFlag        = 0x1;          /* Executable. */
+       PF_W            ProgFlag        = 0x2;          /* Writable. */
+       PF_R            ProgFlag        = 0x4;          /* Readable. */
+       PF_MASKOS       ProgFlag        = 0x0ff00000;   /* Operating system-specific. */
+       PF_MASKPROC     ProgFlag        = 0xf0000000;   /* Processor-specific. */
 )
-var pfStrings = []intName {
-       intName{ 0x1, "PF_X" },
-       intName{ 0x2, "PF_W" },
-       intName{ 0x4, "PF_R" },
+
+var pfStrings = []intName{
+       intName{0x1, "PF_X"},
+       intName{0x2, "PF_W"},
+       intName{0x4, "PF_R"},
 }
+
 func (i ProgFlag) String() string {
-       return flagName(uint32(i), pfStrings, false)
+       return flagName(uint32(i), pfStrings, false);
 }
 func (i ProgFlag) GoString() string {
-       return flagName(uint32(i), pfStrings, true)
+       return flagName(uint32(i), pfStrings, true);
 }
 
 // Dyn.Tag
 type DynTag int
+
 const (
-       DT_NULL DynTag =                0;      /* Terminating entry. */
-       DT_NEEDED DynTag =      1;      /* String table offset of a needed shared library. */
-       DT_PLTRELSZ DynTag =    2;      /* Total size in bytes of PLT relocations. */
-       DT_PLTGOT DynTag =      3;      /* Processor-dependent address. */
-       DT_HASH DynTag =                4;      /* Address of symbol hash table. */
-       DT_STRTAB DynTag =      5;      /* Address of string table. */
-       DT_SYMTAB DynTag =      6;      /* Address of symbol table. */
-       DT_RELA DynTag =                7;      /* Address of ElfNN_Rela relocations. */
-       DT_RELASZ DynTag =      8;      /* Total size of ElfNN_Rela relocations. */
-       DT_RELAENT DynTag =     9;      /* Size of each ElfNN_Rela relocation entry. */
-       DT_STRSZ DynTag =       10;     /* Size of string table. */
-       DT_SYMENT DynTag =      11;     /* Size of each symbol table entry. */
-       DT_INIT DynTag =                12;     /* Address of initialization function. */
-       DT_FINI DynTag =                13;     /* Address of finalization function. */
-       DT_SONAME DynTag =      14;     /* String table offset of shared object name. */
-       DT_RPATH DynTag =       15;     /* String table offset of library path. [sup] */
-       DT_SYMBOLIC DynTag =    16;     /* Indicates "symbolic" linking. [sup] */
-       DT_REL DynTag =         17;     /* Address of ElfNN_Rel relocations. */
-       DT_RELSZ DynTag =       18;     /* Total size of ElfNN_Rel relocations. */
-       DT_RELENT DynTag =      19;     /* Size of each ElfNN_Rel relocation. */
-       DT_PLTREL DynTag =      20;     /* Type of relocation used for PLT. */
-       DT_DEBUG DynTag =       21;     /* Reserved (not used). */
-       DT_TEXTREL DynTag =     22;     /* Indicates there may be relocations in non-writable segments. [sup] */
-       DT_JMPREL DynTag =      23;     /* Address of PLT relocations. */
-       DT_BIND_NOW DynTag =    24;     /* [sup] */
-       DT_INIT_ARRAY DynTag =  25;     /* Address of the array of pointers to initialization functions */
-       DT_FINI_ARRAY DynTag =  26;     /* Address of the array of pointers to termination functions */
-       DT_INIT_ARRAYSZ DynTag =        27;     /* Size in bytes of the array of initialization functions. */
-       DT_FINI_ARRAYSZ DynTag =        28;     /* Size in bytes of the array of terminationfunctions. */
-       DT_RUNPATH DynTag =     29;     /* String table offset of a null-terminated library search path string. */
-       DT_FLAGS DynTag =       30;     /* Object specific flag values. */
-       DT_ENCODING DynTag =    32;     /* Values greater than or equal to DT_ENCODING
-                                  and less than DT_LOOS follow the rules for
-                                  the interpretation of the d_un union
-                                  as follows: even == 'd_ptr', even == 'd_val'
-                                  or none */
-       DT_PREINIT_ARRAY DynTag = 32;   /* Address of the array of pointers to pre-initialization functions. */
-       DT_PREINIT_ARRAYSZ DynTag = 33; /* Size in bytes of the array of pre-initialization functions. */
-       DT_LOOS DynTag =                0x6000000d;     /* First OS-specific */
-       DT_HIOS DynTag =                0x6ffff000;     /* Last OS-specific */
-       DT_LOPROC DynTag =      0x70000000;     /* First processor-specific type. */
-       DT_HIPROC DynTag =      0x7fffffff;     /* Last processor-specific type. */
+       DT_NULL                 DynTag  = 0;            /* Terminating entry. */
+       DT_NEEDED               DynTag  = 1;            /* String table offset of a needed shared library. */
+       DT_PLTRELSZ             DynTag  = 2;            /* Total size in bytes of PLT relocations. */
+       DT_PLTGOT               DynTag  = 3;            /* Processor-dependent address. */
+       DT_HASH                 DynTag  = 4;            /* Address of symbol hash table. */
+       DT_STRTAB               DynTag  = 5;            /* Address of string table. */
+       DT_SYMTAB               DynTag  = 6;            /* Address of symbol table. */
+       DT_RELA                 DynTag  = 7;            /* Address of ElfNN_Rela relocations. */
+       DT_RELASZ               DynTag  = 8;            /* Total size of ElfNN_Rela relocations. */
+       DT_RELAENT              DynTag  = 9;            /* Size of each ElfNN_Rela relocation entry. */
+       DT_STRSZ                DynTag  = 10;           /* Size of string table. */
+       DT_SYMENT               DynTag  = 11;           /* Size of each symbol table entry. */
+       DT_INIT                 DynTag  = 12;           /* Address of initialization function. */
+       DT_FINI                 DynTag  = 13;           /* Address of finalization function. */
+       DT_SONAME               DynTag  = 14;           /* String table offset of shared object name. */
+       DT_RPATH                DynTag  = 15;           /* String table offset of library path. [sup] */
+       DT_SYMBOLIC             DynTag  = 16;           /* Indicates "symbolic" linking. [sup] */
+       DT_REL                  DynTag  = 17;           /* Address of ElfNN_Rel relocations. */
+       DT_RELSZ                DynTag  = 18;           /* Total size of ElfNN_Rel relocations. */
+       DT_RELENT               DynTag  = 19;           /* Size of each ElfNN_Rel relocation. */
+       DT_PLTREL               DynTag  = 20;           /* Type of relocation used for PLT. */
+       DT_DEBUG                DynTag  = 21;           /* Reserved (not used). */
+       DT_TEXTREL              DynTag  = 22;           /* Indicates there may be relocations in non-writable segments. [sup] */
+       DT_JMPREL               DynTag  = 23;           /* Address of PLT relocations. */
+       DT_BIND_NOW             DynTag  = 24;           /* [sup] */
+       DT_INIT_ARRAY           DynTag  = 25;           /* Address of the array of pointers to initialization functions */
+       DT_FINI_ARRAY           DynTag  = 26;           /* Address of the array of pointers to termination functions */
+       DT_INIT_ARRAYSZ         DynTag  = 27;           /* Size in bytes of the array of initialization functions. */
+       DT_FINI_ARRAYSZ         DynTag  = 28;           /* Size in bytes of the array of terminationfunctions. */
+       DT_RUNPATH              DynTag  = 29;           /* String table offset of a null-terminated library search path string. */
+       DT_FLAGS                DynTag  = 30;           /* Object specific flag values. */
+       DT_ENCODING             DynTag  = 32;           /* Values greater than or equal to DT_ENCODING
+                                                                  and less than DT_LOOS follow the rules for
+                                                                  the interpretation of the d_un union
+                                                                  as follows: even == 'd_ptr', even == 'd_val'
+                                                                  or none */
+       DT_PREINIT_ARRAY        DynTag  = 32;           /* Address of the array of pointers to pre-initialization functions. */
+       DT_PREINIT_ARRAYSZ      DynTag  = 33;           /* Size in bytes of the array of pre-initialization functions. */
+       DT_LOOS                 DynTag  = 0x6000000d;   /* First OS-specific */
+       DT_HIOS                 DynTag  = 0x6ffff000;   /* Last OS-specific */
+       DT_LOPROC               DynTag  = 0x70000000;   /* First processor-specific type. */
+       DT_HIPROC               DynTag  = 0x7fffffff;   /* Last processor-specific type. */
 )
-var dtStrings = []intName {
-       intName{ 0, "DT_NULL" },
-       intName{ 1, "DT_NEEDED" },
-       intName{ 2, "DT_PLTRELSZ" },
-       intName{ 3, "DT_PLTGOT" },
-       intName{ 4, "DT_HASH" },
-       intName{ 5, "DT_STRTAB" },
-       intName{ 6, "DT_SYMTAB" },
-       intName{ 7, "DT_RELA" },
-       intName{ 8, "DT_RELASZ" },
-       intName{ 9, "DT_RELAENT" },
-       intName{ 10, "DT_STRSZ" },
-       intName{ 11, "DT_SYMENT" },
-       intName{ 12, "DT_INIT" },
-       intName{ 13, "DT_FINI" },
-       intName{ 14, "DT_SONAME" },
-       intName{ 15, "DT_RPATH" },
-       intName{ 16, "DT_SYMBOLIC" },
-       intName{ 17, "DT_REL" },
-       intName{ 18, "DT_RELSZ" },
-       intName{ 19, "DT_RELENT" },
-       intName{ 20, "DT_PLTREL" },
-       intName{ 21, "DT_DEBUG" },
-       intName{ 22, "DT_TEXTREL" },
-       intName{ 23, "DT_JMPREL" },
-       intName{ 24, "DT_BIND_NOW" },
-       intName{ 25, "DT_INIT_ARRAY" },
-       intName{ 26, "DT_FINI_ARRAY" },
-       intName{ 27, "DT_INIT_ARRAYSZ" },
-       intName{ 28, "DT_FINI_ARRAYSZ" },
-       intName{ 29, "DT_RUNPATH" },
-       intName{ 30, "DT_FLAGS" },
-       intName{ 32, "DT_ENCODING" },
-       intName{ 32, "DT_PREINIT_ARRAY" },
-       intName{ 33, "DT_PREINIT_ARRAYSZ" },
-       intName{ 0x6000000d, "DT_LOOS" },
-       intName{ 0x6ffff000, "DT_HIOS" },
-       intName{ 0x70000000, "DT_LOPROC" },
-       intName{ 0x7fffffff, "DT_HIPROC" },
+
+var dtStrings = []intName{
+       intName{0, "DT_NULL"},
+       intName{1, "DT_NEEDED"},
+       intName{2, "DT_PLTRELSZ"},
+       intName{3, "DT_PLTGOT"},
+       intName{4, "DT_HASH"},
+       intName{5, "DT_STRTAB"},
+       intName{6, "DT_SYMTAB"},
+       intName{7, "DT_RELA"},
+       intName{8, "DT_RELASZ"},
+       intName{9, "DT_RELAENT"},
+       intName{10, "DT_STRSZ"},
+       intName{11, "DT_SYMENT"},
+       intName{12, "DT_INIT"},
+       intName{13, "DT_FINI"},
+       intName{14, "DT_SONAME"},
+       intName{15, "DT_RPATH"},
+       intName{16, "DT_SYMBOLIC"},
+       intName{17, "DT_REL"},
+       intName{18, "DT_RELSZ"},
+       intName{19, "DT_RELENT"},
+       intName{20, "DT_PLTREL"},
+       intName{21, "DT_DEBUG"},
+       intName{22, "DT_TEXTREL"},
+       intName{23, "DT_JMPREL"},
+       intName{24, "DT_BIND_NOW"},
+       intName{25, "DT_INIT_ARRAY"},
+       intName{26, "DT_FINI_ARRAY"},
+       intName{27, "DT_INIT_ARRAYSZ"},
+       intName{28, "DT_FINI_ARRAYSZ"},
+       intName{29, "DT_RUNPATH"},
+       intName{30, "DT_FLAGS"},
+       intName{32, "DT_ENCODING"},
+       intName{32, "DT_PREINIT_ARRAY"},
+       intName{33, "DT_PREINIT_ARRAYSZ"},
+       intName{0x6000000d, "DT_LOOS"},
+       intName{0x6ffff000, "DT_HIOS"},
+       intName{0x70000000, "DT_LOPROC"},
+       intName{0x7fffffff, "DT_HIPROC"},
 }
+
 func (i DynTag) String() string {
-       return stringName(uint32(i), dtStrings, false)
+       return stringName(uint32(i), dtStrings, false);
 }
 func (i DynTag) GoString() string {
-       return stringName(uint32(i), dtStrings, true)
+       return stringName(uint32(i), dtStrings, true);
 }
 
 // DT_FLAGS values.
 type DynFlag int
+
 const (
-       DF_ORIGIN DynFlag =     0x0001; /* Indicates that the object being loaded may
-                                  make reference to the $ORIGIN substitution
-                                  string */
-       DF_SYMBOLIC DynFlag =   0x0002; /* Indicates "symbolic" linking. */
-       DF_TEXTREL DynFlag =    0x0004; /* Indicates there may be relocations in
-                                  non-writable segments. */
-       DF_BIND_NOW DynFlag =   0x0008; /* Indicates that the dynamic linker should
-                                  process all relocations for the object
-                                  containing this entry before transferring
-                                  control to the program. */
-       DF_STATIC_TLS DynFlag = 0x0010; /* Indicates that the shared object or
-                                  executable contains code using a static
-                                  thread-local storage scheme. */
+       DF_ORIGIN       DynFlag = 0x0001;       /* Indicates that the object being loaded may
+                                                          make reference to the $ORIGIN substitution
+                                                          string */
+       DF_SYMBOLIC     DynFlag = 0x0002;       /* Indicates "symbolic" linking. */
+       DF_TEXTREL      DynFlag = 0x0004;       /* Indicates there may be relocations in
+                                                          non-writable segments. */
+       DF_BIND_NOW     DynFlag = 0x0008;       /* Indicates that the dynamic linker should
+                                                          process all relocations for the object
+                                                          containing this entry before transferring
+                                                          control to the program. */
+       DF_STATIC_TLS   DynFlag = 0x0010;       /* Indicates that the shared object or
+                                                  executable contains code using a static
+                                                  thread-local storage scheme. */
 )
-var dflagStrings = []intName {
-       intName{ 0x0001, "DF_ORIGIN" },
-       intName{ 0x0002, "DF_SYMBOLIC" },
-       intName{ 0x0004, "DF_TEXTREL" },
-       intName{ 0x0008, "DF_BIND_NOW" },
-       intName{ 0x0010, "DF_STATIC_TLS" },
+
+var dflagStrings = []intName{
+       intName{0x0001, "DF_ORIGIN"},
+       intName{0x0002, "DF_SYMBOLIC"},
+       intName{0x0004, "DF_TEXTREL"},
+       intName{0x0008, "DF_BIND_NOW"},
+       intName{0x0010, "DF_STATIC_TLS"},
 }
+
 func (i DynFlag) String() string {
-       return flagName(uint32(i), dflagStrings, false)
+       return flagName(uint32(i), dflagStrings, false);
 }
 func (i DynFlag) GoString() string {
-       return flagName(uint32(i), dflagStrings, true)
+       return flagName(uint32(i), dflagStrings, true);
 }
 
 // NType values; used in core files.
 type NType int
+
 const (
-       NT_PRSTATUS NType =     1;      /* Process status. */
-       NT_FPREGSET NType =     2;      /* Floating point registers. */
-       NT_PRPSINFO NType =     3;      /* Process state info. */
+       NT_PRSTATUS     NType   = 1;    /* Process status. */
+       NT_FPREGSET     NType   = 2;    /* Floating point registers. */
+       NT_PRPSINFO     NType   = 3;    /* Process state info. */
 )
-var ntypeStrings = []intName {
-       intName{ 1, "NT_PRSTATUS" },
-       intName{ 2, "NT_FPREGSET" },
-       intName{ 3, "NT_PRPSINFO" },
+
+var ntypeStrings = []intName{
+       intName{1, "NT_PRSTATUS"},
+       intName{2, "NT_FPREGSET"},
+       intName{3, "NT_PRPSINFO"},
 }
+
 func (i NType) String() string {
-       return stringName(uint32(i), ntypeStrings, false)
+       return stringName(uint32(i), ntypeStrings, false);
 }
 func (i NType) GoString() string {
-       return stringName(uint32(i), ntypeStrings, true)
+       return stringName(uint32(i), ntypeStrings, true);
 }
 
 /* Symbol Binding - ELFNN_ST_BIND - st_info */
 type SymBind int
+
 const (
-       STB_LOCAL SymBind =     0;      /* Local symbol */
-       STB_GLOBAL SymBind =    1;      /* Global symbol */
-       STB_WEAK SymBind =      2;      /* like global - lower precedence */
-       STB_LOOS SymBind =      10;     /* Reserved range for operating system */
-       STB_HIOS SymBind =      12;     /*   specific semantics. */
-       STB_LOPROC SymBind =    13;     /* reserved range for processor */
-       STB_HIPROC SymBind =    15;     /*   specific semantics. */
+       STB_LOCAL       SymBind = 0;    /* Local symbol */
+       STB_GLOBAL      SymBind = 1;    /* Global symbol */
+       STB_WEAK        SymBind = 2;    /* like global - lower precedence */
+       STB_LOOS        SymBind = 10;   /* Reserved range for operating system */
+       STB_HIOS        SymBind = 12;   /*   specific semantics. */
+       STB_LOPROC      SymBind = 13;   /* reserved range for processor */
+       STB_HIPROC      SymBind = 15;   /*   specific semantics. */
 )
-var stbStrings = []intName {
-       intName{ 0, "STB_LOCAL" },
-       intName{ 1, "STB_GLOBAL" },
-       intName{ 2, "STB_WEAK" },
-       intName{ 10, "STB_LOOS" },
-       intName{ 12, "STB_HIOS" },
-       intName{ 13, "STB_LOPROC" },
-       intName{ 15, "STB_HIPROC" },
+
+var stbStrings = []intName{
+       intName{0, "STB_LOCAL"},
+       intName{1, "STB_GLOBAL"},
+       intName{2, "STB_WEAK"},
+       intName{10, "STB_LOOS"},
+       intName{12, "STB_HIOS"},
+       intName{13, "STB_LOPROC"},
+       intName{15, "STB_HIPROC"},
 }
+
 func (i SymBind) String() string {
-       return stringName(uint32(i), stbStrings, false)
+       return stringName(uint32(i), stbStrings, false);
 }
 func (i SymBind) GoString() string {
-       return stringName(uint32(i), stbStrings, true)
+       return stringName(uint32(i), stbStrings, true);
 }
 
 /* Symbol type - ELFNN_ST_TYPE - st_info */
 type SymType int
+
 const (
-       STT_NOTYPE SymType =    0;      /* Unspecified type. */
-       STT_OBJECT SymType =    1;      /* Data object. */
-       STT_FUNC SymType =      2;      /* Function. */
-       STT_SECTION SymType =   3;      /* Section. */
-       STT_FILE SymType =      4;      /* Source file. */
-       STT_COMMON SymType =    5;      /* Uninitialized common block. */
-       STT_TLS SymType =               6;      /* TLS object. */
-       STT_LOOS SymType =      10;     /* Reserved range for operating system */
-       STT_HIOS SymType =      12;     /*   specific semantics. */
-       STT_LOPROC SymType =    13;     /* reserved range for processor */
-       STT_HIPROC SymType =    15;     /*   specific semantics. */
+       STT_NOTYPE      SymType = 0;    /* Unspecified type. */
+       STT_OBJECT      SymType = 1;    /* Data object. */
+       STT_FUNC        SymType = 2;    /* Function. */
+       STT_SECTION     SymType = 3;    /* Section. */
+       STT_FILE        SymType = 4;    /* Source file. */
+       STT_COMMON      SymType = 5;    /* Uninitialized common block. */
+       STT_TLS         SymType = 6;    /* TLS object. */
+       STT_LOOS        SymType = 10;   /* Reserved range for operating system */
+       STT_HIOS        SymType = 12;   /*   specific semantics. */
+       STT_LOPROC      SymType = 13;   /* reserved range for processor */
+       STT_HIPROC      SymType = 15;   /*   specific semantics. */
 )
-var sttStrings = []intName {
-       intName{ 0, "STT_NOTYPE" },
-       intName{ 1, "STT_OBJECT" },
-       intName{ 2, "STT_FUNC" },
-       intName{ 3, "STT_SECTION" },
-       intName{ 4, "STT_FILE" },
-       intName{ 5, "STT_COMMON" },
-       intName{ 6, "STT_TLS" },
-       intName{ 10, "STT_LOOS" },
-       intName{ 12, "STT_HIOS" },
-       intName{ 13, "STT_LOPROC" },
-       intName{ 15, "STT_HIPROC" },
+
+var sttStrings = []intName{
+       intName{0, "STT_NOTYPE"},
+       intName{1, "STT_OBJECT"},
+       intName{2, "STT_FUNC"},
+       intName{3, "STT_SECTION"},
+       intName{4, "STT_FILE"},
+       intName{5, "STT_COMMON"},
+       intName{6, "STT_TLS"},
+       intName{10, "STT_LOOS"},
+       intName{12, "STT_HIOS"},
+       intName{13, "STT_LOPROC"},
+       intName{15, "STT_HIPROC"},
 }
+
 func (i SymType) String() string {
-       return stringName(uint32(i), sttStrings, false)
+       return stringName(uint32(i), sttStrings, false);
 }
 func (i SymType) GoString() string {
-       return stringName(uint32(i), sttStrings, true)
+       return stringName(uint32(i), sttStrings, true);
 }
 
 /* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */
 type SymVis int
+
 const (
-       STV_DEFAULT SymVis =    0x0;    /* Default visibility (see binding). */
-       STV_INTERNAL SymVis =   0x1;    /* Special meaning in relocatable objects. */
-       STV_HIDDEN SymVis =     0x2;    /* Not visible. */
-       STV_PROTECTED SymVis =  0x3;    /* Visible but not preemptible. */
+       STV_DEFAULT     SymVis  = 0x0;  /* Default visibility (see binding). */
+       STV_INTERNAL    SymVis  = 0x1;  /* Special meaning in relocatable objects. */
+       STV_HIDDEN      SymVis  = 0x2;  /* Not visible. */
+       STV_PROTECTED   SymVis  = 0x3;  /* Visible but not preemptible. */
 )
-var stvStrings = []intName {
-       intName{ 0x0, "STV_DEFAULT" },
-       intName{ 0x1, "STV_INTERNAL" },
-       intName{ 0x2, "STV_HIDDEN" },
-       intName{ 0x3, "STV_PROTECTED" },
+
+var stvStrings = []intName{
+       intName{0x0, "STV_DEFAULT"},
+       intName{0x1, "STV_INTERNAL"},
+       intName{0x2, "STV_HIDDEN"},
+       intName{0x3, "STV_PROTECTED"},
 }
+
 func (i SymVis) String() string {
-       return stringName(uint32(i), stvStrings, false)
+       return stringName(uint32(i), stvStrings, false);
 }
 func (i SymVis) GoString() string {
-       return stringName(uint32(i), stvStrings, true)
+       return stringName(uint32(i), stvStrings, true);
 }
 
 /*
@@ -717,582 +768,598 @@ func (i SymVis) GoString() string {
 
 // Relocation types for x86-64.
 type R_X86_64 int
+
 const (
-       R_X86_64_NONE R_X86_64 =        0;      /* No relocation. */
-       R_X86_64_64 R_X86_64 =  1;      /* Add 64 bit symbol value. */
-       R_X86_64_PC32 R_X86_64 =        2;      /* PC-relative 32 bit signed sym value. */
-       R_X86_64_GOT32 R_X86_64 =       3;      /* PC-relative 32 bit GOT offset. */
-       R_X86_64_PLT32 R_X86_64 =       4;      /* PC-relative 32 bit PLT offset. */
-       R_X86_64_COPY R_X86_64 =        5;      /* Copy data from shared object. */
-       R_X86_64_GLOB_DAT R_X86_64 = 6; /* Set GOT entry to data address. */
-       R_X86_64_JMP_SLOT R_X86_64 = 7; /* Set GOT entry to code address. */
-       R_X86_64_RELATIVE R_X86_64 = 8; /* Add load address of shared object. */
-       R_X86_64_GOTPCREL R_X86_64 = 9; /* Add 32 bit signed pcrel offset to GOT. */
-       R_X86_64_32 R_X86_64 =  10;     /* Add 32 bit zero extended symbol value */
-       R_X86_64_32S R_X86_64 = 11;     /* Add 32 bit sign extended symbol value */
-       R_X86_64_16 R_X86_64 =  12;     /* Add 16 bit zero extended symbol value */
-       R_X86_64_PC16 R_X86_64 =        13;     /* Add 16 bit signed extended pc relative symbol value */
-       R_X86_64_8 R_X86_64 =   14;     /* Add 8 bit zero extended symbol value */
-       R_X86_64_PC8 R_X86_64 = 15;     /* Add 8 bit signed extended pc relative symbol value */
-       R_X86_64_DTPMOD64 R_X86_64 = 16;        /* ID of module containing symbol */
-       R_X86_64_DTPOFF64 R_X86_64 = 17;        /* Offset in TLS block */
-       R_X86_64_TPOFF64 R_X86_64 = 18; /* Offset in static TLS block */
-       R_X86_64_TLSGD R_X86_64 =       19;     /* PC relative offset to GD GOT entry */
-       R_X86_64_TLSLD R_X86_64 =       20;     /* PC relative offset to LD GOT entry */
-       R_X86_64_DTPOFF32 R_X86_64 = 21;        /* Offset in TLS block */
-       R_X86_64_GOTTPOFF R_X86_64 = 22;        /* PC relative offset to IE GOT entry */
-       R_X86_64_TPOFF32 R_X86_64 = 23; /* Offset in static TLS block */
+       R_X86_64_NONE           R_X86_64        = 0;    /* No relocation. */
+       R_X86_64_64             R_X86_64        = 1;    /* Add 64 bit symbol value. */
+       R_X86_64_PC32           R_X86_64        = 2;    /* PC-relative 32 bit signed sym value. */
+       R_X86_64_GOT32          R_X86_64        = 3;    /* PC-relative 32 bit GOT offset. */
+       R_X86_64_PLT32          R_X86_64        = 4;    /* PC-relative 32 bit PLT offset. */
+       R_X86_64_COPY           R_X86_64        = 5;    /* Copy data from shared object. */
+       R_X86_64_GLOB_DAT       R_X86_64        = 6;    /* Set GOT entry to data address. */
+       R_X86_64_JMP_SLOT       R_X86_64        = 7;    /* Set GOT entry to code address. */
+       R_X86_64_RELATIVE       R_X86_64        = 8;    /* Add load address of shared object. */
+       R_X86_64_GOTPCREL       R_X86_64        = 9;    /* Add 32 bit signed pcrel offset to GOT. */
+       R_X86_64_32             R_X86_64        = 10;   /* Add 32 bit zero extended symbol value */
+       R_X86_64_32S            R_X86_64        = 11;   /* Add 32 bit sign extended symbol value */
+       R_X86_64_16             R_X86_64        = 12;   /* Add 16 bit zero extended symbol value */
+       R_X86_64_PC16           R_X86_64        = 13;   /* Add 16 bit signed extended pc relative symbol value */
+       R_X86_64_8              R_X86_64        = 14;   /* Add 8 bit zero extended symbol value */
+       R_X86_64_PC8            R_X86_64        = 15;   /* Add 8 bit signed extended pc relative symbol value */
+       R_X86_64_DTPMOD64       R_X86_64        = 16;   /* ID of module containing symbol */
+       R_X86_64_DTPOFF64       R_X86_64        = 17;   /* Offset in TLS block */
+       R_X86_64_TPOFF64        R_X86_64        = 18;   /* Offset in static TLS block */
+       R_X86_64_TLSGD          R_X86_64        = 19;   /* PC relative offset to GD GOT entry */
+       R_X86_64_TLSLD          R_X86_64        = 20;   /* PC relative offset to LD GOT entry */
+       R_X86_64_DTPOFF32       R_X86_64        = 21;   /* Offset in TLS block */
+       R_X86_64_GOTTPOFF       R_X86_64        = 22;   /* PC relative offset to IE GOT entry */
+       R_X86_64_TPOFF32        R_X86_64        = 23;   /* Offset in static TLS block */
 )
-var rx86_64Strings = []intName {
-       intName{ 0, "R_X86_64_NONE" },
-       intName{ 1, "R_X86_64_64" },
-       intName{ 2, "R_X86_64_PC32" },
-       intName{ 3, "R_X86_64_GOT32" },
-       intName{ 4, "R_X86_64_PLT32" },
-       intName{ 5, "R_X86_64_COPY" },
-       intName{ 6, "R_X86_64_GLOB_DAT" },
-       intName{ 7, "R_X86_64_JMP_SLOT" },
-       intName{ 8, "R_X86_64_RELATIVE" },
-       intName{ 9, "R_X86_64_GOTPCREL" },
-       intName{ 10, "R_X86_64_32" },
-       intName{ 11, "R_X86_64_32S" },
-       intName{ 12, "R_X86_64_16" },
-       intName{ 13, "R_X86_64_PC16" },
-       intName{ 14, "R_X86_64_8" },
-       intName{ 15, "R_X86_64_PC8" },
-       intName{ 16, "R_X86_64_DTPMOD64" },
-       intName{ 17, "R_X86_64_DTPOFF64" },
-       intName{ 18, "R_X86_64_TPOFF64" },
-       intName{ 19, "R_X86_64_TLSGD" },
-       intName{ 20, "R_X86_64_TLSLD" },
-       intName{ 21, "R_X86_64_DTPOFF32" },
-       intName{ 22, "R_X86_64_GOTTPOFF" },
-       intName{ 23, "R_X86_64_TPOFF32" },
+
+var rx86_64Strings = []intName{
+       intName{0, "R_X86_64_NONE"},
+       intName{1, "R_X86_64_64"},
+       intName{2, "R_X86_64_PC32"},
+       intName{3, "R_X86_64_GOT32"},
+       intName{4, "R_X86_64_PLT32"},
+       intName{5, "R_X86_64_COPY"},
+       intName{6, "R_X86_64_GLOB_DAT"},
+       intName{7, "R_X86_64_JMP_SLOT"},
+       intName{8, "R_X86_64_RELATIVE"},
+       intName{9, "R_X86_64_GOTPCREL"},
+       intName{10, "R_X86_64_32"},
+       intName{11, "R_X86_64_32S"},
+       intName{12, "R_X86_64_16"},
+       intName{13, "R_X86_64_PC16"},
+       intName{14, "R_X86_64_8"},
+       intName{15, "R_X86_64_PC8"},
+       intName{16, "R_X86_64_DTPMOD64"},
+       intName{17, "R_X86_64_DTPOFF64"},
+       intName{18, "R_X86_64_TPOFF64"},
+       intName{19, "R_X86_64_TLSGD"},
+       intName{20, "R_X86_64_TLSLD"},
+       intName{21, "R_X86_64_DTPOFF32"},
+       intName{22, "R_X86_64_GOTTPOFF"},
+       intName{23, "R_X86_64_TPOFF32"},
 }
+
 func (i R_X86_64) String() string {
-       return stringName(uint32(i), rx86_64Strings, false)
+       return stringName(uint32(i), rx86_64Strings, false);
 }
 func (i R_X86_64) GoString() string {
-       return stringName(uint32(i), rx86_64Strings, true)
+       return stringName(uint32(i), rx86_64Strings, true);
 }
 
 // Relocation types for Alpha.
 type R_ALPHA int
+
 const (
-       R_ALPHA_NONE R_ALPHA =          0;      /* No reloc */
-       R_ALPHA_REFLONG R_ALPHA =               1;      /* Direct 32 bit */
-       R_ALPHA_REFQUAD R_ALPHA =               2;      /* Direct 64 bit */
-       R_ALPHA_GPREL32 R_ALPHA =               3;      /* GP relative 32 bit */
-       R_ALPHA_LITERAL R_ALPHA =               4;      /* GP relative 16 bit w/optimization */
-       R_ALPHA_LITUSE R_ALPHA =                5;      /* Optimization hint for LITERAL */
-       R_ALPHA_GPDISP R_ALPHA =                6;      /* Add displacement to GP */
-       R_ALPHA_BRADDR R_ALPHA =                7;      /* PC+4 relative 23 bit shifted */
-       R_ALPHA_HINT R_ALPHA =          8;      /* PC+4 relative 16 bit shifted */
-       R_ALPHA_SREL16 R_ALPHA =                9;      /* PC relative 16 bit */
-       R_ALPHA_SREL32 R_ALPHA =                10;     /* PC relative 32 bit */
-       R_ALPHA_SREL64 R_ALPHA =                11;     /* PC relative 64 bit */
-       R_ALPHA_OP_PUSH R_ALPHA =               12;     /* OP stack push */
-       R_ALPHA_OP_STORE R_ALPHA =      13;     /* OP stack pop and store */
-       R_ALPHA_OP_PSUB R_ALPHA =               14;     /* OP stack subtract */
-       R_ALPHA_OP_PRSHIFT R_ALPHA =    15;     /* OP stack right shift */
-       R_ALPHA_GPVALUE R_ALPHA =               16;
-       R_ALPHA_GPRELHIGH R_ALPHA =     17;
-       R_ALPHA_GPRELLOW R_ALPHA =      18;
-       R_ALPHA_IMMED_GP_16 R_ALPHA =   19;
-       R_ALPHA_IMMED_GP_HI32 R_ALPHA = 20;
-       R_ALPHA_IMMED_SCN_HI32 R_ALPHA =        21;
-       R_ALPHA_IMMED_BR_HI32 R_ALPHA = 22;
-       R_ALPHA_IMMED_LO32 R_ALPHA =    23;
-       R_ALPHA_COPY R_ALPHA =          24;     /* Copy symbol at runtime */
-       R_ALPHA_GLOB_DAT R_ALPHA =      25;     /* Create GOT entry */
-       R_ALPHA_JMP_SLOT R_ALPHA =      26;     /* Create PLT entry */
-       R_ALPHA_RELATIVE R_ALPHA =      27;     /* Adjust by program base */
+       R_ALPHA_NONE            R_ALPHA = 0;    /* No reloc */
+       R_ALPHA_REFLONG         R_ALPHA = 1;    /* Direct 32 bit */
+       R_ALPHA_REFQUAD         R_ALPHA = 2;    /* Direct 64 bit */
+       R_ALPHA_GPREL32         R_ALPHA = 3;    /* GP relative 32 bit */
+       R_ALPHA_LITERAL         R_ALPHA = 4;    /* GP relative 16 bit w/optimization */
+       R_ALPHA_LITUSE          R_ALPHA = 5;    /* Optimization hint for LITERAL */
+       R_ALPHA_GPDISP          R_ALPHA = 6;    /* Add displacement to GP */
+       R_ALPHA_BRADDR          R_ALPHA = 7;    /* PC+4 relative 23 bit shifted */
+       R_ALPHA_HINT            R_ALPHA = 8;    /* PC+4 relative 16 bit shifted */
+       R_ALPHA_SREL16          R_ALPHA = 9;    /* PC relative 16 bit */
+       R_ALPHA_SREL32          R_ALPHA = 10;   /* PC relative 32 bit */
+       R_ALPHA_SREL64          R_ALPHA = 11;   /* PC relative 64 bit */
+       R_ALPHA_OP_PUSH         R_ALPHA = 12;   /* OP stack push */
+       R_ALPHA_OP_STORE        R_ALPHA = 13;   /* OP stack pop and store */
+       R_ALPHA_OP_PSUB         R_ALPHA = 14;   /* OP stack subtract */
+       R_ALPHA_OP_PRSHIFT      R_ALPHA = 15;   /* OP stack right shift */
+       R_ALPHA_GPVALUE         R_ALPHA = 16;
+       R_ALPHA_GPRELHIGH       R_ALPHA = 17;
+       R_ALPHA_GPRELLOW        R_ALPHA = 18;
+       R_ALPHA_IMMED_GP_16     R_ALPHA = 19;
+       R_ALPHA_IMMED_GP_HI32   R_ALPHA = 20;
+       R_ALPHA_IMMED_SCN_HI32  R_ALPHA = 21;
+       R_ALPHA_IMMED_BR_HI32   R_ALPHA = 22;
+       R_ALPHA_IMMED_LO32      R_ALPHA = 23;
+       R_ALPHA_COPY            R_ALPHA = 24;   /* Copy symbol at runtime */
+       R_ALPHA_GLOB_DAT        R_ALPHA = 25;   /* Create GOT entry */
+       R_ALPHA_JMP_SLOT        R_ALPHA = 26;   /* Create PLT entry */
+       R_ALPHA_RELATIVE        R_ALPHA = 27;   /* Adjust by program base */
 )
-var ralphaStrings = []intName {
-       intName{ 0, "R_ALPHA_NONE" },
-       intName{ 1, "R_ALPHA_REFLONG" },
-       intName{ 2, "R_ALPHA_REFQUAD" },
-       intName{ 3, "R_ALPHA_GPREL32" },
-       intName{ 4, "R_ALPHA_LITERAL" },
-       intName{ 5, "R_ALPHA_LITUSE" },
-       intName{ 6, "R_ALPHA_GPDISP" },
-       intName{ 7, "R_ALPHA_BRADDR" },
-       intName{ 8, "R_ALPHA_HINT" },
-       intName{ 9, "R_ALPHA_SREL16" },
-       intName{ 10, "R_ALPHA_SREL32" },
-       intName{ 11, "R_ALPHA_SREL64" },
-       intName{ 12, "R_ALPHA_OP_PUSH" },
-       intName{ 13, "R_ALPHA_OP_STORE" },
-       intName{ 14, "R_ALPHA_OP_PSUB" },
-       intName{ 15, "R_ALPHA_OP_PRSHIFT" },
-       intName{ 16, "R_ALPHA_GPVALUE" },
-       intName{ 17, "R_ALPHA_GPRELHIGH" },
-       intName{ 18, "R_ALPHA_GPRELLOW" },
-       intName{ 19, "R_ALPHA_IMMED_GP_16" },
-       intName{ 20, "R_ALPHA_IMMED_GP_HI32" },
-       intName{ 21, "R_ALPHA_IMMED_SCN_HI32" },
-       intName{ 22, "R_ALPHA_IMMED_BR_HI32" },
-       intName{ 23, "R_ALPHA_IMMED_LO32" },
-       intName{ 24, "R_ALPHA_COPY" },
-       intName{ 25, "R_ALPHA_GLOB_DAT" },
-       intName{ 26, "R_ALPHA_JMP_SLOT" },
-       intName{ 27, "R_ALPHA_RELATIVE" },
+
+var ralphaStrings = []intName{
+       intName{0, "R_ALPHA_NONE"},
+       intName{1, "R_ALPHA_REFLONG"},
+       intName{2, "R_ALPHA_REFQUAD"},
+       intName{3, "R_ALPHA_GPREL32"},
+       intName{4, "R_ALPHA_LITERAL"},
+       intName{5, "R_ALPHA_LITUSE"},
+       intName{6, "R_ALPHA_GPDISP"},
+       intName{7, "R_ALPHA_BRADDR"},
+       intName{8, "R_ALPHA_HINT"},
+       intName{9, "R_ALPHA_SREL16"},
+       intName{10, "R_ALPHA_SREL32"},
+       intName{11, "R_ALPHA_SREL64"},
+       intName{12, "R_ALPHA_OP_PUSH"},
+       intName{13, "R_ALPHA_OP_STORE"},
+       intName{14, "R_ALPHA_OP_PSUB"},
+       intName{15, "R_ALPHA_OP_PRSHIFT"},
+       intName{16, "R_ALPHA_GPVALUE"},
+       intName{17, "R_ALPHA_GPRELHIGH"},
+       intName{18, "R_ALPHA_GPRELLOW"},
+       intName{19, "R_ALPHA_IMMED_GP_16"},
+       intName{20, "R_ALPHA_IMMED_GP_HI32"},
+       intName{21, "R_ALPHA_IMMED_SCN_HI32"},
+       intName{22, "R_ALPHA_IMMED_BR_HI32"},
+       intName{23, "R_ALPHA_IMMED_LO32"},
+       intName{24, "R_ALPHA_COPY"},
+       intName{25, "R_ALPHA_GLOB_DAT"},
+       intName{26, "R_ALPHA_JMP_SLOT"},
+       intName{27, "R_ALPHA_RELATIVE"},
 }
+
 func (i R_ALPHA) String() string {
-       return stringName(uint32(i), ralphaStrings, false)
+       return stringName(uint32(i), ralphaStrings, false);
 }
 func (i R_ALPHA) GoString() string {
-       return stringName(uint32(i), ralphaStrings, true)
+       return stringName(uint32(i), ralphaStrings, true);
 }
 
 // Relocation types for ARM.
 type R_ARM int
+
 const (
-       R_ARM_NONE R_ARM =              0;      /* No relocation. */
-       R_ARM_PC24 R_ARM =              1;
-       R_ARM_ABS32 R_ARM =             2;
-       R_ARM_REL32 R_ARM =             3;
-       R_ARM_PC13 R_ARM =              4;
-       R_ARM_ABS16 R_ARM =             5;
-       R_ARM_ABS12 R_ARM =             6;
-       R_ARM_THM_ABS5 R_ARM =          7;
-       R_ARM_ABS8 R_ARM =              8;
-       R_ARM_SBREL32 R_ARM =           9;
-       R_ARM_THM_PC22 R_ARM =          10;
-       R_ARM_THM_PC8 R_ARM =           11;
-       R_ARM_AMP_VCALL9 R_ARM =        12;
-       R_ARM_SWI24 R_ARM =             13;
-       R_ARM_THM_SWI8 R_ARM =          14;
-       R_ARM_XPC25 R_ARM =             15;
-       R_ARM_THM_XPC22 R_ARM =         16;
-       R_ARM_COPY R_ARM =              20;     /* Copy data from shared object. */
-       R_ARM_GLOB_DAT R_ARM =          21;     /* Set GOT entry to data address. */
-       R_ARM_JUMP_SLOT R_ARM =         22;     /* Set GOT entry to code address. */
-       R_ARM_RELATIVE R_ARM =          23;     /* Add load address of shared object. */
-       R_ARM_GOTOFF R_ARM =            24;     /* Add GOT-relative symbol address. */
-       R_ARM_GOTPC R_ARM =             25;     /* Add PC-relative GOT table address. */
-       R_ARM_GOT32 R_ARM =             26;     /* Add PC-relative GOT offset. */
-       R_ARM_PLT32 R_ARM =             27;     /* Add PC-relative PLT offset. */
-       R_ARM_GNU_VTENTRY R_ARM =       100;
-       R_ARM_GNU_VTINHERIT R_ARM =     101;
-       R_ARM_RSBREL32 R_ARM =          250;
-       R_ARM_THM_RPC22 R_ARM =         251;
-       R_ARM_RREL32 R_ARM =            252;
-       R_ARM_RABS32 R_ARM =            253;
-       R_ARM_RPC24 R_ARM =             254;
-       R_ARM_RBASE R_ARM =             255;
+       R_ARM_NONE              R_ARM   = 0;    /* No relocation. */
+       R_ARM_PC24              R_ARM   = 1;
+       R_ARM_ABS32             R_ARM   = 2;
+       R_ARM_REL32             R_ARM   = 3;
+       R_ARM_PC13              R_ARM   = 4;
+       R_ARM_ABS16             R_ARM   = 5;
+       R_ARM_ABS12             R_ARM   = 6;
+       R_ARM_THM_ABS5          R_ARM   = 7;
+       R_ARM_ABS8              R_ARM   = 8;
+       R_ARM_SBREL32           R_ARM   = 9;
+       R_ARM_THM_PC22          R_ARM   = 10;
+       R_ARM_THM_PC8           R_ARM   = 11;
+       R_ARM_AMP_VCALL9        R_ARM   = 12;
+       R_ARM_SWI24             R_ARM   = 13;
+       R_ARM_THM_SWI8          R_ARM   = 14;
+       R_ARM_XPC25             R_ARM   = 15;
+       R_ARM_THM_XPC22         R_ARM   = 16;
+       R_ARM_COPY              R_ARM   = 20;   /* Copy data from shared object. */
+       R_ARM_GLOB_DAT          R_ARM   = 21;   /* Set GOT entry to data address. */
+       R_ARM_JUMP_SLOT         R_ARM   = 22;   /* Set GOT entry to code address. */
+       R_ARM_RELATIVE          R_ARM   = 23;   /* Add load address of shared object. */
+       R_ARM_GOTOFF            R_ARM   = 24;   /* Add GOT-relative symbol address. */
+       R_ARM_GOTPC             R_ARM   = 25;   /* Add PC-relative GOT table address. */
+       R_ARM_GOT32             R_ARM   = 26;   /* Add PC-relative GOT offset. */
+       R_ARM_PLT32             R_ARM   = 27;   /* Add PC-relative PLT offset. */
+       R_ARM_GNU_VTENTRY       R_ARM   = 100;
+       R_ARM_GNU_VTINHERIT     R_ARM   = 101;
+       R_ARM_RSBREL32          R_ARM   = 250;
+       R_ARM_THM_RPC22         R_ARM   = 251;
+       R_ARM_RREL32            R_ARM   = 252;
+       R_ARM_RABS32            R_ARM   = 253;
+       R_ARM_RPC24             R_ARM   = 254;
+       R_ARM_RBASE             R_ARM   = 255;
 )
-var rarmStrings = []intName {
-       intName{ 0, "R_ARM_NONE" },
-       intName{ 1, "R_ARM_PC24" },
-       intName{ 2, "R_ARM_ABS32" },
-       intName{ 3, "R_ARM_REL32" },
-       intName{ 4, "R_ARM_PC13" },
-       intName{ 5, "R_ARM_ABS16" },
-       intName{ 6, "R_ARM_ABS12" },
-       intName{ 7, "R_ARM_THM_ABS5" },
-       intName{ 8, "R_ARM_ABS8" },
-       intName{ 9, "R_ARM_SBREL32" },
-       intName{ 10, "R_ARM_THM_PC22" },
-       intName{ 11, "R_ARM_THM_PC8" },
-       intName{ 12, "R_ARM_AMP_VCALL9" },
-       intName{ 13, "R_ARM_SWI24" },
-       intName{ 14, "R_ARM_THM_SWI8" },
-       intName{ 15, "R_ARM_XPC25" },
-       intName{ 16, "R_ARM_THM_XPC22" },
-       intName{ 20, "R_ARM_COPY" },
-       intName{ 21, "R_ARM_GLOB_DAT" },
-       intName{ 22, "R_ARM_JUMP_SLOT" },
-       intName{ 23, "R_ARM_RELATIVE" },
-       intName{ 24, "R_ARM_GOTOFF" },
-       intName{ 25, "R_ARM_GOTPC" },
-       intName{ 26, "R_ARM_GOT32" },
-       intName{ 27, "R_ARM_PLT32" },
-       intName{ 100, "R_ARM_GNU_VTENTRY" },
-       intName{ 101, "R_ARM_GNU_VTINHERIT" },
-       intName{ 250, "R_ARM_RSBREL32" },
-       intName{ 251, "R_ARM_THM_RPC22" },
-       intName{ 252, "R_ARM_RREL32" },
-       intName{ 253, "R_ARM_RABS32" },
-       intName{ 254, "R_ARM_RPC24" },
-       intName{ 255, "R_ARM_RBASE" },
+
+var rarmStrings = []intName{
+       intName{0, "R_ARM_NONE"},
+       intName{1, "R_ARM_PC24"},
+       intName{2, "R_ARM_ABS32"},
+       intName{3, "R_ARM_REL32"},
+       intName{4, "R_ARM_PC13"},
+       intName{5, "R_ARM_ABS16"},
+       intName{6, "R_ARM_ABS12"},
+       intName{7, "R_ARM_THM_ABS5"},
+       intName{8, "R_ARM_ABS8"},
+       intName{9, "R_ARM_SBREL32"},
+       intName{10, "R_ARM_THM_PC22"},
+       intName{11, "R_ARM_THM_PC8"},
+       intName{12, "R_ARM_AMP_VCALL9"},
+       intName{13, "R_ARM_SWI24"},
+       intName{14, "R_ARM_THM_SWI8"},
+       intName{15, "R_ARM_XPC25"},
+       intName{16, "R_ARM_THM_XPC22"},
+       intName{20, "R_ARM_COPY"},
+       intName{21, "R_ARM_GLOB_DAT"},
+       intName{22, "R_ARM_JUMP_SLOT"},
+       intName{23, "R_ARM_RELATIVE"},
+       intName{24, "R_ARM_GOTOFF"},
+       intName{25, "R_ARM_GOTPC"},
+       intName{26, "R_ARM_GOT32"},
+       intName{27, "R_ARM_PLT32"},
+       intName{100, "R_ARM_GNU_VTENTRY"},
+       intName{101, "R_ARM_GNU_VTINHERIT"},
+       intName{250, "R_ARM_RSBREL32"},
+       intName{251, "R_ARM_THM_RPC22"},
+       intName{252, "R_ARM_RREL32"},
+       intName{253, "R_ARM_RABS32"},
+       intName{254, "R_ARM_RPC24"},
+       intName{255, "R_ARM_RBASE"},
 }
+
 func (i R_ARM) String() string {
-       return stringName(uint32(i), rarmStrings, false)
+       return stringName(uint32(i), rarmStrings, false);
 }
 func (i R_ARM) GoString() string {
-       return stringName(uint32(i), rarmStrings, true)
+       return stringName(uint32(i), rarmStrings, true);
 }
 
 // Relocation types for 386.
 type R_386 int
+
 const (
-       R_386_NONE R_386 =      0;      /* No relocation. */
-       R_386_32 R_386 =        1;      /* Add symbol value. */
-       R_386_PC32 R_386 =      2;      /* Add PC-relative symbol value. */
-       R_386_GOT32 R_386 =     3;      /* Add PC-relative GOT offset. */
-       R_386_PLT32 R_386 =     4;      /* Add PC-relative PLT offset. */
-       R_386_COPY R_386 =      5;      /* Copy data from shared object. */
-       R_386_GLOB_DAT R_386 =  6;      /* Set GOT entry to data address. */
-       R_386_JMP_SLOT R_386 =  7;      /* Set GOT entry to code address. */
-       R_386_RELATIVE R_386 =  8;      /* Add load address of shared object. */
-       R_386_GOTOFF R_386 =    9;      /* Add GOT-relative symbol address. */
-       R_386_GOTPC R_386 =     10;     /* Add PC-relative GOT table address. */
-       R_386_TLS_TPOFF R_386 = 14;     /* Negative offset in static TLS block */
-       R_386_TLS_IE R_386 =    15;     /* Absolute address of GOT for -ve static TLS */
-       R_386_TLS_GOTIE R_386 = 16;     /* GOT entry for negative static TLS block */
-       R_386_TLS_LE R_386 =    17;     /* Negative offset relative to static TLS */
-       R_386_TLS_GD R_386 =    18;     /* 32 bit offset to GOT (index,off) pair */
-       R_386_TLS_LDM R_386 =   19;     /* 32 bit offset to GOT (index,zero) pair */
-       R_386_TLS_GD_32 R_386 = 24;     /* 32 bit offset to GOT (index,off) pair */
-       R_386_TLS_GD_PUSH R_386 = 25;   /* pushl instruction for Sun ABI GD sequence */
-       R_386_TLS_GD_CALL R_386 = 26;   /* call instruction for Sun ABI GD sequence */
-       R_386_TLS_GD_POP R_386 = 27;    /* popl instruction for Sun ABI GD sequence */
-       R_386_TLS_LDM_32 R_386 = 28;    /* 32 bit offset to GOT (index,zero) pair */
-       R_386_TLS_LDM_PUSH R_386 = 29;  /* pushl instruction for Sun ABI LD sequence */
-       R_386_TLS_LDM_CALL R_386 = 30;  /* call instruction for Sun ABI LD sequence */
-       R_386_TLS_LDM_POP R_386 = 31;   /* popl instruction for Sun ABI LD sequence */
-       R_386_TLS_LDO_32 R_386 = 32;    /* 32 bit offset from start of TLS block */
-       R_386_TLS_IE_32 R_386 = 33;     /* 32 bit offset to GOT static TLS offset entry */
-       R_386_TLS_LE_32 R_386 = 34;     /* 32 bit offset within static TLS block */
-       R_386_TLS_DTPMOD32 R_386 = 35;  /* GOT entry containing TLS index */
-       R_386_TLS_DTPOFF32 R_386 = 36;  /* GOT entry containing TLS offset */
-       R_386_TLS_TPOFF32 R_386 = 37;   /* GOT entry of -ve static TLS offset */
+       R_386_NONE              R_386   = 0;    /* No relocation. */
+       R_386_32                R_386   = 1;    /* Add symbol value. */
+       R_386_PC32              R_386   = 2;    /* Add PC-relative symbol value. */
+       R_386_GOT32             R_386   = 3;    /* Add PC-relative GOT offset. */
+       R_386_PLT32             R_386   = 4;    /* Add PC-relative PLT offset. */
+       R_386_COPY              R_386   = 5;    /* Copy data from shared object. */
+       R_386_GLOB_DAT          R_386   = 6;    /* Set GOT entry to data address. */
+       R_386_JMP_SLOT          R_386   = 7;    /* Set GOT entry to code address. */
+       R_386_RELATIVE          R_386   = 8;    /* Add load address of shared object. */
+       R_386_GOTOFF            R_386   = 9;    /* Add GOT-relative symbol address. */
+       R_386_GOTPC             R_386   = 10;   /* Add PC-relative GOT table address. */
+       R_386_TLS_TPOFF         R_386   = 14;   /* Negative offset in static TLS block */
+       R_386_TLS_IE            R_386   = 15;   /* Absolute address of GOT for -ve static TLS */
+       R_386_TLS_GOTIE         R_386   = 16;   /* GOT entry for negative static TLS block */
+       R_386_TLS_LE            R_386   = 17;   /* Negative offset relative to static TLS */
+       R_386_TLS_GD            R_386   = 18;   /* 32 bit offset to GOT (index,off) pair */
+       R_386_TLS_LDM           R_386   = 19;   /* 32 bit offset to GOT (index,zero) pair */
+       R_386_TLS_GD_32         R_386   = 24;   /* 32 bit offset to GOT (index,off) pair */
+       R_386_TLS_GD_PUSH       R_386   = 25;   /* pushl instruction for Sun ABI GD sequence */
+       R_386_TLS_GD_CALL       R_386   = 26;   /* call instruction for Sun ABI GD sequence */
+       R_386_TLS_GD_POP        R_386   = 27;   /* popl instruction for Sun ABI GD sequence */
+       R_386_TLS_LDM_32        R_386   = 28;   /* 32 bit offset to GOT (index,zero) pair */
+       R_386_TLS_LDM_PUSH      R_386   = 29;   /* pushl instruction for Sun ABI LD sequence */
+       R_386_TLS_LDM_CALL      R_386   = 30;   /* call instruction for Sun ABI LD sequence */
+       R_386_TLS_LDM_POP       R_386   = 31;   /* popl instruction for Sun ABI LD sequence */
+       R_386_TLS_LDO_32        R_386   = 32;   /* 32 bit offset from start of TLS block */
+       R_386_TLS_IE_32         R_386   = 33;   /* 32 bit offset to GOT static TLS offset entry */
+       R_386_TLS_LE_32         R_386   = 34;   /* 32 bit offset within static TLS block */
+       R_386_TLS_DTPMOD32      R_386   = 35;   /* GOT entry containing TLS index */
+       R_386_TLS_DTPOFF32      R_386   = 36;   /* GOT entry containing TLS offset */
+       R_386_TLS_TPOFF32       R_386   = 37;   /* GOT entry of -ve static TLS offset */
 )
-var r386Strings = []intName {
-       intName{ 0, "R_386_NONE" },
-       intName{ 1, "R_386_32" },
-       intName{ 2, "R_386_PC32" },
-       intName{ 3, "R_386_GOT32" },
-       intName{ 4, "R_386_PLT32" },
-       intName{ 5, "R_386_COPY" },
-       intName{ 6, "R_386_GLOB_DAT" },
-       intName{ 7, "R_386_JMP_SLOT" },
-       intName{ 8, "R_386_RELATIVE" },
-       intName{ 9, "R_386_GOTOFF" },
-       intName{ 10, "R_386_GOTPC" },
-       intName{ 14, "R_386_TLS_TPOFF" },
-       intName{ 15, "R_386_TLS_IE" },
-       intName{ 16, "R_386_TLS_GOTIE" },
-       intName{ 17, "R_386_TLS_LE" },
-       intName{ 18, "R_386_TLS_GD" },
-       intName{ 19, "R_386_TLS_LDM" },
-       intName{ 24, "R_386_TLS_GD_32" },
-       intName{ 25, "R_386_TLS_GD_PUSH" },
-       intName{ 26, "R_386_TLS_GD_CALL" },
-       intName{ 27, "R_386_TLS_GD_POP" },
-       intName{ 28, "R_386_TLS_LDM_32" },
-       intName{ 29, "R_386_TLS_LDM_PUSH" },
-       intName{ 30, "R_386_TLS_LDM_CALL" },
-       intName{ 31, "R_386_TLS_LDM_POP" },
-       intName{ 32, "R_386_TLS_LDO_32" },
-       intName{ 33, "R_386_TLS_IE_32" },
-       intName{ 34, "R_386_TLS_LE_32" },
-       intName{ 35, "R_386_TLS_DTPMOD32" },
-       intName{ 36, "R_386_TLS_DTPOFF32" },
-       intName{ 37, "R_386_TLS_TPOFF32" },
+
+var r386Strings = []intName{
+       intName{0, "R_386_NONE"},
+       intName{1, "R_386_32"},
+       intName{2, "R_386_PC32"},
+       intName{3, "R_386_GOT32"},
+       intName{4, "R_386_PLT32"},
+       intName{5, "R_386_COPY"},
+       intName{6, "R_386_GLOB_DAT"},
+       intName{7, "R_386_JMP_SLOT"},
+       intName{8, "R_386_RELATIVE"},
+       intName{9, "R_386_GOTOFF"},
+       intName{10, "R_386_GOTPC"},
+       intName{14, "R_386_TLS_TPOFF"},
+       intName{15, "R_386_TLS_IE"},
+       intName{16, "R_386_TLS_GOTIE"},
+       intName{17, "R_386_TLS_LE"},
+       intName{18, "R_386_TLS_GD"},
+       intName{19, "R_386_TLS_LDM"},
+       intName{24, "R_386_TLS_GD_32"},
+       intName{25, "R_386_TLS_GD_PUSH"},
+       intName{26, "R_386_TLS_GD_CALL"},
+       intName{27, "R_386_TLS_GD_POP"},
+       intName{28, "R_386_TLS_LDM_32"},
+       intName{29, "R_386_TLS_LDM_PUSH"},
+       intName{30, "R_386_TLS_LDM_CALL"},
+       intName{31, "R_386_TLS_LDM_POP"},
+       intName{32, "R_386_TLS_LDO_32"},
+       intName{33, "R_386_TLS_IE_32"},
+       intName{34, "R_386_TLS_LE_32"},
+       intName{35, "R_386_TLS_DTPMOD32"},
+       intName{36, "R_386_TLS_DTPOFF32"},
+       intName{37, "R_386_TLS_TPOFF32"},
 }
+
 func (i R_386) String() string {
-       return stringName(uint32(i), r386Strings, false)
+       return stringName(uint32(i), r386Strings, false);
 }
 func (i R_386) GoString() string {
-       return stringName(uint32(i), r386Strings, true)
+       return stringName(uint32(i), r386Strings, true);
 }
 
 // Relocation types for PowerPC.
 type R_PPC int
+
 const (
-       R_PPC_NONE R_PPC =              0;      /* No relocation. */
-       R_PPC_ADDR32 R_PPC =            1;
-       R_PPC_ADDR24 R_PPC =            2;
-       R_PPC_ADDR16 R_PPC =            3;
-       R_PPC_ADDR16_LO R_PPC =         4;
-       R_PPC_ADDR16_HI R_PPC =         5;
-       R_PPC_ADDR16_HA R_PPC =         6;
-       R_PPC_ADDR14 R_PPC =            7;
-       R_PPC_ADDR14_BRTAKEN R_PPC =    8;
-       R_PPC_ADDR14_BRNTAKEN R_PPC =   9;
-       R_PPC_REL24 R_PPC =             10;
-       R_PPC_REL14 R_PPC =             11;
-       R_PPC_REL14_BRTAKEN R_PPC =     12;
-       R_PPC_REL14_BRNTAKEN R_PPC =    13;
-       R_PPC_GOT16 R_PPC =             14;
-       R_PPC_GOT16_LO R_PPC =          15;
-       R_PPC_GOT16_HI R_PPC =          16;
-       R_PPC_GOT16_HA R_PPC =          17;
-       R_PPC_PLTREL24 R_PPC =          18;
-       R_PPC_COPY R_PPC =              19;
-       R_PPC_GLOB_DAT R_PPC =          20;
-       R_PPC_JMP_SLOT R_PPC =          21;
-       R_PPC_RELATIVE R_PPC =          22;
-       R_PPC_LOCAL24PC R_PPC =         23;
-       R_PPC_UADDR32 R_PPC =           24;
-       R_PPC_UADDR16 R_PPC =           25;
-       R_PPC_REL32 R_PPC =             26;
-       R_PPC_PLT32 R_PPC =             27;
-       R_PPC_PLTREL32 R_PPC =          28;
-       R_PPC_PLT16_LO R_PPC =          29;
-       R_PPC_PLT16_HI R_PPC =          30;
-       R_PPC_PLT16_HA R_PPC =          31;
-       R_PPC_SDAREL16 R_PPC =          32;
-       R_PPC_SECTOFF R_PPC =           33;
-       R_PPC_SECTOFF_LO R_PPC =        34;
-       R_PPC_SECTOFF_HI R_PPC =        35;
-       R_PPC_SECTOFF_HA R_PPC =        36;
-
-       R_PPC_TLS R_PPC =               67;
-       R_PPC_DTPMOD32 R_PPC =          68;
-       R_PPC_TPREL16 R_PPC =           69;
-       R_PPC_TPREL16_LO R_PPC =        70;
-       R_PPC_TPREL16_HI R_PPC =        71;
-       R_PPC_TPREL16_HA R_PPC =        72;
-       R_PPC_TPREL32 R_PPC =           73;
-       R_PPC_DTPREL16 R_PPC =          74;
-       R_PPC_DTPREL16_LO R_PPC =       75;
-       R_PPC_DTPREL16_HI R_PPC =       76;
-       R_PPC_DTPREL16_HA R_PPC =       77;
-       R_PPC_DTPREL32 R_PPC =          78;
-       R_PPC_GOT_TLSGD16 R_PPC =       79;
-       R_PPC_GOT_TLSGD16_LO R_PPC =    80;
-       R_PPC_GOT_TLSGD16_HI R_PPC =    81;
-       R_PPC_GOT_TLSGD16_HA R_PPC =    82;
-       R_PPC_GOT_TLSLD16 R_PPC =       83;
-       R_PPC_GOT_TLSLD16_LO R_PPC =    84;
-       R_PPC_GOT_TLSLD16_HI R_PPC =    85;
-       R_PPC_GOT_TLSLD16_HA R_PPC =    86;
-       R_PPC_GOT_TPREL16 R_PPC =       87;
-       R_PPC_GOT_TPREL16_LO R_PPC =    88;
-       R_PPC_GOT_TPREL16_HI R_PPC =    89;
-       R_PPC_GOT_TPREL16_HA R_PPC =    90;
-
-       R_PPC_EMB_NADDR32 R_PPC =       101;
-       R_PPC_EMB_NADDR16 R_PPC =       102;
-       R_PPC_EMB_NADDR16_LO R_PPC =    103;
-       R_PPC_EMB_NADDR16_HI R_PPC =    104;
-       R_PPC_EMB_NADDR16_HA R_PPC =    105;
-       R_PPC_EMB_SDAI16 R_PPC =        106;
-       R_PPC_EMB_SDA2I16 R_PPC =       107;
-       R_PPC_EMB_SDA2REL R_PPC =       108;
-       R_PPC_EMB_SDA21 R_PPC =         109;
-       R_PPC_EMB_MRKREF R_PPC =        110;
-       R_PPC_EMB_RELSEC16 R_PPC =      111;
-       R_PPC_EMB_RELST_LO R_PPC =      112;
-       R_PPC_EMB_RELST_HI R_PPC =      113;
-       R_PPC_EMB_RELST_HA R_PPC =      114;
-       R_PPC_EMB_BIT_FLD R_PPC =       115;
-       R_PPC_EMB_RELSDA R_PPC =        116;
+       R_PPC_NONE              R_PPC   = 0;    /* No relocation. */
+       R_PPC_ADDR32            R_PPC   = 1;
+       R_PPC_ADDR24            R_PPC   = 2;
+       R_PPC_ADDR16            R_PPC   = 3;
+       R_PPC_ADDR16_LO         R_PPC   = 4;
+       R_PPC_ADDR16_HI         R_PPC   = 5;
+       R_PPC_ADDR16_HA         R_PPC   = 6;
+       R_PPC_ADDR14            R_PPC   = 7;
+       R_PPC_ADDR14_BRTAKEN    R_PPC   = 8;
+       R_PPC_ADDR14_BRNTAKEN   R_PPC   = 9;
+       R_PPC_REL24             R_PPC   = 10;
+       R_PPC_REL14             R_PPC   = 11;
+       R_PPC_REL14_BRTAKEN     R_PPC   = 12;
+       R_PPC_REL14_BRNTAKEN    R_PPC   = 13;
+       R_PPC_GOT16             R_PPC   = 14;
+       R_PPC_GOT16_LO          R_PPC   = 15;
+       R_PPC_GOT16_HI          R_PPC   = 16;
+       R_PPC_GOT16_HA          R_PPC   = 17;
+       R_PPC_PLTREL24          R_PPC   = 18;
+       R_PPC_COPY              R_PPC   = 19;
+       R_PPC_GLOB_DAT          R_PPC   = 20;
+       R_PPC_JMP_SLOT          R_PPC   = 21;
+       R_PPC_RELATIVE          R_PPC   = 22;
+       R_PPC_LOCAL24PC         R_PPC   = 23;
+       R_PPC_UADDR32           R_PPC   = 24;
+       R_PPC_UADDR16           R_PPC   = 25;
+       R_PPC_REL32             R_PPC   = 26;
+       R_PPC_PLT32             R_PPC   = 27;
+       R_PPC_PLTREL32          R_PPC   = 28;
+       R_PPC_PLT16_LO          R_PPC   = 29;
+       R_PPC_PLT16_HI          R_PPC   = 30;
+       R_PPC_PLT16_HA          R_PPC   = 31;
+       R_PPC_SDAREL16          R_PPC   = 32;
+       R_PPC_SECTOFF           R_PPC   = 33;
+       R_PPC_SECTOFF_LO        R_PPC   = 34;
+       R_PPC_SECTOFF_HI        R_PPC   = 35;
+       R_PPC_SECTOFF_HA        R_PPC   = 36;
+       R_PPC_TLS               R_PPC   = 67;
+       R_PPC_DTPMOD32          R_PPC   = 68;
+       R_PPC_TPREL16           R_PPC   = 69;
+       R_PPC_TPREL16_LO        R_PPC   = 70;
+       R_PPC_TPREL16_HI        R_PPC   = 71;
+       R_PPC_TPREL16_HA        R_PPC   = 72;
+       R_PPC_TPREL32           R_PPC   = 73;
+       R_PPC_DTPREL16          R_PPC   = 74;
+       R_PPC_DTPREL16_LO       R_PPC   = 75;
+       R_PPC_DTPREL16_HI       R_PPC   = 76;
+       R_PPC_DTPREL16_HA       R_PPC   = 77;
+       R_PPC_DTPREL32          R_PPC   = 78;
+       R_PPC_GOT_TLSGD16       R_PPC   = 79;
+       R_PPC_GOT_TLSGD16_LO    R_PPC   = 80;
+       R_PPC_GOT_TLSGD16_HI    R_PPC   = 81;
+       R_PPC_GOT_TLSGD16_HA    R_PPC   = 82;
+       R_PPC_GOT_TLSLD16       R_PPC   = 83;
+       R_PPC_GOT_TLSLD16_LO    R_PPC   = 84;
+       R_PPC_GOT_TLSLD16_HI    R_PPC   = 85;
+       R_PPC_GOT_TLSLD16_HA    R_PPC   = 86;
+       R_PPC_GOT_TPREL16       R_PPC   = 87;
+       R_PPC_GOT_TPREL16_LO    R_PPC   = 88;
+       R_PPC_GOT_TPREL16_HI    R_PPC   = 89;
+       R_PPC_GOT_TPREL16_HA    R_PPC   = 90;
+       R_PPC_EMB_NADDR32       R_PPC   = 101;
+       R_PPC_EMB_NADDR16       R_PPC   = 102;
+       R_PPC_EMB_NADDR16_LO    R_PPC   = 103;
+       R_PPC_EMB_NADDR16_HI    R_PPC   = 104;
+       R_PPC_EMB_NADDR16_HA    R_PPC   = 105;
+       R_PPC_EMB_SDAI16        R_PPC   = 106;
+       R_PPC_EMB_SDA2I16       R_PPC   = 107;
+       R_PPC_EMB_SDA2REL       R_PPC   = 108;
+       R_PPC_EMB_SDA21         R_PPC   = 109;
+       R_PPC_EMB_MRKREF        R_PPC   = 110;
+       R_PPC_EMB_RELSEC16      R_PPC   = 111;
+       R_PPC_EMB_RELST_LO      R_PPC   = 112;
+       R_PPC_EMB_RELST_HI      R_PPC   = 113;
+       R_PPC_EMB_RELST_HA      R_PPC   = 114;
+       R_PPC_EMB_BIT_FLD       R_PPC   = 115;
+       R_PPC_EMB_RELSDA        R_PPC   = 116;
 )
-var rppcStrings = []intName {
-       intName{ 0, "R_PPC_NONE" },
-       intName{ 1, "R_PPC_ADDR32" },
-       intName{ 2, "R_PPC_ADDR24" },
-       intName{ 3, "R_PPC_ADDR16" },
-       intName{ 4, "R_PPC_ADDR16_LO" },
-       intName{ 5, "R_PPC_ADDR16_HI" },
-       intName{ 6, "R_PPC_ADDR16_HA" },
-       intName{ 7, "R_PPC_ADDR14" },
-       intName{ 8, "R_PPC_ADDR14_BRTAKEN" },
-       intName{ 9, "R_PPC_ADDR14_BRNTAKEN" },
-       intName{ 10, "R_PPC_REL24" },
-       intName{ 11, "R_PPC_REL14" },
-       intName{ 12, "R_PPC_REL14_BRTAKEN" },
-       intName{ 13, "R_PPC_REL14_BRNTAKEN" },
-       intName{ 14, "R_PPC_GOT16" },
-       intName{ 15, "R_PPC_GOT16_LO" },
-       intName{ 16, "R_PPC_GOT16_HI" },
-       intName{ 17, "R_PPC_GOT16_HA" },
-       intName{ 18, "R_PPC_PLTREL24" },
-       intName{ 19, "R_PPC_COPY" },
-       intName{ 20, "R_PPC_GLOB_DAT" },
-       intName{ 21, "R_PPC_JMP_SLOT" },
-       intName{ 22, "R_PPC_RELATIVE" },
-       intName{ 23, "R_PPC_LOCAL24PC" },
-       intName{ 24, "R_PPC_UADDR32" },
-       intName{ 25, "R_PPC_UADDR16" },
-       intName{ 26, "R_PPC_REL32" },
-       intName{ 27, "R_PPC_PLT32" },
-       intName{ 28, "R_PPC_PLTREL32" },
-       intName{ 29, "R_PPC_PLT16_LO" },
-       intName{ 30, "R_PPC_PLT16_HI" },
-       intName{ 31, "R_PPC_PLT16_HA" },
-       intName{ 32, "R_PPC_SDAREL16" },
-       intName{ 33, "R_PPC_SECTOFF" },
-       intName{ 34, "R_PPC_SECTOFF_LO" },
-       intName{ 35, "R_PPC_SECTOFF_HI" },
-       intName{ 36, "R_PPC_SECTOFF_HA" },
-
-       intName{ 67, "R_PPC_TLS" },
-       intName{ 68, "R_PPC_DTPMOD32" },
-       intName{ 69, "R_PPC_TPREL16" },
-       intName{ 70, "R_PPC_TPREL16_LO" },
-       intName{ 71, "R_PPC_TPREL16_HI" },
-       intName{ 72, "R_PPC_TPREL16_HA" },
-       intName{ 73, "R_PPC_TPREL32" },
-       intName{ 74, "R_PPC_DTPREL16" },
-       intName{ 75, "R_PPC_DTPREL16_LO" },
-       intName{ 76, "R_PPC_DTPREL16_HI" },
-       intName{ 77, "R_PPC_DTPREL16_HA" },
-       intName{ 78, "R_PPC_DTPREL32" },
-       intName{ 79, "R_PPC_GOT_TLSGD16" },
-       intName{ 80, "R_PPC_GOT_TLSGD16_LO" },
-       intName{ 81, "R_PPC_GOT_TLSGD16_HI" },
-       intName{ 82, "R_PPC_GOT_TLSGD16_HA" },
-       intName{ 83, "R_PPC_GOT_TLSLD16" },
-       intName{ 84, "R_PPC_GOT_TLSLD16_LO" },
-       intName{ 85, "R_PPC_GOT_TLSLD16_HI" },
-       intName{ 86, "R_PPC_GOT_TLSLD16_HA" },
-       intName{ 87, "R_PPC_GOT_TPREL16" },
-       intName{ 88, "R_PPC_GOT_TPREL16_LO" },
-       intName{ 89, "R_PPC_GOT_TPREL16_HI" },
-       intName{ 90, "R_PPC_GOT_TPREL16_HA" },
-
-       intName{ 101, "R_PPC_EMB_NADDR32" },
-       intName{ 102, "R_PPC_EMB_NADDR16" },
-       intName{ 103, "R_PPC_EMB_NADDR16_LO" },
-       intName{ 104, "R_PPC_EMB_NADDR16_HI" },
-       intName{ 105, "R_PPC_EMB_NADDR16_HA" },
-       intName{ 106, "R_PPC_EMB_SDAI16" },
-       intName{ 107, "R_PPC_EMB_SDA2I16" },
-       intName{ 108, "R_PPC_EMB_SDA2REL" },
-       intName{ 109, "R_PPC_EMB_SDA21" },
-       intName{ 110, "R_PPC_EMB_MRKREF" },
-       intName{ 111, "R_PPC_EMB_RELSEC16" },
-       intName{ 112, "R_PPC_EMB_RELST_LO" },
-       intName{ 113, "R_PPC_EMB_RELST_HI" },
-       intName{ 114, "R_PPC_EMB_RELST_HA" },
-       intName{ 115, "R_PPC_EMB_BIT_FLD" },
-       intName{ 116, "R_PPC_EMB_RELSDA" },
+
+var rppcStrings = []intName{
+       intName{0, "R_PPC_NONE"},
+       intName{1, "R_PPC_ADDR32"},
+       intName{2, "R_PPC_ADDR24"},
+       intName{3, "R_PPC_ADDR16"},
+       intName{4, "R_PPC_ADDR16_LO"},
+       intName{5, "R_PPC_ADDR16_HI"},
+       intName{6, "R_PPC_ADDR16_HA"},
+       intName{7, "R_PPC_ADDR14"},
+       intName{8, "R_PPC_ADDR14_BRTAKEN"},
+       intName{9, "R_PPC_ADDR14_BRNTAKEN"},
+       intName{10, "R_PPC_REL24"},
+       intName{11, "R_PPC_REL14"},
+       intName{12, "R_PPC_REL14_BRTAKEN"},
+       intName{13, "R_PPC_REL14_BRNTAKEN"},
+       intName{14, "R_PPC_GOT16"},
+       intName{15, "R_PPC_GOT16_LO"},
+       intName{16, "R_PPC_GOT16_HI"},
+       intName{17, "R_PPC_GOT16_HA"},
+       intName{18, "R_PPC_PLTREL24"},
+       intName{19, "R_PPC_COPY"},
+       intName{20, "R_PPC_GLOB_DAT"},
+       intName{21, "R_PPC_JMP_SLOT"},
+       intName{22, "R_PPC_RELATIVE"},
+       intName{23, "R_PPC_LOCAL24PC"},
+       intName{24, "R_PPC_UADDR32"},
+       intName{25, "R_PPC_UADDR16"},
+       intName{26, "R_PPC_REL32"},
+       intName{27, "R_PPC_PLT32"},
+       intName{28, "R_PPC_PLTREL32"},
+       intName{29, "R_PPC_PLT16_LO"},
+       intName{30, "R_PPC_PLT16_HI"},
+       intName{31, "R_PPC_PLT16_HA"},
+       intName{32, "R_PPC_SDAREL16"},
+       intName{33, "R_PPC_SECTOFF"},
+       intName{34, "R_PPC_SECTOFF_LO"},
+       intName{35, "R_PPC_SECTOFF_HI"},
+       intName{36, "R_PPC_SECTOFF_HA"},
+
+       intName{67, "R_PPC_TLS"},
+       intName{68, "R_PPC_DTPMOD32"},
+       intName{69, "R_PPC_TPREL16"},
+       intName{70, "R_PPC_TPREL16_LO"},
+       intName{71, "R_PPC_TPREL16_HI"},
+       intName{72, "R_PPC_TPREL16_HA"},
+       intName{73, "R_PPC_TPREL32"},
+       intName{74, "R_PPC_DTPREL16"},
+       intName{75, "R_PPC_DTPREL16_LO"},
+       intName{76, "R_PPC_DTPREL16_HI"},
+       intName{77, "R_PPC_DTPREL16_HA"},
+       intName{78, "R_PPC_DTPREL32"},
+       intName{79, "R_PPC_GOT_TLSGD16"},
+       intName{80, "R_PPC_GOT_TLSGD16_LO"},
+       intName{81, "R_PPC_GOT_TLSGD16_HI"},
+       intName{82, "R_PPC_GOT_TLSGD16_HA"},
+       intName{83, "R_PPC_GOT_TLSLD16"},
+       intName{84, "R_PPC_GOT_TLSLD16_LO"},
+       intName{85, "R_PPC_GOT_TLSLD16_HI"},
+       intName{86, "R_PPC_GOT_TLSLD16_HA"},
+       intName{87, "R_PPC_GOT_TPREL16"},
+       intName{88, "R_PPC_GOT_TPREL16_LO"},
+       intName{89, "R_PPC_GOT_TPREL16_HI"},
+       intName{90, "R_PPC_GOT_TPREL16_HA"},
+
+       intName{101, "R_PPC_EMB_NADDR32"},
+       intName{102, "R_PPC_EMB_NADDR16"},
+       intName{103, "R_PPC_EMB_NADDR16_LO"},
+       intName{104, "R_PPC_EMB_NADDR16_HI"},
+       intName{105, "R_PPC_EMB_NADDR16_HA"},
+       intName{106, "R_PPC_EMB_SDAI16"},
+       intName{107, "R_PPC_EMB_SDA2I16"},
+       intName{108, "R_PPC_EMB_SDA2REL"},
+       intName{109, "R_PPC_EMB_SDA21"},
+       intName{110, "R_PPC_EMB_MRKREF"},
+       intName{111, "R_PPC_EMB_RELSEC16"},
+       intName{112, "R_PPC_EMB_RELST_LO"},
+       intName{113, "R_PPC_EMB_RELST_HI"},
+       intName{114, "R_PPC_EMB_RELST_HA"},
+       intName{115, "R_PPC_EMB_BIT_FLD"},
+       intName{116, "R_PPC_EMB_RELSDA"},
 }
+
 func (i R_PPC) String() string {
-       return stringName(uint32(i), rppcStrings, false)
+       return stringName(uint32(i), rppcStrings, false);
 }
 func (i R_PPC) GoString() string {
-       return stringName(uint32(i), rppcStrings, true)
+       return stringName(uint32(i), rppcStrings, true);
 }
 
 // Relocation types for SPARC.
 type R_SPARC int
+
 const (
-       R_SPARC_NONE R_SPARC =          0;
-       R_SPARC_8 R_SPARC =             1;
-       R_SPARC_16 R_SPARC =            2;
-       R_SPARC_32 R_SPARC =            3;
-       R_SPARC_DISP8 R_SPARC =         4;
-       R_SPARC_DISP16 R_SPARC =                5;
-       R_SPARC_DISP32 R_SPARC =                6;
-       R_SPARC_WDISP30 R_SPARC =               7;
-       R_SPARC_WDISP22 R_SPARC =               8;
-       R_SPARC_HI22 R_SPARC =          9;
-       R_SPARC_22 R_SPARC =            10;
-       R_SPARC_13 R_SPARC =            11;
-       R_SPARC_LO10 R_SPARC =          12;
-       R_SPARC_GOT10 R_SPARC =         13;
-       R_SPARC_GOT13 R_SPARC =         14;
-       R_SPARC_GOT22 R_SPARC =         15;
-       R_SPARC_PC10 R_SPARC =          16;
-       R_SPARC_PC22 R_SPARC =          17;
-       R_SPARC_WPLT30 R_SPARC =                18;
-       R_SPARC_COPY R_SPARC =          19;
-       R_SPARC_GLOB_DAT R_SPARC =      20;
-       R_SPARC_JMP_SLOT R_SPARC =      21;
-       R_SPARC_RELATIVE R_SPARC =      22;
-       R_SPARC_UA32 R_SPARC =          23;
-       R_SPARC_PLT32 R_SPARC =         24;
-       R_SPARC_HIPLT22 R_SPARC =               25;
-       R_SPARC_LOPLT10 R_SPARC =               26;
-       R_SPARC_PCPLT32 R_SPARC =               27;
-       R_SPARC_PCPLT22 R_SPARC =               28;
-       R_SPARC_PCPLT10 R_SPARC =               29;
-       R_SPARC_10 R_SPARC =            30;
-       R_SPARC_11 R_SPARC =            31;
-       R_SPARC_64 R_SPARC =            32;
-       R_SPARC_OLO10 R_SPARC =         33;
-       R_SPARC_HH22 R_SPARC =          34;
-       R_SPARC_HM10 R_SPARC =          35;
-       R_SPARC_LM22 R_SPARC =          36;
-       R_SPARC_PC_HH22 R_SPARC =               37;
-       R_SPARC_PC_HM10 R_SPARC =               38;
-       R_SPARC_PC_LM22 R_SPARC =               39;
-       R_SPARC_WDISP16 R_SPARC =               40;
-       R_SPARC_WDISP19 R_SPARC =               41;
-       R_SPARC_GLOB_JMP R_SPARC =      42;
-       R_SPARC_7 R_SPARC =             43;
-       R_SPARC_5 R_SPARC =             44;
-       R_SPARC_6 R_SPARC =             45;
-       R_SPARC_DISP64 R_SPARC =                46;
-       R_SPARC_PLT64 R_SPARC =         47;
-       R_SPARC_HIX22 R_SPARC =         48;
-       R_SPARC_LOX10 R_SPARC =         49;
-       R_SPARC_H44 R_SPARC =           50;
-       R_SPARC_M44 R_SPARC =           51;
-       R_SPARC_L44 R_SPARC =           52;
-       R_SPARC_REGISTER R_SPARC =      53;
-       R_SPARC_UA64 R_SPARC =          54;
-       R_SPARC_UA16 R_SPARC =          55;
+       R_SPARC_NONE            R_SPARC = 0;
+       R_SPARC_8               R_SPARC = 1;
+       R_SPARC_16              R_SPARC = 2;
+       R_SPARC_32              R_SPARC = 3;
+       R_SPARC_DISP8           R_SPARC = 4;
+       R_SPARC_DISP16          R_SPARC = 5;
+       R_SPARC_DISP32          R_SPARC = 6;
+       R_SPARC_WDISP30         R_SPARC = 7;
+       R_SPARC_WDISP22         R_SPARC = 8;
+       R_SPARC_HI22            R_SPARC = 9;
+       R_SPARC_22              R_SPARC = 10;
+       R_SPARC_13              R_SPARC = 11;
+       R_SPARC_LO10            R_SPARC = 12;
+       R_SPARC_GOT10           R_SPARC = 13;
+       R_SPARC_GOT13           R_SPARC = 14;
+       R_SPARC_GOT22           R_SPARC = 15;
+       R_SPARC_PC10            R_SPARC = 16;
+       R_SPARC_PC22            R_SPARC = 17;
+       R_SPARC_WPLT30          R_SPARC = 18;
+       R_SPARC_COPY            R_SPARC = 19;
+       R_SPARC_GLOB_DAT        R_SPARC = 20;
+       R_SPARC_JMP_SLOT        R_SPARC = 21;
+       R_SPARC_RELATIVE        R_SPARC = 22;
+       R_SPARC_UA32            R_SPARC = 23;
+       R_SPARC_PLT32           R_SPARC = 24;
+       R_SPARC_HIPLT22         R_SPARC = 25;
+       R_SPARC_LOPLT10         R_SPARC = 26;
+       R_SPARC_PCPLT32         R_SPARC = 27;
+       R_SPARC_PCPLT22         R_SPARC = 28;
+       R_SPARC_PCPLT10         R_SPARC = 29;
+       R_SPARC_10              R_SPARC = 30;
+       R_SPARC_11              R_SPARC = 31;
+       R_SPARC_64              R_SPARC = 32;
+       R_SPARC_OLO10           R_SPARC = 33;
+       R_SPARC_HH22            R_SPARC = 34;
+       R_SPARC_HM10            R_SPARC = 35;
+       R_SPARC_LM22            R_SPARC = 36;
+       R_SPARC_PC_HH22         R_SPARC = 37;
+       R_SPARC_PC_HM10         R_SPARC = 38;
+       R_SPARC_PC_LM22         R_SPARC = 39;
+       R_SPARC_WDISP16         R_SPARC = 40;
+       R_SPARC_WDISP19         R_SPARC = 41;
+       R_SPARC_GLOB_JMP        R_SPARC = 42;
+       R_SPARC_7               R_SPARC = 43;
+       R_SPARC_5               R_SPARC = 44;
+       R_SPARC_6               R_SPARC = 45;
+       R_SPARC_DISP64          R_SPARC = 46;
+       R_SPARC_PLT64           R_SPARC = 47;
+       R_SPARC_HIX22           R_SPARC = 48;
+       R_SPARC_LOX10           R_SPARC = 49;
+       R_SPARC_H44             R_SPARC = 50;
+       R_SPARC_M44             R_SPARC = 51;
+       R_SPARC_L44             R_SPARC = 52;
+       R_SPARC_REGISTER        R_SPARC = 53;
+       R_SPARC_UA64            R_SPARC = 54;
+       R_SPARC_UA16            R_SPARC = 55;
 )
-var rsparcStrings = []intName {
-       intName{ 0, "R_SPARC_NONE" },
-       intName{ 1, "R_SPARC_8" },
-       intName{ 2, "R_SPARC_16" },
-       intName{ 3, "R_SPARC_32" },
-       intName{ 4, "R_SPARC_DISP8" },
-       intName{ 5, "R_SPARC_DISP16" },
-       intName{ 6, "R_SPARC_DISP32" },
-       intName{ 7, "R_SPARC_WDISP30" },
-       intName{ 8, "R_SPARC_WDISP22" },
-       intName{ 9, "R_SPARC_HI22" },
-       intName{ 10, "R_SPARC_22" },
-       intName{ 11, "R_SPARC_13" },
-       intName{ 12, "R_SPARC_LO10" },
-       intName{ 13, "R_SPARC_GOT10" },
-       intName{ 14, "R_SPARC_GOT13" },
-       intName{ 15, "R_SPARC_GOT22" },
-       intName{ 16, "R_SPARC_PC10" },
-       intName{ 17, "R_SPARC_PC22" },
-       intName{ 18, "R_SPARC_WPLT30" },
-       intName{ 19, "R_SPARC_COPY" },
-       intName{ 20, "R_SPARC_GLOB_DAT" },
-       intName{ 21, "R_SPARC_JMP_SLOT" },
-       intName{ 22, "R_SPARC_RELATIVE" },
-       intName{ 23, "R_SPARC_UA32" },
-       intName{ 24, "R_SPARC_PLT32" },
-       intName{ 25, "R_SPARC_HIPLT22" },
-       intName{ 26, "R_SPARC_LOPLT10" },
-       intName{ 27, "R_SPARC_PCPLT32" },
-       intName{ 28, "R_SPARC_PCPLT22" },
-       intName{ 29, "R_SPARC_PCPLT10" },
-       intName{ 30, "R_SPARC_10" },
-       intName{ 31, "R_SPARC_11" },
-       intName{ 32, "R_SPARC_64" },
-       intName{ 33, "R_SPARC_OLO10" },
-       intName{ 34, "R_SPARC_HH22" },
-       intName{ 35, "R_SPARC_HM10" },
-       intName{ 36, "R_SPARC_LM22" },
-       intName{ 37, "R_SPARC_PC_HH22" },
-       intName{ 38, "R_SPARC_PC_HM10" },
-       intName{ 39, "R_SPARC_PC_LM22" },
-       intName{ 40, "R_SPARC_WDISP16" },
-       intName{ 41, "R_SPARC_WDISP19" },
-       intName{ 42, "R_SPARC_GLOB_JMP" },
-       intName{ 43, "R_SPARC_7" },
-       intName{ 44, "R_SPARC_5" },
-       intName{ 45, "R_SPARC_6" },
-       intName{ 46, "R_SPARC_DISP64" },
-       intName{ 47, "R_SPARC_PLT64" },
-       intName{ 48, "R_SPARC_HIX22" },
-       intName{ 49, "R_SPARC_LOX10" },
-       intName{ 50, "R_SPARC_H44" },
-       intName{ 51, "R_SPARC_M44" },
-       intName{ 52, "R_SPARC_L44" },
-       intName{ 53, "R_SPARC_REGISTER" },
-       intName{ 54, "R_SPARC_UA64" },
-       intName{ 55, "R_SPARC_UA16" },
+
+var rsparcStrings = []intName{
+       intName{0, "R_SPARC_NONE"},
+       intName{1, "R_SPARC_8"},
+       intName{2, "R_SPARC_16"},
+       intName{3, "R_SPARC_32"},
+       intName{4, "R_SPARC_DISP8"},
+       intName{5, "R_SPARC_DISP16"},
+       intName{6, "R_SPARC_DISP32"},
+       intName{7, "R_SPARC_WDISP30"},
+       intName{8, "R_SPARC_WDISP22"},
+       intName{9, "R_SPARC_HI22"},
+       intName{10, "R_SPARC_22"},
+       intName{11, "R_SPARC_13"},
+       intName{12, "R_SPARC_LO10"},
+       intName{13, "R_SPARC_GOT10"},
+       intName{14, "R_SPARC_GOT13"},
+       intName{15, "R_SPARC_GOT22"},
+       intName{16, "R_SPARC_PC10"},
+       intName{17, "R_SPARC_PC22"},
+       intName{18, "R_SPARC_WPLT30"},
+       intName{19, "R_SPARC_COPY"},
+       intName{20, "R_SPARC_GLOB_DAT"},
+       intName{21, "R_SPARC_JMP_SLOT"},
+       intName{22, "R_SPARC_RELATIVE"},
+       intName{23, "R_SPARC_UA32"},
+       intName{24, "R_SPARC_PLT32"},
+       intName{25, "R_SPARC_HIPLT22"},
+       intName{26, "R_SPARC_LOPLT10"},
+       intName{27, "R_SPARC_PCPLT32"},
+       intName{28, "R_SPARC_PCPLT22"},
+       intName{29, "R_SPARC_PCPLT10"},
+       intName{30, "R_SPARC_10"},
+       intName{31, "R_SPARC_11"},
+       intName{32, "R_SPARC_64"},
+       intName{33, "R_SPARC_OLO10"},
+       intName{34, "R_SPARC_HH22"},
+       intName{35, "R_SPARC_HM10"},
+       intName{36, "R_SPARC_LM22"},
+       intName{37, "R_SPARC_PC_HH22"},
+       intName{38, "R_SPARC_PC_HM10"},
+       intName{39, "R_SPARC_PC_LM22"},
+       intName{40, "R_SPARC_WDISP16"},
+       intName{41, "R_SPARC_WDISP19"},
+       intName{42, "R_SPARC_GLOB_JMP"},
+       intName{43, "R_SPARC_7"},
+       intName{44, "R_SPARC_5"},
+       intName{45, "R_SPARC_6"},
+       intName{46, "R_SPARC_DISP64"},
+       intName{47, "R_SPARC_PLT64"},
+       intName{48, "R_SPARC_HIX22"},
+       intName{49, "R_SPARC_LOX10"},
+       intName{50, "R_SPARC_H44"},
+       intName{51, "R_SPARC_M44"},
+       intName{52, "R_SPARC_L44"},
+       intName{53, "R_SPARC_REGISTER"},
+       intName{54, "R_SPARC_UA64"},
+       intName{55, "R_SPARC_UA16"},
 }
+
 func (i R_SPARC) String() string {
-       return stringName(uint32(i), rsparcStrings, false)
+       return stringName(uint32(i), rsparcStrings, false);
 }
 func (i R_SPARC) GoString() string {
-       return stringName(uint32(i), rsparcStrings, true)
+       return stringName(uint32(i), rsparcStrings, true);
 }
 
 /*
@@ -1306,44 +1373,44 @@ const ARM_MAGIC_TRAMP_NUMBER = 0x5c000003
  * ELF32 File header.
  */
 type Header32 struct {
-       Ident   [EI_NIDENT]byte;        /* File identification. */
-       Type    uint16;         /* File type. */
-       Machine uint16; /* Machine architecture. */
-       Version uint32; /* ELF format version. */
-       Entry   uint32; /* Entry point. */
-       Phoff   uint32; /* Program header file offset. */
-       Shoff   uint32; /* Section header file offset. */
-       Flags   uint32; /* Architecture-specific flags. */
-       Ehsize  uint16; /* Size of ELF header in bytes. */
-       Phentsize       uint16; /* Size of program header entry. */
-       Phnum   uint16; /* Number of program header entries. */
-       Shentsize       uint16; /* Size of section header entry. */
-       Shnum   uint16; /* Number of section header entries. */
-       Shstrndx        uint16; /* Section name strings section. */
+       Ident           [EI_NIDENT]byte;        /* File identification. */
+       Type            uint16;                 /* File type. */
+       Machine         uint16;                 /* Machine architecture. */
+       Version         uint32;                 /* ELF format version. */
+       Entry           uint32;                 /* Entry point. */
+       Phoff           uint32;                 /* Program header file offset. */
+       Shoff           uint32;                 /* Section header file offset. */
+       Flags           uint32;                 /* Architecture-specific flags. */
+       Ehsize          uint16;                 /* Size of ELF header in bytes. */
+       Phentsize       uint16;                 /* Size of program header entry. */
+       Phnum           uint16;                 /* Number of program header entries. */
+       Shentsize       uint16;                 /* Size of section header entry. */
+       Shnum           uint16;                 /* Number of section header entries. */
+       Shstrndx        uint16;                 /* Section name strings section. */
 }
 
 /*
  * ELF32 Section header.
  */
 type Section32 struct {
-       Name    uint32; /* Section name (index into the
-                                          section header string table). */
-       Type    uint32; /* Section type. */
-       Flags   uint32; /* Section flags. */
-       Addr    uint32; /* Address in memory image. */
-       Off     uint32; /* Offset in file. */
-       Size    uint32; /* Size in bytes. */
-       Link    uint32; /* Index of a related section. */
-       Info    uint32; /* Depends on section type. */
+       Name            uint32; /* Section name (index into the
+                                                          section header string table). */
+       Type            uint32; /* Section type. */
+       Flags           uint32; /* Section flags. */
+       Addr            uint32; /* Address in memory image. */
+       Off             uint32; /* Offset in file. */
+       Size            uint32; /* Size in bytes. */
+       Link            uint32; /* Index of a related section. */
+       Info            uint32; /* Depends on section type. */
        Addralign       uint32; /* Alignment in bytes. */
-       Entsize uint32; /* Size of each entry in section. */
+       Entsize         uint32; /* Size of each entry in section. */
 }
 
 /*
  * ELF32 Program header.
  */
 type Prog32 struct {
-       Type    uint32;         /* Entry type. */
+       Type    uint32; /* Entry type. */
        Off     uint32; /* File offset of contents. */
        Vaddr   uint32; /* Virtual address in memory image. */
        Paddr   uint32; /* Physical address (not used). */
@@ -1357,9 +1424,9 @@ type Prog32 struct {
  * ELF32 Dynamic structure.  The ".dynamic" section contains an array of them.
  */
 type Dyn32 struct {
-       Tag     int32;          /* Entry type. */
-       Val     uint32;         /* Integer/Address value. */
-};
+       Tag     int32;  /* Entry type. */
+       Val     uint32; /* Integer/Address value. */
+}
 
 /*
  * Relocation entries.
@@ -1368,21 +1435,21 @@ type Dyn32 struct {
 // ELF32 Relocations that don't need an addend field.
 type Rel32 struct {
        Off     uint32; /* Location to be relocated. */
-       Info    uint32;         /* Relocation type and symbol index. */
+       Info    uint32; /* Relocation type and symbol index. */
 }
 
 // ELF32 Relocations that need an addend field.
 type Rela32 struct {
        Off     uint32; /* Location to be relocated. */
-       Info    uint32;         /* Relocation type and symbol index. */
+       Info    uint32; /* Relocation type and symbol index. */
        Addend  int32;  /* Addend. */
 }
 
 func R_SYM32(info uint32) uint32 {
-       return uint32(info>>8)
+       return uint32(info>>8);
 }
 func R_TYPE32(info uint32) uint32 {
-       return uint32(info&0xff)
+       return uint32(info&0xff);
 }
 func R_INFO32(sym, typ uint32) uint32 {
        return sym<<8 | typ;
@@ -1399,13 +1466,13 @@ type Sym32 struct {
 }
 
 func ST_BIND(info uint8) SymBind {
-       return SymBind(info>>4)
+       return SymBind(info>>4);
 }
 func ST_TYPE(bind SymBind, typ SymType) uint8 {
-       return uint8(bind)<<4 | uint8(typ)&0xf
+       return uint8(bind)<<4 | uint8(typ)&0xf;
 }
 func ST_VISIBILITY(other uint8) SymVis {
-       return SymVis(other & 3)
+       return SymVis(other&3);
 }
 
 /*
@@ -1417,20 +1484,20 @@ func ST_VISIBILITY(other uint8) SymVis {
  */
 
 type Header64 struct {
-       Ident   [EI_NIDENT]byte;        /* File identification. */
-       Type    uint16;         /* File type. */
-       Machine uint16; /* Machine architecture. */
-       Version uint32; /* ELF format version. */
-       Entry   uint64; /* Entry point. */
-       Phoff   uint64; /* Program header file offset. */
-       Shoff   uint64; /* Section header file offset. */
-       Flags   uint32; /* Architecture-specific flags. */
-       Ehsize  uint16; /* Size of ELF header in bytes. */
-       Phentsize       uint16; /* Size of program header entry. */
-       Phnum   uint16; /* Number of program header entries. */
-       Shentsize       uint16; /* Size of section header entry. */
-       Shnum   uint16; /* Number of section header entries. */
-       Shstrndx        uint16; /* Section name strings section. */
+       Ident           [EI_NIDENT]byte;        /* File identification. */
+       Type            uint16;                 /* File type. */
+       Machine         uint16;                 /* Machine architecture. */
+       Version         uint32;                 /* ELF format version. */
+       Entry           uint64;                 /* Entry point. */
+       Phoff           uint64;                 /* Program header file offset. */
+       Shoff           uint64;                 /* Section header file offset. */
+       Flags           uint32;                 /* Architecture-specific flags. */
+       Ehsize          uint16;                 /* Size of ELF header in bytes. */
+       Phentsize       uint16;                 /* Size of program header entry. */
+       Phnum           uint16;                 /* Number of program header entries. */
+       Shentsize       uint16;                 /* Size of section header entry. */
+       Shnum           uint16;                 /* Number of section header entries. */
+       Shstrndx        uint16;                 /* Section name strings section. */
 }
 
 /*
@@ -1438,17 +1505,17 @@ type Header64 struct {
  */
 
 type Section64 struct {
-       Name    uint32; /* Section name (index into the
-                                          section header string table). */
-       Type    uint32; /* Section type. */
-       Flags   uint64; /* Section flags. */
-       Addr    uint64; /* Address in memory image. */
-       Off     uint64; /* Offset in file. */
-       Size    uint64; /* Size in bytes. */
-       Link    uint32; /* Index of a related section. */
-       Info    uint32; /* Depends on section type. */
+       Name            uint32; /* Section name (index into the
+                                                          section header string table). */
+       Type            uint32; /* Section type. */
+       Flags           uint64; /* Section flags. */
+       Addr            uint64; /* Address in memory image. */
+       Off             uint64; /* Offset in file. */
+       Size            uint64; /* Size in bytes. */
+       Link            uint32; /* Index of a related section. */
+       Info            uint32; /* Depends on section type. */
        Addralign       uint64; /* Alignment in bytes. */
-       Entsize uint64; /* Size of each entry in section. */
+       Entsize         uint64; /* Size of each entry in section. */
 }
 
 /*
@@ -1456,7 +1523,7 @@ type Section64 struct {
  */
 
 type Prog64 struct {
-       Type    uint32;         /* Entry type. */
+       Type    uint32; /* Entry type. */
        Flags   uint32; /* Access permission flags. */
        Off     uint64; /* File offset of contents. */
        Vaddr   uint64; /* Virtual address in memory image. */
@@ -1471,8 +1538,8 @@ type Prog64 struct {
  */
 
 type Dyn64 struct {
-       Tag     int64;          /* Entry type. */
-       Val     uint64;         /* Integer/address value */
+       Tag     int64;  /* Entry type. */
+       Val     uint64; /* Integer/address value */
 }
 
 /*
@@ -1482,24 +1549,24 @@ type Dyn64 struct {
 /* ELF64 relocations that don't need an addend field. */
 type Rel64 struct {
        Off     uint64; /* Location to be relocated. */
-       Info    uint64;         /* Relocation type and symbol index. */
+       Info    uint64; /* Relocation type and symbol index. */
 }
 
 /* ELF64 relocations that need an addend field. */
 type Rela64 struct {
        Off     uint64; /* Location to be relocated. */
-       Info    uint64;         /* Relocation type and symbol index. */
+       Info    uint64; /* Relocation type and symbol index. */
        Addend  int64;  /* Addend. */
 }
 
 func R_SYM64(info uint64) uint32 {
-       return uint32(info>>32)
+       return uint32(info>>32);
 }
 func R_TYPE64(info uint64) uint32 {
-       return uint32(info)
+       return uint32(info);
 }
 func R_INFO(sym, typ uint32) uint64 {
-       return uint64(sym)<<32 | uint64(typ)
+       return uint64(sym)<<32 | uint64(typ);
 }
 
 
@@ -1508,7 +1575,7 @@ func R_INFO(sym, typ uint32) uint64 {
  */
 type Sym64 struct {
        Name    uint32; /* String table index of name. */
-       Info            uint8;  /* Type and binding information. */
+       Info    uint8;  /* Type and binding information. */
        Other   uint8;  /* Reserved (not used). */
        Shndx   uint16; /* Section index of symbol. */
        Value   uint64; /* Symbol value. */
@@ -1517,34 +1584,34 @@ type Sym64 struct {
 
 
 type intName struct {
-       i uint32;
-       s string;
+       i       uint32;
+       s       string;
 }
 
 func stringName(i uint32, names []intName, goSyntax bool) string {
        for _, n := range names {
                if n.i == i {
                        if goSyntax {
-                               return "elf." + n.s
+                               return "elf." + n.s;
                        }
-                       return n.s
+                       return n.s;
                }
        }
 
        // second pass - look for smaller to add with.
        // assume sorted already
-       for j := len(names)-1; j>=0; j-- {
+       for j := len(names)-1; j >= 0; j-- {
                n := names[j];
                if n.i < i {
                        s := n.s;
                        if goSyntax {
-                               s = "elf." + s;
+                               s = "elf."+s;
                        }
                        return s + "+" + strconv.Uitoa64(uint64(i - n.i));
                }
        }
 
-       return strconv.Uitoa64(uint64(i))
+       return strconv.Uitoa64(uint64(i));
 }
 
 func flagName(i uint32, names []intName, goSyntax bool) string {
@@ -1562,10 +1629,10 @@ func flagName(i uint32, names []intName, goSyntax bool) string {
                }
        }
        if len(s) == 0 {
-               return "0x" + strconv.Uitob64(uint64(i), 16)
+               return "0x" + strconv.Uitob64(uint64(i), 16);
        }
        if i != 0 {
-               s += "+0x" + strconv.Uitob64(uint64(i), 16)
+               s += "+0x" + strconv.Uitob64(uint64(i), 16);
        }
-       return s
+       return s;
 }
index bafa3d36e1ce310b7bf990b035b32480aac69586..c6cf7bfe46612e253a71bd5cf5b8fd6848b22981 100644 (file)
@@ -10,11 +10,11 @@ import (
 )
 
 type nameTest struct {
-       val interface{};
-       str string
+       val     interface{};
+       str     string;
 }
 
-var nameTests = []nameTest {
+var nameTests = []nameTest{
        nameTest{ELFOSABI_LINUX, "ELFOSABI_LINUX"},
        nameTest{ET_EXEC, "ET_EXEC"},
        nameTest{EM_860, "EM_860"},
index 6bb36bd6fde9ca72ab63b56ff33628b3bf3f05c2..f2d66579754149bcb244b06bd3c392911ae236c9 100644 (file)
@@ -21,37 +21,36 @@ import (
 
 // A FileHeader represents an ELF file header.
 type FileHeader struct {
-       Class Class;
-       Data Data;
-       Version Version;
-       OSABI OSABI;
-       ABIVersion uint8;
-       ByteOrder binary.ByteOrder;
-       Type Type;
-       Machine Machine;
+       Class           Class;
+       Data            Data;
+       Version         Version;
+       OSABI           OSABI;
+       ABIVersion      uint8;
+       ByteOrder       binary.ByteOrder;
+       Type            Type;
+       Machine         Machine;
 }
 
 // A File represents an open ELF file.
 type File struct {
        FileHeader;
-       Sections []*Section;
-       Progs []*Prog;
-
-       closer io.Closer;
+       Sections        []*Section;
+       Progs           []*Prog;
+       closer          io.Closer;
 }
 
 // A SectionHeader represents a single ELF section header.
 type SectionHeader struct {
-       Name string;
-       Type SectionType;
-       Flags SectionFlag;
-       Addr uint64;
-       Offset uint64;
-       Size uint64;
-       Link uint32;
-       Info uint32;
-       Addralign uint64;
-       Entsize uint64;
+       Name            string;
+       Type            SectionType;
+       Flags           SectionFlag;
+       Addr            uint64;
+       Offset          uint64;
+       Size            uint64;
+       Link            uint32;
+       Info            uint32;
+       Addralign       uint64;
+       Entsize         uint64;
 }
 
 // A Section represents a single section in an ELF file.
@@ -65,7 +64,7 @@ type Section struct {
        // Open() to avoid fighting over the seek offset
        // with other clients.
        io.ReaderAt;
-       sr *io.SectionReader;
+       sr      *io.SectionReader;
 }
 
 // Data reads and returns the contents of the ELF section.
@@ -82,13 +81,13 @@ func (s *Section) Open() io.ReadSeeker {
 
 // A ProgHeader represents a single ELF program header.
 type ProgHeader struct {
-       Type ProgType;
-       Flags ProgFlag;
-       Vaddr uint64;
-       Paddr uint64;
-       Filesz uint64;
-       Memsz uint64;
-       Align uint64;
+       Type    ProgType;
+       Flags   ProgFlag;
+       Vaddr   uint64;
+       Paddr   uint64;
+       Filesz  uint64;
+       Memsz   uint64;
+       Align   uint64;
 }
 
 // A Prog represents a single ELF program header in an ELF binary.
@@ -102,7 +101,7 @@ type Prog struct {
        // Open() to avoid fighting over the seek offset
        // with other clients.
        io.ReaderAt;
-       sr *io.SectionReader;
+       sr      *io.SectionReader;
 }
 
 // Open returns a new ReadSeeker reading the ELF program body.
@@ -116,9 +115,9 @@ func (p *Prog) Open() io.ReadSeeker {
  */
 
 type FormatError struct {
-       off int64;
-       msg string;
-       val interface{};
+       off     int64;
+       msg     string;
+       val     interface{};
 }
 
 func (e *FormatError) String() string {
@@ -175,7 +174,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
        switch f.Class {
        case ELFCLASS32:
        case ELFCLASS64:
-               // ok
+       // ok
        default:
                return nil, &FormatError{0, "unknown ELF class", f.Class};
        }
@@ -282,7 +281,6 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
                                Info: uint32(sh.Info),
                                Addralign: uint64(sh.Addralign),
                                Entsize: uint64(sh.Entsize),
-
                        };
                }
                s.sr = io.NewSectionReader(r, int64(s.Offset), int64(s.Size));
index aceda51fee5593080eb3b8e732a6497bbe8c926d..140841b6da3e777061c6ff59df80b592c4b28613 100644 (file)
@@ -11,12 +11,12 @@ import (
 )
 
 type fileTest struct {
-       file string;
-       hdr FileHeader;
-       sections []SectionHeader;
+       file            string;
+       hdr             FileHeader;
+       sections        []SectionHeader;
 }
 
-var fileTests = []fileTest {
+var fileTests = []fileTest{
        fileTest{
                "testdata/gcc-386-freebsd-exec",
                FileHeader{ELFCLASS32, ELFDATA2LSB, EV_CURRENT, ELFOSABI_FREEBSD, 0, binary.LittleEndian, ET_EXEC, EM_386},
@@ -27,10 +27,10 @@ var fileTests = []fileTest {
                        SectionHeader{".dynsym", SHT_DYNSYM, SHF_ALLOC, 0x804817c, 0x17c, 0x110, 0x4, 0x1, 0x4, 0x10},
                        SectionHeader{".dynstr", SHT_STRTAB, SHF_ALLOC, 0x804828c, 0x28c, 0xbb, 0x0, 0x0, 0x1, 0x0},
                        SectionHeader{".rel.plt", SHT_REL, SHF_ALLOC, 0x8048348, 0x348, 0x20, 0x3, 0x7, 0x4, 0x8},
-                       SectionHeader{".init", SHT_PROGBITS, SHF_ALLOC+SHF_EXECINSTR, 0x8048368, 0x368, 0x11, 0x0, 0x0, 0x4, 0x0},
-                       SectionHeader{".plt", SHT_PROGBITS, SHF_ALLOC+SHF_EXECINSTR, 0x804837c, 0x37c, 0x50, 0x0, 0x0, 0x4, 0x4},
-                       SectionHeader{".text", SHT_PROGBITS, SHF_ALLOC+SHF_EXECINSTR, 0x80483cc, 0x3cc, 0x180, 0x0, 0x0, 0x4, 0x0},
-                       SectionHeader{".fini", SHT_PROGBITS, SHF_ALLOC+SHF_EXECINSTR, 0x804854c, 0x54c, 0xc, 0x0, 0x0, 0x4, 0x0},
+                       SectionHeader{".init", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR, 0x8048368, 0x368, 0x11, 0x0, 0x0, 0x4, 0x0},
+                       SectionHeader{".plt", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR, 0x804837c, 0x37c, 0x50, 0x0, 0x0, 0x4, 0x4},
+                       SectionHeader{".text", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR, 0x80483cc, 0x3cc, 0x180, 0x0, 0x0, 0x4, 0x0},
+                       SectionHeader{".fini", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR, 0x804854c, 0x54c, 0xc, 0x0, 0x0, 0x4, 0x0},
                        SectionHeader{".rodata", SHT_PROGBITS, SHF_ALLOC, 0x8048558, 0x558, 0xa3, 0x0, 0x0, 0x1, 0x0},
                        SectionHeader{".data", SHT_PROGBITS, SHF_WRITE+SHF_ALLOC, 0x80495fc, 0x5fc, 0xc, 0x0, 0x0, 0x4, 0x0},
                        SectionHeader{".eh_frame", SHT_PROGBITS, SHF_ALLOC, 0x8049608, 0x608, 0x4, 0x0, 0x0, 0x4, 0x0},
@@ -51,7 +51,7 @@ var fileTests = []fileTest {
                        SectionHeader{".shstrtab", SHT_STRTAB, 0x0, 0x0, 0xa0d, 0xf8, 0x0, 0x0, 0x1, 0x0},
                        SectionHeader{".symtab", SHT_SYMTAB, 0x0, 0x0, 0xfb8, 0x4b0, 0x1d, 0x38, 0x4, 0x10},
                        SectionHeader{".strtab", SHT_STRTAB, 0x0, 0x0, 0x1468, 0x206, 0x0, 0x0, 0x1, 0x0},
-               }
+               },
        },
        fileTest{
                "testdata/gcc-amd64-linux-exec",
@@ -61,17 +61,17 @@ var fileTests = []fileTest {
                        SectionHeader{".interp", SHT_PROGBITS, SHF_ALLOC, 0x400200, 0x200, 0x1c, 0x0, 0x0, 0x1, 0x0},
                        SectionHeader{".note.ABI-tag", SHT_NOTE, SHF_ALLOC, 0x40021c, 0x21c, 0x20, 0x0, 0x0, 0x4, 0x0},
                        SectionHeader{".hash", SHT_HASH, SHF_ALLOC, 0x400240, 0x240, 0x24, 0x5, 0x0, 0x8, 0x4},
-                       SectionHeader{".gnu.hash", SHT_LOOS+268435446, SHF_ALLOC, 0x400268, 0x268, 0x1c, 0x5, 0x0, 0x8, 0x0},
+                       SectionHeader{".gnu.hash", SHT_LOOS + 268435446, SHF_ALLOC, 0x400268, 0x268, 0x1c, 0x5, 0x0, 0x8, 0x0},
                        SectionHeader{".dynsym", SHT_DYNSYM, SHF_ALLOC, 0x400288, 0x288, 0x60, 0x6, 0x1, 0x8, 0x18},
                        SectionHeader{".dynstr", SHT_STRTAB, SHF_ALLOC, 0x4002e8, 0x2e8, 0x3d, 0x0, 0x0, 0x1, 0x0},
                        SectionHeader{".gnu.version", SHT_HIOS, SHF_ALLOC, 0x400326, 0x326, 0x8, 0x5, 0x0, 0x2, 0x2},
-                       SectionHeader{".gnu.version_r", SHT_LOOS+268435454, SHF_ALLOC, 0x400330, 0x330, 0x20, 0x6, 0x1, 0x8, 0x0},
+                       SectionHeader{".gnu.version_r", SHT_LOOS + 268435454, SHF_ALLOC, 0x400330, 0x330, 0x20, 0x6, 0x1, 0x8, 0x0},
                        SectionHeader{".rela.dyn", SHT_RELA, SHF_ALLOC, 0x400350, 0x350, 0x18, 0x5, 0x0, 0x8, 0x18},
                        SectionHeader{".rela.plt", SHT_RELA, SHF_ALLOC, 0x400368, 0x368, 0x30, 0x5, 0xc, 0x8, 0x18},
-                       SectionHeader{".init", SHT_PROGBITS, SHF_ALLOC+SHF_EXECINSTR, 0x400398, 0x398, 0x18, 0x0, 0x0, 0x4, 0x0},
-                       SectionHeader{".plt", SHT_PROGBITS, SHF_ALLOC+SHF_EXECINSTR, 0x4003b0, 0x3b0, 0x30, 0x0, 0x0, 0x4, 0x10},
-                       SectionHeader{".text", SHT_PROGBITS, SHF_ALLOC+SHF_EXECINSTR, 0x4003e0, 0x3e0, 0x1b4, 0x0, 0x0, 0x10, 0x0},
-                       SectionHeader{".fini", SHT_PROGBITS, SHF_ALLOC+SHF_EXECINSTR, 0x400594, 0x594, 0xe, 0x0, 0x0, 0x4, 0x0},
+                       SectionHeader{".init", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR, 0x400398, 0x398, 0x18, 0x0, 0x0, 0x4, 0x0},
+                       SectionHeader{".plt", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR, 0x4003b0, 0x3b0, 0x30, 0x0, 0x0, 0x4, 0x10},
+                       SectionHeader{".text", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR, 0x4003e0, 0x3e0, 0x1b4, 0x0, 0x0, 0x10, 0x0},
+                       SectionHeader{".fini", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR, 0x400594, 0x594, 0xe, 0x0, 0x0, 0x4, 0x0},
                        SectionHeader{".rodata", SHT_PROGBITS, SHF_ALLOC, 0x4005a4, 0x5a4, 0x11, 0x0, 0x0, 0x4, 0x0},
                        SectionHeader{".eh_frame_hdr", SHT_PROGBITS, SHF_ALLOC, 0x4005b8, 0x5b8, 0x24, 0x0, 0x0, 0x4, 0x0},
                        SectionHeader{".eh_frame", SHT_PROGBITS, SHF_ALLOC, 0x4005e0, 0x5e0, 0xa4, 0x0, 0x0, 0x8, 0x0},
@@ -94,8 +94,8 @@ var fileTests = []fileTest {
                        SectionHeader{".shstrtab", SHT_STRTAB, 0x0, 0x0, 0xf10, 0x149, 0x0, 0x0, 0x1, 0x0},
                        SectionHeader{".symtab", SHT_SYMTAB, 0x0, 0x0, 0x19a0, 0x6f0, 0x24, 0x39, 0x8, 0x18},
                        SectionHeader{".strtab", SHT_STRTAB, 0x0, 0x0, 0x2090, 0x1fc, 0x0, 0x0, 0x1, 0x0},
-               }
-       }
+               },
+       },
 }
 
 func TestOpen(t *testing.T) {
index ee6359f9dcd52ba1d4b5da0560570fb0bda43544..458b5243d4cecb122706413b31383f7e382ff1e1 100644 (file)
@@ -11,13 +11,13 @@ package gosym
 import "debug/binary"
 
 type LineTable struct {
-       Data []byte;
-       PC uint64;
-       Line int;
+       Data    []byte;
+       PC      uint64;
+       Line    int;
 }
 
 // TODO(rsc): Need to pull in quantum from architecture definition.
-const quantum = 1;
+const quantum = 1
 
 func (t *LineTable) parse(targetPC uint64, targetLine int) (b []byte, pc uint64, line int) {
        // The PC/line table can be thought of as a sequence of
@@ -44,9 +44,9 @@ func (t *LineTable) parse(targetPC uint64, targetLine int) (b []byte, pc uint64,
                case code <= 64:
                        line += int(code);
                case code <= 128:
-                       line -= int(code - 64);
+                       line -= int(code-64);
                default:
-                       pc += quantum*uint64(code - 128);
+                       pc += quantum * uint64(code-128);
                        continue;
                }
                pc += quantum;
@@ -70,7 +70,7 @@ func (t *LineTable) LineToPC(line int, maxpc uint64) uint64 {
                return 0;
        }
        // Subtract quantum from PC to account for post-line increment
-       return pc - quantum;
+       return pc-quantum;
 }
 
 // NewLineTable returns a new PC/line table
index 4345112ccbd90aa5cb53a8f5f667ce6c97b66188..6b70ba1638b6b20795418a36374eb1b2be6df598 100644 (file)
@@ -13,7 +13,7 @@ import (
 
 func dotest() bool {
        // For now, only works on ELF platforms.
-       return syscall.OS == "linux" && os.Getenv("GOARCH") == "amd64"
+       return syscall.OS == "linux" && os.Getenv("GOARCH") == "amd64";
 }
 
 func getTable(t *testing.T) *Table {
@@ -70,14 +70,14 @@ func TestLineFromAline(t *testing.T) {
 
        // Walk every absolute line and ensure that we hit every
        // source line monotonically
-       lastline := make(map[string] int);
+       lastline := make(map[string]int);
        final := -1;
        for i := 0; i < 10000; i++ {
                path, line := pkg.lineFromAline(i);
                // Check for end of object
                if path == "" {
                        if final == -1 {
-                               final = i - 1;
+                               final = i-1;
                        }
                        continue;
                } else if final != -1 {
@@ -92,8 +92,8 @@ func TestLineFromAline(t *testing.T) {
                ll, ok := lastline[path];
                if !ok {
                        t.Errorf("file %s starts on line %d", path, line);
-               } else if line != ll + 1 {
-                       t.Errorf("expected next line of file %s to be %d, got %d", path, ll + 1, line);
+               } else if line != ll+1 {
+                       t.Errorf("expected next line of file %s to be %d, got %d", path, ll+1, line);
                }
                lastline[path] = line;
        }
@@ -113,7 +113,7 @@ func TestLineAline(t *testing.T) {
                // A source file can appear multiple times in a
                // object.  alineFromLine will always return alines in
                // the first file, so track which lines we've seen.
-               found := make(map[string] int);
+               found := make(map[string]int);
                for i := 0; i < 1000; i++ {
                        path, line := o.lineFromAline(i);
                        if path == "" {
@@ -121,7 +121,7 @@ func TestLineAline(t *testing.T) {
                        }
 
                        // cgo files are full of 'Z' symbols, which we don't handle
-                       if len(path) > 4 && path[len(path)-4:len(path)] == ".cgo" {
+                       if len(path) > 4 && path[len(path)-4 : len(path)] == ".cgo" {
                                continue;
                        }
 
@@ -167,7 +167,7 @@ func TestPCLine(t *testing.T) {
                wantLine += int(textdat[off]);
                if fn == nil {
                        t.Errorf("failed to get line of PC %#x", pc);
-               } else if len(file) < 12 || file[len(file)-12:len(file)] != "pclinetest.s" || line != wantLine || fn != sym {
+               } else if len(file) < 12 || file[len(file)-12 : len(file)] != "pclinetest.s" || line != wantLine || fn != sym {
                        t.Errorf("expected %s:%d (%s) at PC %#x, got %s:%d (%s)", "pclinetest.s", wantLine, sym.Name, pc, file, line, fn.Name);
                }
        }
@@ -177,13 +177,13 @@ func TestPCLine(t *testing.T) {
        lookupline := -1;
        wantLine = 0;
        off := uint64(0);       // TODO(rsc): should not need off; bug in 8g
-       for pc := sym.Value; pc < sym.End; pc += 2 + uint64(textdat[off]) {
+       for pc := sym.Value; pc < sym.End; pc += 2+uint64(textdat[off]) {
                file, line, fn := tab.PCToLine(pc);
-               off = pc-text.Addr;
+               off = pc - text.Addr;
                wantLine += int(textdat[off]);
                if line != wantLine {
                        t.Errorf("expected line %d at PC %#x in pcfromline, got %d", wantLine, pc, line);
-                       off = pc+1-text.Addr;
+                       off = pc + 1 - text.Addr;
                        continue;
                }
                if lookupline == -1 {
@@ -202,6 +202,6 @@ func TestPCLine(t *testing.T) {
                                t.Errorf("expected PC %#x (%s) at line %d, got PC %#x (%s)", pc, fn.Name, line, pc2, fn2.Name);
                        }
                }
-               off = pc+1-text.Addr;
+               off = pc + 1 - text.Addr;
        }
 }
index 69b87575f202f244401addbcb577a3fa5c4b1420..fe0b3ff12cdcd67fefdc8035bf1fdc889dcdd4ed 100644 (file)
@@ -10,13 +10,13 @@ import (
 )
 
 type fileTest struct {
-       file string;
-       hdr FileHeader;
-       segments []*SegmentHeader;
-       sections []*SectionHeader;
+       file            string;
+       hdr             FileHeader;
+       segments        []*SegmentHeader;
+       sections        []*SectionHeader;
 }
 
-var fileTests = []fileTest {
+var fileTests = []fileTest{
        fileTest{
                "testdata/gcc-386-darwin-exec",
                FileHeader{0xfeedface, Cpu386, 0x3, 0x2, 0xc, 0x3c0, 0x85},
index 78f2d7fc3b9f792ce563d1b593e36e2f7a4efd5d..4903f13450b8ba54994b6d0fd65e54c677dce844 100644 (file)
@@ -19,60 +19,67 @@ type FileHeader struct {
        Cmdsz   uint32;
        Flags   uint32;
 }
+
 const (
-       fileHeaderSize32 = 7*4;
-       fileHeaderSize64 = 8*4;
+       fileHeaderSize32        = 7*4;
+       fileHeaderSize64        = 8*4;
 )
 
 const (
-       Magic32 uint32 = 0xfeedface;
-       Magic64 uint32 = 0xfeedfacf;
+       Magic32 uint32  = 0xfeedface;
+       Magic64 uint32  = 0xfeedfacf;
 )
 
 // A Type is a Mach-O file type, either an object or an executable.
 type Type uint32
+
 const (
-       TypeObj Type = 1;
-       TypeExec Type = 2;
+       TypeObj         Type    = 1;
+       TypeExec        Type    = 2;
 )
 
 // A Cpu is a Mach-O cpu type.
 type Cpu uint32
+
 const (
-       Cpu386 Cpu = 7;
-       CpuAmd64 Cpu = Cpu386 + 1<<24;
+       Cpu386          Cpu     = 7;
+       CpuAmd64        Cpu     = Cpu386 + 1<<24;
 )
 
-var cpuStrings = []intName {
-       intName{ uint32(Cpu386), "Cpu386" },
-       intName{ uint32(CpuAmd64), "CpuAmd64" },
+var cpuStrings = []intName{
+       intName{uint32(Cpu386), "Cpu386"},
+       intName{uint32(CpuAmd64), "CpuAmd64"},
 }
+
 func (i Cpu) String() string {
-       return stringName(uint32(i), cpuStrings, false)
+       return stringName(uint32(i), cpuStrings, false);
 }
 func (i Cpu) GoString() string {
-       return stringName(uint32(i), cpuStrings, true)
+       return stringName(uint32(i), cpuStrings, true);
 }
 
 // A LoadCmd is a Mach-O load command.
-type LoadCmd uint32;
+type LoadCmd uint32
+
 const (
-       LoadCmdSegment LoadCmd = 1;
-       LoadCmdSegment64 LoadCmd = 25;
-       LoadCmdThread LoadCmd = 4;
-       LoadCmdUnixThread LoadCmd = 5;  // thread+stack
+       LoadCmdSegment          LoadCmd = 1;
+       LoadCmdSegment64        LoadCmd = 25;
+       LoadCmdThread           LoadCmd = 4;
+       LoadCmdUnixThread       LoadCmd = 5;    // thread+stack
 )
-var cmdStrings = []intName {
-       intName{ uint32(LoadCmdSegment), "LoadCmdSegment" },
-       intName{ uint32(LoadCmdSegment64), "LoadCmdSegment64" },
-       intName{ uint32(LoadCmdThread), "LoadCmdThread" },
-       intName{ uint32(LoadCmdUnixThread), "LoadCmdUnixThread" },
+
+var cmdStrings = []intName{
+       intName{uint32(LoadCmdSegment), "LoadCmdSegment"},
+       intName{uint32(LoadCmdSegment64), "LoadCmdSegment64"},
+       intName{uint32(LoadCmdThread), "LoadCmdThread"},
+       intName{uint32(LoadCmdUnixThread), "LoadCmdUnixThread"},
 }
+
 func (i LoadCmd) String() string {
-       return stringName(uint32(i), cmdStrings, false)
+       return stringName(uint32(i), cmdStrings, false);
 }
 func (i LoadCmd) GoString() string {
-       return stringName(uint32(i), cmdStrings, true)
+       return stringName(uint32(i), cmdStrings, true);
 }
 
 // A Segment64 is a 64-bit Mach-O segment load command.
@@ -107,30 +114,30 @@ type Segment32 struct {
 
 // A Section32 is a 32-bit Mach-O section header.
 type Section32 struct {
-       Name    [16]byte;
+       Name            [16]byte;
        Seg             [16]byte;
-       Addr    uint32;
-       Size    uint32;
-       Offset  uint32;
-       Align   uint32;
-       Reloff  uint32;
-       Nreloc  uint32;
-       Flags   uint32;
+       Addr            uint32;
+       Size            uint32;
+       Offset          uint32;
+       Align           uint32;
+       Reloff          uint32;
+       Nreloc          uint32;
+       Flags           uint32;
        Reserve1        uint32;
        Reserve2        uint32;
 }
 
 // A Section32 is a 64-bit Mach-O section header.
 type Section64 struct {
-       Name    [16]byte;
+       Name            [16]byte;
        Seg             [16]byte;
-       Addr    uint64;
-       Size    uint64;
-       Offset  uint32;
-       Align   uint32;
-       Reloff  uint32;
-       Nreloc  uint32;
-       Flags   uint32;
+       Addr            uint64;
+       Size            uint64;
+       Offset          uint32;
+       Align           uint32;
+       Reloff          uint32;
+       Nreloc          uint32;
+       Flags           uint32;
        Reserve1        uint32;
        Reserve2        uint32;
        Reserve3        uint32;
@@ -190,20 +197,20 @@ type RegsAMD64 struct {
 }
 
 type intName struct {
-       i uint32;
-       s string;
+       i       uint32;
+       s       string;
 }
 
 func stringName(i uint32, names []intName, goSyntax bool) string {
        for _, n := range names {
                if n.i == i {
                        if goSyntax {
-                               return "macho." + n.s
+                               return "macho." + n.s;
                        }
-                       return n.s
+                       return n.s;
                }
        }
-       return strconv.Uitoa64(uint64(i))
+       return strconv.Uitoa64(uint64(i));
 }
 
 func flagName(i uint32, names []intName, goSyntax bool) string {
@@ -221,10 +228,10 @@ func flagName(i uint32, names []intName, goSyntax bool) string {
                }
        }
        if len(s) == 0 {
-               return "0x" + strconv.Uitob64(uint64(i), 16)
+               return "0x" + strconv.Uitob64(uint64(i), 16);
        }
        if i != 0 {
-               s += "+0x" + strconv.Uitob64(uint64(i), 16)
+               s += "+0x" + strconv.Uitob64(uint64(i), 16);
        }
-       return s
+       return s;
 }
index c67e02fea6503a568b775d61e7c6e737264cfc38..fc56914b1c739bcb72190c32fe35a7dca34e0848 100644 (file)
@@ -13,15 +13,15 @@ package proc
 // and proc_darwin.go do, because deps.bash only looks at
 // this file.
 import (
-       _ "container/vector";
-       _ "fmt";
-       _ "io";
-       "os";
-       _ "runtime";
-       "strconv";
-       _ "strings";
-       _ "sync";
-       _ "syscall";
+       _       "container/vector";
+       _       "fmt";
+       _       "io";
+               "os";
+       _       "runtime";
+               "strconv";
+       _       "strings";
+       _       "sync";
+       _       "syscall";
 )
 
 type Word uint64
@@ -149,7 +149,7 @@ type Process interface {
 // user request (e.g., from the Stop method or after single stepping),
 // or that are stopped because some other thread caused the program to
 // stop.
-type Stopped struct {}
+type Stopped struct{}
 
 func (c Stopped) String() string {
        return "stopped";
@@ -157,7 +157,7 @@ func (c Stopped) String() string {
 
 // Breakpoint is a stop cause resulting from a thread reaching a set
 // breakpoint.
-type Breakpoint        Word
+type Breakpoint Word
 
 // PC returns the program counter that the program is stopped at.
 func (c Breakpoint) PC() Word {
@@ -202,8 +202,8 @@ func (c *ThreadCreate) String() string {
 // process threads and its registers and memory will still be
 // accessible.
 type ThreadExit struct {
-       exitStatus int;
-       signal string;
+       exitStatus      int;
+       signal          string;
 }
 
 // Exited returns true if the thread exited normally.
index 8fb147ddc2cf342de5abab67cb64e054bba30c32..82291be239366490ef4274502f451d632ab5daa5 100644 (file)
@@ -35,9 +35,9 @@ import (
 // as well as experimentation and examination of gdb's behavior.
 
 const (
-       trace = false;
-       traceIP = false;
-       traceMem = false;
+       trace           = false;
+       traceIP         = false;
+       traceMem        = false;
 )
 
 /*
@@ -60,20 +60,20 @@ const (
 //
 // Terminal threads no longer exist in the OS and thus you can't do
 // anything with them.
-type threadState string;
+type threadState string
 
 const (
-       running             threadState = "Running";
-       singleStepping      threadState = "SingleStepping";     // Transient
-       stopping            threadState = "Stopping";   // Transient
-       stopped             threadState = "Stopped";
-       stoppedBreakpoint   threadState = "StoppedBreakpoint";
-       stoppedSignal       threadState = "StoppedSignal";
-       stoppedThreadCreate threadState = "StoppedThreadCreate";
-       stoppedExiting      threadState = "StoppedExiting";
-       exiting             threadState = "Exiting";    // Transient (except main thread)
-       exited              threadState = "Exited";
-       detached            threadState = "Detached";
+       running                 threadState     = "Running";
+       singleStepping          threadState     = "SingleStepping";     // Transient
+       stopping                threadState     = "Stopping";           // Transient
+       stopped                 threadState     = "Stopped";
+       stoppedBreakpoint       threadState     = "StoppedBreakpoint";
+       stoppedSignal           threadState     = "StoppedSignal";
+       stoppedThreadCreate     threadState     = "StoppedThreadCreate";
+       stoppedExiting          threadState     = "StoppedExiting";
+       exiting                 threadState     = "Exiting";    // Transient (except main thread)
+       exited                  threadState     = "Exited";
+       detached                threadState     = "Detached";
 )
 
 func (ts threadState) isRunning() bool {
@@ -104,8 +104,8 @@ func (ts threadState) String() string {
 // including its program counter, the overwritten text if the
 // breakpoint is installed.
 type breakpoint struct {
-       pc uintptr;
-       olddata []byte;
+       pc      uintptr;
+       olddata []byte;
 }
 
 func (bp *breakpoint) String() string {
@@ -116,19 +116,19 @@ func (bp *breakpoint) String() string {
 }
 
 // bpinst386 is the breakpoint instruction used on 386 and amd64.
-var bpinst386 = []byte{0xcc};
+var bpinst386 = []byte{0xcc}
 
 // A debugEvent represents a reason a thread stopped or a wait error.
 type debugEvent struct {
        *os.Waitmsg;
-       t *thread;
-       err os.Error;
+       t       *thread;
+       err     os.Error;
 }
 
 // A debugReq is a request to execute a closure in the monitor thread.
 type debugReq struct {
-       f func () os.Error;
-       res chan os.Error;
+       f       func() os.Error;
+       res     chan os.Error;
 }
 
 // A transitionHandler specifies a function to be called when a thread
@@ -137,8 +137,8 @@ type debugReq struct {
 // invokes a handler, it removes the handler from the handler queue.
 // The handler should re-add itself if needed.
 type transitionHandler struct {
-       handle func (*thread, threadState, threadState);
-       onErr func (os.Error);
+       handle  func(*thread, threadState, threadState);
+       onErr   func(os.Error);
 }
 
 // A process is a Linux process, which consists of a set of threads.
@@ -146,34 +146,34 @@ type transitionHandler struct {
 // messages from the debugEvents, debugReqs, and stopReq channels and
 // calls transition handlers.
 type process struct {
-       pid int;
-       threads map[int] *thread;
-       breakpoints map[uintptr] *breakpoint;
-       debugEvents chan *debugEvent;
-       debugReqs chan *debugReq;
-       stopReq chan os.Error;
-       transitionHandlers *vector.Vector;
+       pid                     int;
+       threads                 map[int]*thread;
+       breakpoints             map[uintptr]*breakpoint;
+       debugEvents             chan *debugEvent;
+       debugReqs               chan *debugReq;
+       stopReq                 chan os.Error;
+       transitionHandlers      *vector.Vector;
 }
 
 // A thread represents a Linux thread in another process that is being
 // debugged.  Each running thread has an associated goroutine that
 // waits for thread updates and sends them to the process monitor.
 type thread struct {
-       tid int;
-       proc *process;
+       tid     int;
+       proc    *process;
        // Whether to ignore the next SIGSTOP received by wait.
-       ignoreNextSigstop bool;
+       ignoreNextSigstop       bool;
 
        // Thread state.  Only modified via setState.
-       state threadState;
+       state   threadState;
        // If state == StoppedBreakpoint
-       breakpoint *breakpoint;
+       breakpoint      *breakpoint;
        // If state == StoppedSignal or state == Exited
-       signal int;
+       signal  int;
        // If state == StoppedThreadCreate
-       newThread *thread;
+       newThread       *thread;
        // If state == Exited
-       exitStatus int;
+       exitStatus      int;
 }
 
 /*
@@ -181,9 +181,9 @@ type thread struct {
  */
 
 type badState struct {
-       thread *thread;
-       message string;
-       state threadState;
+       thread  *thread;
+       message string;
+       state   threadState;
 }
 
 func (e *badState) String() string {
@@ -204,8 +204,8 @@ func (e noBreakpointError) String() string {
 
 type newThreadError struct {
        *os.Waitmsg;
-       wantPid int;
-       wantSig int;
+       wantPid int;
+       wantSig int;
 }
 
 func (e *newThreadError) String() string {
@@ -435,9 +435,9 @@ func (t *thread) wait() {
                        if err == nil {
                                continue;
                        }
-                       // If we failed to continue, just let
-                       // the stop go through so we can
-                       // update the thread's state.
+               // If we failed to continue, just let
+               // the stop go through so we can
+               // update the thread's state.
                }
                t.proc.debugEvents <- &ev;
                break;
@@ -515,7 +515,7 @@ func (ev *debugEvent) doTrap() (threadState, os.Error) {
                return stopped, err;
        }
 
-       b, ok := t.proc.breakpoints[uintptr(regs.PC())-uintptr(len(bpinst386))];
+       b, ok := t.proc.breakpoints[uintptr(regs.PC()) - uintptr(len(bpinst386))];
        if !ok {
                // We must have hit a breakpoint that was actually in
                // the program.  Leave the IP where it is so we don't
@@ -673,13 +673,13 @@ func (ev *debugEvent) process() os.Error {
 // thread.
 //
 // Must be called from the monitor thread.
-func (t *thread) onStop(handle func (), onErr func (os.Error)) {
+func (t *thread) onStop(handle func(), onErr func(os.Error)) {
        // TODO(austin) This is rather inefficient for things like
        // stepping all threads during a continue.  Maybe move
        // transitionHandlers to the thread, or have both per-thread
        // and per-process transition handlers.
        h := &transitionHandler{nil, onErr};
-       h.handle = func (st *thread, old, new threadState) {
+       h.handle = func(st *thread, old, new threadState) {
                if t == st && old.isRunning() && !new.isRunning() {
                        handle();
                } else {
@@ -753,7 +753,7 @@ func (p *process) monitor() {
 // respect to thread state changes).  f must not block.
 //
 // Must NOT be called from the monitor thread.
-func (p *process) do(f func () os.Error) os.Error {
+func (p *process) do(f func() os.Error) os.Error {
        // TODO(austin) If monitor is stopped, return error.
        req := &debugReq{f, make(chan os.Error)};
        p.debugReqs <- req;
@@ -764,7 +764,7 @@ func (p *process) do(f func () os.Error) os.Error {
 // is already stopped, does nothing.
 func (p *process) stopMonitor(err os.Error) {
        _ = p.stopReq <- err;   // do not block
-       // TODO(austin) Wait until monitor has exited?
+// TODO(austin) Wait until monitor has exited?
 }
 
 /*
@@ -774,7 +774,7 @@ func (p *process) stopMonitor(err os.Error) {
 func (t *thread) Regs() (Regs, os.Error) {
        var regs syscall.PtraceRegs;
 
-       err := t.proc.do(func () os.Error {
+       err := t.proc.do(func() os.Error {
                if !t.state.isStopped() {
                        return &badState{t, "cannot get registers", t.state};
                }
@@ -784,8 +784,8 @@ func (t *thread) Regs() (Regs, os.Error) {
                return nil, err;
        }
 
-       setter := func (r *syscall.PtraceRegs) os.Error {
-               return t.proc.do(func () os.Error {
+       setter := func(r *syscall.PtraceRegs) os.Error {
+               return t.proc.do(func() os.Error {
                        if !t.state.isStopped() {
                                return &badState{t, "cannot get registers", t.state};
                        }
@@ -798,7 +798,7 @@ func (t *thread) Regs() (Regs, os.Error) {
 func (t *thread) Peek(addr Word, out []byte) (int, os.Error) {
        var c int;
 
-       err := t.proc.do(func () os.Error {
+       err := t.proc.do(func() os.Error {
                if !t.state.isStopped() {
                        return &badState{t, "cannot peek text", t.state};
                }
@@ -814,7 +814,7 @@ func (t *thread) Peek(addr Word, out []byte) (int, os.Error) {
 func (t *thread) Poke(addr Word, out []byte) (int, os.Error) {
        var c int;
 
-       err := t.proc.do(func () os.Error {
+       err := t.proc.do(func() os.Error {
                if !t.state.isStopped() {
                        return &badState{t, "cannot poke text", t.state};
                }
@@ -837,10 +837,10 @@ func (t *thread) stepAsync(ready chan os.Error) os.Error {
                return err;
        }
        t.setState(singleStepping);
-       t.onStop(func () {
-                       ready <- nil;
-               },
-               func (err os.Error) {
+       t.onStop(func() {
+               ready <- nil;
+       },
+               func(err os.Error) {
                        ready <- err;
                });
        return nil;
@@ -852,7 +852,7 @@ func (t *thread) Step() os.Error {
 
        ready := make(chan os.Error);
 
-       err := t.proc.do(func () os.Error {
+       err := t.proc.do(func() os.Error {
                if !t.state.isStopped() {
                        return &badState{t, "cannot single step", t.state};
                }
@@ -867,14 +867,14 @@ func (t *thread) Step() os.Error {
 }
 
 // TODO(austin) We should probably get this via C's strsignal.
-var sigNames = [...]string {
+var sigNames = [...]string{
        "SIGEXIT", "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
        "SIGTRAP", "SIGABRT", "SIGBUS", "SIGFPE", "SIGKILL",
        "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGPIPE", "SIGALRM",
        "SIGTERM", "SIGSTKFLT", "SIGCHLD", "SIGCONT", "SIGSTOP",
        "SIGTSTP", "SIGTTIN", "SIGTTOU", "SIGURG", "SIGXCPU",
        "SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH", "SIGPOLL",
-       "SIGPWR", "SIGSYS"
+       "SIGPWR", "SIGSYS",
 }
 
 // sigName returns the symbolic name for the given signal number.  If
@@ -924,7 +924,7 @@ func (t *thread) Stopped() (Cause, os.Error) {
 func (p *process) Threads() []Thread {
        var res []Thread;
 
-       p.do(func () os.Error {
+       p.do(func() os.Error {
                res = make([]Thread, len(p.threads));
                i := 0;
                for _, t := range p.threads {
@@ -944,7 +944,7 @@ func (p *process) Threads() []Thread {
 }
 
 func (p *process) AddBreakpoint(pc Word) os.Error {
-       return p.do(func () os.Error {
+       return p.do(func() os.Error {
                if t := p.someRunningThread(); t != nil {
                        return &badState{t, "cannot add breakpoint", t.state};
                }
@@ -957,7 +957,7 @@ func (p *process) AddBreakpoint(pc Word) os.Error {
 }
 
 func (p *process) RemoveBreakpoint(pc Word) os.Error {
-       return p.do(func () os.Error {
+       return p.do(func() os.Error {
                if t := p.someRunningThread(); t != nil {
                        return &badState{t, "cannot remove breakpoint", t.state};
                }
@@ -975,7 +975,7 @@ func (p *process) Continue() os.Error {
        var ready chan os.Error;
        count := 0;
 
-       err := p.do(func () os.Error {
+       err := p.do(func() os.Error {
                // We make the ready channel big enough to hold all
                // ready message so we don't jam up the monitor if we
                // stop listening (e.g., if there's an error).
@@ -1022,7 +1022,7 @@ func (p *process) Continue() os.Error {
        }
 
        // Continue all threads
-       err = p.do(func () os.Error {
+       err = p.do(func() os.Error {
                if err := p.installBreakpoints(); err != nil {
                        return err;
                }
@@ -1067,7 +1067,7 @@ func (p *process) WaitStop() os.Error {
        // threads are already stopped.
        ready := make(chan os.Error, 1);
 
-       err := p.do(func () os.Error {
+       err := p.do(func() os.Error {
                // Are all of the threads already stopped?
                if p.someRunningThread() == nil {
                        ready <- nil;
@@ -1076,7 +1076,7 @@ func (p *process) WaitStop() os.Error {
 
                // Monitor state transitions
                h := &transitionHandler{};
-               h.handle = func (st *thread, old, new threadState) {
+               h.handle = func(st *thread, old, new threadState) {
                        if !new.isRunning() {
                                if p.someRunningThread() == nil {
                                        ready <- nil;
@@ -1085,7 +1085,7 @@ func (p *process) WaitStop() os.Error {
                        }
                        p.transitionHandlers.Push(h);
                };
-               h.onErr = func (err os.Error) {
+               h.onErr = func(err os.Error) {
                        ready <- err;
                };
                p.transitionHandlers.Push(h);
@@ -1099,7 +1099,7 @@ func (p *process) WaitStop() os.Error {
 }
 
 func (p *process) Stop() os.Error {
-       err := p.do(func () os.Error {
+       err := p.do(func() os.Error {
                return p.stopAsync();
        });
        if err != nil {
@@ -1114,7 +1114,7 @@ func (p *process) Detach() os.Error {
                return err;
        }
 
-       err := p.do(func () os.Error {
+       err := p.do(func() os.Error {
                if err := p.uninstallBreakpoints(); err != nil {
                        return err;
                }
@@ -1171,7 +1171,7 @@ func (p *process) newThread(tid int, signal int, cloned bool) (*thread, os.Error
 func (p *process) attachThread(tid int) (*thread, os.Error) {
        p.logTrace("attaching to thread %d", tid);
        var thr *thread;
-       err := p.do(func () os.Error {
+       err := p.do(func() os.Error {
                errno := syscall.PtraceAttach(tid);
                if errno != 0 {
                        return os.NewSyscallError("ptrace(ATTACH)", errno);
@@ -1253,12 +1253,12 @@ func (p *process) attachAllThreads() os.Error {
 func newProcess(pid int) *process {
        p := &process{
                pid: pid,
-               threads: make(map[int] *thread),
-               breakpoints: make(map[uintptr] *breakpoint),
+               threads: make(map[int]*thread),
+               breakpoints: make(map[uintptr]*breakpoint),
                debugEvents: make(chan *debugEvent),
                debugReqs: make(chan *debugReq),
                stopReq: make(chan os.Error),
-               transitionHandlers: vector.New(0)
+               transitionHandlers: vector.New(0),
        };
 
        go p.monitor();
@@ -1285,8 +1285,7 @@ func Attach(pid int) (Process, os.Error) {
 // ForkExec forks the current process and execs argv0, stopping the
 // new process after the exec syscall.  See os.ForkExec for additional
 // details.
-func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.File) (Process, os.Error)
-{
+func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.File) (Process, os.Error) {
        p := newProcess(-1);
 
        // Create array of integer (system) fds.
@@ -1300,7 +1299,7 @@ func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.F
        }
 
        // Fork from the monitor thread so we get the right tracer pid.
-       err := p.do(func () os.Error {
+       err := p.do(func() os.Error {
                pid, errno := syscall.PtraceForkExec(argv0, argv, envv, dir, intfd);
                if errno != 0 {
                        return &os.PathError{"fork/exec", argv0, os.Errno(errno)};
index c4f6067393a5bd361f5abb2f31a33641817293c7..6942209a6b47c2f4ec28933ca4c10c77a5781768 100644 (file)
@@ -12,9 +12,9 @@ import (
 // Process tracing is not supported on Native Client.
 
 func Attach(pid int) (Process, os.Error) {
-       return nil, os.NewSyscallError("ptrace", syscall.ENACL)
+       return nil, os.NewSyscallError("ptrace", syscall.ENACL);
 }
 
 func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.File) (Process, os.Error) {
-       return nil, os.NewSyscallError("fork/exec", syscall.ENACL)
+       return nil, os.NewSyscallError("fork/exec", syscall.ENACL);
 }
index e171f72a95bb9125f2aca7b739fd1a1f26dc219f..60c9ac719e90a13f9b53cedc41905ea8ba26836c 100644 (file)
@@ -3,4 +3,3 @@
 // license that can be found in the LICENSE file.
 
 package proc
-
index 725223ccda8b210976e00fd89b5de1d27c205e8a..496fbc3375f975b5c901ab04aa407f1111346848 100644 (file)
@@ -12,10 +12,10 @@ import (
 
 type _386Regs struct {
        syscall.PtraceRegs;
-       setter func (*syscall.PtraceRegs) os.Error;
+       setter  func(*syscall.PtraceRegs) os.Error;
 }
 
-var names = [...]string {
+var names = [...]string{
        "eax",
        "ebx",
        "ecx",
@@ -67,51 +67,83 @@ func (r *_386Regs) Names() []string {
 
 func (r *_386Regs) Get(i int) Word {
        switch i {
-       case 0: return Word(uint32(r.Eax));
-       case 1: return Word(uint32(r.Ebx));
-       case 2: return Word(uint32(r.Ecx));
-       case 3: return Word(uint32(r.Edx));
-       case 4: return Word(uint32(r.Esi));
-       case 5: return Word(uint32(r.Edi));
-       case 6: return Word(uint32(r.Ebp));
-       case 7: return Word(uint32(r.Esp));
-       case 8: return Word(uint32(r.Eip));
-       case 9: return Word(uint32(r.Eflags));
-       case 10: return Word(r.Cs);
-       case 11: return Word(r.Ss);
-       case 12: return Word(r.Ds);
-       case 13: return Word(r.Es);
-       case 14: return Word(r.Fs);
-       case 15: return Word(r.Gs);
+       case 0:
+               return Word(uint32(r.Eax));
+       case 1:
+               return Word(uint32(r.Ebx));
+       case 2:
+               return Word(uint32(r.Ecx));
+       case 3:
+               return Word(uint32(r.Edx));
+       case 4:
+               return Word(uint32(r.Esi));
+       case 5:
+               return Word(uint32(r.Edi));
+       case 6:
+               return Word(uint32(r.Ebp));
+       case 7:
+               return Word(uint32(r.Esp));
+       case 8:
+               return Word(uint32(r.Eip));
+       case 9:
+               return Word(uint32(r.Eflags));
+       case 10:
+               return Word(r.Cs);
+       case 11:
+               return Word(r.Ss);
+       case 12:
+               return Word(r.Ds);
+       case 13:
+               return Word(r.Es);
+       case 14:
+               return Word(r.Fs);
+       case 15:
+               return Word(r.Gs);
        }
        panic("invalid register index ", strconv.Itoa(i));
 }
 
 func (r *_386Regs) Set(i int, val Word) os.Error {
        switch i {
-       case 0: r.Eax = int32(val);
-       case 1: r.Ebx = int32(val);
-       case 2: r.Ecx = int32(val);
-       case 3: r.Edx = int32(val);
-       case 4: r.Esi = int32(val);
-       case 5: r.Edi = int32(val);
-       case 6: r.Ebp = int32(val);
-       case 7: r.Esp = int32(val);
-       case 8: r.Eip = int32(val);
-       case 9: r.Eflags = int32(val);
-       case 10: r.Cs = uint16(val);
-       case 11: r.Ss = uint16(val);
-       case 12: r.Ds = uint16(val);
-       case 13: r.Es = uint16(val);
-       case 14: r.Fs = uint16(val);
-       case 15: r.Gs = uint16(val);
+       case 0:
+               r.Eax = int32(val);
+       case 1:
+               r.Ebx = int32(val);
+       case 2:
+               r.Ecx = int32(val);
+       case 3:
+               r.Edx = int32(val);
+       case 4:
+               r.Esi = int32(val);
+       case 5:
+               r.Edi = int32(val);
+       case 6:
+               r.Ebp = int32(val);
+       case 7:
+               r.Esp = int32(val);
+       case 8:
+               r.Eip = int32(val);
+       case 9:
+               r.Eflags = int32(val);
+       case 10:
+               r.Cs = uint16(val);
+       case 11:
+               r.Ss = uint16(val);
+       case 12:
+               r.Ds = uint16(val);
+       case 13:
+               r.Es = uint16(val);
+       case 14:
+               r.Fs = uint16(val);
+       case 15:
+               r.Gs = uint16(val);
        default:
                panic("invalid register index ", strconv.Itoa(i));
        }
        return r.setter(&r.PtraceRegs);
 }
 
-func newRegs(regs *syscall.PtraceRegs, setter func (*syscall.PtraceRegs) os.Error) Regs {
+func newRegs(regs *syscall.PtraceRegs, setter func(*syscall.PtraceRegs) os.Error) Regs {
        res := _386Regs{};
        res.PtraceRegs = *regs;
        res.setter = setter;
index e171f72a95bb9125f2aca7b739fd1a1f26dc219f..60c9ac719e90a13f9b53cedc41905ea8ba26836c 100644 (file)
@@ -3,4 +3,3 @@
 // license that can be found in the LICENSE file.
 
 package proc
-