Skip to content

Commit 3022685

Browse files
nathanchancehcahca
authored andcommitted
s390: vmlinux.lds.S: explicitly handle '.got' and '.plt' sections
When building with CONFIG_LD_ORPHAN_WARN after selecting CONFIG_ARCH_HAS_LD_ORPHAN_WARN, there are a lot of warnings around the GOT and PLT sections: s390-linux-ld: warning: orphan section `.plt' from `arch/s390/kernel/head64.o' being placed in section `.plt' s390-linux-ld: warning: orphan section `.got' from `arch/s390/kernel/head64.o' being placed in section `.got' s390-linux-ld: warning: orphan section `.got.plt' from `arch/s390/kernel/head64.o' being placed in section `.got.plt' s390-linux-ld: warning: orphan section `.iplt' from `arch/s390/kernel/head64.o' being placed in section `.iplt' s390-linux-ld: warning: orphan section `.igot.plt' from `arch/s390/kernel/head64.o' being placed in section `.igot.plt' s390-linux-ld: warning: orphan section `.iplt' from `arch/s390/boot/head.o' being placed in section `.iplt' s390-linux-ld: warning: orphan section `.igot.plt' from `arch/s390/boot/head.o' being placed in section `.igot.plt' s390-linux-ld: warning: orphan section `.got' from `arch/s390/boot/head.o' being placed in section `.got' Currently, only the '.got' section is actually emitted in the final binary. In a manner similar to other architectures, put the '.got' section near the '.data' section and coalesce the PLT sections, checking that the final section is zero sized, which is a safe/tested approach versus full discard. Signed-off-by: Nathan Chancellor <[email protected]> Tested-by: Justin Stitt <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Heiko Carstens <[email protected]>
1 parent bdf2cd2 commit 3022685

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

arch/s390/boot/vmlinux.lds.S

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ SECTIONS
3939
*(.rodata.*)
4040
_erodata = . ;
4141
}
42+
.got : {
43+
*(.got)
44+
}
4245
NOTES
4346
.data : {
4447
_data = . ;
@@ -118,6 +121,19 @@ SECTIONS
118121
}
119122
_end = .;
120123

124+
/*
125+
* Sections that should stay zero sized, which is safer to
126+
* explicitly check instead of blindly discarding.
127+
*/
128+
.got.plt : {
129+
*(.got.plt)
130+
}
131+
ASSERT(SIZEOF(.got.plt) == 0, "Unexpected GOT/PLT entries detected!")
132+
.plt : {
133+
*(.plt) *(.plt.*) *(.iplt) *(.igot .igot.plt)
134+
}
135+
ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
136+
121137
/* Sections to be discarded */
122138
/DISCARD/ : {
123139
*(.eh_frame)

arch/s390/kernel/vmlinux.lds.S

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ SECTIONS
6262
.data.rel.ro : {
6363
*(.data.rel.ro .data.rel.ro.*)
6464
}
65+
.got : {
66+
*(.got)
67+
}
6568

6669
. = ALIGN(PAGE_SIZE);
6770
_sdata = .; /* Start of data section */
@@ -241,6 +244,19 @@ SECTIONS
241244
DWARF_DEBUG
242245
ELF_DETAILS
243246

247+
/*
248+
* Sections that should stay zero sized, which is safer to
249+
* explicitly check instead of blindly discarding.
250+
*/
251+
.got.plt : {
252+
*(.got.plt)
253+
}
254+
ASSERT(SIZEOF(.got.plt) == 0, "Unexpected GOT/PLT entries detected!")
255+
.plt : {
256+
*(.plt) *(.plt.*) *(.iplt) *(.igot .igot.plt)
257+
}
258+
ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
259+
244260
/* Sections to be discarded */
245261
DISCARDS
246262
/DISCARD/ : {

0 commit comments

Comments
 (0)