Commit f44f1e7d authored by Florian Fainelli's avatar Florian Fainelli Committed by Richard Weinberger

um: Avoid longjmp/setjmp symbol clashes with libpthread.a

Building a statically linked UML kernel on a Centos 6.9 host resulted in
the following linking failure (GCC 4.4, glibc-2.12):

/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/libpthread.a(libpthread.o):
In function `siglongjmp':
(.text+0x8490): multiple definition of `longjmp'
arch/x86/um/built-in.o:/local/users/fainelli/openwrt/trunk/build_dir/target-x86_64_musl/linux-uml/linux-4.4.69/arch/x86/um/setjmp_64.S:44:
first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/libpthread.a(libpthread.o):
In function `sem_open':
(.text+0x77cd): warning: the use of `mktemp' is dangerous, better use
`mkstemp'
collect2: ld returned 1 exit status
make[4]: *** [vmlinux] Error 1

Adopt a solution similar to the one done for vmap where we define
longjmp/setjmp to be kernel_longjmp/setjmp. In the process, make sure we
do rename the functions in arch/x86/um/setjmp_*.S accordingly.

Fixes: a7df4716 ("um: link with -lpthread")
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 745a600c
...@@ -59,10 +59,14 @@ KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um ...@@ -59,10 +59,14 @@ KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um
# Same things for in6addr_loopback and mktime - found in libc. For these two we # Same things for in6addr_loopback and mktime - found in libc. For these two we
# only get link-time error, luckily. # only get link-time error, luckily.
# #
# -Dlongjmp=kernel_longjmp prevents anything from referencing the libpthread.a
# embedded copy of longjmp, same thing for setjmp.
#
# These apply to USER_CFLAGS to. # These apply to USER_CFLAGS to.
KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \ KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \
$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \ $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
-Dlongjmp=kernel_longjmp -Dsetjmp=kernel_setjmp \
-Din6addr_loopback=kernel_in6addr_loopback \ -Din6addr_loopback=kernel_in6addr_loopback \
-Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr -Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
.text .text
.align 4 .align 4
.globl setjmp .globl kernel_setjmp
.type setjmp, @function .type kernel_setjmp, @function
setjmp: kernel_setjmp:
#ifdef _REGPARM #ifdef _REGPARM
movl %eax,%edx movl %eax,%edx
#else #else
...@@ -35,13 +35,13 @@ setjmp: ...@@ -35,13 +35,13 @@ setjmp:
movl %ecx,20(%edx) # Return address movl %ecx,20(%edx) # Return address
ret ret
.size setjmp,.-setjmp .size kernel_setjmp,.-kernel_setjmp
.text .text
.align 4 .align 4
.globl longjmp .globl kernel_longjmp
.type longjmp, @function .type kernel_longjmp, @function
longjmp: kernel_longjmp:
#ifdef _REGPARM #ifdef _REGPARM
xchgl %eax,%edx xchgl %eax,%edx
#else #else
...@@ -55,4 +55,4 @@ longjmp: ...@@ -55,4 +55,4 @@ longjmp:
movl 16(%edx),%edi movl 16(%edx),%edi
jmp *20(%edx) jmp *20(%edx)
.size longjmp,.-longjmp .size kernel_longjmp,.-kernel_longjmp
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
.text .text
.align 4 .align 4
.globl setjmp .globl kernel_setjmp
.type setjmp, @function .type kernel_setjmp, @function
setjmp: kernel_setjmp:
pop %rsi # Return address, and adjust the stack pop %rsi # Return address, and adjust the stack
xorl %eax,%eax # Return value xorl %eax,%eax # Return value
movq %rbx,(%rdi) movq %rbx,(%rdi)
...@@ -34,13 +34,13 @@ setjmp: ...@@ -34,13 +34,13 @@ setjmp:
movq %rsi,56(%rdi) # Return address movq %rsi,56(%rdi) # Return address
ret ret
.size setjmp,.-setjmp .size kernel_setjmp,.-kernel_setjmp
.text .text
.align 4 .align 4
.globl longjmp .globl kernel_longjmp
.type longjmp, @function .type kernel_longjmp, @function
longjmp: kernel_longjmp:
movl %esi,%eax # Return value (int) movl %esi,%eax # Return value (int)
movq (%rdi),%rbx movq (%rdi),%rbx
movq 8(%rdi),%rsp movq 8(%rdi),%rsp
...@@ -51,4 +51,4 @@ longjmp: ...@@ -51,4 +51,4 @@ longjmp:
movq 48(%rdi),%r15 movq 48(%rdi),%r15
jmp *56(%rdi) jmp *56(%rdi)
.size longjmp,.-longjmp .size kernel_longjmp,.-kernel_longjmp
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment