Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni via buildroot <buildroot@buildroot.org>
To: Thomas Petazzoni via buildroot <buildroot@buildroot.org>
Cc: Bernd Kuhls <bernd@kuhls.net>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [Buildroot] [PATCH 1/1] package/mjpg-streamer: fix undefined symbol error
Date: Tue, 6 Aug 2024 00:21:54 +0200	[thread overview]
Message-ID: <20240806002154.2498f917@windsurf> (raw)
In-Reply-To: <20240510214957.7961fff9@windsurf>

Hello Bernd,

On Fri, 10 May 2024 21:49:57 +0200
Thomas Petazzoni via buildroot <buildroot@buildroot.org> wrote:

> Thanks for the patch. Are you sure this is the right fix?
> 
> Indeed, the way I understand it is that there is a main executable
> (mjpg-streamer), which loads using dlopen() a number of plugins. This
> symbol resolutions_help is already provided by the mjpg-streamer main
> executable itself, so why can't the dlopen()'ed plugin use it? Here
> you're basically duplicating this symbol into the plugin itself. Is
> that the right way to fix this issue? I am not sure 100% clear on what
> are the rules that allow a dlopen() library to use the symbols of the
> "thing" that dlopen()s the plugin, but it seems like it is possible.
> 
> Also, there is another plugin, input_opencv, which uses the exact same
> symbol, so it would also need to be fixed.
> 
> Opinion from upstream here would be greatly appreciated to see how they
> chose to design their code base.

Since I had no feedback from you on this question, I had a deeper look,
and indeed your proposed fix is incorrect: the plugin should really
call into the resolutions_help() function of the mjpg_streamer
executable.

It doesn't work because the resolutions_help() symbol is not explicitly
exported *and* we are stripping our executables.

An easy solution is to export all symbols of the main binary, which can
be achieved by adding:

set_property(TARGET mjpg_streamer PROPERTY ENABLE_EXPORTS ON)

into the CMakeLists.txt file. A better solution would be to only export
those symbols which are needed by the plugins, but obviously it
requires a bit more work.

I couldn't test at runtime, but before my patch, I can clearly see that
the stripped mjpg_streamer no longer has any symbol table containing
resolutions_help(), while after my patch it contains a symbol table
with this symbol.

Could you give it a try and report back?

Thanks a lot!

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2024-08-05 22:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-24 18:56 [Buildroot] [PATCH 1/1] package/mjpg-streamer: fix undefined symbol error Bernd Kuhls
2024-05-10 19:49 ` Thomas Petazzoni via buildroot
2024-08-05 22:21   ` Thomas Petazzoni via buildroot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240806002154.2498f917@windsurf \
    --to=buildroot@buildroot.org \
    --cc=bernd@kuhls.net \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox