1 /* go-fieldtrack.c -- structure field data analysis.
3 Copyright 2012 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
11 /* The compiler will track fields that have the tag go:"track". Any
12 function that refers to such a field will call this function with a
14 fieldtrack "package.type.field"
16 This function does not actually do anything. Instead, we gather
17 the field tracking information by looking for strings of that form
18 in the read-only data section. This is, of course, a horrible
19 hack, but it's good enough for now. We can improve it, e.g., by a
20 linker plugin, if this turns out to be useful. */
23 __go_fieldtrack (byte *p __attribute__ ((unused)))
27 /* A runtime function to add all the tracked fields to a
30 extern const char _etext[] __attribute__ ((weak));
31 extern const char __etext[] __attribute__ ((weak));
32 extern const char __data_start[] __attribute__ ((weak));
33 extern const char _edata[] __attribute__ ((weak));
34 extern const char __edata[] __attribute__ ((weak));
35 extern const char __bss_start[] __attribute__ ((weak));
37 void runtime_Fieldtrack (struct __go_map *) __asm__ (GOSYM_PREFIX "runtime.Fieldtrack");
40 runtime_Fieldtrack (struct __go_map *m)
63 prefix = "fieldtrack ";
64 prefix_len = __builtin_strlen (prefix);
71 q1 = __builtin_memchr (p + prefix_len, '"', pend - (p + prefix_len));
75 if (__builtin_memcmp (q1 - prefix_len, prefix, prefix_len) != 0)
82 q2 = __builtin_memchr (q1, '"', pend - q1);
86 if (__builtin_memchr (q1, '\0', q2 - q1) == NULL)
92 s.str = (const byte *) q1;
94 v = __go_map_index (m, &s, 1);