From 805b87ea74e0d6b0f6f35a146ae727de198ab801 Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 20 Dec 2023 14:50:08 +0000 Subject: [PATCH] For strange reasons which made sense at the time, the text segment was placed head of the btext (boot.text) segment. (the boot.text segment is "unmapped" after initization, as a self-protection mechanism). this meant the LOAD's virtual addresses were not in sequence, which clearly isn't what we intended. --- libexec/ld.so/aarch64/ld.script | 6 +++--- libexec/ld.so/alpha/ld.script | 4 ++-- libexec/ld.so/amd64/ld.script | 2 +- libexec/ld.so/arm/ld.script | 6 +++--- libexec/ld.so/hppa/ld.script | 6 +++--- libexec/ld.so/i386/ld.script | 2 +- libexec/ld.so/m88k/ld.script | 2 +- libexec/ld.so/mips64/ld.script | 2 +- libexec/ld.so/powerpc/ld.script | 2 +- libexec/ld.so/riscv64/ld.script | 6 +++--- libexec/ld.so/sh/ld.script | 6 +++--- libexec/ld.so/sparc64/ld.script | 2 +- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/libexec/ld.so/aarch64/ld.script b/libexec/ld.so/aarch64/ld.script index f2dbd181fd1..23ff1c3e0c1 100644 --- a/libexec/ld.so/aarch64/ld.script +++ b/libexec/ld.so/aarch64/ld.script @@ -1,8 +1,8 @@ PHDRS { rodata PT_LOAD FILEHDR PHDRS FLAGS (4); - text PT_LOAD FLAGS (1); btext PT_LOAD FLAGS (0x08000001); + text PT_LOAD FLAGS (1); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; syscalls PT_OPENBSD_SYSCALLS; @@ -23,8 +23,6 @@ SECTIONS /* TEXT */ . = ALIGN(0x10000); - .text : { *(.text .text.*) } :text - . = ALIGN(0x1000); .boot.text : { . = ALIGN(0x1000); @@ -33,6 +31,8 @@ SECTIONS . = ALIGN(0x1000); boot_text_end = .; } :btext + . = ALIGN(0x1000); + .text : { *(.text .text.*) } :text /* RELRO DATA */ . = DATA_SEGMENT_ALIGN (0x10000, 0x1000); diff --git a/libexec/ld.so/alpha/ld.script b/libexec/ld.so/alpha/ld.script index 33bfb8d8c7a..dd642a29f0c 100644 --- a/libexec/ld.so/alpha/ld.script +++ b/libexec/ld.so/alpha/ld.script @@ -23,8 +23,6 @@ SECTIONS /* TEXT */ . = ALIGN(0x10000); - .text : { *(.text .text.*) } :text - . = ALIGN(0x2000); .boot.text : { . = ALIGN(0x2000); @@ -33,6 +31,8 @@ SECTIONS *(.boot.text) boot_text_end = .; } :btext + . = ALIGN(0x2000); + .text : { *(.text .text.*) } :text /* RELRO DATA */ . = DATA_SEGMENT_ALIGN (0x10000, 0x2000); diff --git a/libexec/ld.so/amd64/ld.script b/libexec/ld.so/amd64/ld.script index 12bb242a63c..78da6e58c71 100644 --- a/libexec/ld.so/amd64/ld.script +++ b/libexec/ld.so/amd64/ld.script @@ -1,8 +1,8 @@ PHDRS { rodata PT_LOAD FILEHDR PHDRS FLAGS (4); - text PT_LOAD FLAGS (1); btext PT_LOAD FLAGS (0x08000005); + text PT_LOAD FLAGS (1); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; syscalls PT_OPENBSD_SYSCALLS; diff --git a/libexec/ld.so/arm/ld.script b/libexec/ld.so/arm/ld.script index 0d66e23cd51..5784d962a7f 100644 --- a/libexec/ld.so/arm/ld.script +++ b/libexec/ld.so/arm/ld.script @@ -1,8 +1,8 @@ PHDRS { rodata PT_LOAD FILEHDR PHDRS FLAGS (4); - text PT_LOAD; btext PT_LOAD FLAGS (0x08000005); + text PT_LOAD; data PT_LOAD; random PT_OPENBSD_RANDOMIZE; syscalls PT_OPENBSD_SYSCALLS; @@ -24,8 +24,6 @@ SECTIONS /* TEXT */ . = ALIGN(0x10000); - .text : { *(.text .text.*) } :text - . = ALIGN(0x1000); .boot.text : { . = ALIGN(0x1000); @@ -34,6 +32,8 @@ SECTIONS . = ALIGN(0x1000); boot_text_end = .; } :btext + . = ALIGN(0x1000); + .text : { *(.text .text.*) } :text /* RELRO DATA */ . = DATA_SEGMENT_ALIGN (0x10000, 0x1000); diff --git a/libexec/ld.so/hppa/ld.script b/libexec/ld.so/hppa/ld.script index 163c667a7a8..6ea4aab5728 100644 --- a/libexec/ld.so/hppa/ld.script +++ b/libexec/ld.so/hppa/ld.script @@ -1,8 +1,8 @@ PHDRS { rodata PT_LOAD FILEHDR PHDRS FLAGS (4); - text PT_LOAD FLAGS (1); btext PT_LOAD FLAGS (0x08000005); + text PT_LOAD FLAGS (1); pltgot PT_LOAD; data PT_LOAD; random PT_OPENBSD_RANDOMIZE; @@ -24,8 +24,6 @@ SECTIONS /* TEXT */ . = ALIGN(0x1000); - .text : { *(.text .text.*) } :text - . = ALIGN(0x1000); .boot.text : { . = ALIGN(0x1000); @@ -34,6 +32,8 @@ SECTIONS . = ALIGN(0x1000); boot_text_end = .; } :btext + . = ALIGN(0x1000); + .text : { *(.text .text.*) } :text /* PLT and GOT */ . = ALIGN(0x1000); diff --git a/libexec/ld.so/i386/ld.script b/libexec/ld.so/i386/ld.script index 555c3741ed9..dc8cca7a629 100644 --- a/libexec/ld.so/i386/ld.script +++ b/libexec/ld.so/i386/ld.script @@ -1,8 +1,8 @@ PHDRS { rodata PT_LOAD FILEHDR PHDRS FLAGS (4); - text PT_LOAD FLAGS (1); btext PT_LOAD FLAGS (0x08000005); + text PT_LOAD FLAGS (1); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; syscalls PT_OPENBSD_SYSCALLS; diff --git a/libexec/ld.so/m88k/ld.script b/libexec/ld.so/m88k/ld.script index 342524544b6..b5f405715ba 100644 --- a/libexec/ld.so/m88k/ld.script +++ b/libexec/ld.so/m88k/ld.script @@ -1,8 +1,8 @@ PHDRS { rodata PT_LOAD FILEHDR PHDRS FLAGS (4); - text PT_LOAD; btext PT_LOAD FLAGS (0x08000005); + text PT_LOAD; data PT_LOAD; random PT_OPENBSD_RANDOMIZE; syscalls PT_OPENBSD_SYSCALLS; diff --git a/libexec/ld.so/mips64/ld.script b/libexec/ld.so/mips64/ld.script index a1392fb2342..db683960646 100644 --- a/libexec/ld.so/mips64/ld.script +++ b/libexec/ld.so/mips64/ld.script @@ -1,8 +1,8 @@ PHDRS { rodata PT_LOAD FILEHDR PHDRS FLAGS (4); - text PT_LOAD FLAGS (1); btext PT_LOAD FLAGS (0x08000005); + text PT_LOAD FLAGS (1); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; syscalls PT_OPENBSD_SYSCALLS; diff --git a/libexec/ld.so/powerpc/ld.script b/libexec/ld.so/powerpc/ld.script index afd66c5afd1..a3fbc0c340a 100644 --- a/libexec/ld.so/powerpc/ld.script +++ b/libexec/ld.so/powerpc/ld.script @@ -1,8 +1,8 @@ PHDRS { rodata PT_LOAD FILEHDR PHDRS FLAGS (4); - text PT_LOAD FLAGS (1); btext PT_LOAD FLAGS (0x08000005); + text PT_LOAD FLAGS (1); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; syscalls PT_OPENBSD_SYSCALLS; diff --git a/libexec/ld.so/riscv64/ld.script b/libexec/ld.so/riscv64/ld.script index 7050c4a995b..91e9dc4adeb 100644 --- a/libexec/ld.so/riscv64/ld.script +++ b/libexec/ld.so/riscv64/ld.script @@ -1,8 +1,8 @@ PHDRS { rodata PT_LOAD FILEHDR PHDRS FLAGS (4); - text PT_LOAD FLAGS (1); btext PT_LOAD FLAGS (0x08000005); + text PT_LOAD FLAGS (1); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; syscalls PT_OPENBSD_SYSCALLS; @@ -23,8 +23,6 @@ SECTIONS /* TEXT */ . = ALIGN(0x10000); - .text : { *(.text .text.*) } :text - . = ALIGN(0x1000); .boot.text : { . = ALIGN(0x1000); @@ -33,6 +31,8 @@ SECTIONS . = ALIGN(0x1000); boot_text_end = .; } :btext + . = ALIGN(0x1000); + .text : { *(.text .text.*) } :text /* RELRO DATA */ . = DATA_SEGMENT_ALIGN (0x10000, 0x1000); diff --git a/libexec/ld.so/sh/ld.script b/libexec/ld.so/sh/ld.script index d5a87d7e848..a393c8f931d 100644 --- a/libexec/ld.so/sh/ld.script +++ b/libexec/ld.so/sh/ld.script @@ -1,8 +1,8 @@ PHDRS { rodata PT_LOAD FILEHDR PHDRS FLAGS (4); - text PT_LOAD FLAGS (5); /* architecturally required data islands */ btext PT_LOAD FLAGS (0x08000005); + text PT_LOAD FLAGS (5); /* architecturally required data islands */ data PT_LOAD; random PT_OPENBSD_RANDOMIZE; syscalls PT_OPENBSD_SYSCALLS; @@ -23,14 +23,14 @@ SECTIONS /* TEXT */ . = ALIGN (0x1000); - .text : { *(.text .text.*) } :text =0xc3c3c3c3 - . = ALIGN (0x1000); .boot.text : { boot_text_start = .; *(.boot.text) boot_text_end = .; } :btext + . = ALIGN (0x1000); + .text : { *(.text .text.*) } :text =0xc3c3c3c3 /* RELRO DATA */ . = DATA_SEGMENT_ALIGN (0x10000, 0x1000); diff --git a/libexec/ld.so/sparc64/ld.script b/libexec/ld.so/sparc64/ld.script index e7b0c06c94e..77873fa40d0 100644 --- a/libexec/ld.so/sparc64/ld.script +++ b/libexec/ld.so/sparc64/ld.script @@ -1,8 +1,8 @@ PHDRS { rodata PT_LOAD FILEHDR PHDRS FLAGS (4); - text PT_LOAD FLAGS (1); btext PT_LOAD FLAGS (0x08000005); + text PT_LOAD FLAGS (1); data PT_LOAD; random PT_OPENBSD_RANDOMIZE; syscalls PT_OPENBSD_SYSCALLS; -- 2.20.1