Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: crosstest/test_global.cpp

Issue 667763002: Fix handling of relocation names, so that prefix mangling works. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « crosstest/test_calling_conv_main.cpp ('k') | src/IceCfg.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/crosstest/test_global.cpp - Global variable access tests ---===// 1 //===- subzero/crosstest/test_global.cpp - Global variable access tests ---===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // Implementation for crosstesting global variable access operations. 10 // Implementation for crosstesting global variable access operations.
(...skipping 13 matching lines...) Expand all
24 extern uint8_t *ExternName3; 24 extern uint8_t *ExternName3;
25 extern uint8_t *ExternName4; 25 extern uint8_t *ExternName4;
26 extern uint8_t *ExternName5; 26 extern uint8_t *ExternName5;
27 27
28 // Partially initialized array 28 // Partially initialized array
29 int ArrayInitPartial[10] = {60, 70, 80, 90, 100}; 29 int ArrayInitPartial[10] = {60, 70, 80, 90, 100};
30 int ArrayInitFull[] = {10, 20, 30, 40, 50}; 30 int ArrayInitFull[] = {10, 20, 30, 40, 50};
31 const int ArrayConst[] = {-10, -20, -30}; 31 const int ArrayConst[] = {-10, -20, -30};
32 static double ArrayDouble[10] = { 0.5, 1.5, 2.5, 3.5 }; 32 static double ArrayDouble[10] = { 0.5, 1.5, 2.5, 3.5 };
33 33
34 #if 0
35 // TODO(kschimpf) Add this example once we know how to not mangle
36 // uninitialized, external globals (so that we can compare that
37 // the same, unmangled relocations are used). See comment in
38 // TargetGlobalInitX8632::lower in IceTargetLoweringX8632.cpp for
39 // details.
40 static struct { 34 static struct {
41 int Array1[5]; 35 int Array1[5];
42 uint8_t *Pointer1; 36 uint8_t *Pointer1;
43 double Array2[3]; 37 double Array2[3];
44 uint8_t *Pointer2; 38 uint8_t *Pointer2;
45 struct { 39 struct {
46 uint8_t *Pointer3; 40 uint8_t *Pointer3;
47 int Array1[3]; 41 int Array1[3];
48 uint8_t *Pointer4; 42 uint8_t *Pointer4;
49 } NestedStuff; 43 } NestedStuff;
50 uint8_t *Pointer5; 44 uint8_t *Pointer5;
51 } StructEx = { 45 } StructEx = {
52 { 10, 20, 30, 40, 50 }, 46 { 10, 20, 30, 40, 50 },
53 ExternName1, 47 ExternName1,
54 { 0.5, 1.5, 2.5 }, 48 { 0.5, 1.5, 2.5 },
55 ExternName4, 49 ExternName4,
56 { ExternName3, {1000, 1010, 1020}, ExternName2 }, 50 { ExternName3, {1000, 1010, 1020}, ExternName2 },
57 ExternName5, 51 ExternName5,
58 }; 52 };
59 #endif
60 53
61 #define ARRAY(a) \ 54 #define ARRAY(a) \
62 { (uint8_t *)(a), sizeof(a) } 55 { (uint8_t *)(a), sizeof(a) }
63 56
64 // Note: By embedding the array addresses in this table, we are indirectly 57 // Note: By embedding the array addresses in this table, we are indirectly
65 // testing relocations (i.e. getArray would return the wrong address if 58 // testing relocations (i.e. getArray would return the wrong address if
66 // relocations are broken). 59 // relocations are broken).
67 struct { 60 struct {
68 uint8_t *ArrayAddress; 61 uint8_t *ArrayAddress;
69 size_t ArraySizeInBytes; 62 size_t ArraySizeInBytes;
70 } Arrays[] = { 63 } Arrays[] = {
71 ARRAY(ArrayInitPartial), 64 ARRAY(ArrayInitPartial),
72 ARRAY(ArrayInitFull), 65 ARRAY(ArrayInitFull),
73 ARRAY(ArrayConst), 66 ARRAY(ArrayConst),
74 ARRAY(ArrayDouble), 67 ARRAY(ArrayDouble),
75 {(uint8_t *)(ArrayInitPartial + 2), 68 {(uint8_t *)(ArrayInitPartial + 2),
76 sizeof(ArrayInitPartial) - 2 * sizeof(int)}, 69 sizeof(ArrayInitPartial) - 2 * sizeof(int)},
77 // { (uint8_t*)(&StructEx), sizeof(StructEx) }, 70 { (uint8_t*)(&StructEx), sizeof(StructEx) },
78 }; 71 };
79 size_t NumArraysElements = sizeof(Arrays) / sizeof(*Arrays); 72 size_t NumArraysElements = sizeof(Arrays) / sizeof(*Arrays);
80 73
81 size_t getNumArrays() { return NumArraysElements; } 74 size_t getNumArrays() { return NumArraysElements; }
82 75
83 const uint8_t *getArray(size_t WhichArray, size_t &Len) { 76 const uint8_t *getArray(size_t WhichArray, size_t &Len) {
84 if (WhichArray >= NumArraysElements) { 77 if (WhichArray >= NumArraysElements) {
85 Len = -1; 78 Len = -1;
86 return NULL; 79 return NULL;
87 } 80 }
88 Len = Arrays[WhichArray].ArraySizeInBytes; 81 Len = Arrays[WhichArray].ArraySizeInBytes;
89 return Arrays[WhichArray].ArrayAddress; 82 return Arrays[WhichArray].ArrayAddress;
90 } 83 }
OLDNEW
« no previous file with comments | « crosstest/test_calling_conv_main.cpp ('k') | src/IceCfg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698