compat: fix glibc >= 2.14 requirement
authorLuis R. Rodriguez <mcgrof@frijolero.org>
Thu, 9 Aug 2012 03:22:24 +0000 (20:22 -0700)
committerLuis R. Rodriguez <mcgrof@frijolero.org>
Thu, 9 Aug 2012 03:22:24 +0000 (20:22 -0700)
This project uses the vanilla kernels from the Ubuntu
vanilla kernel PPA. As of >= v3.4 vanilla kernel releases,
there are a few files which are binary in the kernel
headers which are linked with dynamic libraries. Of interest
to us here are the ones required to build external modules.

An example:

/lib/modules/3.4.4-030404-generic/build/scripts/genksyms/genksyms

The folks building these packages are using a glibc >= 2.14 and
although the *only* symbol I see being required from glibc >= 2.14
being memcpy():

mcgrof@garbanzo ~/compat (git::master)$ objdump -T
/home/mcgrof/compat-ksrc/lib/modules/3.4.4-030404-generic/build/scripts/genksyms/genksyms

/home/mcgrof/compat-ksrc/lib/modules/3.4.4-030404-generic/build/scripts/genksyms/genksyms:
    file format elf64-x86-64

DYNAMIC SYMBOL TABLE:
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.3.4 __snprintf_chk
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 free
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.3.4 __vfprintf_chk
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 __errno_location
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 ferror
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 isatty
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 fread
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 fclose
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strlen
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.4   __stack_chk_fail
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 getopt_long
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strchr
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 _IO_putc
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 fputs
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 fgetc
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 fputc
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 __strdup
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 __libc_start_main
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strcmp
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 feof
0000000000000000  w   D  *UND*  0000000000000000              __gmon_start__
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 strtol
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 clearerr

Bleh:

0000000000000000      DF *UND*  0000000000000000  GLIBC_2.14  memcpy

0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 fileno
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 malloc
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 _IO_getc
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 ungetc
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 realloc
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.3.4 __printf_chk
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 fopen
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 perror
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 exit
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.2.5 fwrite
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.3.4 __fprintf_chk
000000000060b160 g    DO .bss   0000000000000008  GLIBC_2.2.5 stdout
000000000060b168 g    DO .bss   0000000000000008  GLIBC_2.2.5 stdin
000000000060b178 g    DO .bss   0000000000000008  GLIBC_2.2.5 stderr
000000000060b170 g    DO .bss   0000000000000008  GLIBC_2.2.5 optarg

As proposed by Ozan we fix this by re-building some of the required
binaries under scripts/ to build external modules.

For details see:

https://lkml.org/lkml/2012/8/7/489

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
bin/get-compat-kernels

index 4479d0f4ec6f8fc46ed40cad1f5f225d653d9289..7975ccabbe9195db1c521f80554a3c1a9d445e73 100755 (executable)
@@ -151,15 +151,47 @@ function get_ubuntu_kernels() {
        rm -rf $TEMP_DIR
 }
 
+function rebuild_header_binary_deps() {
+       if [[ ! -d ${KSRC_PREFIX}/lib/modules/ ]]; then
+               echo "You do not seem to have any vanilla kernels available to fix"
+               exit 1
+       fi
+
+       COUNT=$(ls -d ${KSRC_PREFIX}/lib/modules/*generic | wc -l)
+       if [[ $COUNT -le 0 ]]; then
+               echo "You do not seem to have any vanilla kernels available to fix"
+               exit 1
+       fi
+
+       for kernel in $(ls -d ${KSRC_PREFIX}/lib/modules/*generic | tail -3); do
+               echo $kernel
+               make -C ${kernel}/build/ M=scripts/mod/
+               make -C ${kernel}/build/ M=scripts/basic/
+               make -C ${kernel}/build/ M=scripts/genksyms
+       done
+}
+
 function usage() {
-       echo -e "Usage: $0"
+       echo -e "Usage: $0 [ -r ] "
+       echo -e "-r Rebuilds binaries required in kernel headers. Use"
+       echo -e "   this option if you've already ran this script and"
+       echo -e "   just need to fix the libc versions against which"
+       echo -e "   the binaries in the headers files are linked against. "
+       echo -e "   This was added since kernels >= 3.4 used require"
+       echo -e "   a glibc >= 2.14 for memcpy(), and not all Linux"
+       echo -e "   Linux distributions have such glibc."
 }
 
-if [[ $# -gt 1 ]]; then
+if [[ $# -gt 2 ]]; then
        usage
        exit 1
 fi
 
+if [[ $1 == "-r" ]]; then
+       rebuild_header_binary_deps
+       exit
+fi
+
 # Check for the availability of 'ar' before continuing
 which ar 2>&1 > /dev/null
 if [[ $? -ne 0 ]]; then
@@ -200,3 +232,7 @@ if [[ "${REPLY}" != "y" ]]; then
 fi
 
 get_ubuntu_kernels
+echo -e "Vanilla kernels headers ${BLUE}installed${NORMAL}, "
+echo -e "now going to ${GREEN}rebuild${NORMAL} some binary dependencies..."
+sleep 1
+rebuild_header_binary_deps