<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJzFVE1zmzAQ_TXisgMDAupw4NDayTWnnjsSLFipkBhJ2Il_fRdwHPo9nRzKMGgl7b7d91ZI2val3tthVFqZHjrrQLgBziocQZh2MewUwI5BDeoigrIGegweWtV16NAE8NjMy36JDkcEZVRQQqsLtuADxTRwEk4JqRGGFzJZ_pGlB5Zev58NPo8EMruvWD84NFpQcXEchKPcLD-E4zTI0w6HeDJfjT2b2FiDMQqpIH7MIG5gEMokzRqv9WmIrXxqp2FM8BkhYeV-cbDA7jm7S1mVh9U3Zmnlj_bsiYoIC58rhy2t7_mA8rT7Wjwk0s9zH1C0YLu39VYEkawRwsMr6RvZGADS9SlAw_w8rmC39ewq4Eac-1ftGL9rrHM0Yby6Jf1lB8lV4wk1pOT6PrHT_y32RtTfaf43tdM3tWf3Lyvathtb1ctPC5uLGll5ICWPIYx-huUP9Pak9ySTxg40mbW4DvHo7NPSm4dOafQ07nZVle0-kHUDpG5sWhG1dd5WeSUiMVEXXd2iHqYsmpyu_zmr8n5a0pa8KsvoWJey69qCS5nnO563HS-6LE8bLncZ3uWdiLSQqH1NhBnnBs-wQJBNvKP3V6BqnnKeZinPiqwsi0TmUtBUlDmvsEDJihRJGZ3MOIl1feTqBVJOvadNrXzwb5vCe9UbxKVgqjCooLEenegHcTsP86W2_RUY39MZ_NONRWdt-umCihYu9ULkG_ybts4>52955</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
pragma section and optimization, initialized static variable in unexpected section
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
delmu1
</td>
</tr>
</table>
<pre>
Compiling for arm with and without optimization gets different sections for the initialized static variable myvar:
Unexpected section:
clang --target=thumbv7em-unknown-none-eabi -O1 -c main.c
llvm-objdump.exe .\main.o –t
- shows that the static initialized variable myvar is in section .bss instead of section .data.myvar as expected:
- 00000004 l O .bss 00000001 myvar
Expected (correct) section without optimization (level 0):
clang --target=thumbv7em-unknown-none-eabi -O0 -c main.c
llvm-objdump.exe .\main.o –t
- shows that the static initialized variable myvar is in section .data.myvar instead of section .data as expected:
- 00000000 l O .data_myvar 00000004 myvar
[main.zip](https://github.com/llvm/llvm-project/files/7799176/main.zip)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFk01znDAMhn-NuWhgjIFsOHBoN8k1p547NmhZp8ZmbLOb5NdXwGZDv6fTQz0Mlm1Z1vtopFz30uzdMGqjbQ8H50H6Ac46HkHabjHcFMGNUQ_6VUbtLPQYA3T6cECPNkLAdt4Oy-14RNBWRy2NfsUOQqQ7LZyk11IZhOGFTFZ8YPyO8cv_k8XnkYLM7mus7xxaIym5NI3S09usuIvHaVCnHQ7pZL9Yd7apdRZTlEpD-phD2sIgtc3a9b4xpyF16qmbhjHDZ4SMVfvFwQG7F-yWs7qIq2_KeB2O7hxIioyLnouGraxv9YAOdPqWPGQqzOsQUXbgDu_7nYwyW2_IAG-ir2JTAODrKMHAPB7XYNf9_AJwA-f-jR0Tt63znhZM1NdHf1pBcjV4QgOcXP8NNv_fsDdQf8X8T7T5O-3Z_fMabVuNLfXq46LmVY-suiOSxxjHMIcVD_T1xHtSWesGWswsLlM6eve01ObhoA0Gmne7us53N2RdA1I1NqVIuqbo6qKWSdTRYDN62Q_yqm1u0G1ZmdgTz991H3Gbfmi2ZPKm-WsROoRpUVGJuqqSY6N2HemRXCmh1E1XywrbGzJueVmKoigTIxWa0BA_JoTFMywhyCaMiW4EF4LnXORlXlVlpgolaSmrQtRYomIlR8JksjmPzPk-8c2Skpr6QIdGhxjeD2UIureIy3MUX07UBr7p0AxTniwvN0vmXwEsdqEy">