[llvm] [RISCV] Place mergeable small read only data into srodata section (PR #82214)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 25 06:55:27 PST 2024
stephan-gh wrote:
I believe this PR might fix the problem I reported on the LLVM security bug tracker back in January, since I was unsure about the security implications: https://bugs.chromium.org/p/llvm/issues/detail?id=61 It was decided that this is better handled publicly.
Aside from not being able to merge those constants the current behavior of placing constants in .sdata by default is also non-ideal because it makes it impossible to differentiate between small **read-only** constants and actual small **mutable** global variables. This is necessary if you want to favor security hardening (by mapping the constants read-only at runtime) over the slight performance/size benefit of linker relaxation. For example, [in the Linux kernel a custom linker script is used to place .srodata next to .rodata](https://github.com/torvalds/linux/blob/v6.7/arch/riscv/kernel/vmlinux.lds.S#L120-L125) rather than merging it into the mutable .data. This works only with GCC at the moment because LLVM does not generate .srodata.
In my report linked above, I suggested setting `-msmall-data-limit` to 0 by default as a workaround but these changes look like they would fix the actual problem. :)
https://github.com/llvm/llvm-project/pull/82214
More information about the llvm-commits
mailing list