[llvm] [RISCV] Let -data-sections also work on sbss/sdata sections (PR #87040)

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 10:39:01 PDT 2024


petrhosek wrote:

There's a change in semantics which I think is undesirable due to https://github.com/llvm/llvm-project/pull/87040/files#diff-16406b22032eaeb81527fc5cf1938dd0981c926fcad2f5b2e9a9f9db7d31f03cR79-R82

For example, if you have the following:
```
__attribute__((section(".bss"))) int foo = 0;
```
`foo` will end up in `.bss` even when `-fdata-sections` is set.

However, if you have the following:
```
__attribute__((section(".sbss"))) int foo = 0;
```
`foo` will end up in `.sbss.foo` after this change and I think that's undesirable.

If a symbol has an explicit section, we should honor that. This could be achieved simply by always returning `false` if https://github.com/llvm/llvm-project/pull/87040/files#diff-16406b22032eaeb81527fc5cf1938dd0981c926fcad2f5b2e9a9f9db7d31f03cL76 is true.

https://github.com/llvm/llvm-project/pull/87040


More information about the llvm-commits mailing list