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

SGX: Change ELF entrypoint #67084

Merged
merged 4 commits into from
Dec 14, 2019

Conversation

Pagten
Copy link
Contributor

@Pagten Pagten commented Dec 6, 2019

This fixes rust-sgx issue #148.

A new entry point is created for the ELF file generated by rustc, separate from the enclave entry point. When the ELF file is executed as a Linux binary, the error message below is written to stderr.

Error: This file is an SGX enclave which cannot be executed as a standard Linux binary.
See the installation guide at https://edp.fortanix.com/docs/installation/guide/ on how to use 'cargo run' or follow the steps at https://edp.fortanix.com/docs/tasks/deployment/ for manual deployment.

When the ELF file is converted to an SGXS using elf2sgxs, the old entry point is still set as the enclave entry point. In a future pull request in the rust-sgx repository, elf2sgxs will be modified to remove the code in the ELF entry point, since this code is not needed in the enclave.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Kimundi (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 6, 2019
@Pagten Pagten changed the title Change ELF entrypoint SGX: Change ELF entrypoint Dec 6, 2019
bors bot added a commit to fortanix/rust-sgx that referenced this pull request Dec 9, 2019
203: elf2sgx: Remove .text_no_sgx section during conversion r=jethrogb a=Pagten

This pull request is related to [rust-lang pull request #67084](rust-lang/rust#67084), which places the ELF entry point in a separate section of the ELF file. This pull request removes/overwrites that section during the conversion from ELF to SGXS, because that code is not needed in the enclave. To avoid changing the relative position of other code, the section is only removed if it is at the end of a program segment. It is overwritten with NOPs otherwise.

The pull request also includes some general refactoring of the code related to Splices.

Co-authored-by: Pieter Agten <[email protected]>
@Dylan-DPC-zz
Copy link

r? @Amanieu

@rust-highfive rust-highfive assigned Amanieu and unassigned Kimundi Dec 12, 2019
@Amanieu
Copy link
Member

Amanieu commented Dec 12, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Dec 12, 2019

📌 Commit f02ffb8 has been approved by Amanieu

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 12, 2019
@bors
Copy link
Contributor

bors commented Dec 14, 2019

⌛ Testing commit f02ffb8 with merge 12307b3...

bors added a commit that referenced this pull request Dec 14, 2019
…r=Amanieu

SGX: Change ELF entrypoint

This fixes [rust-sgx issue #148](fortanix/rust-sgx#148).

A new entry point is created for the ELF file generated by `rustc`, separate from the enclave entry point. When the ELF file is executed as a Linux binary, the error message below is written to stderr.

> Error: This file is an SGX enclave which cannot be executed as a standard Linux binary.
> See the installation guide at https://edp.fortanix.com/docs/installation/guide/ on how to use 'cargo run' or follow the steps at https://edp.fortanix.com/docs/tasks/deployment/ for manual deployment.

When the ELF file is converted to an SGXS using `elf2sgxs`, the old entry point is still set as the enclave entry point. In a future pull request in the rust-sgx repository, `elf2sgxs` will be modified to remove the code in the ELF entry point, since this code is not needed in the enclave.
@bors
Copy link
Contributor

bors commented Dec 14, 2019

☀️ Test successful - checks-azure
Approved by: Amanieu
Pushing 12307b3 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 14, 2019
@bors bors merged commit f02ffb8 into rust-lang:master Dec 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change ELF entrypoint
7 participants