Skip to content

Commit 6354d48

Browse files
committed
Processed review comments
1 parent 9a428e1 commit 6354d48

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub fn target() -> Result<Target, String> {
2929
];
3030

3131
const EXPORT_SYMBOLS: &[&str] = &[
32-
"elf_entry",
3332
"sgx_entry",
3433
"HEAP_BASE",
3534
"HEAP_SIZE",

src/libstd/sys/sgx/abi/entry.S

+17-7
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,29 @@ IMAGE_BASE:
109109
.section .text_no_sgx, "ax"
110110
.Lelf_entry_error_msg:
111111
.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"
112+
.Lelf_entry_error_msg_end:
113+
112114
.global elf_entry
113115
.type elf_entry,function
114116
elf_entry:
115117
/* print error message */
116-
movq $1, %rax /* write() syscall */
117-
movq $2, %rdi /* write to stderr */
118-
lea .Lelf_entry_error_msg(%rip), %rsi
119-
movq $288, %rdx /* num chars to write */
118+
movq $1,%rax /* write() syscall */
119+
movq $2,%rdi /* write to stderr (fd 2) */
120+
lea .Lelf_entry_error_msg(%rip),%rsi
121+
movq $.Lelf_entry_error_msg_end-.Lelf_entry_error_msg,%rdx
122+
.Lelf_entry_call:
120123
syscall
121-
122-
movq $60, %rax /* exit() syscall */
123-
movq $0, %rdi /* error code */
124+
test %rax,%rax
125+
jle .Lelf_exit /* exit on error */
126+
add %rax,%rsi
127+
sub %rax,%rdx /* all chars written? */
128+
jnz .Lelf_entry_call
129+
130+
.Lelf_exit:
131+
movq $60,%rax /* exit() syscall */
132+
movq $1,%rdi /* exit code 1 */
124133
syscall
134+
ud2 /* should not be reached */
125135
/* end elf_entry */
126136

127137
.text

0 commit comments

Comments
 (0)