Search code examples
linuxgccassemblyglibcpowerpc

Error unsupported relocate against assembly system call


I am trying to cross compile glibc-2.18 for powerpc freescale evaluation board.

At one of the stages in the build I get following error:

    glibc
Failed:
 ../sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S: Assembler messages:
 ../sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S:40: Error: unsupported relocation against swapcontext
 make[3]: *** [/home/user/Desktop/SmoothWall/bcutm/distrib/build/sources/glibc/glibc-2.18-compile/stdlib/setcontext.o] Error 1
 make[3]: Leaving directory  /home/user/Desktop/SmoothWall/bcutm/distrib/build/sources/glibc/glibc-2.18/stdlib'
 make[2]: *** [stdlib/subdir_lib] Error 2
 make[2]: Leaving directory `/home/user/Desktop/SmoothWall/bcutm/distrib/build/sources/glibc/glibc-2.18'
 make[1]: *** [all] Error 2
 make[1]: Leaving directory `/home/user/Desktop/SmoothWall/bcutm/distrib/build/sources/glibc/glibc-2.18-compile'

Solution

  • The SYS_ify(swapcontext) macro there should evaluate to __NR_swapcontext, which is the number for the swapcontext system call.

    __NR_swapcontext is a macro, not a variable name - so it should have been resolved by the preprocessor (see asm/unistd.h). It looks like you don't have a definition for this, and so it didn't get preprocessed to the syscall number, and so left you with an unresolved variable name.

    So, your problem is the missing definition for __NR_swapcontext, which should be provided by the kernel headers that glibc is compiling against. Do you have the correct kernel headers available?

    Since swapcontext is a powerpc-only system call, it it possible that you're trying to compile glibc against your build machine's headers instead.