1*b9411a12SAndroid Build Coastguard WorkerThis patch contains our local modifications for gcov-io.h and libgcov.c. 2*b9411a12SAndroid Build Coastguard WorkerThe file gcov-iov.h is taken from a gcc build (produced at compile 3*b9411a12SAndroid Build Coastguard Workertime). The file gcov-io.c is unchanged. 4*b9411a12SAndroid Build Coastguard Worker 5*b9411a12SAndroid Build Coastguard Worker--- gcc-4.7.2/gcc/gcov-io.h 2011-12-04 10:27:19.000000000 -0800 6*b9411a12SAndroid Build Coastguard Worker+++ coreboot/src/lib/gcov-io.h 2013-01-12 16:45:57.000000000 -0800 7*b9411a12SAndroid Build Coastguard Worker@@ -163,6 +163,24 @@ 8*b9411a12SAndroid Build Coastguard Worker #ifndef GCC_GCOV_IO_H 9*b9411a12SAndroid Build Coastguard Worker #define GCC_GCOV_IO_H 10*b9411a12SAndroid Build Coastguard Worker 11*b9411a12SAndroid Build Coastguard Worker+#ifdef __COREBOOT__ 12*b9411a12SAndroid Build Coastguard Worker+#define GCOV_LINKAGE /* nothing */ 13*b9411a12SAndroid Build Coastguard Worker+/* We need the definitions for 14*b9411a12SAndroid Build Coastguard Worker+ BITS_PER_UNIT and 15*b9411a12SAndroid Build Coastguard Worker+ LONG_LONG_TYPE_SIZE 16*b9411a12SAndroid Build Coastguard Worker+ They are defined in gcc/defaults.h and gcc/config/<arch_depend_files> 17*b9411a12SAndroid Build Coastguard Worker+ (like, gcc/config/i386/i386.h). And it can be overridden by setting 18*b9411a12SAndroid Build Coastguard Worker+ in build scripts. Here I hardcoded the value for x86. */ 19*b9411a12SAndroid Build Coastguard Worker+#define BITS_PER_UNIT 8 20*b9411a12SAndroid Build Coastguard Worker+#define LONG_LONG_TYPE_SIZE 64 21*b9411a12SAndroid Build Coastguard Worker+ 22*b9411a12SAndroid Build Coastguard Worker+/* There are many gcc_assertions. Set the value to 1 if we want a warning 23*b9411a12SAndroid Build Coastguard Worker+ message if the assertion fails. */ 24*b9411a12SAndroid Build Coastguard Worker+#ifndef ENABLE_ASSERT_CHECKING 25*b9411a12SAndroid Build Coastguard Worker+#define ENABLE_ASSERT_CHECKING 1 26*b9411a12SAndroid Build Coastguard Worker+#endif 27*b9411a12SAndroid Build Coastguard Worker+#endif /* __COREBOOT__ */ 28*b9411a12SAndroid Build Coastguard Worker+ 29*b9411a12SAndroid Build Coastguard Worker #if IN_LIBGCOV 30*b9411a12SAndroid Build Coastguard Worker /* About the target */ 31*b9411a12SAndroid Build Coastguard Worker 32*b9411a12SAndroid Build Coastguard Worker@@ -232,7 +250,9 @@ 33*b9411a12SAndroid Build Coastguard Worker is not also used in a DSO. */ 34*b9411a12SAndroid Build Coastguard Worker #if IN_LIBGCOV 35*b9411a12SAndroid Build Coastguard Worker 36*b9411a12SAndroid Build Coastguard Worker+#ifndef __COREBOOT__ 37*b9411a12SAndroid Build Coastguard Worker #include "tconfig.h" 38*b9411a12SAndroid Build Coastguard Worker+#endif /* __COREBOOT__ */ 39*b9411a12SAndroid Build Coastguard Worker 40*b9411a12SAndroid Build Coastguard Worker #define gcov_var __gcov_var 41*b9411a12SAndroid Build Coastguard Worker #define gcov_open __gcov_open 42*b9411a12SAndroid Build Coastguard Worker@@ -455,8 +475,10 @@ 43*b9411a12SAndroid Build Coastguard Worker /* Register a new object file module. */ 44*b9411a12SAndroid Build Coastguard Worker extern void __gcov_init (struct gcov_info *) ATTRIBUTE_HIDDEN; 45*b9411a12SAndroid Build Coastguard Worker 46*b9411a12SAndroid Build Coastguard Worker+#ifndef __COREBOOT__ 47*b9411a12SAndroid Build Coastguard Worker /* Called before fork, to avoid double counting. */ 48*b9411a12SAndroid Build Coastguard Worker extern void __gcov_flush (void) ATTRIBUTE_HIDDEN; 49*b9411a12SAndroid Build Coastguard Worker+#endif 50*b9411a12SAndroid Build Coastguard Worker 51*b9411a12SAndroid Build Coastguard Worker /* The merge function that just sums the counters. */ 52*b9411a12SAndroid Build Coastguard Worker extern void __gcov_merge_add (gcov_type *, unsigned) ATTRIBUTE_HIDDEN; 53*b9411a12SAndroid Build Coastguard Worker--- gcc-4.7.2/libgcc/libgcov.c 2012-01-11 10:50:21.000000000 -0800 54*b9411a12SAndroid Build Coastguard Worker+++ coreboot/src/lib/libgcov.c 2013-01-16 09:45:11.000000000 -0800 55*b9411a12SAndroid Build Coastguard Worker@@ -25,12 +25,41 @@ 56*b9411a12SAndroid Build Coastguard Worker see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 57*b9411a12SAndroid Build Coastguard Worker <http://www.gnu.org/licenses/>. */ 58*b9411a12SAndroid Build Coastguard Worker 59*b9411a12SAndroid Build Coastguard Worker+#define __COREBOOT__ 60*b9411a12SAndroid Build Coastguard Worker+#ifdef __COREBOOT__ 61*b9411a12SAndroid Build Coastguard Worker+#include <stdlib.h> 62*b9411a12SAndroid Build Coastguard Worker+#include <string.h> 63*b9411a12SAndroid Build Coastguard Worker+#include <console/console.h> 64*b9411a12SAndroid Build Coastguard Worker+#include <assert.h> 65*b9411a12SAndroid Build Coastguard Worker+typedef s32 pid_t; 66*b9411a12SAndroid Build Coastguard Worker+#define gcc_assert(x) ASSERT(x) 67*b9411a12SAndroid Build Coastguard Worker+#define fprintf(file, x...) printk(BIOS_ERR, x) 68*b9411a12SAndroid Build Coastguard Worker+#define alloca(size) __builtin_alloca (size) 69*b9411a12SAndroid Build Coastguard Worker+#include "gcov-glue.c" 70*b9411a12SAndroid Build Coastguard Worker+ 71*b9411a12SAndroid Build Coastguard Worker+/* Define MACROs to be used by coreboot compilation. */ 72*b9411a12SAndroid Build Coastguard Worker+# define L_gcov 73*b9411a12SAndroid Build Coastguard Worker+# define L_gcov_interval_profiler 74*b9411a12SAndroid Build Coastguard Worker+# define L_gcov_pow2_profiler 75*b9411a12SAndroid Build Coastguard Worker+# define L_gcov_one_value_profiler 76*b9411a12SAndroid Build Coastguard Worker+# define L_gcov_indirect_call_profiler 77*b9411a12SAndroid Build Coastguard Worker+# define L_gcov_average_profiler 78*b9411a12SAndroid Build Coastguard Worker+# define L_gcov_ior_profiler 79*b9411a12SAndroid Build Coastguard Worker+ 80*b9411a12SAndroid Build Coastguard Worker+# define HAVE_CC_TLS 0 81*b9411a12SAndroid Build Coastguard Worker+# define __GCOV_KERNEL__ 82*b9411a12SAndroid Build Coastguard Worker+ 83*b9411a12SAndroid Build Coastguard Worker+# define IN_LIBGCOV 1 84*b9411a12SAndroid Build Coastguard Worker+# define IN_GCOV 0 85*b9411a12SAndroid Build Coastguard Worker+#else /* __COREBOOT__ */ 86*b9411a12SAndroid Build Coastguard Worker #include "tconfig.h" 87*b9411a12SAndroid Build Coastguard Worker #include "tsystem.h" 88*b9411a12SAndroid Build Coastguard Worker #include "coretypes.h" 89*b9411a12SAndroid Build Coastguard Worker #include "tm.h" 90*b9411a12SAndroid Build Coastguard Worker #include "libgcc_tm.h" 91*b9411a12SAndroid Build Coastguard Worker+#endif /* __COREBOOT__ */ 92*b9411a12SAndroid Build Coastguard Worker 93*b9411a12SAndroid Build Coastguard Worker+#ifndef __COREBOOT__ 94*b9411a12SAndroid Build Coastguard Worker #if defined(inhibit_libc) 95*b9411a12SAndroid Build Coastguard Worker #define IN_LIBGCOV (-1) 96*b9411a12SAndroid Build Coastguard Worker #else 97*b9411a12SAndroid Build Coastguard Worker@@ -41,6 +70,7 @@ 98*b9411a12SAndroid Build Coastguard Worker #define GCOV_LINKAGE /* nothing */ 99*b9411a12SAndroid Build Coastguard Worker #endif 100*b9411a12SAndroid Build Coastguard Worker #endif 101*b9411a12SAndroid Build Coastguard Worker+#endif /* __COREBOOT__ */ 102*b9411a12SAndroid Build Coastguard Worker #include "gcov-io.h" 103*b9411a12SAndroid Build Coastguard Worker 104*b9411a12SAndroid Build Coastguard Worker #if defined(inhibit_libc) 105*b9411a12SAndroid Build Coastguard Worker@@ -68,12 +98,17 @@ 106*b9411a12SAndroid Build Coastguard Worker 107*b9411a12SAndroid Build Coastguard Worker #else 108*b9411a12SAndroid Build Coastguard Worker 109*b9411a12SAndroid Build Coastguard Worker+#ifndef __COREBOOT__ 110*b9411a12SAndroid Build Coastguard Worker #include <string.h> 111*b9411a12SAndroid Build Coastguard Worker #if GCOV_LOCKED 112*b9411a12SAndroid Build Coastguard Worker #include <fcntl.h> 113*b9411a12SAndroid Build Coastguard Worker #include <errno.h> 114*b9411a12SAndroid Build Coastguard Worker #include <sys/stat.h> 115*b9411a12SAndroid Build Coastguard Worker #endif 116*b9411a12SAndroid Build Coastguard Worker+#else 117*b9411a12SAndroid Build Coastguard Worker+void __gcov_merge_add(gcov_type *counters __attribute__ ((unused)), 118*b9411a12SAndroid Build Coastguard Worker+ unsigned n_counters __attribute__ ((unused))) {} 119*b9411a12SAndroid Build Coastguard Worker+#endif /* __COREBOOT__ */ 120*b9411a12SAndroid Build Coastguard Worker 121*b9411a12SAndroid Build Coastguard Worker #ifdef L_gcov 122*b9411a12SAndroid Build Coastguard Worker #include "gcov-io.c" 123*b9411a12SAndroid Build Coastguard Worker@@ -99,6 +134,10 @@ 124*b9411a12SAndroid Build Coastguard Worker static int 125*b9411a12SAndroid Build Coastguard Worker create_file_directory (char *filename) 126*b9411a12SAndroid Build Coastguard Worker { 127*b9411a12SAndroid Build Coastguard Worker+#ifdef __COREBOOT__ 128*b9411a12SAndroid Build Coastguard Worker+ (void) filename; 129*b9411a12SAndroid Build Coastguard Worker+ return 0; 130*b9411a12SAndroid Build Coastguard Worker+#else 131*b9411a12SAndroid Build Coastguard Worker #if !defined(TARGET_POSIX_IO) && !defined(_WIN32) 132*b9411a12SAndroid Build Coastguard Worker (void) filename; 133*b9411a12SAndroid Build Coastguard Worker return -1; 134*b9411a12SAndroid Build Coastguard Worker@@ -137,6 +176,7 @@ 135*b9411a12SAndroid Build Coastguard Worker }; 136*b9411a12SAndroid Build Coastguard Worker return 0; 137*b9411a12SAndroid Build Coastguard Worker #endif 138*b9411a12SAndroid Build Coastguard Worker+#endif 139*b9411a12SAndroid Build Coastguard Worker } 140*b9411a12SAndroid Build Coastguard Worker 141*b9411a12SAndroid Build Coastguard Worker static struct gcov_fn_buffer * 142*b9411a12SAndroid Build Coastguard Worker@@ -279,7 +319,7 @@ 143*b9411a12SAndroid Build Coastguard Worker struct gcov_ctr_summary *cs_ptr; 144*b9411a12SAndroid Build Coastguard Worker const struct gcov_ctr_info *ci_ptr; 145*b9411a12SAndroid Build Coastguard Worker unsigned t_ix; 146*b9411a12SAndroid Build Coastguard Worker- int f_ix; 147*b9411a12SAndroid Build Coastguard Worker+ int f_ix = 0; 148*b9411a12SAndroid Build Coastguard Worker gcov_unsigned_t c_num; 149*b9411a12SAndroid Build Coastguard Worker const char *gcov_prefix; 150*b9411a12SAndroid Build Coastguard Worker int gcov_prefix_strip = 0; 151*b9411a12SAndroid Build Coastguard Worker@@ -329,6 +369,7 @@ 152*b9411a12SAndroid Build Coastguard Worker } 153*b9411a12SAndroid Build Coastguard Worker } 154*b9411a12SAndroid Build Coastguard Worker 155*b9411a12SAndroid Build Coastguard Worker+#ifndef __COREBOOT__ 156*b9411a12SAndroid Build Coastguard Worker { 157*b9411a12SAndroid Build Coastguard Worker /* Check if the level of dirs to strip off specified. */ 158*b9411a12SAndroid Build Coastguard Worker char *tmp = getenv("GCOV_PREFIX_STRIP"); 159*b9411a12SAndroid Build Coastguard Worker@@ -352,6 +393,7 @@ 160*b9411a12SAndroid Build Coastguard Worker prefix_length--; 161*b9411a12SAndroid Build Coastguard Worker } 162*b9411a12SAndroid Build Coastguard Worker else 163*b9411a12SAndroid Build Coastguard Worker+#endif 164*b9411a12SAndroid Build Coastguard Worker prefix_length = 0; 165*b9411a12SAndroid Build Coastguard Worker 166*b9411a12SAndroid Build Coastguard Worker /* If no prefix was specified and a prefix stip, then we assume 167*b9411a12SAndroid Build Coastguard Worker@@ -696,8 +738,10 @@ 168*b9411a12SAndroid Build Coastguard Worker if (filename_length > gcov_max_filename) 169*b9411a12SAndroid Build Coastguard Worker gcov_max_filename = filename_length; 170*b9411a12SAndroid Build Coastguard Worker 171*b9411a12SAndroid Build Coastguard Worker+#ifndef __COREBOOT__ 172*b9411a12SAndroid Build Coastguard Worker if (!gcov_list) 173*b9411a12SAndroid Build Coastguard Worker atexit (gcov_exit); 174*b9411a12SAndroid Build Coastguard Worker+#endif 175*b9411a12SAndroid Build Coastguard Worker 176*b9411a12SAndroid Build Coastguard Worker info->next = gcov_list; 177*b9411a12SAndroid Build Coastguard Worker gcov_list = info; 178*b9411a12SAndroid Build Coastguard Worker@@ -767,14 +811,15 @@ 179*b9411a12SAndroid Build Coastguard Worker 180*b9411a12SAndroid Build Coastguard Worker #ifdef L_gcov_merge_single 181*b9411a12SAndroid Build Coastguard Worker /* The profile merging function for choosing the most common value. 182*b9411a12SAndroid Build Coastguard Worker- It is given an array COUNTERS of N_COUNTERS old counters and it 183*b9411a12SAndroid Build Coastguard Worker- reads the same number of counters from the gcov file. The counters 184*b9411a12SAndroid Build Coastguard Worker- are split into 3-tuples where the members of the tuple have 185*b9411a12SAndroid Build Coastguard Worker- meanings: 186*b9411a12SAndroid Build Coastguard Worker- 187*b9411a12SAndroid Build Coastguard Worker- -- the stored candidate on the most common value of the measured entity 188*b9411a12SAndroid Build Coastguard Worker- -- counter 189*b9411a12SAndroid Build Coastguard Worker- -- total number of evaluations of the value */ 190*b9411a12SAndroid Build Coastguard Worker+ * It is given an array COUNTERS of N_COUNTERS old counters and it 191*b9411a12SAndroid Build Coastguard Worker+ * reads the same number of counters from the gcov file. The counters 192*b9411a12SAndroid Build Coastguard Worker+ * are split into 3-tuples where the members of the tuple have 193*b9411a12SAndroid Build Coastguard Worker+ * meanings: 194*b9411a12SAndroid Build Coastguard Worker+ * 195*b9411a12SAndroid Build Coastguard Worker+ * -- the stored candidate on the most common value of the measured entity 196*b9411a12SAndroid Build Coastguard Worker+ * -- counter 197*b9411a12SAndroid Build Coastguard Worker+ * -- total number of evaluations of the value 198*b9411a12SAndroid Build Coastguard Worker+ */ 199*b9411a12SAndroid Build Coastguard Worker void 200*b9411a12SAndroid Build Coastguard Worker __gcov_merge_single (gcov_type *counters, unsigned n_counters) 201*b9411a12SAndroid Build Coastguard Worker { 202*b9411a12SAndroid Build Coastguard Worker@@ -805,15 +850,16 @@ 203*b9411a12SAndroid Build Coastguard Worker 204*b9411a12SAndroid Build Coastguard Worker #ifdef L_gcov_merge_delta 205*b9411a12SAndroid Build Coastguard Worker /* The profile merging function for choosing the most common 206*b9411a12SAndroid Build Coastguard Worker- difference between two consecutive evaluations of the value. It is 207*b9411a12SAndroid Build Coastguard Worker- given an array COUNTERS of N_COUNTERS old counters and it reads the 208*b9411a12SAndroid Build Coastguard Worker- same number of counters from the gcov file. The counters are split 209*b9411a12SAndroid Build Coastguard Worker- into 4-tuples where the members of the tuple have meanings: 210*b9411a12SAndroid Build Coastguard Worker- 211*b9411a12SAndroid Build Coastguard Worker- -- the last value of the measured entity 212*b9411a12SAndroid Build Coastguard Worker- -- the stored candidate on the most common difference 213*b9411a12SAndroid Build Coastguard Worker- -- counter 214*b9411a12SAndroid Build Coastguard Worker- -- total number of evaluations of the value */ 215*b9411a12SAndroid Build Coastguard Worker+ * difference between two consecutive evaluations of the value. It is 216*b9411a12SAndroid Build Coastguard Worker+ * given an array COUNTERS of N_COUNTERS old counters and it reads the 217*b9411a12SAndroid Build Coastguard Worker+ * same number of counters from the gcov file. The counters are split 218*b9411a12SAndroid Build Coastguard Worker+ * into 4-tuples where the members of the tuple have meanings: 219*b9411a12SAndroid Build Coastguard Worker+ * 220*b9411a12SAndroid Build Coastguard Worker+ * -- the last value of the measured entity 221*b9411a12SAndroid Build Coastguard Worker+ * -- the stored candidate on the most common difference 222*b9411a12SAndroid Build Coastguard Worker+ * -- counter 223*b9411a12SAndroid Build Coastguard Worker+ * -- total number of evaluations of the value 224*b9411a12SAndroid Build Coastguard Worker+ */ 225*b9411a12SAndroid Build Coastguard Worker void 226*b9411a12SAndroid Build Coastguard Worker __gcov_merge_delta (gcov_type *counters, unsigned n_counters) 227*b9411a12SAndroid Build Coastguard Worker { 228