单独编译 kernel 中某些 ko 的方法

更改 Linux kernel 驱动每次重编 kernel 引导非常费力。为了便于调试,可以通过已经有的 Makefile 使用 gcc 来对特定 module 进行编译。这样只需要将 module 以模块方式加载。可以在 linux 环境下进行简单的调试。

命令:

make -C $src_path M=$(pwd) modules

例如:

make -C /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/ M=$(pwd) modules

[root@localhost ata]# ls
acard-ahci.c         libahci.mod.c       pata_artop.c    pata_it821x.c        pata_piccolo.c      sata_inic162x.c
ahci.c               libahci.mod.o       pata_at32.c     pata_ixp4xx_cf.c     pata_platform.c     sata_mv.c
ahci.h               libahci.o           pata_at91.c     pata_jmicron.c       pata_pxa.c          sata_mv.ko
ahci.ko              libata-acpi.c       pata_atiixp.c   pata_legacy.c        pata_qdi.c          sata_mv.mod.c
ahci.mod.c           libata-core.c       pata_atp867x.c  pata_macio.c         pata_radisys.c      sata_mv.mod.o
ahci.mod.o           libata-eh.c         pata_bf54x.c    pata_marvell.c       pata_rb532_cf.c     sata_mv.o
ahci.o               libata.h            pata_cmd640.c   pata_mpc52xx.c       pata_rdc.c          sata_nv.c
ahci_platform.c      libata-pmp.c        pata_cmd64x.c   pata_mpiix.c         pata_rz1000.c       sata_promise.c
ahci_platform.ko     libata-pmp.c.mod    pata_cs5520.c   pata_netcell.c       pata_samsung_cf.c   sata_promise.h
ahci_platform.mod.c  libata-scsi.c       pata_cs5530.c   pata_ninja32.c       pata_sc1200.c       sata_qstor.c
ahci_platform.mod.o  libata-sff.c        pata_cs5535.c   pata_ns87410.c       pata_scc.c          sata_sil24.c
ahci_platform.o      libata-transport.c  pata_cs5536.c   pata_ns87415.c       pata_sch.c          sata_sil.c
ata_generic.c        libata-transport.h  pata_cypress.c  pata_octeon_cf.c     pata_serverworks.c  sata_sis.c
ata_generic.ko       Makefile            pata_efar.c     pata_of_platform.c   pata_sil680.c       sata_svw.c
ata_generic.mod.c    modules.builtin     pata_hpt366.c   pata_oldpiix.c       pata_sis.c          sata_sx4.c
ata_generic.mod.o    modules.order       pata_hpt37x.c   pata_opti.c          pata_sl82c105.c     sata_uli.c
ata_generic.o        Module.symvers      pata_hpt3x2n.c  pata_optidma.c       pata_triflex.c      sata_via.c
ata_piix.c           pata_acpi.c         pata_hpt3x3.c   pata_palmld.c        pata_via.c          sata_vsc.c
Kconfig              pata_ali.c          pata_icside.c   pata_pcmcia.c        pdc_adma.c          sis.h
libahci.c            pata_amd.c          pata_isapnp.c   pata_pdc2027x.c      sata_dwc_460ex.c
libahci.ko           pata_arasan_cf.c    pata_it8213.c   pata_pdc202xx_old.c  sata_fsl.c
[root@localhost ata]# rm *.ko *.o -f
[root@localhost ata]# ls

