Skip to content

Commit 3657d10

Browse files
committed
further small edits
1 parent 6558783 commit 3657d10

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

docs/cpp/ASAN/asan-building.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,31 @@ You can customize address sanitizer functionality compiled into the binaries use
5252

5353
There are smaller tweaks that can be made by setting the environment variable `ASAN_OPTIONS`
5454

55-
## Address Sanitizer Runtimes
55+
## Address Sanitizer Binaries
5656

57-
This implementation of AddressSanitizer makes use of the Clang ASan runtime libraries. The runtime library version packaged with Visual Studio may contain features that are not yet available in the version packaged with Clang.
57+
58+
This implementation of AddressSanitizer makes use of the Clang ASan runtime libraries. The runtime library version packaged with Visual Studio may contain features that are not yet available in the version packaged with Clang on Windows10.
5859

5960
An overview of the features in this ported version of the Address Sanitizer runtime runtime is available here: [AddressSanitizer runtime overview](address-sanitizer-runtime.md)
6061

61-
### Static (x86,AMD64)
6262

63-
These would appear on the raw link lines
63+
### Linking – With static CRT
64+
65+
Link the EXE with
66+
67+
- set _LINK_= /debug -incremental:no /wholearchive:%MyVS%\lib\{arch}\clang_rt.asan-{arch}.lib
68+
/wholearchive:%MyVS%\lib\{arch}\clang_rt.asan_cxx-{arch}.lib
69+
70+
Link the DLL with
71+
72+
- set _LINK_= /debug -incremental:no /wholearchive:%MyVS%\lib\{arch}\clang_rt.asan_dll_thunk-{arch}.lib
73+
74+
### Linking – With dynamic CRT
75+
76+
Link both the EXE and DLL with:
6477

65-
### Dynamic (x86,AMD64)
78+
- set _LINK_= /debug -incremental:no /wholearchive:%MyVS%\lib\{arch}\clang_rt.asan_dynamic-{arch}.lib /wholearchive:%MyVS%\lib\{arch}\clang_rt.asan_dynamic_runtime_thunk-{arch}.lib
6679

67-
These would appear on the raw link lines
6880

6981
## Visual Studio
7082

docs/cpp/ASAN/asan-shadowbytes.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Shadow bytes
22

3-
We summarize the runtime implementation of `-fsanitize=address`. For futher details we refer you to the [seminal paper](
4-
https://www.usenix.org/system/files/conference/atc12/atc12-final39.pdf).
3+
We briefly summarize the concept of shadow bytes and how they can be used by the runtime implementation of `-fsanitize=address`. For further details we refer you to the [seminal paper](
4+
https://www.usenix.org/system/files/conference/atc12/atc12-final39.pdf).
55

66
## Core concept
77

@@ -11,7 +11,7 @@ The shadow-byte describes how many bytes in the 8-byte user address are currentl
1111

1212
- 0 means all 8 bytes
1313
- 1-7 means 1 to seven bytes
14-
- Negtive numbers encode context for the runtime to diagnose
14+
- Negtive numbers encode context for the runtime to use for reporting diagnostics.
1515

1616
Consider this shadow byte legend:
1717

@@ -20,7 +20,7 @@ Consider this shadow byte legend:
2020

2121
## Mapping
2222

23-
Every 8-byte address that is 0 mod 8 aligned, can be mapped to the shadow byte that describes that slot in the virtual address space. This mapping can be accomplished with a simple shift and add.
23+
Every 8-byte address that is 0 mod 8 aligned, can be mapped to the shadow byte that describes that slot in the virtual address space. This mapping can be accomplished with a **simple shift and add**.
2424

2525
On x86:
2626

@@ -30,8 +30,7 @@ On amd64:
3030

3131
char shadow_byte_value = *((Your_Address >> 3) + _asan_runtime_assigned_offset)
3232

33-
34-
## Code generation
33+
## Code generation - tests
3534

3635
Assume that specific shadow bytes will have been written, either by the compiler generated code, static data, or the runtime. Then the following pseudo code shows how it would be simple to generate a check which would precede any load or store.
3736

@@ -53,8 +52,12 @@ When instrumenting 1-, 2-, or 4- byte accesses, the instrumentation is slightly
5352

5453
The runtime and the compiler generated code, will write shadow bytes to allow or revoke access when scopes end or storage is freed. Thus the checks above, are reading shadow bytes describing 8-byte slots in your application space, **at a certain time in the programs execution**.
5554

56-
## See Also
55+
In addition to these explicitly generated checks the runtime will check shadow bytes after it "intercepts or hooks" many functions in the CRT. See [the list of intercepted functions](#address-sanitizer-intercepted-functions.md)
5756

58-
The Address Sanitizer [algorithm](https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm) for further details.
57+
## Setting shadow bytes
5958

59+
Both the code the compiler generates and and the Address Sanitizer runtime can write shadow bytes. For example the compiler can set shadow bytes to allow fixed sized access to stack locals defined in an inner scope. The runtime can surround global variables in the data section with shadow bytes.
6060

61+
## See Also
62+
63+
The Address Sanitizer [algorithm](https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm) for further details.

docs/cpp/ASAN/asan-top-level.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ Microsoft recommends using the Address Sanitizer in these **three standard workf
4444

4545
This MSDN article will cover all the information needed to enable your builds for any of the three workflows listed above. The information will be specific to the Microsoft Windows 10 platform and supplement existing documentation from [Google, Apple and GCC](#Google,-Apple-and-GCC-documentation). We start with a simple command line use of the compiler and linker.
4646

47-
> [!NOTE] Current support is limited to x86 and AMD64 on Windows10. **Customer feedback** would help us prioritize shipping these sanitizers in the future: -fsanitize=thread, -fsanitize=leak, -fsanitize=memory, -fsanitize=hwaddress or -fsanitize=undefined.
47+
> [!NOTE] Current support is limited to x86 and AMD64 on Windows 10. **Customer feedback** would help us prioritize shipping these sanitizers in the future: -fsanitize=thread, -fsanitize=leak, -fsanitize=memory, -fsanitize=hwaddress or -fsanitize=undefined.
48+
4849

4950
## Simple command line interface
5051

@@ -121,7 +122,7 @@ From top to bottom
121122
122123
4.) The [**shadow bytes**](.\asan-shadowbytes.md) that correspond to the address used in the overflowing store, indicate 13 bytes (8 + 5) were explicitly allocated for the alloca.
123124
124-
**Note:** The call stack is converted to function names through the [LLVM symbolizer](https://llvm.org/docs/CommandGuide/llvm-symbolizer.html). The Address Sanitizer creates the resto of the report based on its context, the shadow bytes, and meta-data the compiler produces.
125+
**Note:** The call stack is converted to function names through the [LLVM symbolizer](https://llvm.org/docs/CommandGuide/llvm-symbolizer.html). The Address Sanitizer creates the rest of of the report based on its context, the shadow bytes, and meta-data the compiler produces.
125126
126127
### IDE
127128

0 commit comments

Comments
 (0)