mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	Minimum version of binutils required to compile the kernel is 2.25. This version correctly handles the "rep" prefixes, so it is possible to remove the semicolon, which was used to support ancient versions of GNU as. Due to the semicolon, the compiler considers "rep; insn" (or its alternate "rep\n\tinsn" form) as two separate instructions. Removing the semicolon makes asm length calculations more accurate, consequently making scheduling and inlining decisions of the compiler more accurate. Removing the semicolon also enables assembler checks involving "rep" prefixes. Trying to assemble e.g. "rep addl %eax, %ebx" results in: Error: invalid instruction `add' after `rep' Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Brian Gerst <brgerst@gmail.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Juergen Gross <jgross@suse.com> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Pavel Machek <pavel@kernel.org> Cc: Rafael J. Wysocki <rafael@kernel.org> Link: https://lore.kernel.org/r/20250418071437.4144391-2-ubizjak@gmail.com
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			744 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			744 B
		
	
	
	
		
			C
		
	
	
	
	
	
// SPDX-License-Identifier: GPL-2.0
 | 
						|
#include <linux/string.h>
 | 
						|
#include <linux/export.h>
 | 
						|
 | 
						|
char *strstr(const char *cs, const char *ct)
 | 
						|
{
 | 
						|
int	d0, d1;
 | 
						|
register char *__res;
 | 
						|
__asm__ __volatile__(
 | 
						|
	"movl %6,%%edi\n\t"
 | 
						|
	"repne scasb\n\t"
 | 
						|
	"notl %%ecx\n\t"
 | 
						|
	"decl %%ecx\n\t"	/* NOTE! This also sets Z if searchstring='' */
 | 
						|
	"movl %%ecx,%%edx\n"
 | 
						|
	"1:\tmovl %6,%%edi\n\t"
 | 
						|
	"movl %%esi,%%eax\n\t"
 | 
						|
	"movl %%edx,%%ecx\n\t"
 | 
						|
	"repe cmpsb\n\t"
 | 
						|
	"je 2f\n\t"		/* also works for empty string, see above */
 | 
						|
	"xchgl %%eax,%%esi\n\t"
 | 
						|
	"incl %%esi\n\t"
 | 
						|
	"cmpb $0,-1(%%eax)\n\t"
 | 
						|
	"jne 1b\n\t"
 | 
						|
	"xorl %%eax,%%eax\n\t"
 | 
						|
	"2:"
 | 
						|
	: "=a" (__res), "=&c" (d0), "=&S" (d1)
 | 
						|
	: "0" (0), "1" (0xffffffff), "2" (cs), "g" (ct)
 | 
						|
	: "dx", "di");
 | 
						|
return __res;
 | 
						|
}
 | 
						|
EXPORT_SYMBOL(strstr);
 |