Skip to content

Commit 7cf891a

Browse files
keesingomolnar
authored andcommitted
x86/boot/compressed: Reorganize zero-size section asserts
For readability, move the zero-sized sections to the end after DISCARDS. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20200821194310.3089815-27-keescook@chromium.org
1 parent 5354e84 commit 7cf891a

1 file changed

Lines changed: 26 additions & 18 deletions

File tree

arch/x86/boot/compressed/vmlinux.lds.S

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,6 @@ SECTIONS
4242
*(.rodata.*)
4343
_erodata = . ;
4444
}
45-
.rel.dyn : {
46-
*(.rel.*)
47-
}
48-
.rela.dyn : {
49-
*(.rela.*)
50-
}
51-
.got : {
52-
*(.got)
53-
}
54-
.got.plt : {
55-
*(.got.plt)
56-
}
57-
5845
.data : {
5946
_data = . ;
6047
*(.data)
@@ -85,13 +72,34 @@ SECTIONS
8572
ELF_DETAILS
8673

8774
DISCARDS
88-
}
8975

90-
ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!")
76+
.got.plt (INFO) : {
77+
*(.got.plt)
78+
}
79+
ASSERT(SIZEOF(.got.plt) == 0 ||
9180
#ifdef CONFIG_X86_64
92-
ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!")
81+
SIZEOF(.got.plt) == 0x18,
9382
#else
94-
ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0xc, "Unexpected GOT/PLT entries detected!")
83+
SIZEOF(.got.plt) == 0xc,
9584
#endif
85+
"Unexpected GOT/PLT entries detected!")
86+
87+
/*
88+
* Sections that should stay zero sized, which is safer to
89+
* explicitly check instead of blindly discarding.
90+
*/
91+
.got : {
92+
*(.got)
93+
}
94+
ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!")
95+
96+
.rel.dyn : {
97+
*(.rel.*)
98+
}
99+
ASSERT(SIZEOF(.rel.dyn) == 0, "Unexpected run-time relocations (.rel) detected!")
96100

97-
ASSERT(SIZEOF(.rel.dyn) == 0 && SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations detected!")
101+
.rela.dyn : {
102+
*(.rela.*)
103+
}
104+
ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!")
105+
}

0 commit comments

Comments
 (0)