[gccsdk] Linux fun with GCCSDK

Theo Markettos theo at markettos.org.uk
Sat Nov 12 14:24:19 PST 2011


I've just made a pointless discovery.  Take one Linux 3.2 kernel source
tree fresh out of git:

atm26 at bulova:/local/scratch/atm26/linux$ ls
arch	 Documentation	init	 lib		 net		 security
block	 drivers	ipc	 MAINTAINERS	 README		 sound
COPYING  firmware	Kbuild	 Makefile	 REPORTING-BUGS  tools
CREDITS  fs		Kconfig  mm		 samples	 usr
crypto	 include	kernel	 Module.symvers  scripts	 virt


First configure the kernel for ARM:

atm26 at bulova:/local/scratch/atm26/linux$
 PATH=/local/scratch/atm26/riscos/gccsdk/cross/bin/:$PATH make
 CROSS_COMPILE=arm-unknown-riscos- ARCH=arm menuconfig

Then let's build a random kernel module... how about Firewire?

atm26 at bulova:/local/scratch/atm26/linux$
 PATH=/local/scratch/atm26/riscos/gccsdk/cross/bin/:$PATH make
 CROSS_COMPILE=arm-unknown-riscos- ARCH=arm drivers/firewire/firewire-core.ko

  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  HOSTCC  scripts/basic/fixdep
make[1]: `include/generated/mach-types.h' is up to date.
  CC      kernel/bounds.s
  GEN     include/generated/bounds.h
  CC      arch/arm/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
<stdin>:1562:2: warning: #warning syscall process_vm_readv not implemented [-Wcpp]
<stdin>:1566:2: warning: #warning syscall process_vm_writev not implemented [-Wcpp]
  CC      scripts/mod/empty.o
  HOSTCC  scripts/mod/mk_elfconfig
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/mod/modpost.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  HOSTCC  scripts/selinux/genheaders/genheaders
  HOSTCC  scripts/selinux/mdp/mdp
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/pnmtologo
  HOSTCC  scripts/conmakehash
  HOSTCC  scripts/recordmcount
scripts/recordmcount.c:287:1: warning: ‘do_file’ defined but not used
  CC      drivers/firewire/core-card.o
  CC      drivers/firewire/core-cdev.o
  CC      drivers/firewire/core-device.o
  CC      drivers/firewire/core-iso.o
  CC      drivers/firewire/core-topology.o
  CC      drivers/firewire/core-transaction.o
  CC      drivers/firewire/ohci.o
  CC      drivers/firewire/sbp2.o
  LD      drivers/firewire/firewire-core.o
  MODPOST 0 modules

Let's see what happened:

atm26 at bulova:/local/scratch/atm26/linux$ ls -l drivers/firewire/firewire-core.o 
-rw-r--r-- 1 atm26 atm26 597243 2011-11-12 22:10 drivers/firewire/firewire-core.o

atm26 at bulova:/local/scratch/atm26/linux$ file drivers/firewire/firewire-core.o
drivers/firewire/firewire-core.o: ELF 32-bit LSB relocatable, ARM, version
1, not stripped


You read that right, GCCSDK can compile and link Linux kernel modules.
Pointless, but I'm impressed :) If you check the verbose output with 'make
V=1' it confirms it's doing the right thing.  Of course there will be one or
two symbols that RISC OS won't be able to provide...

I only made a two character change to the source tree to achieve this:
commented out one line in recordmcount.c (which is something that reads ELF
files for creating a table to use with ftrace() which traces syscalls -
completely irrelevant for RISC OS but didn't like its ELF format for some
reason).  It's a credit to both GCCSDK and the Linux source tree that zero
faffing about with the build system is required.

Now imagine trying to do this with AOF Norcroft.  I think the reason to use
ELF just paid off :)

Theo




More information about the gcc mailing list