forked from mirrors/linux
		
	arm64/build: Assert for unwanted sections
In preparation for warning on orphan sections, discard unwanted non-zero-sized generated sections, and enforce other expected-to-be-zero-sized sections (since discarding them might hide problems with them suddenly gaining unexpected entries). Suggested-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20200821194310.3089815-14-keescook@chromium.org
This commit is contained in:
		
							parent
							
								
									578d7f0fd6
								
							
						
					
					
						commit
						be2881824a
					
				
					 1 changed files with 20 additions and 0 deletions
				
			
		| 
						 | 
					@ -121,6 +121,14 @@ SECTIONS
 | 
				
			||||||
		*(.got)			/* Global offset table		*/
 | 
							*(.got)			/* Global offset table		*/
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Make sure that the .got.plt is either completely empty or it
 | 
				
			||||||
 | 
						 * contains only the lazy dispatch entries.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						.got.plt : { *(.got.plt) }
 | 
				
			||||||
 | 
						ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18,
 | 
				
			||||||
 | 
						       "Unexpected GOT/PLT entries detected!")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	. = ALIGN(SEGMENT_ALIGN);
 | 
						. = ALIGN(SEGMENT_ALIGN);
 | 
				
			||||||
	_etext = .;			/* End of text section */
 | 
						_etext = .;			/* End of text section */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -243,6 +251,18 @@ SECTIONS
 | 
				
			||||||
	ELF_DETAILS
 | 
						ELF_DETAILS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	HEAD_SYMBOLS
 | 
						HEAD_SYMBOLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Sections that should stay zero sized, which is safer to
 | 
				
			||||||
 | 
						 * explicitly check instead of blindly discarding.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						.plt : {
 | 
				
			||||||
 | 
							*(.plt) *(.plt.*) *(.iplt) *(.igot)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						.data.rel.ro : { *(.data.rel.ro) }
 | 
				
			||||||
 | 
						ASSERT(SIZEOF(.data.rel.ro) == 0, "Unexpected RELRO detected!")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "image-vars.h"
 | 
					#include "image-vars.h"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue