I want to Port Peep2k's web failsafe http to mt7620 Uboot, but there is an error undefined reference to ' strstr '.
The console output is as follows:
NET/LIBNET.A (HTTPD.O): in function ' Httpd_findandstore_firstchunk ':
uip-0.9/httpd.c: (. text+0x90): undefined Reference to ' Strstr '
uip-0.9/httpd.c: (. text+0xa8): Undefined reference to ' strstr '
uip-0.9/httpd.c: (. text+ 0xd4): Undefined reference to ' strstr '
uip-0.9/httpd.c: (. text+0x108): Undefined reference to ' strstr '
uip-0.9/ HTTPD.C: (. text+0x14c): Undefined reference to ' strstr '
Analysis:
This error is in the link stage, stating that the method that provides the STRSTR function is not eventually compiled into the target file. Obviously, the STRSTR function appears in the STRING.C source file, where is the problem.
Then opened the string.c file, found the mystery.
#ifndef __have_arch_strstr
/**
* Strstr-find the first substring in a%nul terminated string
* @s1: The Stri ng to is searched
* @s2: The string to search for
*
/char * STRSTR (const char * s1,const char * s2)
{
int L1, L2;
L2 = strlen (s2);
if (!L2)
return (char *) s1;
L1 = strlen (S1);
while (L1 >= L2) {
l1--;
if (!memcmp (S1,S2,L2))
return (char *) s1;
s1++;
}
return NULL;
}
#endif
#ifndef __HAVE_ARCH_STRSTR
If __HAVE_ARCH_STRSTR is not defined, the STRSTR is compiled. Look at the front of the file on the definition of the macro, it will be enlightened.
/* In the order to save flash space, we declare below the definition here.
* Please modify the IT if you need below function */
#define __HAVE_ARCH_STRNICMP
#define __HAVE_ARCH_STRNICMP
#d Efine __have_arch_strcpy
#define __HAVE_ARCH_STRNCPY
#define __HAVE_ARCH_STRCAT
#define __have_arch_ Strncat
#define __HAVE_ARCH_STRCMP
#define __HAVE_ARCH_STRNCMP
#define __HAVE_ARCH_STRDUP
# Define __HAVE_ARCH_STRSPN
#define __HAVE_ARCH_STRPBRK
#define __HAVE_ARCH_STRTOK
#define __have_ Arch_strsep
#define __HAVE_ARCH_STRSWAB
#define __HAVE_ARCH_BCOPY
#define __have_arch_memscan
#define __HAVE_ARCH_STRSTR
#define __HAVE_ARCH_MEMCHR
Look at the English comments above, you should understand what is going on, comment out the corresponding macro can be.