[llvm] [BOLT, test] Make linker scripts less sensitive to lld's orphan placement (PR #93763)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 29 21:09:10 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-bolt

Author: Fangrui Song (MaskRay)

<details>
<summary>Changes</summary>

Then two tests rely on .interp being the first section.
llvm-bolt would crash if lld places .interp after .got
(f639b57f7993cadb82ee9c36f04703ae4430ed85).

For best portability, when a linker scripts specifies a SECTIONS
command, the first section for each PT_LOAD segment should be specified
with a MAXPAGESIZE alignment. Otherwise, linkers have freedom to decide
how to place orphan sections, which might break intention.


---
Full diff: https://github.com/llvm/llvm-project/pull/93763.diff


2 Files Affected:

- (modified) bolt/test/AArch64/Inputs/array_end.lld_script (+3) 
- (modified) bolt/test/Inputs/lsda.ldscript (+3) 


``````````diff
diff --git a/bolt/test/AArch64/Inputs/array_end.lld_script b/bolt/test/AArch64/Inputs/array_end.lld_script
index 182c13d370a39..bf77c0493a095 100644
--- a/bolt/test/AArch64/Inputs/array_end.lld_script
+++ b/bolt/test/AArch64/Inputs/array_end.lld_script
@@ -1,4 +1,7 @@
 SECTIONS {
+  .interp : { *(.interp) }
+
+  . = ALIGN(CONSTANT(MAXPAGESIZE));
   .fini_array    :
   {
     PROVIDE_HIDDEN (__fini_array_start = .);
diff --git a/bolt/test/Inputs/lsda.ldscript b/bolt/test/Inputs/lsda.ldscript
index aa608ecd97e8c..011e0c6ac8a0f 100644
--- a/bolt/test/Inputs/lsda.ldscript
+++ b/bolt/test/Inputs/lsda.ldscript
@@ -1,5 +1,8 @@
 SECTIONS {
+  .interp : { *(.interp) }
+  . = ALIGN(CONSTANT(MAXPAGESIZE));
   .text : { *(.text*) }
+  . = ALIGN(CONSTANT(MAXPAGESIZE));
   .gcc_except_table.main : { *(.gcc_except_table*) }
   . = 0x20000;
   .eh_frame : { *(.eh_frame) }

``````````

</details>


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


More information about the llvm-commits mailing list