summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2025-01-28 10:34:01 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-02-02 09:20:53 +0000
commitf2b42c83dd0086dce484eae47b87b4351426746e (patch)
tree957d61faf8a57ac3c1a62906e8126cf76fcda5ad
parente5d95c786b6f25d81d754cb1d1b439a8b5c2340c (diff)
downloadedk2-f2b42c83dd0086dce484eae47b87b4351426746e.tar.gz
BaseTools/Scripts/GccBase.lds: Use separate R-W and RW- ELF segments
To prevent the ELF linkers from complaining about emitted ELF segments that require both writable and executable permissions, define two separate R-X and RW- ELF segments, and emit the output sections explicitly into those segments as appropriate. Note that this has no bearing on the PE image, and using a single RW- segment would probably be fine too. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
-rw-r--r--BaseTools/Scripts/GccBase.lds14
1 files changed, 11 insertions, 3 deletions
diff --git a/BaseTools/Scripts/GccBase.lds b/BaseTools/Scripts/GccBase.lds
index 582d00ccba..8d6c29d7b6 100644
--- a/BaseTools/Scripts/GccBase.lds
+++ b/BaseTools/Scripts/GccBase.lds
@@ -10,6 +10,12 @@
**/
+PHDRS {
+ text PT_LOAD FLAGS(5); /* R_X */
+ data PT_LOAD FLAGS(6); /* RW_ */
+ dynamic PT_DYNAMIC FLAGS(4); /* R__ */
+}
+
SECTIONS {
/*
@@ -35,7 +41,7 @@ SECTIONS {
* emitted GUIDs here.
*/
*:AutoGen.obj(.data.g*Guid)
- }
+ } :text
/*
* The alignment of the .data section should be less than or equal to the
@@ -46,19 +52,21 @@ SECTIONS {
.data ALIGN(ALIGNOF(.text)) : ALIGN(CONSTANT(COMMONPAGESIZE)) {
*(.data .data.* .gnu.linkonce.d.*)
*(.bss .bss.*)
- }
+ } :data
.eh_frame ALIGN(CONSTANT(COMMONPAGESIZE)) : {
KEEP (*(.eh_frame))
}
+ .dynamic : { *(.dynamic) } :data :dynamic
+
.rela (INFO) : {
*(.rela .rela.*)
}
.hii : ALIGN(CONSTANT(COMMONPAGESIZE)) {
KEEP (*(.hii))
- }
+ } :data
.got : {
*(.got)