acard-ahci.c         libata-sff.c        pata_cs5520.c     pata_mpc52xx.c       pata_radisys.c      sata_mv.mod.c
ahci.c               libata-transport.c  pata_cs5530.c     pata_mpiix.c         pata_rb532_cf.c     sata_nv.c
ahci.h               libata-transport.h  pata_cs5535.c     pata_netcell.c       pata_rdc.c          sata_promise.c
ahci.mod.c           Makefile            pata_cs5536.c     pata_ninja32.c       pata_rz1000.c       sata_promise.h
ahci_platform.c      modules.builtin     pata_cypress.c    pata_ns87410.c       pata_samsung_cf.c   sata_qstor.c
ahci_platform.mod.c  modules.order       pata_efar.c       pata_ns87415.c       pata_sc1200.c       sata_sil24.c
ata_generic.c        Module.symvers      pata_hpt366.c     pata_octeon_cf.c     pata_scc.c          sata_sil.c
ata_generic.mod.c    pata_acpi.c         pata_hpt37x.c     pata_of_platform.c   pata_sch.c          sata_sis.c
ata_piix.c           pata_ali.c          pata_hpt3x2n.c    pata_oldpiix.c       pata_serverworks.c  sata_svw.c
Kconfig              pata_amd.c          pata_hpt3x3.c     pata_opti.c          pata_sil680.c       sata_sx4.c
libahci.c            pata_arasan_cf.c    pata_icside.c     pata_optidma.c       pata_sis.c          sata_uli.c
libahci.mod.c        pata_artop.c        pata_isapnp.c     pata_palmld.c        pata_sl82c105.c     sata_via.c
libata-acpi.c        pata_at32.c         pata_it8213.c     pata_pcmcia.c        pata_triflex.c      sata_vsc.c
libata-core.c        pata_at91.c         pata_it821x.c     pata_pdc2027x.c      pata_via.c          sis.h
libata-eh.c          pata_atiixp.c       pata_ixp4xx_cf.c  pata_pdc202xx_old.c  pdc_adma.c
libata.h             pata_atp867x.c      pata_jmicron.c    pata_piccolo.c       sata_dwc_460ex.c
libata-pmp.c         pata_bf54x.c        pata_legacy.c     pata_platform.c      sata_fsl.c
libata-pmp.c.mod     pata_cmd640.c       pata_macio.c      pata_pxa.c           sata_inic162x.c
libata-scsi.c        pata_cmd64x.c       pata_marvell.c    pata_qdi.c           sata_mv.c
[root@localhost ata]# make -C /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/ M=$(pwd) modules
make: Entering directory `/home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15'
  CC [M]  /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/ahci.o
/home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/ahci.c: In function ‘ahci_init_one’:
/home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/ahci.c:1226:67: warning: initialization from incompatible pointer type [enabled by default]
  CC [M]  /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/libahci.o
  CC [M]  /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/ahci_platform.o
  CC [M]  /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/sata_mv.o
  CC [M]  /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/ata_generic.o
  Building modules, stage 2.
  MODPOST 5 modules
  CC      /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/ahci.mod.o
  LD [M]  /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/ahci.ko
  CC      /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/ahci_platform.mod.o
  LD [M]  /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/ahci_platform.ko
  CC      /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/ata_generic.mod.o
  LD [M]  /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/ata_generic.ko
  CC      /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/libahci.mod.o
  LD [M]  /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/libahci.ko
  CC      /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/sata_mv.mod.o
  LD [M]  /home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15/drivers/ata/sata_mv.ko
make: Leaving directory `/home/edwin/rpmbuild/BUILD/kernel-2.6.40.fc15'
[root@localhost ata]# ls
acard-ahci.c         libahci.mod.c       pata_artop.c    pata_it821x.c        pata_piccolo.c      sata_inic162x.c
ahci.c               libahci.mod.o       pata_at32.c     pata_ixp4xx_cf.c     pata_platform.c     sata_mv.c
ahci.h               libahci.o           pata_at91.c     pata_jmicron.c       pata_pxa.c          sata_mv.ko
ahci.ko              libata-acpi.c       pata_atiixp.c   pata_legacy.c        pata_qdi.c          sata_mv.mod.c
ahci.mod.c           libata-core.c       pata_atp867x.c  pata_macio.c         pata_radisys.c      sata_mv.mod.o
ahci.mod.o           libata-eh.c         pata_bf54x.c    pata_marvell.c       pata_rb532_cf.c     sata_mv.o
ahci.o               libata.h            pata_cmd640.c   pata_mpc52xx.c       pata_rdc.c          sata_nv.c
ahci_platform.c      libata-pmp.c        pata_cmd64x.c   pata_mpiix.c         pata_rz1000.c       sata_promise.c
ahci_platform.ko     libata-pmp.c.mod    pata_cs5520.c   pata_netcell.c       pata_samsung_cf.c   sata_promise.h
ahci_platform.mod.c  libata-scsi.c       pata_cs5530.c   pata_ninja32.c       pata_sc1200.c       sata_qstor.c
ahci_platform.mod.o  libata-sff.c        pata_cs5535.c   pata_ns87410.c       pata_scc.c          sata_sil24.c
ahci_platform.o      libata-transport.c  pata_cs5536.c   pata_ns87415.c       pata_sch.c          sata_sil.c
ata_generic.c        libata-transport.h  pata_cypress.c  pata_octeon_cf.c     pata_serverworks.c  sata_sis.c
ata_generic.ko       Makefile            pata_efar.c     pata_of_platform.c   pata_sil680.c       sata_svw.c
ata_generic.mod.c    modules.builtin     pata_hpt366.c   pata_oldpiix.c       pata_sis.c          sata_sx4.c
ata_generic.mod.o    modules.order       pata_hpt37x.c   pata_opti.c          pata_sl82c105.c     sata_uli.c
ata_generic.o        Module.symvers      pata_hpt3x2n.c  pata_optidma.c       pata_triflex.c      sata_via.c
ata_piix.c           pata_acpi.c         pata_hpt3x3.c   pata_palmld.c        pata_via.c          sata_vsc.c
Kconfig              pata_ali.c          pata_icside.c   pata_pcmcia.c        pdc_adma.c          sis.h
libahci.c            pata_amd.c          pata_isapnp.c   pata_pdc2027x.c      sata_dwc_460ex.c
libahci.ko           pata_arasan_cf.c    pata_it8213.c   pata_pdc202xx_old.c  sata_fsl.c


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.