@@ -152,7 +152,7 @@ void WriteMemoryProfile(char *buf, uptr buf_size, u64 uptime_ns) {
152
152
#if !SANITIZER_GO
153
153
// Mark shadow for .rodata sections with the special Shadow::kRodata marker.
154
154
// Accesses to .rodata can't race, so this saves time, memory and trace space.
155
- static void MapRodata () {
155
+ static NOINLINE void MapRodata (char * buffer, uptr size ) {
156
156
// First create temp file.
157
157
const char *tmpdir = GetEnv (" TMPDIR" );
158
158
if (tmpdir == 0 )
@@ -163,13 +163,12 @@ static void MapRodata() {
163
163
#endif
164
164
if (tmpdir == 0 )
165
165
return ;
166
- char name[256 ];
167
- internal_snprintf (name, sizeof (name), " %s/tsan.rodata.%d" ,
166
+ internal_snprintf (buffer, size, " %s/tsan.rodata.%d" ,
168
167
tmpdir, (int )internal_getpid ());
169
- uptr openrv = internal_open (name , O_RDWR | O_CREAT | O_EXCL, 0600 );
168
+ uptr openrv = internal_open (buffer , O_RDWR | O_CREAT | O_EXCL, 0600 );
170
169
if (internal_iserror (openrv))
171
170
return ;
172
- internal_unlink (name ); // Unlink it now, so that we can reuse the buffer.
171
+ internal_unlink (buffer ); // Unlink it now, so that we can reuse the buffer.
173
172
fd_t fd = openrv;
174
173
// Fill the file with Shadow::kRodata.
175
174
const uptr kMarkerSize = 512 * 1024 / sizeof (RawShadow);
@@ -188,8 +187,8 @@ static void MapRodata() {
188
187
}
189
188
// Map the file into shadow of .rodata sections.
190
189
MemoryMappingLayout proc_maps (/* cache_enabled*/ true );
191
- // Reusing the buffer 'name '.
192
- MemoryMappedSegment segment (name, ARRAY_SIZE (name) );
190
+ // Reusing the buffer 'buffer '.
191
+ MemoryMappedSegment segment (buffer, size );
193
192
while (proc_maps.Next (&segment)) {
194
193
if (segment.filename [0 ] != 0 && segment.filename [0 ] != ' [' &&
195
194
segment.IsReadable () && segment.IsExecutable () &&
@@ -209,7 +208,8 @@ static void MapRodata() {
209
208
}
210
209
211
210
void InitializeShadowMemoryPlatform () {
212
- MapRodata ();
211
+ char buffer[256 ]; // Keep in a different frame.
212
+ MapRodata (buffer, ARRAY_SIZE (buffer));
213
213
}
214
214
215
215
#endif // #if !SANITIZER_GO
0 commit comments