x86, setup: Allow global variables and functions in the decompressor
In order for global variables and functions to work in the decompressor, we need to fix up the GOT in assembly code. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> LKML-Reference: <4C57382E.8050501@zytor.com>
This commit is contained in:
		
					parent
					
						
							
								70b0d22d58
							
						
					
				
			
			
				commit
				
					
						22a57f5896
					
				
			
		
					 3 changed files with 32 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -123,6 +123,19 @@ relocated:
 | 
			
		|||
	shrl	$2, %ecx
 | 
			
		||||
	rep	stosl
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Adjust our own GOT
 | 
			
		||||
 */
 | 
			
		||||
	leal	_got(%ebx), %edx
 | 
			
		||||
	leal	_egot(%ebx), %ecx
 | 
			
		||||
1:
 | 
			
		||||
	cmpl	%ecx, %edx
 | 
			
		||||
	jae	2f
 | 
			
		||||
	addl	%ebx, (%edx)
 | 
			
		||||
	addl	$4, %edx
 | 
			
		||||
	jmp	1b
 | 
			
		||||
2:
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Do the decompression, and jump to the new kernel..
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -279,6 +279,19 @@ relocated:
 | 
			
		|||
	shrq	$3, %rcx
 | 
			
		||||
	rep	stosq
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Adjust our own GOT
 | 
			
		||||
 */
 | 
			
		||||
	leaq	_got(%rip), %rdx
 | 
			
		||||
	leaq	_egot(%rip), %rcx
 | 
			
		||||
1:
 | 
			
		||||
	cmpq	%rcx, %rdx
 | 
			
		||||
	jae	2f
 | 
			
		||||
	addq	%rbx, (%rdx)
 | 
			
		||||
	addq	$8, %rdx
 | 
			
		||||
	jmp	1b
 | 
			
		||||
2:
 | 
			
		||||
	
 | 
			
		||||
/*
 | 
			
		||||
 * Do the decompression, and jump to the new kernel..
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,6 +41,12 @@ SECTIONS
 | 
			
		|||
		*(.rodata.*)
 | 
			
		||||
		_erodata = . ;
 | 
			
		||||
	}
 | 
			
		||||
	.got : {
 | 
			
		||||
		_got = .;
 | 
			
		||||
		KEEP(*(.got.plt))
 | 
			
		||||
		KEEP(*(.got))
 | 
			
		||||
		_egot = .;
 | 
			
		||||
	}
 | 
			
		||||
	.data :	{
 | 
			
		||||
		_data = . ;
 | 
			
		||||
		*(.data)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue