section mismatch with a platform driver - Kernel

This is a discussion on section mismatch with a platform driver - Kernel ; Hi all, I am working on a platform driver, and getting the following warning: WARNING: vmlinux.o(.data+0x44bc4): Section mismatch: reference to ..init.text:my_probe_func (between 'my_platform_struct' and 'debug_level_variable') If I understand correctly, it shouts about my probe function being referenced from the data ...

+ Reply to Thread
Results 1 to 13 of 13

Thread: section mismatch with a platform driver

  1. section mismatch with a platform driver

    Hi all,

    I am working on a platform driver, and getting the following warning:

    WARNING: vmlinux.o(.data+0x44bc4): Section mismatch: reference to
    ..init.text:my_probe_func (between 'my_platform_struct' and
    'debug_level_variable')

    If I understand correctly, it shouts about my probe function being
    referenced from the data section:

    static struct platform_driver my_platform_struct = {
    .probe = my_probe,
    .remove = my_remove,
    .suspend = my_suspend,
    .resume = my_resume,
    .driver = {
    .name = DRIVER_NAME,
    },
    };

    Why is that a problem ? Should I do something different ? Isn't my
    platform_driver struct completely standard ?

    Thank You !
    Pnesh
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. Re: section mismatch with a platform driver

    On Mon, Oct 13, 2008 at 10:19:05AM +0200, Neshama Parhoti wrote:
    > Hi all,
    >
    > I am working on a platform driver, and getting the following warning:
    >
    > WARNING: vmlinux.o(.data+0x44bc4): Section mismatch: reference to
    > .init.text:my_probe_func (between 'my_platform_struct' and
    > 'debug_level_variable')
    >
    > If I understand correctly, it shouts about my probe function being
    > referenced from the data section:
    >
    > static struct platform_driver my_platform_struct = {
    > .probe = my_probe,
    > .remove = my_remove,
    > .suspend = my_suspend,
    > .resume = my_resume,
    > .driver = {
    > .name = DRIVER_NAME,
    > },
    > };
    >
    > Why is that a problem ? Should I do something different ? Isn't my
    > platform_driver struct completely standard ?


    It complains about "my_probe_func", and that's not even in the code
    you posted.

    Please send the complete file.

    > Thank You !
    > Pnesh


    cu
    Adrian

    --

    "Is there not promise of rain?" Ling Tan asked suddenly out
    of the darkness. There had been need of rain for many days.
    "Only a promise," Lao Er said.
    Pearl S. Buck - Dragon Seed

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. Re: section mismatch with a platform driver

    Hi Adrian and thank you for the help!

    On Mon, Oct 13, 2008 at 10:51 AM, Adrian Bunk wrote:
    > On Mon, Oct 13, 2008 at 10:19:05AM +0200, Neshama Parhoti wrote:
    >> WARNING: vmlinux.o(.data+0x44bc4): Section mismatch: reference to
    >> .init.text:my_probe_func (between 'my_platform_struct' and
    >> 'debug_level_variable')
    >>
    >> If I understand correctly, it shouts about my probe function being
    >> referenced from the data section:
    >>
    >> static struct platform_driver my_platform_struct = {
    >> .probe = my_probe_func,
    >> .remove = my_remove,
    >> .suspend = my_suspend,
    >> .resume = my_resume,
    >> .driver = {
    >> .name = DRIVER_NAME,
    >> },
    >> };
    >>

    > It complains about "my_probe_func", and that's not even in the code
    > you posted.


    It happens even if I use an empty function like this:

    static int __init my_probe_func(struct platform_device *pdev)
    {
    return 0;
    }


    any idea what's the problem ?

    thanks again!
    pnesh
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  4. Re: section mismatch with a platform driver

    Neshama Parhoti wrote:

    > Hi Adrian and thank you for the help!
    >
    > On Mon, Oct 13, 2008 at 10:51 AM, Adrian Bunk wrote:
    >
    >> On Mon, Oct 13, 2008 at 10:19:05AM +0200, Neshama Parhoti wrote:
    >>
    >>> WARNING: vmlinux.o(.data+0x44bc4): Section mismatch: reference to
    >>> .init.text:my_probe_func (between 'my_platform_struct' and
    >>> 'debug_level_variable')
    >>>
    >>> If I understand correctly, it shouts about my probe function being
    >>> referenced from the data section:
    >>>
    >>> static struct platform_driver my_platform_struct = {
    >>> .probe = my_probe_func,
    >>> .remove = my_remove,
    >>> .suspend = my_suspend,
    >>> .resume = my_resume,
    >>> .driver = {
    >>> .name = DRIVER_NAME,
    >>> },
    >>> };
    >>>
    >>>

    >> It complains about "my_probe_func", and that's not even in the code
    >> you posted.
    >>

    >
    > It happens even if I use an empty function like this:
    >
    > static int __init my_probe_func(struct platform_device *pdev)
    > {
    > return 0;
    > }
    >
    >
    > any idea what's the problem ?
    >

    That __init macro marks the probe function as "throw after init" - it
    tells the compiler to put this function in a separate ELF section that
    the kernel automatically frees when module init is done, but you are
    referencing this function in a structure that is not marked as "throw
    after init".

    Can't be sure without seeing the whole picture, but the most probable
    solution is to drop that __init from the probe function. It's seems
    wrong as in theory the probe function can be called at any time in the
    life of the kernel, not just in this module init, even if in practice
    this will never happen, as I suspect is the case with such a platform
    driver.

    Gilad



    --
    Gilad Ben-Yossef
    Chief Coffee Drinker

    Codefidence Ltd.
    The code is free, your time isn't.(TM)

    Web: http://codefidence.com
    Email: gilad@codefidence.com
    Office: +972-8-9316883 ext. 201
    Fax: +972-8-9316885
    Mobile: +972-52-8260388

    The Doctor: Don't worry, Reinette, just a nightmare.
    Everyone has nightmares. Even monsters from under the
    bed have nightmares, don't you, monster?
    Reinette: What do monsters have nightmares about?
    The Doctor: Me!

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  5. Re: section mismatch with a platform driver

    On Mon, Oct 13, 2008 at 11:28:23AM +0200, Neshama Parhoti wrote:
    > Hi Adrian and thank you for the help!
    >
    > On Mon, Oct 13, 2008 at 10:51 AM, Adrian Bunk wrote:
    > > On Mon, Oct 13, 2008 at 10:19:05AM +0200, Neshama Parhoti wrote:
    > >> WARNING: vmlinux.o(.data+0x44bc4): Section mismatch: reference to
    > >> .init.text:my_probe_func (between 'my_platform_struct' and
    > >> 'debug_level_variable')
    > >>
    > >> If I understand correctly, it shouts about my probe function being
    > >> referenced from the data section:
    > >>
    > >> static struct platform_driver my_platform_struct = {
    > >> .probe = my_probe_func,

    ^^^^^

    Ah, you had your example wrong and silently edited your quoted email.

    > >> .remove = my_remove,
    > >> .suspend = my_suspend,
    > >> .resume = my_resume,
    > >> .driver = {
    > >> .name = DRIVER_NAME,
    > >> },
    > >> };
    > >>

    > > It complains about "my_probe_func", and that's not even in the code
    > > you posted.

    >
    > It happens even if I use an empty function like this:
    >
    > static int __init my_probe_func(struct platform_device *pdev)
    > {
    > return 0;
    > }
    >
    > any idea what's the problem ?


    The function has a wrong name.

    > thanks again!
    > pnesh


    cu
    Adrian

    --

    "Is there not promise of rain?" Ling Tan asked suddenly out
    of the darkness. There had been need of rain for many days.
    "Only a promise," Lao Er said.
    Pearl S. Buck - Dragon Seed

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  6. Re: section mismatch with a platform driver

    On Mon, Oct 13, 2008 at 11:43 AM, Gilad Ben-Yossef
    wrote:
    > Can't be sure without seeing the whole picture, but the most probable
    > solution is to drop that __init from the probe function. It's seems wrong as
    > in theory the probe function can be called at any time in the life of the
    > kernel, not just in this module init, even if in practice this will never
    > happen, as I suspect is the case with such a platform driver.


    Yes, thanks, removing that macro did make the warning go away.
    That's weird because I was using other in-tree drivers as a template for this,
    and they don't have this section mismatch problem...

    >
    > Gilad
    >
    >
    >
    > --
    > Gilad Ben-Yossef Chief Coffee Drinker
    >
    > Codefidence Ltd.
    > The code is free, your time isn't.(TM)
    >
    > Web: http://codefidence.com
    > Email: gilad@codefidence.com
    > Office: +972-8-9316883 ext. 201
    > Fax: +972-8-9316885
    > Mobile: +972-52-8260388
    >
    > The Doctor: Don't worry, Reinette, just a nightmare. Everyone
    > has nightmares. Even monsters from under the bed have nightmares,
    > don't you, monster?
    > Reinette: What do monsters have nightmares about?
    > The Doctor: Me!
    >

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  7. Re: section mismatch with a platform driver

    On Mon, Oct 13, 2008 at 11:50 AM, Adrian Bunk wrote:
    >> any idea what's the problem ?

    >
    > The function has a wrong name.


    Thanks but that was just in-mail editing problem..
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  8. Re: section mismatch with a platform driver

    On Mon, 13 Oct 2008 11:28:23 +0200 Neshama Parhoti wrote:

    > Hi Adrian and thank you for the help!
    >
    > On Mon, Oct 13, 2008 at 10:51 AM, Adrian Bunk wrote:
    > > On Mon, Oct 13, 2008 at 10:19:05AM +0200, Neshama Parhoti wrote:
    > >> WARNING: vmlinux.o(.data+0x44bc4): Section mismatch: reference to
    > >> .init.text:my_probe_func (between 'my_platform_struct' and
    > >> 'debug_level_variable')
    > >>
    > >> If I understand correctly, it shouts about my probe function being
    > >> referenced from the data section:
    > >>
    > >> static struct platform_driver my_platform_struct = {
    > >> .probe = my_probe_func,
    > >> .remove = my_remove,
    > >> .suspend = my_suspend,
    > >> .resume = my_resume,
    > >> .driver = {
    > >> .name = DRIVER_NAME,
    > >> },
    > >> };
    > >>

    > > It complains about "my_probe_func", and that's not even in the code
    > > you posted.

    >
    > It happens even if I use an empty function like this:
    >
    > static int __init my_probe_func(struct platform_device *pdev)
    > {
    > return 0;
    > }
    >
    >
    > any idea what's the problem ?


    A probe function can be called at any time -- i.e., after system init
    has completed, so discarding the __init function my_probe_func() is BAD,
    dangerous, BUGgy.

    ---
    ~Randy
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  9. Re: section mismatch with a platform driver

    On Mon, Oct 13, 2008 at 6:01 PM, Randy Dunlap wrote:
    > A probe function can be called at any time -- i.e., after system init
    > has completed, so discarding the __init function my_probe_func() is BAD,
    > dangerous, BUGgy.


    Thanks for the explanation!

    Does that mean that all drivers with __init in their probe functions are bogus ?

    >
    > ---
    > ~Randy
    >

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  10. Re: section mismatch with a platform driver

    Neshama Parhoti wrote:
    > On Mon, Oct 13, 2008 at 6:01 PM, Randy Dunlap wrote:
    >> A probe function can be called at any time -- i.e., after system init
    >> has completed, so discarding the __init function my_probe_func() is BAD,
    >> dangerous, BUGgy.

    >
    > Thanks for the explanation!
    >
    > Does that mean that all drivers with __init in their probe functions are bogus ?


    It depends. If your platform doesn't support hotplug, then it's possible
    that the probe function is only called during system init, so it would be OK.

    And in general, if a kernel is built without hotplug support, then the
    __init probe functions are probably safe. But I'm not sure about it.

    --
    ~Randy
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  11. Re: section mismatch with a platform driver

    On Mon, Oct 13, 2008 at 6:31 PM, Randy Dunlap wrote:
    >> Does that mean that all drivers with __init in their probe functions are bogus ?

    >
    > It depends. If your platform doesn't support hotplug, then it's possible
    > that the probe function is only called during system init, so it would be OK.


    Hmm any idea then why did it give me a section mismatch warning ?

    Thanks!!
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  12. Re: section mismatch with a platform driver

    Neshama Parhoti wrote:
    > On Mon, Oct 13, 2008 at 6:31 PM, Randy Dunlap wrote:
    >>> Does that mean that all drivers with __init in their probe functions are bogus ?

    >> It depends. If your platform doesn't support hotplug, then it's possible
    >> that the probe function is only called during system init, so it would be OK.

    >
    > Hmm any idea then why did it give me a section mismatch warning ?


    Just because the probe function is marked __init.
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  13. Re: section mismatch with a platform driver

    There are some examples in kernel as following:

    static struct platform_driver my_platform_driver = {
    .probe = my_probe_func,
    .remove = __devexit_p(my_remove),
    .suspend = my_suspend,
    .resume = my_resume,
    .driver = {
    .name = DRIVER_NAME,
    },
    };


    static int __devinit my_probe_func(struct platform_device *pdev)
    {
    return 0;
    }

    note that my_platform_*driver*, it let this variable can refer to
    init/exit sections.
    You can find the explanation in /scripts/mod/modpost.c:

    /* symbols in .data that may refer to init/exit sections */
    static const char *symbol_white_list[] =
    {
    "*driver",
    "*_template", /* scsi uses *_template a lot */
    "*_timer", /* arm uses ops structures named _timer a lot */
    "*_sht", /* scsi also used *_sht to some extent */
    "*_ops",
    "*_probe",
    "*_probe_one",
    "*_console",
    NULL
    };


    On Tue, Oct 14, 2008 at 2:58 AM, Neshama Parhoti wrote:
    > On Mon, Oct 13, 2008 at 6:31 PM, Randy Dunlap wrote:
    >>> Does that mean that all drivers with __init in their probe functions are bogus ?

    >>
    >> It depends. If your platform doesn't support hotplug, then it's possible
    >> that the probe function is only called during system init, so it would be OK.

    >
    > Hmm any idea then why did it give me a section mismatch warning ?
    >
    > Thanks!!
    > --
    > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    > the body of a message to majordomo@vger.kernel.org
    > More majordomo info at http://vger.kernel.org/majordomo-info.html
    > Please read the FAQ at http://www.tux.org/lkml/
    >

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread