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

Loading ELF file failed #762

Closed
Rlyown opened this issue Jul 17, 2022 · 3 comments
Closed

Loading ELF file failed #762

Rlyown opened this issue Jul 17, 2022 · 3 comments

Comments

@Rlyown
Copy link

Rlyown commented Jul 17, 2022

Description of the problem

I'm trying to run apache httpd with gramine-sgx, which is compiled from source. The compiled components include apr, apr-util, httpd, php. But apachectl doesn't execute successfully, and the debug info shows debug: loading ELF file failed: ELF file with invalid header.

Steps to reproduce

  1. change configure prefix to same subdirectory, and compile apr, apr-util, httpd, php
  2. update apachectl path and library path in manifest.template
  3. Run gramine-sgx apachectl -k start

Expected results

Php web page can be accessed normally.

Actual results

warning: DkVirtualMemoryProtect is unimplemented in Linux-SGX PAL
[ :: ] debug: Gramine was built from commit: 1.2
[ :: ]debug: Host: Linux-SGX
[ :: ]debug: Lib0S save_enabled 1, xsave_size 0x340 (832), xsave_features 0x7
[ :: ]debug: Initial VMA region 0xfcee0000-0xfcf7f000 (LibS) bookkeeped
[ :: ]debug: Initial VMA region 0xff85e000-0x100000000 (manifest) bookkeeped
[ :: ]debug: ASLR top address adjusted to 0x775bf000
[ :: ]debug: host is Linux-SGX, adding SGX-specific /dev/attestation files: report, quote, etc.
[ :: ]debug: Shim loaded at 0xfcee0000, ready to initialize
[ :: ]debug: mounting "file:." (chroot) under /
[ :: ]debug: mounting"proc" (pseudo) under /proc
[ :: ]debug: mounting "dev" (pseudo) under /dev
[ :: ]debug: mounting "dev:tty" (chroot) under /dev/tty
[ :: ]debug: mounting "sys" (pseudo) under /sys 
[ :: ]debug: Creating pipe: pipe.srv:88651f24a205bfa773d582818563a723a125120031861b7d483d404a4b0c7ae5
[P1: T1:] debug: mounting "file:/usr/lib/x86_64-Linux-gnu/gramine/runtime/glibc"(chroot)under/lib
[P1: T1:] debug: mounting "file: /Lib/x86_64-Linux-gnu" (chroot) under /lib/x86_64-Linux-gnu
[P1: T1:] debug: mounting "file: /usr" (chroot) under /usr
[P1:T1:] debug: mounting "file: /home/sspku/Desktop/some_test/TEST/packages/httpd-2.4.54" (chroot) under /home/sspku/Desktop/some test/TEST/packages/httod-2.4.54
[P1: T1: apachectl] debug: Creating pipe: pipe.srv:c1f09e209d4654d05da69d31699d5f8dd0ede7c8dd31197fef09613de427d518
[P1: T1: apachectl] debug: Allocating stack at O (size = 262144)
[P1:T1: apachect] debug: loading "file:/home/sspku/Desktop/some_test/TEST/packages/httpd-2.4.54/install/bin/apachectl"
[P1: T1: apachectl] debug: loading ELF file failed: ELF file with invalid header
[P1:T1: apachectl] error: Error during shim_init() in init_elf_objects (-8)
debug: DkProcessExit: Returning exit code 8

Gramine commit hash

fd2e302

@mkow
Copy link
Member

mkow commented Jul 17, 2022

Quoting our issue template: @@@ PLEASE ENSURE THAT THE ISSUE REPRODUCES ON THE CURRENT MASTER BRANCH @@@. The commit you tested is quite old.
You may also want to try #722.

@boryspoplawski
Copy link
Contributor

apachectl seems to be a shell script. #722 add support for running these directly as entrypoint. For now as a workaround you can change your entrypoint to be /bin/sh and pass the script as an argument.

@Rlyown
Copy link
Author

Rlyown commented Jul 18, 2022

Thanks, I didn't realize that apachectl is a shell script, not a binary program. After setting /bin/sh as the entrypoint httpd successfully executed.

@Rlyown Rlyown closed this as completed Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants