| Issue |
166380
|
| Summary |
-fsanitize=memtag-globals doesn't tag global variables in the presence of __attribute__ section
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
tarcisiofischer
|
The following program:
```
__attribute__((section("foo_section"))) int foo = 42;
int main() { return foo; }
```
compiled with `-fsanitize=memtag-globals` yields
```
$ llvm-readelf --memtag a.out
Memtag Dynamic Entries:
AARCH64_MEMTAG_MODE: Synchronous (0)
AARCH64_MEMTAG_HEAP: Disabled (0)
AARCH64_MEMTAG_STACK: Disabled (0)
Memtag Android Note:
Tagging Mode: SYNC
Heap: Disabled
Stack: Disabled
```
I'd expect the same result as:
```
int foo = 42;
int main() { return foo; }
```
```
$ llvm-readelf --memtag a.out
Memtag Dynamic Entries:
AARCH64_MEMTAG_MODE: Synchronous (0)
AARCH64_MEMTAG_HEAP: Disabled (0)
AARCH64_MEMTAG_STACK: Disabled (0)
AARCH64_MEMTAG_GLOBALS: 0x338
AARCH64_MEMTAG_GLOBALSSZ: 3
Memtag Android Note:
Tagging Mode: SYNC
Heap: Disabled
Stack: Disabled
Memtag Global Descriptors:
0x89b0: 0x10
```
The reason seems to be the following code: https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp#L2608-L2627
I tried removing this code, and I can confirm the memory in the section is tagged, and my test executable runs just fine 👍 But I didn't run into any of the issues mentioned in the comments... So I'm creating this issue hoping to either remove that bit of code or to understand more about the issues mentioned in the comments. (Marking @fmayer since he appears in the blame in that code)
Thanks in advance.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs