This is an automated email from the ASF dual-hosted git repository.

lunderberg pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new b1951a7811 [USMP] add missing const specifier for 
global_const_workspace (#16999)
b1951a7811 is described below

commit b1951a78110f991d31c8d2533184876cc6a4c975
Author: Philipp van Kempen <[email protected]>
AuthorDate: Thu May 23 18:04:42 2024 +0200

    [USMP] add missing const specifier for global_const_workspace (#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
    ```
---
 src/target/source/source_module.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/target/source/source_module.cc 
b/src/target/source/source_module.cc
index 90640a6db6..1877d3da8e 100644
--- a/src/target/source/source_module.cc
+++ b/src/target/source/source_module.cc
@@ -337,7 +337,7 @@ class CSourceCrtMetadataModuleNode : public 
runtime::ModuleNode {
       // Pool is RO, form an initialized struct
       code_ << "__attribute__((section(\".rodata.tvm\"), ";
       code_ << "))\n";
-      code_ << "static struct " << pool_info->pool_name << " {\n";
+      code_ << "static const struct " << pool_info->pool_name << " {\n";
       // emit struct field names
       std::vector<ConstantInfo> 
const_info_vec(pool_info->constant_info_array.begin(),
                                                
pool_info->constant_info_array.end());

Reply via email to