PhilippvK opened a new pull request, #16999:
URL: https://github.com/apache/tvm/pull/16999
The `.rodata*` section of any program should not be writable.
The missing `const` specifier in `static struct global_const_workspace
{...}` leads to the following `readelf -e` output (shortened):
```
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk
Inf Al
[ 0] NULL 00000000 000000 000000 00 0
0 0
[ 1] .text PROGBITS 00000000 001000 009fbe 00 AX 0
0 16
[ 2] .rodata PROGBITS 00009fc0 00afc0 000e50 00 WA 0
0 16
[ 3] .srodata PROGBITS 0000ae10 00be10 000068 08 AM 0
0 8
...
```
After this fix, the output looks as follows (`AW -> A`):
```
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk
Inf Al
[ 0] NULL 00000000 000000 000000 00 0
0 0
[ 1] .text PROGBITS 00000000 001000 00a1be 00 AX 0
0 16
[ 2] .rodata PROGBITS 0000a1c0 00b1c0 000e50 00 A 0
0 16
[ 3] .srodata PROGBITS 0000b010 00c010 000070 00 A 0
0 8
```
## More context
This bug affects the `default_lib0.c` file generated when using CRT AoT &
USMP. See this shortened example:
**Before fix:**
```
__attribute__((section(".rodata.tvm"), ))
static struct global_const_workspace {
float fused_constant_1_let[256] __attribute__((aligned(16))); // 1024
bytes, aligned offset: 0
...
} global_const_workspace = {
.fused_constant_1_let = {
0x1.05a71cp-3, 0x1.660c26p-2, 0x1.9765b6p-2, 0x1.dc7fdp-5,
0x1.4f3b88p-4, 0x1.1bdb82p-2, 0x1.f2443cp-3, 0x1.d3f5e4p-3,
...
},
};// of total size 1284 bytes
```
**After fix:**
```
__attribute__((section(".rodata.tvm"), ))
static const struct global_const_workspace {
float fused_constant_1_let[256] __attribute__((aligned(16))); // 1024
bytes, aligned offset: 0
...
} global_const_workspace = {
.fused_constant_1_let = {
0x1.05a71cp-3, 0x1.660c26p-2, 0x1.9765b6p-2, 0x1.dc7fdp-5,
0x1.4f3b88p-4, 0x1.1bdb82p-2, 0x1.f2443cp-3, 0x1.d3f5e4p-3,
...
},
};// of total size 1284 bytes
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]