Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix imports in ctap, embedded_flash and lang-items. #156

Merged
merged 2 commits into from
Sep 22, 2020

Conversation

gendx
Copy link
Collaborator

@gendx gendx commented Sep 22, 2020

This pull request fixes the way modules are imported depending on features in src/ctap and src/embedded_flash. It also adds a stub in lang-items with the std feature to prevent any linker error.

This prepares #149.

  • Tests pass
  • Appropriate changes to README are included in PR

@google-cla google-cla bot added the cla: yes label Sep 22, 2020
@gendx gendx requested review from jmichelp and ia0 September 22, 2020 11:17
Copy link
Member

@ia0 ia0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that's also a solution: have all modules be in both the library and the binary with the same paths. That's not clean but it's probably cleaner to read than controlling the module memberships with a feature. The main danger is that we should make sure the library is not used by the binary to avoid code duplication (and bigger binary size).

Was this tested on a board?

src/embedded_flash/store/mod.rs Show resolved Hide resolved
@gendx
Copy link
Collaborator Author

gendx commented Sep 22, 2020

I guess that's also a solution: have all modules be in both the library and the binary with the same paths. That's not clean but it's probably cleaner to read than controlling the module memberships with a feature. The main danger is that we should make sure the library is not used by the binary to avoid code duplication (and bigger binary size).

The reproduced binaries have a larger .text section, but it's still reasonable. We can anyway later split out everything in libraries and keep the binary as thin as possible.
And wouldn't potential duplicated code be stripped with LTO?

Was this tested on a board?

Not yet.

@gendx
Copy link
Collaborator Author

gendx commented Sep 22, 2020

Was this tested on a board?

I tried:

$ ./deploy.py --board nrf52840dk --panic_test
$ ./deploy.py --board nrf52840dk --panic-console --panic_test
$ ./deploy.py --board nrf52840dk --panic-console --debug --panic_test
$ ./deploy.py --board nrf52840dk --panic-console --debug --debug-allocations --panic_test
$ ./deploy.py --board nrf52840dk --oom_test
$ ./deploy.py --board nrf52840dk --panic-console --debug --debug-allocations --oom_test
$ ./deploy.py --board nrf52840dk --panic-console --debug --debug-allocations --opensk

I tried OpenSK itself on both https://webauthn.io/ and https://webauthn.me/.

All as expected.

@gendx gendx merged commit 658b767 into google:master Sep 22, 2020
@ia0
Copy link
Member

ia0 commented Sep 22, 2020

The reproduced binaries have a larger .text section, but it's still reasonable. We can anyway later split out everything in libraries and keep the binary as thin as possible.

It's not that "we can", we should avoid this error-prone code duplication, besides the fact that this is bad design. This is just a temporary workaround to enable fuzzing. We should create an issue to track this tech debt.

And wouldn't potential duplicated code be stripped with LTO?

Not necessarily. If the same function is used from its library path and its binary path, then I'm not sure the linker is allowed to merge the symbols even if they have the same code, because they have different names and would thus get the same address.

This was referenced Sep 22, 2020
@gendx gendx deleted the fix-imports branch September 24, 2020 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants