Skip to contentSkip to conversation

arc4.c:(___ksymtab+arc4_setkey+0x8): undefined reference to `no symbol'

PATCH Jessica Yu 2 participants 2 messages Sep 11, 2019 2 messages not in the archive Generic include/asm header files

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 201909110352.uPcQrbuc%[email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Jessica Yu

author
#2 lore raw

+++ Matthias Maennich [11/09/19 06:21 +0100]:

Quoted 43 lines · kbuild test robot
Quoted 12 lines
tree:   https://kernel.googlesource.com/pub/scm/linux/kernel/git/jeyu/linux.git modules-next
head:   32bca2df7da27be34371a37f9bb5e2b85fdd92bd
commit: 8651ec01daedad26290f76beeb4736f9d2da4b87 [3/11] module: add support for symbol namespaces.
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 7.4.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
git checkout 8651ec01daedad26290f76beeb4736f9d2da4b87
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=arm64

Quoted 9 lines

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

lib/crypto/arc4.o: In function `__ksymtab_arc4_setkey':

Quoted 1 line
Quoted 1 line

arc4.c:(___ksymtab+arc4_setkey+0x8): undefined reference to `no symbol'

lib/crypto/arc4.o: In function `__ksymtab_arc4_crypt':

Quoted 1 line
Quoted 1 line

arc4.c:(___ksymtab+arc4_crypt+0x8): undefined reference to `no symbol'

Hmm, this is caused by the relative relocation of the 'namespace_offset' struct member to NULL in case there is no namespace defined:

#define __KSYMTAB_ENTRY(sym, sec)					\
	__ADDRESSABLE(sym)						\
	asm("	.section \"___ksymtab" sec "+" #sym "\", \"a\"	\n"	\
	    "	.balign 4					\n"	\
	    "__ksymtab_" #sym ":				\n"	\
	    "	.long	" #sym "- .				\n"	\
	    "	.long	__kstrtab_" #sym "- .			\n"	\
	    "	.long	0 - .					\n"	\
	    	       ^^^^^^^
	    "	.previous					\n")
struct kernel_symbol {
	int value_offset;
	int name_offset;
	int namespace_offset;
};
Quoted 5 lines

That is apparently not an issue on x86, but on arm. Not sure how to express a relative relocation to NULL then.

I will try to solve this somehow, just wanted to check if somebody knows the trick here.

(Adding more CC's..)

Do we have to have a place-relative relocation there? If we can't find a workaround, having just .long 0 for a null namespace seemed to fix the build issues on arm64 for me at least..

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw

Hi all,

Quoted 47 lines · Jessica Yu

+++ Matthias Maennich [11/09/19 06:21 +0100]:

Quoted 46 lines · kbuild test robot
Quoted 12 lines
tree:   https://kernel.googlesource.com/pub/scm/linux/kernel/git/jeyu/linux.git modules-next
head:   32bca2df7da27be34371a37f9bb5e2b85fdd92bd
commit: 8651ec01daedad26290f76beeb4736f9d2da4b87 [3/11] module: add support for symbol namespaces.
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 7.4.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
git checkout 8651ec01daedad26290f76beeb4736f9d2da4b87
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=arm64

Quoted 9 lines

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

lib/crypto/arc4.o: In function `__ksymtab_arc4_setkey':

Quoted 1 line
Quoted 1 line

arc4.c:(___ksymtab+arc4_setkey+0x8): undefined reference to `no symbol'

lib/crypto/arc4.o: In function `__ksymtab_arc4_crypt':

Quoted 1 line
Quoted 1 line

arc4.c:(___ksymtab+arc4_crypt+0x8): undefined reference to `no symbol'

Hmm, this is caused by the relative relocation of the 'namespace_offset' struct member to NULL in case there is no namespace defined:

#define __KSYMTAB_ENTRY(sym, sec)					\
	__ADDRESSABLE(sym)						\
	asm("	.section \"___ksymtab" sec "+" #sym "\", \"a\"	\n"	\
	    "	.balign 4					\n"	\
	    "__ksymtab_" #sym ":				\n"	\
	    "	.long	" #sym "- .				\n"	\
	    "	.long	__kstrtab_" #sym "- .			\n"	\
	    "	.long	0 - .					\n"	\
	    	       ^^^^^^^
	    "	.previous					\n")
struct kernel_symbol {
	int value_offset;
	int name_offset;
	int namespace_offset;
};

That is apparently not an issue on x86, but on arm. Not sure how to express a relative relocation to NULL then.

Quoted 8 lines
Quoted 2 lines

I will try to solve this somehow, just wanted to check if somebody knows the trick here.

(Adding more CC's..)

Do we have to have a place-relative relocation there? If we can't find a workaround, having just .long 0 for a null namespace seemed to fix the build issues on arm64 for me at least..

Ard, Alex and I have hacked the following diff which seems to do the trick. I'll post as a proper patch later today.

Will

--->8

include/asm-generic/export.h +1 -1
index e2b5d0f569d3..d0912c7ac2fc 100644
@@ -17,7 +17,7 @@
 
 .macro __put, val, name
 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
-	.long	\val - ., \name - ., 0 - .
+	.long	\val - ., \name - ., 0
 #elif defined(CONFIG_64BIT)
 	.quad	\val, \name, 0
 #else
include/linux/export.h +1 -1
index 2c5468d8ea9a..ef5d015d754a 100644
@@ -68,7 +68,7 @@ extern struct module __this_module;
 	    "__ksymtab_" #sym ":				\n"	\
 	    "	.long	" #sym "- .				\n"	\
 	    "	.long	__kstrtab_" #sym "- .			\n"	\
-	    "	.long	0 - .					\n"	\
+	    "	.long	0					\n"	\
 	    "	.previous					\n")
 
 struct kernel_symbol {
kernel/module.c +2 -0
index f76efcf2043e..7ab244c4e1ba 100644
@@ -547,6 +547,8 @@ static const char *kernel_symbol_name(const struct kernel_symbol *sym)
 static const char *kernel_symbol_namespace(const struct kernel_symbol *sym)
 {
 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+	if (!sym->namespace_offset)
+		return NULL;
 	return offset_to_ptr(&sym->namespace_offset);
 #else
 	return sym->namespace;

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel