Lines Matching full:g

34   const Global *g;
43 Global g;
58 ALWAYS_INLINE void PoisonShadowForGlobal(const Global *g, u8 value) {
59 FastPoisonShadow(g->beg, g->size_with_redzone, value);
62 ALWAYS_INLINE void PoisonRedZones(const Global &g) {
63 uptr aligned_size = RoundUpTo(g.size, ASAN_SHADOW_GRANULARITY);
64 FastPoisonShadow(g.beg + aligned_size, g.size_with_redzone - aligned_size,
66 if (g.size != aligned_size) {
68 g.beg + RoundDownTo(g.size, ASAN_SHADOW_GRANULARITY),
69 g.size % ASAN_SHADOW_GRANULARITY, ASAN_SHADOW_GRANULARITY,
76 static bool IsAddressNearGlobal(uptr addr, const __asan_global &g) {
77 if (addr <= g.beg - kMinimalDistanceFromAnotherGlobal) return false;
78 if (addr >= g.beg + g.size_with_redzone) return false;
82 static void ReportGlobal(const Global &g, const char *prefix) {
84 bool symbolized = Symbolizer::GetOrInit()->SymbolizeData(g.beg, &info);
89 prefix, (void *)&g, (void *)g.beg, g.size, g.size_with_redzone, g.name,
90 g.module_name, (symbolized ? info.module : "?"), g.has_dynamic_init,
91 (void *)g.odr_indicator);
95 } else if (g.gcc_location != 0) {
97 Report(" location: name=%s, %d\n", g.gcc_location->filename, g.gcc_location->line_no);
101 static u32 FindRegistrationSite(const Global *g) {
106 if (g >= grs.g_first && g <= grs.g_last)
118 const Global &g = *l->g;
120 ReportGlobal(g, "Search");
121 if (IsAddressNearGlobal(addr, g)) {
122 internal_memcpy(&globals[res], &g, sizeof(g));
124 reg_sites[res] = FindRegistrationSite(&g);
138 // Check ODR violation for given global G via special ODR indicator. We use
141 static void CheckODRViolationViaIndicator(const Global *g) {
143 if (g->odr_indicator == UINTPTR_MAX)
145 u8 *odr_indicator = reinterpret_cast<u8 *>(g->odr_indicator);
153 if (g->odr_indicator == l->g->odr_indicator &&
154 (flags()->detect_odr_violation >= 2 || g->size != l->g->size) &&
155 !IsODRViolationSuppressed(g->name))
156 ReportODRViolation(g, FindRegistrationSite(g),
157 l->g, FindRegistrationSite(l->g));
161 // Check ODR violation for given global G by checking if it's already poisoned.
164 static void CheckODRViolationViaPoisoning(const Global *g) {
165 if (__asan_region_is_poisoned(g->beg, g->size_with_redzone)) {
169 if (g->beg == l->g->beg &&
170 (flags()->detect_odr_violation >= 2 || g->size != l->g->size) &&
171 !IsODRViolationSuppressed(g->name))
172 ReportODRViolation(g, FindRegistrationSite(g),
173 l->g, FindRegistrationSite(l->g));
194 static inline bool UseODRIndicator(const Global *g) {
195 return g->odr_indicator > 0;
201 static void RegisterGlobal(const Global *g) {
204 ReportGlobal(*g, "Added");
206 CHECK(AddrIsInMem(g->beg));
207 if (!AddrIsAlignedByGranularity(g->beg)) {
214 ReportODRViolation(g, FindRegistrationSite(g), g, FindRegistrationSite(g));
215 CHECK(AddrIsAlignedByGranularity(g->beg));
217 CHECK(AddrIsAlignedByGranularity(g->size_with_redzone));
221 if (UseODRIndicator(g))
222 CheckODRViolationViaIndicator(g);
224 CheckODRViolationViaPoisoning(g);
227 PoisonRedZones(*g);
229 l->g = g;
232 if (g->has_dynamic_init) {
237 DynInitGlobal dyn_global = { *g, false };
242 static void UnregisterGlobal(const Global *g) {
245 ReportGlobal(*g, "Removed");
247 CHECK(AddrIsInMem(g->beg));
248 CHECK(AddrIsAlignedByGranularity(g->beg));
249 CHECK(AddrIsAlignedByGranularity(g->size_with_redzone));
251 PoisonShadowForGlobal(g, 0);
257 if (UseODRIndicator(g) && g->odr_indicator != UINTPTR_MAX) {
258 u8 *odr_indicator = reinterpret_cast<u8 *>(g->odr_indicator);
270 const Global *g = &dyn_g.g;
272 PoisonShadowForGlobal(g, 0);
274 PoisonRedZones(*g);
293 void PrintGlobalNameIfASCII(InternalScopedString *str, const __asan_global &g) {
294 for (uptr p = g.beg; p < g.beg + g.size - 1; p++) {
298 if (*(char *)(g.beg + g.size - 1) != '\0') return;
299 str->AppendF(" '%s' is ascii string '%s'\n", MaybeDemangleGlobalName(g.name),
300 (char *)g.beg);
303 void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g,
306 if (Symbolizer::GetOrInit()->SymbolizeData(g.beg, &info) && info.line != 0) {
308 } else if (g.gcc_location != 0) {
310 str->AppendF("%s", g.gcc_location->filename ? g.gcc_location->filename
311 : g.module_name);
312 if (g.gcc_location->line_no)
313 str->AppendF(":%d", g.gcc_location->line_no);
314 if (g.gcc_location->column_no)
315 str->AppendF(":%d", g.gcc_location->column_no);
317 str->AppendF("%s", g.module_name);
442 const Global *g = &dyn_g.g;
445 if (g->module_name != module_name)
446 PoisonShadowForGlobal(g, kAsanInitializationOrderMagic);
465 const Global *g = &dyn_g.g;
468 PoisonShadowForGlobal(g, 0);
470 PoisonRedZones(*g);