Skip to content

Commit fbe6a8e

Browse files
keessuryasaimadhu
authored andcommitted
vmlinux.lds.h: Move Program Header restoration into NOTES macro
In preparation for moving NOTES into RO_DATA, make the Program Header assignment restoration be part of the NOTES macro itself. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Borislav Petkov <bp@suse.de> Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> # s390 Cc: Andy Lutomirski <luto@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: linux-alpha@vger.kernel.org Cc: linux-arch@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-c6x-dev@linux-c6x.org Cc: linux-ia64@vger.kernel.org Cc: linux-s390@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Simek <monstr@monstr.eu> Cc: Rick Edgecombe <rick.p.edgecombe@intel.com> Cc: Segher Boessenkool <segher@kernel.crashing.org> Cc: Will Deacon <will@kernel.org> Cc: x86-ml <x86@kernel.org> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Link: https://lkml.kernel.org/r/20191029211351.13243-10-keescook@chromium.org
1 parent 441110a commit fbe6a8e

7 files changed

Lines changed: 17 additions & 19 deletions

File tree

‎arch/alpha/kernel/vmlinux.lds.S‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ SECTIONS
3434
swapper_pg_dir = SWAPPER_PGD;
3535
_etext = .; /* End of text section */
3636

37-
NOTES :text :note
38-
.dummy : {
39-
*(.dummy)
40-
} :text
37+
NOTES
4138

4239
RODATA
4340
EXCEPTION_TABLE(16)

‎arch/ia64/kernel/vmlinux.lds.S‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ SECTIONS {
7070
/*
7171
* Read-only data
7272
*/
73-
NOTES :text :note /* put .notes in text and mark in PT_NOTE */
74-
code_continues : {
75-
} :text /* switch back to regular program... */
73+
NOTES
7674

7775
EXCEPTION_TABLE(16)
7876

‎arch/mips/kernel/vmlinux.lds.S‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ SECTIONS
8181
__stop___dbe_table = .;
8282
}
8383

84-
NOTES NOTES_HEADERS
85-
.dummy : { *(.dummy) } :text
84+
NOTES
8685

8786
_sdata = .; /* Start of data section */
8887
RODATA

‎arch/powerpc/kernel/vmlinux.lds.S‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ SECTIONS
164164
#endif
165165
EXCEPTION_TABLE(0)
166166

167-
NOTES :text :note
168-
/* Restore program header away from PT_NOTE. */
169-
.dummy : { *(.dummy) } :text
167+
NOTES
170168

171169
/*
172170
* Init sections discarded at runtime

‎arch/s390/kernel/vmlinux.lds.S‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ SECTIONS
5252
_etext = .; /* End of text section */
5353
} :text = 0x0700
5454

55-
NOTES :text :note
56-
57-
.dummy : { *(.dummy) } :text
55+
NOTES
5856

5957
RO_DATA_SECTION(PAGE_SIZE)
6058

‎arch/x86/kernel/vmlinux.lds.S‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ SECTIONS
148148
_etext = .;
149149
} :text = 0x9090
150150

151-
NOTES :text :note
152-
.dummy : { *(.dummy) } :text
151+
NOTES
153152

154153
EXCEPTION_TABLE(16)
155154

‎include/asm-generic/vmlinux.lds.h‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,18 @@
5656

5757
/*
5858
* Only some architectures want to have the .notes segment visible in
59-
* a separate PT_NOTE ELF Program Header.
59+
* a separate PT_NOTE ELF Program Header. When this happens, it needs
60+
* to be visible in both the kernel text's PT_LOAD and the PT_NOTE
61+
* Program Headers. In this case, though, the PT_LOAD needs to be made
62+
* the default again so that all the following sections don't also end
63+
* up in the PT_NOTE Program Header.
6064
*/
6165
#ifdef EMITS_PT_NOTE
6266
#define NOTES_HEADERS :text :note
67+
#define NOTES_HEADERS_RESTORE __restore_ph : { *(.__restore_ph) } :text
68+
#else
69+
#define NOTES_HEADERS
70+
#define NOTES_HEADERS_RESTORE
6371
#endif
6472

6573
/* Align . to a 8 byte boundary equals to maximum function alignment. */
@@ -798,7 +806,8 @@
798806
__start_notes = .; \
799807
KEEP(*(.note.*)) \
800808
__stop_notes = .; \
801-
}
809+
} NOTES_HEADERS \
810+
NOTES_HEADERS_RESTORE
802811

803812
#define INIT_SETUP(initsetup_align) \
804813
. = ALIGN(initsetup_align); \

0 commit comments

Comments
 (0)