Skip to content

Commit 53fde9b

Browse files
committed
more robust test; nits
1 parent 471137c commit 53fde9b

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,18 @@ static bool NextSegmentLoad(MemoryMappedSegment *segment,
257257
if (((const load_command *)lc)->cmd == kLCSegment) {
258258
const SegmentCommand* sc = (const SegmentCommand *)lc;
259259
if (strncmp(sc->segname, "__LINKEDIT", sizeof("__LINKEDIT")) == 0) {
260-
// The LINKEDIT sections alias, so we ignore these sections to
261-
// ensure our mappings are disjoint.
260+
// The LINKEDIT sections are for internal linker use, and may alias
261+
// with the LINKEDIT section for other modules. (If we included them,
262+
// our memory map would contain overlappping sections.)
262263
return false;
263264
}
264265

265266
uptr base_virt_addr;
266-
if (layout_data->current_image == kDyldImageIdx) {
267+
if (layout_data->current_image == kDyldImageIdx)
267268
base_virt_addr = (uptr)_dyld_get_image_slide(get_dyld_hdr());
268-
} else {
269+
else
269270
base_virt_addr =
270271
(uptr)_dyld_get_image_vmaddr_slide(layout_data->current_image);
271-
}
272272

273273
segment->start = sc->vmaddr + base_virt_addr;
274274
segment->end = segment->start + sc->vmsize;
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
// This test simply checks that the "Invalid dyld module map" warning is not printed
22
// in the output of a backtrace.
33

4-
// RUN: %clangxx_asan -O0 -g %s -o %t.executable
5-
// RUN: %env_asan_opts="print_module_map=2" not %run %t.executable 2>&1 | FileCheck %s
4+
// RUN: %clangxx_asan -DSHARED_LIB -g %s -dynamiclib -o %t.dylib
5+
// RUN: %clangxx_asan -O0 -g %s %t.dylib -o %t.executable
6+
// RUN: %env_asan_opts="print_module_map=2" not %run %t.executable 2>&1 | FileCheck %s -DDYLIB=%t.dylib
67

78
// CHECK-NOT: WARN: Invalid dyld module map
9+
// CHECK-DAG: 0x{{.*}}-0x{{.*}} [[DYLIB]]
10+
// CHECK-DAG: 0x{{.*}}-0x{{.*}} {{.*}}libsystem
811

9-
#include <cstdlib>
10-
12+
#ifdef SHARED_LIB
1113
extern "C" void foo(int *a) { *a = 5; }
14+
#else
15+
# include <cstdlib>
16+
17+
extern "C" void foo(int *a);
1218

1319
int main() {
1420
int *a = (int *)malloc(sizeof(int));
15-
if (!a)
16-
return 0;
1721
free(a);
1822
foo(a);
1923
return 0;
20-
}
24+
}
25+
#endif

0 commit comments

Comments
 (0)