• Home
  • Raw
  • Download

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, 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, SHADOW_GRANULARITY), in PoisonRedZones()
70 g.size % SHADOW_GRANULARITY, in PoisonRedZones()
78 static bool IsAddressNearGlobal(uptr addr, const __asan_global &g) { in IsAddressNearGlobal() argument
79 if (addr <= g.beg - kMinimalDistanceFromAnotherGlobal) return false; in IsAddressNearGlobal()
80 if (addr >= g.beg + g.size_with_redzone) return false; in IsAddressNearGlobal()
84 static void ReportGlobal(const Global &g, const char *prefix) { in ReportGlobal() argument
86 prefix, &g, (void *)g.beg, g.size, g.size_with_redzone, g.name, in ReportGlobal()
87 g.module_name, g.has_dynamic_init); in ReportGlobal()
88 if (g.location) { in ReportGlobal()
89 Report(" location (%p): name=%s[%p], %d %d\n", g.location, in ReportGlobal()
90 g.location->filename, g.location->filename, g.location->line_no, in ReportGlobal()
91 g.location->column_no); in ReportGlobal()
95 static u32 FindRegistrationSite(const Global *g) { in FindRegistrationSite() argument
100 if (g >= grs.g_first && g <= grs.g_last) in FindRegistrationSite()
112 const Global &g = *l->g; in GetGlobalsForAddress() local
114 ReportGlobal(g, "Search"); in GetGlobalsForAddress()
115 if (IsAddressNearGlobal(addr, g)) { in GetGlobalsForAddress()
116 globals[res] = g; in GetGlobalsForAddress()
118 reg_sites[res] = FindRegistrationSite(&g); in GetGlobalsForAddress()
127 Global g = {}; in GetInfoForAddressIfGlobal() local
128 if (GetGlobalsForAddress(addr, &g, nullptr, 1)) { in GetInfoForAddressIfGlobal()
129 internal_strncpy(descr->name, g.name, descr->name_size); in GetInfoForAddressIfGlobal()
130 descr->region_address = g.beg; in GetInfoForAddressIfGlobal()
131 descr->region_size = g.size; in GetInfoForAddressIfGlobal()
146 static void CheckODRViolationViaIndicator(const Global *g) { in CheckODRViolationViaIndicator() argument
147 u8 *odr_indicator = reinterpret_cast<u8 *>(g->odr_indicator); in CheckODRViolationViaIndicator()
155 if (g->odr_indicator == l->g->odr_indicator && in CheckODRViolationViaIndicator()
156 (flags()->detect_odr_violation >= 2 || g->size != l->g->size) && in CheckODRViolationViaIndicator()
157 !IsODRViolationSuppressed(g->name)) in CheckODRViolationViaIndicator()
158 ReportODRViolation(g, FindRegistrationSite(g), in CheckODRViolationViaIndicator()
159 l->g, FindRegistrationSite(l->g)); in CheckODRViolationViaIndicator()
166 static void CheckODRViolationViaPoisoning(const Global *g) { in CheckODRViolationViaPoisoning() argument
167 if (__asan_region_is_poisoned(g->beg, g->size_with_redzone)) { in CheckODRViolationViaPoisoning()
171 if (g->beg == l->g->beg && in CheckODRViolationViaPoisoning()
172 (flags()->detect_odr_violation >= 2 || g->size != l->g->size) && in CheckODRViolationViaPoisoning()
173 !IsODRViolationSuppressed(g->name)) in CheckODRViolationViaPoisoning()
174 ReportODRViolation(g, FindRegistrationSite(g), in CheckODRViolationViaPoisoning()
175 l->g, FindRegistrationSite(l->g)); in CheckODRViolationViaPoisoning()
196 static inline bool UseODRIndicator(const Global *g) { in UseODRIndicator() argument
199 return flags()->use_odr_indicator && g->odr_indicator > 0; in UseODRIndicator()
205 static void RegisterGlobal(const Global *g) { in RegisterGlobal() argument
208 ReportGlobal(*g, "Added"); in RegisterGlobal()
210 CHECK(AddrIsInMem(g->beg)); in RegisterGlobal()
211 if (!AddrIsAlignedByGranularity(g->beg)) { in RegisterGlobal()
218 ReportODRViolation(g, FindRegistrationSite(g), g, FindRegistrationSite(g)); in RegisterGlobal()
219 CHECK(AddrIsAlignedByGranularity(g->beg)); in RegisterGlobal()
221 CHECK(AddrIsAlignedByGranularity(g->size_with_redzone)); in RegisterGlobal()
225 if (UseODRIndicator(g)) in RegisterGlobal()
226 CheckODRViolationViaIndicator(g); in RegisterGlobal()
228 CheckODRViolationViaPoisoning(g); in RegisterGlobal()
231 PoisonRedZones(*g); in RegisterGlobal()
233 l->g = g; in RegisterGlobal()
236 if (g->has_dynamic_init) { in RegisterGlobal()
241 DynInitGlobal dyn_global = { *g, false }; in RegisterGlobal()
246 static void UnregisterGlobal(const Global *g) { in UnregisterGlobal() argument
249 ReportGlobal(*g, "Removed"); in UnregisterGlobal()
251 CHECK(AddrIsInMem(g->beg)); in UnregisterGlobal()
252 CHECK(AddrIsAlignedByGranularity(g->beg)); in UnregisterGlobal()
253 CHECK(AddrIsAlignedByGranularity(g->size_with_redzone)); in UnregisterGlobal()
255 PoisonShadowForGlobal(g, 0); in UnregisterGlobal()
261 if (UseODRIndicator(g)) { in UnregisterGlobal()
262 u8 *odr_indicator = reinterpret_cast<u8 *>(g->odr_indicator); in UnregisterGlobal()
274 const Global *g = &dyn_g.g; in StopInitOrderChecking() local
276 PoisonShadowForGlobal(g, 0); in StopInitOrderChecking()
278 PoisonRedZones(*g); in StopInitOrderChecking()
353 const Global *g = &dyn_g.g; in __asan_before_dynamic_init() local
356 if (g->module_name != module_name) in __asan_before_dynamic_init()
357 PoisonShadowForGlobal(g, kAsanInitializationOrderMagic); in __asan_before_dynamic_init()
375 const Global *g = &dyn_g.g; in __asan_after_dynamic_init() local
378 PoisonShadowForGlobal(g, 0); in __asan_after_dynamic_init()
380 PoisonRedZones(*g); in __asan_after_dynamic_init()