Can I add functions to the compiled binary?

Hello.
In a binary file with a compiled base program,
Can we do something like connecting a program that the user can update?

As a prerequisite

  1. we give the user a specific function and publish the IF.
  2. the base program calls that function and retrieves the value.

In this case, we would like to provide the base program in binary form, without exposing it to the public.

Hi @nishihara. It isn't clear to me what you are hoping to accomplish but you might be interested in learning about the support for precompiled binaries in Arduino libraries:

https://arduino.github.io/arduino-cli/latest/library-specification/#precompiled-binaries

Is the base program built on the Arduino libraries? Or is it based on something different?

It is created in the configuration of arduino.
*.ino setup(),loop() to create

Thank you very much.
It looks very difficult but I will study it.

If you are interested in giving it a try, you might find this guide useful:

There is another one here:

But really in the end you are probably better off not bothering and instead just sharing your source code in the open source spirit. All of us in the Arduino community have benefited greatly from the generosity of others with their code so we do have an obligation to give back when possible. I think that often people spend a lot of energy on trying to keep their code secret when there isn't actually anything novel in it that someone would bother to "steal". And there is also a chance that you have used code with a license that legally requires you to make the source code available.

1 Like

There's a very good chance of this.

Whenever people in the microcontroller world start talking about keeping source code secret I like to remind them, I don't need to see your code to copy it. All I need to see is what your device does. Keeping your code secret just makes sure someone won't run into any licensing or copyright issues when they steal your idea.

A simple answer - no.
All the options mentioned above, for example the use of precompiled libraries, require rebuilding the program before use, which is hardly accessible to the end user.
It is impossible to add another binary file to the existing program, from where the main code could load new functions.

Many programs check for updates and allow to download updates. What's your reason for modifying a flashed program instead of installing a newer version? Introduce a virus or other malware?

May not be intent, but is certainly vulnerability.

how would the existing binary know about the new function and invoke it?

however, if the existing code executes functions thru a table of pointers, "gateways", a new function could be added, replacing an existing one by changing the address in the table.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.