4.14 kernel link error - strrchr undefined

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

jay214128
Posts: 20
Joined: Fri Jan 23, 2015 3:29 am

4.14 kernel link error - strrchr undefined

Sat Oct 27, 2018 12:35 am

I am trying to build the new 4.14 kernel (linux-at91-linux-4.14-at91) and am getting a link error.

Code: Select all

arch/arm/boot/compressed/fdt_ro.o: In function `fdt_get_name':
fdt_ro.c:(.text+0x1dc): undefined reference to `strrchr'
arch/arm/boot/compressed/Makefile:182: recipe for target 'arch/arm/boot/compressed/vmlinux' failed
make[2]: *** [arch/arm/boot/compressed/vmlinux] Error 1
arch/arm/boot/Makefile:53: recipe for target 'arch/arm/boot/compressed/vmlinux' failed
make[1]: *** [arch/arm/boot/compressed/vmlinux] Error 2
arch/arm/Makefile:343: recipe for target 'zImage' failed
make: *** [zImage] Error 2
make uImage failed - 2.
On a whim, I commented out the definition of __HAVE_ARCH_STRRCHR in arch/arm/include/asm/string.h, so that the strrchr() function from lib/string.c would get included, but then I got a duplicate definition for strrchr() with arch/arm/lib.

Any idea on how to get fdt to link with the arch/arm/lib strrchr() function?
jay214128
Posts: 20
Joined: Fri Jan 23, 2015 3:29 am

Re: 4.14 kernel link error - strrchr undefined

Mon Oct 29, 2018 6:08 pm

After some more investigation, I am able to resolve this by adding the strrchr() function to arch/arm/boot/compressed/string.c (copied from lib/string.c).

Code: Select all

Index: arch/arm/boot/compressed/string.c
===================================================================
--- arch/arm/boot/compressed/string.c	(revision 5582)
+++ arch/arm/boot/compressed/string.c	(working copy)
@@ -121,6 +121,16 @@
 	return (char *)s;
 }
 
+char *strrchr(const char *s, int c)
+{
+	const char *last = NULL;
+	do {
+		if (*s == (char)c)
+			last = s;
+	} while (*s++);
+	return (char *)last;
+}
+
 #undef memset
 
 void *memset(void *s, int c, size_t count)
It looks like a call to strrchr() was added in new code in arch/arm/boot/compressed/fdt_ro.c, but the strrchr() function was not added the arch/arm/boot/compressed/string.c file.
blue_z
Location: USA
Posts: 1785
Joined: Thu Apr 19, 2007 10:15 pm

Re: 4.14 kernel link error - strrchr undefined

Tue Oct 30, 2018 11:58 pm

Looks like you found Rob Herring's patch that went into mainline 4.17.
Are you actually using this boot feature, i.e. appending the DT blob to the zImage, which is intended for legacy boot programs?

Regards
jay214128
Posts: 20
Joined: Fri Jan 23, 2015 3:29 am

Re: 4.14 kernel link error - strrchr undefined

Thu Nov 01, 2018 1:19 am

Yes, I am using that feature. I use this feature to produce an updated kernel that is compatible with units in the field that do not have boot loaders that have or pass a DTB to the kernel.

Return to “LINUX”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests