Skip to content

Commit

Permalink
Processed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagten committed Dec 5, 2019
1 parent 9a428e1 commit 6354d48
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub fn target() -> Result<Target, String> {
];

const EXPORT_SYMBOLS: &[&str] = &[
"elf_entry",
"sgx_entry",
"HEAP_BASE",
"HEAP_SIZE",
Expand Down
24 changes: 17 additions & 7 deletions src/libstd/sys/sgx/abi/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,29 @@ IMAGE_BASE:
.section .text_no_sgx, "ax"
.Lelf_entry_error_msg:
.ascii "Error: This file is an SGX enclave which cannot be executed as a standard Linux binary.\nSee 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.\n"
.Lelf_entry_error_msg_end:

.global elf_entry
.type elf_entry,function
elf_entry:
/* print error message */
movq $1, %rax /* write() syscall */
movq $2, %rdi /* write to stderr */
lea .Lelf_entry_error_msg(%rip), %rsi
movq $288, %rdx /* num chars to write */
movq $1,%rax /* write() syscall */
movq $2,%rdi /* write to stderr (fd 2) */
lea .Lelf_entry_error_msg(%rip),%rsi
movq $.Lelf_entry_error_msg_end-.Lelf_entry_error_msg,%rdx
.Lelf_entry_call:
syscall

movq $60, %rax /* exit() syscall */
movq $0, %rdi /* error code */
test %rax,%rax
jle .Lelf_exit /* exit on error */
add %rax,%rsi
sub %rax,%rdx /* all chars written? */

This comment has been minimized.

Copy link
@jethrogb

jethrogb Dec 5, 2019

Contributor

Does the syscall ABI specify that input registers are unchanged?

This comment has been minimized.

Copy link
@Pagten

Pagten Dec 6, 2019

Author Contributor

Only %rcx and %r11 are overwritten (see https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf section A.2.1).

jnz .Lelf_entry_call

.Lelf_exit:
movq $60,%rax /* exit() syscall */
movq $1,%rdi /* exit code 1 */
syscall
ud2 /* should not be reached */
/* end elf_entry */

.text
Expand Down

0 comments on commit 6354d48

Please sign in to comment.