[llvm] [BOLT, test] Make linker scripts less sensitive to lld's orphan placement (PR #93763)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 21:08:35 PDT 2024
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/93763
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.
>From 5bf6c888bfd4435f0c08c5d7cbcececd16fb057c Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Wed, 29 May 2024 21:08:27 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.5-bogner
---
bolt/test/AArch64/Inputs/array_end.lld_script | 3 +++
bolt/test/Inputs/lsda.ldscript | 3 +++
2 files changed, 6 insertions(+)
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) }
More information about the llvm-commits
mailing list