<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/95400>95400</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            -ffunction-sections doesn't put functions in separate sections if section is named
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          john-brawn-arm
      </td>
    </tr>
</table>

<pre>
    If the following example is compiled with ``clang -ffunction-sections``
```
#pragma clang section text="example1"
int fn1() { return 10; } 
int fn2() { return 20; } 
#pragma clang section text=""
__attribute__((section("example2"))) int fn3() { return 30; }
__attribute__((section("example2"))) int fn4() { return 40; }
```
then we get a single section named example1 containing both fn1 and fn2, and a single section named example2 containing both fn3 and fn4. This goes against the documented behaviour of ``-ffunction-sections``, which is that each function is placed in its own section.

We can have multiple sections with the same name (on ELF targets at least, I don't know about others), and in fact we currently do actually do that when the ``retain`` attribute is used. We could do this for the above example as well.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE_vmzgQ_TTmMkoEhvzhwKG_ZiNV2uNKe4wGPIC7xkb2OLTffmVI0m5_3d1DpSgMYeb5vTcvYAh6sESNOLyJwyXDyKPzzWc32l3rcbE79FPWOvW1-dQDjwS9M8Yt2g5AX3CaDYEO0Llp1oYULJpHEMdcHPPOoB1g1_fRdqyd3QVar2F7LPKLyD886tetLGePw4SwTT9GgOkLi_IipHwcWggptxFtGXpbCHkWsgZxegNPHL2FIhflG4jTBb5vlO8b5Q-N_0_idfjthsxet5HpdluRz4_u9ebJdh2Q9faBjUj5nkj5JPLL4NV78Oqf4D8YzyNZWAgGYkAI2g6GXsItTqSe6y6gc5ZR2xSB1vGY3Ae0ajP341r-N4T8CUT5gKj28MeoAwyOAuCA2gZec6dcFyeyTApaGvGuXfTg-kfY_j1m8iMso-7GFFMekYGwG-HZnX6dDXakQFvQHMAt9sl6_7Bq_f6ToEMLI94JpmhYz9_khS33iWbAiVa1IOTZWfjt9ysw-oE4ADIYwsCJ0ydQaY8nhr-sWwBbFxkcj-TDusnNR22hx47TZrroPVk2X0E5wI4jmq1eRS1pf-n8TbWnZO9WwytFSWwMpPaQxLho1DavA_TOr-PYuju9_tkYYCFj9plqSlWXNWbUFKfiLM9FUZbZ2HR13quyanOkozph1bZVf67Lirpetao9ZbqRuazyY1EWsjgfyv3h2B9kLmss6laVeSWqnCbUZm_Mfdo7P2Q6hEhNfajyPDPYkgnry0lKSwusD1PgD5fMN2lm18YhiCo3OnD4hsKaDTU_iQUoR2Fzfo78CkJIXgea0SN_t1fdvyKsw5biLHrTjMxzEOUHIa9CXgfNY2z3nZuEvCYKj8tu9u4zdSzkdSUehLxuwu6N_DsAAP___MjDsw">