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

Linker-Plugin-LTO encodes wrong OS ABI in the ELF header #73606

Closed
stlankes opened this issue Jun 22, 2020 · 1 comment
Closed

Linker-Plugin-LTO encodes wrong OS ABI in the ELF header #73606

stlankes opened this issue Jun 22, 2020 · 1 comment
Labels
A-linkage Area: linking into static, shared libraries and binaries T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@stlankes
Copy link
Contributor

I am working on the library operating system RustyHermit. If I enable LTO support, I have to use the Linker-Plugin-LTO, because parts of the kernel are provided as static library. Unfortunately, the final result uses in the ELF file a wrong byte to define the OS ABI. In my case, it encodes the byte of the host operating system.

$ readelf -a target/x86_64-unknown-hermit/release/rusty_demo|less

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x30a730
  Start of program headers:          64 (bytes into file)
  Start of section headers:          1791520 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         7
  Size of section headers:           64 (bytes)
  Number of section headers:         12
  Section header string table index: 10

In our case. the binary should encode that the application is able run standalonen. According to the ELF standard 0xff must be coded. If I disable LTO, the file uses the correct value for the OS ABI.

$ readelf -a target/x86_64-unknown-hermit/debug/rusty_demo|less

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 ff 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            <unknown: ff>
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x3c3540
  Start of program headers:          64 (bytes into file)
  Start of section headers:          28120976 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         7
  Size of section headers:           64 (bytes)
  Number of section headers:         23
  Section header string table index: 21

Besides this issue, the file is correct. If I change the OS ABI with elfedit, the applicationsruns correctly.

Does anyone have an idea what this might be caused to?

@camelid camelid added the A-linkage Area: linking into static, shared libraries and binaries label Oct 20, 2020
@pnkfelix pnkfelix added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 15, 2020
@stlankes
Copy link
Contributor Author

Currently, we disable the LTO support. We have more problems with LTO and have to investigate it. I think that this isn't a Rust linker problem. Consequently, I close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants