[lld] ELF: Introduce --shuffle-padding flag. (PR #117653)

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 27 16:04:26 PST 2024


================
@@ -1444,6 +1444,38 @@ static void finalizeSynthetic(Ctx &ctx, SyntheticSection *sec) {
   }
 }
 
+static bool canInsertPadding(OutputSection *sec) {
+  StringRef s = sec->name;
+  return s == ".bss" || s == ".data" || s == ".data.rel.ro" || s == ".rodata" ||
----------------
pcc wrote:

This is matching on the output section name, and since the suffix on `.rodata.*` and so on is removed when forming the output section name the feature works as intended with `-fdata-sections` enabled.

The reason for using `starts_with` to match `.text` is because of sections such as `.text.hot` and `.text.unlikely` that are preserved as output section names.

There won't be a linker defined start/stop on `.data.foo` without a linker script and I think the solution there is to allow user control as noted in the main reply.

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


More information about the llvm-commits mailing list