1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CRAZY_LINKER_GNU_HASH_TABLE_TEST_DATA_H
6 #define CRAZY_LINKER_GNU_HASH_TABLE_TEST_DATA_H
7 
8 // clang-format off
9 // BEGIN_AUTO_GENERATED [generate_test_gnu_hash_tables.py] DO NOT EDIT!!
10 //
11 
12 namespace crazy {
13 namespace testing {
14 
15 // GNU hash table: num_buckets=4 bloom_size=2 bloom_shift=5
16 //
17 // idx symbol               hash      bucket  bloom32  bloom64  chain
18 //
19 //   0 ST_UNDEF
20 //   1 cfsetispeed          830acc54  0       0:20:02  1:20:34  830acc54
21 //   2 strsigna             90f1e4b0  0       1:16:05  0:48:37  90f1e4b0
22 //   3 hcreate_             4c7e3240  0       0:00:18  1:00:18  4c7e3240
23 //   4 endrpcen             b6c44714  0       0:20:24  0:20:56  b6c44715
24 //   5 uselib               2124d3e9  1       1:09:31  1:41:31  2124d3e8
25 //   6 gettyen              f07bdd25  1       1:05:09  0:37:41  f07bdd24
26 //   7 umoun                1081e019  1       0:25:00  0:25:00  1081e019
27 //   8 freelocal            e3364372  2       1:18:27  1:50:27  e3364372
28 //   9 listxatt             ced3d862  2       1:02:03  1:34:03  ced3d862
29 //  10 isnan                0fabfd7e  2       1:30:11  1:62:43  0fabfd7e
30 //  11 isinf                0fabe9de  2       0:30:14  1:30:14  0fabe9de
31 //  12 setrlimi             12e23bae  2       1:14:29  0:46:29  12e23baf
32 //  13 getspen              f07b2a7b  3       1:27:19  1:59:19  f07b2a7a
33 //  14 pthread_mutex_lock   4f152227  3       1:07:17  0:39:17  4f152226
34 //  15 getopt_long_onl      57b1584f  3       0:15:02  1:15:02  57b1584f
35 //
36 // Buckets: 1, 5, 8, 13
37 //
38 // Bloom filter (32 bits):
39 // bit#       24       16        8        0
40 //      .x....xx ...x.x.. xx...... .....x.x
41 //      xxx.x... ....xxxx .x..x.x. x.x.xx..
42 //
43 //   also as:  0x4314c005 0xe80f4aac
44 //
45 // Bloom filter (64 bits):
46 // bit#       56       48       40       32       24       16        8        0
47 //      .......x .......x .x....x. x.x..... ..x...x. ...x..x. ........ .......x
48 //      .x..x... .....x.. ....x.x. .....x.. xx..x... ...xxx.. xx...... ....xx.x
49 //
50 //   also as:  0x010142a022120001 0x48040a04c81cc00d
51 //
52 static const char kTestGnuStringTable[145] = {
53     '\0','c','f','s','e','t','i','s','p','e','e','d','\0','s','t','r','s','i',
54     'g','n','a','\0','h','c','r','e','a','t','e','_','\0','e','n','d','r','p',
55     'c','e','n','\0','u','s','e','l','i','b','\0','g','e','t','t','y','e','n',
56     '\0','u','m','o','u','n','\0','f','r','e','e','l','o','c','a','l','\0','l',
57     'i','s','t','x','a','t','t','\0','i','s','n','a','n','\0','i','s','i','n',
58     'f','\0','s','e','t','r','l','i','m','i','\0','g','e','t','s','p','e','n',
59     '\0','p','t','h','r','e','a','d','_','m','u','t','e','x','_','l','o','c',
60     'k','\0','g','e','t','o','p','t','_','l','o','n','g','_','o','n','l','\0',
61     '\0'};
62 
63 // Auto-generated macro used to list all symbols
64 // XX must be a macro that takes the following parameters:
65 //   name: symbol name (quoted).
66 //   str_offset: symbol name offset in string table
67 //   address: virtual address.
68 //   size: size in bytes
69 #define LIST_ELF_SYMBOLS_TestGnu(XX) \
70     XX("cfsetispeed", 1, 0x10000, 16) \
71     XX("strsigna", 13, 0x10020, 16) \
72     XX("hcreate_", 22, 0x10040, 16) \
73     XX("endrpcen", 31, 0x10060, 16) \
74     XX("uselib", 40, 0x10080, 16) \
75     XX("gettyen", 47, 0x100a0, 16) \
76     XX("umoun", 55, 0x100c0, 16) \
77     XX("freelocal", 61, 0x100e0, 16) \
78     XX("listxatt", 71, 0x10100, 16) \
79     XX("isnan", 80, 0x10120, 16) \
80     XX("isinf", 86, 0x10140, 16) \
81     XX("setrlimi", 92, 0x10160, 16) \
82     XX("getspen", 101, 0x10180, 16) \
83     XX("pthread_mutex_lock", 109, 0x101a0, 16) \
84     XX("getopt_long_onl", 128, 0x101c0, 16) \
85     // END OF LIST
86 
87 // NOTE: ELF32_Sym and ELF64_Sym have very different layout.
88 #if UINTPTR_MAX == UINT32_MAX  // ELF32_Sym
89 #  define DEFINE_ELF_SYMBOL(name, name_offset, address, size) \
90     { (name_offset), (address), (size), ELF_ST_INFO(STB_GLOBAL, STT_FUNC), \
91       0 /* other */, 1 /* shndx */ },
92 #else  // ELF64_Sym
93 #  define DEFINE_ELF_SYMBOL(name, name_offset, address, size) \
94     { (name_offset), ELF_ST_INFO(STB_GLOBAL, STT_FUNC), \
95       0 /* other */, 1 /* shndx */, (address), (size) },
96 #endif  // !ELF64_Sym
97 static const ELF::Sym kTestGnuSymbolTable[] = {
98     { 0 },  // ST_UNDEF
99     LIST_ELF_SYMBOLS_TestGnu(DEFINE_ELF_SYMBOL)
100 };
101 #undef DEFINE_ELF_SYMBOL
102 
103 static const uint32_t kTestGnuHashTable[] = {
104     4,  // num_buckets
105     1,  // sym_offset
106     2,  // bloom_size
107     5,  // bloom_shift
108     // Bloom filter words
109 #if UINTPTR_MAX == UINT32_MAX  // 32-bit bloom filter words
110     0x4314c005, 0xe80f4aac,
111 #else  // 64-bits filter bloom words (assumes little-endianess)
112     0x22120001, 0x010142a0, 0xc81cc00d, 0x48040a04,
113 #endif  // bloom filter words
114     // Buckets
115     0x00000001, 0x00000005, 0x00000008, 0x0000000d,
116     // Chain
117     0x830acc54, 0x90f1e4b0, 0x4c7e3240, 0xb6c44715, 0x2124d3e8, 0xf07bdd24,
118     0x1081e019, 0xe3364372, 0xced3d862, 0x0fabfd7e, 0x0fabe9de, 0x12e23baf,
119     0xf07b2a7a, 0x4f152226, 0x57b1584f,
120 };
121 
122 }  // namespace testing
123 }  // namespace crazy
124 
125 // END_AUTO_GENERATED_CODE [generate_test_gnu_hash_tables.py]
126 // clang-format on
127 
128 #endif  // CRAZY_LINKER_GNU_HASH_TABLE_TEST_DATA_H
129