Lines Matching refs:g
34 const Global *g; member
44 Global g; member
59 ALWAYS_INLINE void PoisonShadowForGlobal(const Global *g, u8 value) { in PoisonShadowForGlobal() argument
60 FastPoisonShadow(g->beg, g->size_with_redzone, value); in PoisonShadowForGlobal()
63 ALWAYS_INLINE void PoisonRedZones(const Global &g) { in PoisonRedZones() argument
64 uptr aligned_size = RoundUpTo(g.size, ASAN_SHADOW_GRANULARITY); in PoisonRedZones()
65 FastPoisonShadow(g.beg + aligned_size, g.size_with_redzone - aligned_size, in PoisonRedZones()
67 if (g.size != aligned_size) { in PoisonRedZones()
69 g.beg + RoundDownTo(g.size, ASAN_SHADOW_GRANULARITY), in PoisonRedZones()
70 g.size % ASAN_SHADOW_GRANULARITY, ASAN_SHADOW_GRANULARITY, in PoisonRedZones()
77 static bool IsAddressNearGlobal(uptr addr, const __asan_global &g) { in IsAddressNearGlobal() argument
78 if (addr <= g.beg - kMinimalDistanceFromAnotherGlobal) return false; in IsAddressNearGlobal()
79 if (addr >= g.beg + g.size_with_redzone) return false; in IsAddressNearGlobal()
83 static void ReportGlobal(const Global &g, const char *prefix) { in ReportGlobal() argument
87 prefix, (void *)&g, (void *)g.beg, g.size, g.size_with_redzone, g.name, in ReportGlobal()
88 g.module_name, g.has_dynamic_init, (void *)g.odr_indicator); in ReportGlobal()
91 Symbolizer::GetOrInit()->SymbolizeData(g.beg, &info); in ReportGlobal()
97 static u32 FindRegistrationSite(const Global *g) { in FindRegistrationSite() argument
102 if (g >= grs.g_first && g <= grs.g_last) in FindRegistrationSite()
114 const Global &g = *l->g; in GetGlobalsForAddress() local
116 ReportGlobal(g, "Search"); in GetGlobalsForAddress()
117 if (IsAddressNearGlobal(addr, g)) { in GetGlobalsForAddress()
118 internal_memcpy(&globals[res], &g, sizeof(g)); in GetGlobalsForAddress()
120 reg_sites[res] = FindRegistrationSite(&g); in GetGlobalsForAddress()
137 static void CheckODRViolationViaIndicator(const Global *g) { in CheckODRViolationViaIndicator() argument
139 if (g->odr_indicator == UINTPTR_MAX) in CheckODRViolationViaIndicator()
141 u8 *odr_indicator = reinterpret_cast<u8 *>(g->odr_indicator); in CheckODRViolationViaIndicator()
149 if (g->odr_indicator == l->g->odr_indicator && in CheckODRViolationViaIndicator()
150 (flags()->detect_odr_violation >= 2 || g->size != l->g->size) && in CheckODRViolationViaIndicator()
151 !IsODRViolationSuppressed(g->name)) in CheckODRViolationViaIndicator()
152 ReportODRViolation(g, FindRegistrationSite(g), in CheckODRViolationViaIndicator()
153 l->g, FindRegistrationSite(l->g)); in CheckODRViolationViaIndicator()
160 static void CheckODRViolationViaPoisoning(const Global *g) { in CheckODRViolationViaPoisoning() argument
161 if (__asan_region_is_poisoned(g->beg, g->size_with_redzone)) { in CheckODRViolationViaPoisoning()
165 if (g->beg == l->g->beg && in CheckODRViolationViaPoisoning()
166 (flags()->detect_odr_violation >= 2 || g->size != l->g->size) && in CheckODRViolationViaPoisoning()
167 !IsODRViolationSuppressed(g->name)) in CheckODRViolationViaPoisoning()
168 ReportODRViolation(g, FindRegistrationSite(g), in CheckODRViolationViaPoisoning()
169 l->g, FindRegistrationSite(l->g)); in CheckODRViolationViaPoisoning()
190 static inline bool UseODRIndicator(const Global *g) { in UseODRIndicator() argument
191 return g->odr_indicator > 0; in UseODRIndicator()
197 static void RegisterGlobal(const Global *g) { in RegisterGlobal() argument
200 ReportGlobal(*g, "Added"); in RegisterGlobal()
202 CHECK(AddrIsInMem(g->beg)); in RegisterGlobal()
203 if (!AddrIsAlignedByGranularity(g->beg)) { in RegisterGlobal()
210 ReportODRViolation(g, FindRegistrationSite(g), g, FindRegistrationSite(g)); in RegisterGlobal()
211 CHECK(AddrIsAlignedByGranularity(g->beg)); in RegisterGlobal()
213 CHECK(AddrIsAlignedByGranularity(g->size_with_redzone)); in RegisterGlobal()
217 if (UseODRIndicator(g)) in RegisterGlobal()
218 CheckODRViolationViaIndicator(g); in RegisterGlobal()
220 CheckODRViolationViaPoisoning(g); in RegisterGlobal()
223 PoisonRedZones(*g); in RegisterGlobal()
225 l->g = g; in RegisterGlobal()
228 if (g->has_dynamic_init) { in RegisterGlobal()
233 DynInitGlobal dyn_global = { *g, false }; in RegisterGlobal()
238 static void UnregisterGlobal(const Global *g) { in UnregisterGlobal() argument
241 ReportGlobal(*g, "Removed"); in UnregisterGlobal()
243 CHECK(AddrIsInMem(g->beg)); in UnregisterGlobal()
244 CHECK(AddrIsAlignedByGranularity(g->beg)); in UnregisterGlobal()
245 CHECK(AddrIsAlignedByGranularity(g->size_with_redzone)); in UnregisterGlobal()
247 PoisonShadowForGlobal(g, 0); in UnregisterGlobal()
253 if (UseODRIndicator(g) && g->odr_indicator != UINTPTR_MAX) { in UnregisterGlobal()
254 u8 *odr_indicator = reinterpret_cast<u8 *>(g->odr_indicator); in UnregisterGlobal()
266 const Global *g = &dyn_g.g; in StopInitOrderChecking() local
268 PoisonShadowForGlobal(g, 0); in StopInitOrderChecking()
270 PoisonRedZones(*g); in StopInitOrderChecking()
289 void PrintGlobalNameIfASCII(InternalScopedString *str, const __asan_global &g) { in PrintGlobalNameIfASCII() argument
290 for (uptr p = g.beg; p < g.beg + g.size - 1; p++) { in PrintGlobalNameIfASCII()
294 if (*(char *)(g.beg + g.size - 1) != '\0') return; in PrintGlobalNameIfASCII()
295 str->append(" '%s' is ascii string '%s'\n", MaybeDemangleGlobalName(g.name), in PrintGlobalNameIfASCII()
296 (char *)g.beg); in PrintGlobalNameIfASCII()
299 void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g) { in PrintGlobalLocation() argument
301 Symbolizer::GetOrInit()->SymbolizeData(g.beg, &info); in PrintGlobalLocation()
306 str->append("%s", g.module_name); in PrintGlobalLocation()
429 const Global *g = &dyn_g.g; in __asan_before_dynamic_init() local
432 if (g->module_name != module_name) in __asan_before_dynamic_init()
433 PoisonShadowForGlobal(g, kAsanInitializationOrderMagic); in __asan_before_dynamic_init()
452 const Global *g = &dyn_g.g; in __asan_after_dynamic_init() local
455 PoisonShadowForGlobal(g, 0); in __asan_after_dynamic_init()
457 PoisonRedZones(*g); in __asan_after_dynamic_init()